diff options
Diffstat (limited to 'deps/v8/test')
446 files changed, 25964 insertions, 7655 deletions
diff --git a/deps/v8/test/cctest/BUILD.gn b/deps/v8/test/cctest/BUILD.gn index fdb281140f..3dae59bac2 100644 --- a/deps/v8/test/cctest/BUILD.gn +++ b/deps/v8/test/cctest/BUILD.gn @@ -6,6 +6,34 @@ import("../../gni/v8.gni") v8_executable("cctest") { testonly = true + deps = [ + ":cctest_sources", + ] + configs = [ + "../..:external_config", + "../..:internal_config_base", + ] + + ldflags = [] + + # TODO(machenbach): Translate from gyp. + #["OS=="aix"", { + # "ldflags": [ "-Wl,-bbigtoc" ], + #}], + + # crbug.com/676417: Suppress symbol import warning from linker. + if (is_win && is_component_build) { + ldflags += [ + "/ignore:4217", + "/ignore:4049", + ] + remove_configs = [ "//build/config/win:default_incremental_linking" ] + configs += [ "//build/config/win:no_incremental_linking" ] + } +} + +v8_source_set("cctest_sources") { + testonly = true sources = [ "$target_gen_dir/resources.cc", @@ -61,7 +89,6 @@ v8_executable("cctest") { "compiler/test-run-wasm-machops.cc", "compiler/value-helper.h", "expression-type-collector-macros.h", - "ffi/test-ffi.cc", "gay-fixed.cc", "gay-fixed.h", "gay-precision.cc", @@ -119,7 +146,6 @@ v8_executable("cctest") { "test-bignum.cc", "test-bit-vector.cc", "test-circular-queue.cc", - "test-code-cache.cc", "test-code-layout.cc", "test-code-stub-assembler.cc", "test-compiler.cc", @@ -150,7 +176,6 @@ v8_executable("cctest") { "test-identity-map.cc", "test-inobject-slack-tracking.cc", "test-intl.cc", - "test-list.cc", "test-liveedit.cc", "test-lockers.cc", "test-log.cc", @@ -200,13 +225,27 @@ v8_executable("cctest") { "wasm/test-run-wasm-relocation.cc", "wasm/test-run-wasm-simd.cc", "wasm/test-run-wasm.cc", + "wasm/test-streaming-compilation.cc", "wasm/test-wasm-breakpoints.cc", "wasm/test-wasm-interpreter-entry.cc", "wasm/test-wasm-stack.cc", "wasm/test-wasm-trap-position.cc", + "wasm/wasm-run-utils.cc", "wasm/wasm-run-utils.h", ] + if (use_jumbo_build) { + jumbo_excluded_sources = [ + # TODO(mostynb@opera.com): figure out the jumbo issues with these source + # files, and include them in jumbo compilation units. + "interpreter/bytecode-expectations-printer.cc", + "interpreter/bytecode-expectations-printer.h", + "interpreter/test-bytecode-generator.cc", + "test-api.cc", + "test-api.h", + ] + } + if (v8_current_cpu == "arm") { sources += [ ### gcmole(arch:arm) ### "test-assembler-arm.cc", @@ -318,14 +357,9 @@ v8_executable("cctest") { "../..:internal_config_base", ] - # TODO(machenbach): Translate from gyp. - #["OS=="aix"", { - # "ldflags": [ "-Wl,-bbigtoc" ], - #}], - - deps = [ + public_deps = [ ":resources", - "../..:v8_builtins_generators", + "../..:v8_initializers", "../..:v8_libbase", "../..:v8_libplatform", "../..:wasm_module_runner", @@ -334,6 +368,7 @@ v8_executable("cctest") { ] defines = [] + deps = [] if (is_component_build) { # cctest can't be built against a shared library, so we @@ -351,18 +386,6 @@ v8_executable("cctest") { } cflags = [] - ldflags = [] - - # crbug.com/676417: Suppress symbol import warning from linker. - if (is_win && is_component_build) { - ldflags += [ - "/ignore:4217", - "/ignore:4049", - ] - remove_configs = [ "//build/config/win:default_incremental_linking" ] - configs += [ "//build/config/win:no_incremental_linking" ] - } - if (v8_current_cpu == "ppc" || v8_current_cpu == "ppc64" || v8_current_cpu == "arm" || v8_current_cpu == "arm64" || v8_current_cpu == "s390" || v8_current_cpu == "s390x" || diff --git a/deps/v8/test/cctest/cctest.gyp b/deps/v8/test/cctest/cctest.gyp index 9e2e2ad875..ffcd865531 100644 --- a/deps/v8/test/cctest/cctest.gyp +++ b/deps/v8/test/cctest/cctest.gyp @@ -79,7 +79,6 @@ 'cctest.cc', 'cctest.h', 'expression-type-collector-macros.h', - 'ffi/test-ffi.cc', 'gay-fixed.cc', 'gay-fixed.h', 'gay-precision.cc', @@ -137,7 +136,6 @@ 'test-bignum-dtoa.cc', 'test-bit-vector.cc', 'test-circular-queue.cc', - 'test-code-cache.cc', 'test-code-layout.cc', 'test-code-stub-assembler.cc', 'test-compiler.cc', @@ -168,7 +166,6 @@ 'test-identity-map.cc', 'test-intl.cc', 'test-inobject-slack-tracking.cc', - 'test-list.cc', 'test-liveedit.cc', 'test-lockers.cc', 'test-log.cc', @@ -209,6 +206,7 @@ 'types-fuzz.h', 'unicode-helpers.h', 'wasm/test-c-wasm-entry.cc', + 'wasm/test-streaming-compilation.cc', 'wasm/test-run-wasm.cc', 'wasm/test-run-wasm-64.cc', 'wasm/test-run-wasm-asmjs.cc', @@ -222,6 +220,7 @@ 'wasm/test-wasm-interpreter-entry.cc', 'wasm/test-wasm-stack.cc', 'wasm/test-wasm-trap-position.cc', + 'wasm/wasm-run-utils.cc', 'wasm/wasm-run-utils.h', ], 'cctest_sources_ia32': [ ### gcmole(arch:ia32) ### @@ -432,7 +431,7 @@ 'dependencies': ['../../src/v8.gyp:v8'], }], ['v8_use_snapshot=="true"', { - 'dependencies': ['../../src/v8.gyp:v8_builtins_generators'], + 'dependencies': ['../../src/v8.gyp:v8_initializers'], }], ], }, diff --git a/deps/v8/test/cctest/cctest.h b/deps/v8/test/cctest/cctest.h index 513885cb9a..155d7393a0 100644 --- a/deps/v8/test/cctest/cctest.h +++ b/deps/v8/test/cctest/cctest.h @@ -33,9 +33,10 @@ #include "include/libplatform/libplatform.h" #include "include/v8-platform.h" #include "src/debug/debug-interface.h" +#include "src/factory.h" #include "src/flags.h" #include "src/isolate.h" -#include "src/objects-inl.h" +#include "src/objects.h" #include "src/utils.h" #include "src/v8.h" #include "src/zone/accounting-allocator.h" @@ -677,6 +678,10 @@ class TestPlatform : public v8::Platform { return old_platform_->MonotonicallyIncreasingTime(); } + double CurrentClockTimeMillis() override { + return old_platform_->CurrentClockTimeMillis(); + } + void CallIdleOnForegroundThread(v8::Isolate* isolate, v8::IdleTask* task) override { old_platform_->CallIdleOnForegroundThread(isolate, task); diff --git a/deps/v8/test/cctest/cctest.status b/deps/v8/test/cctest/cctest.status index 2c9117ae80..c82ca85ab8 100644 --- a/deps/v8/test/cctest/cctest.status +++ b/deps/v8/test/cctest/cctest.status @@ -198,6 +198,15 @@ }], # 'no_snap == True and system == windows' ############################################################################## +['byteorder == big', { + # Skip WASM atomic tests on big-endian machines. + # There is no support to emulate atomic WASM operations on big-endian + # platforms, since this would require bit swapping as a part of atomic + # operations. + 'test-run-wasm-atomics/*': [SKIP], +}], # 'byteorder == big' + +############################################################################## ['system == windows', { # BUG(3331). Fails on windows. @@ -340,6 +349,11 @@ }], # 'arch == ppc or arch == ppc64 or arch == s390 or arch == s390x' ############################################################################## +['variant == stress_incremental_marking', { + 'test-heap-profiler/SamplingHeapProfiler': [SKIP], +}], # variant == stress_incremental_marking + +############################################################################## ['variant == wasm_traps', { 'test-accessors/*': [SKIP], 'test-api-interceptors/*': [SKIP], diff --git a/deps/v8/test/cctest/compiler/code-assembler-tester.h b/deps/v8/test/cctest/compiler/code-assembler-tester.h index f49e8c55c9..8bfdb72ea1 100644 --- a/deps/v8/test/cctest/compiler/code-assembler-tester.h +++ b/deps/v8/test/cctest/compiler/code-assembler-tester.h @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#ifndef V8_TEST_CCTEST_COMPILER_CODE_ASSEMBLER_TESTER_H_ +#define V8_TEST_CCTEST_COMPILER_CODE_ASSEMBLER_TESTER_H_ + #include "src/compiler/code-assembler.h" #include "src/handles.h" #include "src/interface-descriptors.h" @@ -18,23 +21,21 @@ class CodeAssemblerTester { explicit CodeAssemblerTester(Isolate* isolate) : zone_(isolate->allocator(), ZONE_NAME), scope_(isolate), - state_(isolate, &zone_, VoidDescriptor(isolate), - Code::ComputeFlags(Code::STUB), "test") {} + state_(isolate, &zone_, VoidDescriptor(isolate), Code::STUB, "test") {} // Test generating code for a JS function (e.g. builtins). CodeAssemblerTester(Isolate* isolate, int parameter_count, Code::Kind kind = Code::BUILTIN) : zone_(isolate->allocator(), ZONE_NAME), scope_(isolate), - state_(isolate, &zone_, parameter_count, Code::ComputeFlags(kind), - "test") {} + state_(isolate, &zone_, parameter_count, kind, "test") {} // This constructor is intended to be used for creating code objects with // specific flags. - CodeAssemblerTester(Isolate* isolate, Code::Flags flags) + CodeAssemblerTester(Isolate* isolate, Code::Kind kind) : zone_(isolate->allocator(), ZONE_NAME), scope_(isolate), - state_(isolate, &zone_, 0, flags, "test") {} + state_(isolate, &zone_, 0, kind, "test") {} CodeAssemblerState* state() { return &state_; } @@ -54,3 +55,5 @@ class CodeAssemblerTester { } // namespace compiler } // namespace internal } // namespace v8 + +#endif // V8_TEST_CCTEST_COMPILER_CODE_ASSEMBLER_TESTER_H_ diff --git a/deps/v8/test/cctest/compiler/codegen-tester.h b/deps/v8/test/cctest/compiler/codegen-tester.h index ca20e6fb6d..ea1eee55f1 100644 --- a/deps/v8/test/cctest/compiler/codegen-tester.h +++ b/deps/v8/test/cctest/compiler/codegen-tester.h @@ -69,7 +69,7 @@ class RawMachineAssemblerTester : public HandleAndZoneScope, CallDescriptor* call_descriptor = this->call_descriptor(); Graph* graph = this->graph(); CompilationInfo info(ArrayVector("testing"), main_isolate(), main_zone(), - Code::ComputeFlags(Code::STUB)); + Code::STUB); code_ = Pipeline::GenerateCodeForTesting(&info, call_descriptor, graph, schedule); } @@ -100,7 +100,7 @@ class BufferedRawMachineAssemblerTester // parameters from memory. Thereby it is possible to pass 64 bit parameters // to the IR graph. Node* Parameter(size_t index) { - CHECK(index < 4); + CHECK_GT(4, index); return parameter_nodes_[index]; } @@ -260,7 +260,7 @@ class BufferedRawMachineAssemblerTester<void> // parameters from memory. Thereby it is possible to pass 64 bit parameters // to the IR graph. Node* Parameter(size_t index) { - CHECK(index < 4); + CHECK_GT(4, index); return parameter_nodes_[index]; } diff --git a/deps/v8/test/cctest/compiler/function-tester.cc b/deps/v8/test/cctest/compiler/function-tester.cc index 3a396ed361..facbd8eb55 100644 --- a/deps/v8/test/cctest/compiler/function-tester.cc +++ b/deps/v8/test/cctest/compiler/function-tester.cc @@ -4,6 +4,7 @@ #include "test/cctest/compiler/function-tester.h" +#include "src/api.h" #include "src/ast/ast-numbering.h" #include "src/compilation-info.h" #include "src/compiler.h" @@ -42,7 +43,7 @@ FunctionTester::FunctionTester(Handle<Code> code, int param_count) flags_(0) { CHECK(!code.is_null()); Compile(function); - function->ReplaceCode(*code); + function->set_code(*code); } FunctionTester::FunctionTester(Handle<Code> code) : FunctionTester(code, 0) {} @@ -139,8 +140,8 @@ Handle<JSFunction> FunctionTester::ForMachineGraph(Graph* graph, Handle<JSFunction> FunctionTester::Compile(Handle<JSFunction> function) { Handle<SharedFunctionInfo> shared(function->shared()); ParseInfo parse_info(shared); - CompilationInfo info(parse_info.zone(), function->GetIsolate(), - parse_info.script(), shared, function); + CompilationInfo info(parse_info.zone(), function->GetIsolate(), shared, + function); if (flags_ & CompilationInfo::kInliningEnabled) { info.MarkAsInliningEnabled(); @@ -155,7 +156,7 @@ Handle<JSFunction> FunctionTester::Compile(Handle<JSFunction> function) { CHECK(!code.is_null()); info.dependencies()->Commit(code); info.context()->native_context()->AddOptimizedCode(*code); - function->ReplaceCode(*code); + function->set_code(*code); return function; } @@ -164,12 +165,12 @@ Handle<JSFunction> FunctionTester::Compile(Handle<JSFunction> function) { Handle<JSFunction> FunctionTester::CompileGraph(Graph* graph) { Handle<SharedFunctionInfo> shared(function->shared()); ParseInfo parse_info(shared); - CompilationInfo info(parse_info.zone(), function->GetIsolate(), - parse_info.script(), shared, function); + CompilationInfo info(parse_info.zone(), function->GetIsolate(), shared, + function); Handle<Code> code = Pipeline::GenerateCodeForTesting(&info, graph); CHECK(!code.is_null()); - function->ReplaceCode(*code); + function->set_code(*code); return function; } diff --git a/deps/v8/test/cctest/compiler/graph-builder-tester.h b/deps/v8/test/cctest/compiler/graph-builder-tester.h index a2436ad1d2..0de682e86e 100644 --- a/deps/v8/test/cctest/compiler/graph-builder-tester.h +++ b/deps/v8/test/cctest/compiler/graph-builder-tester.h @@ -281,7 +281,7 @@ class GraphBuilderTester : public HandleAndZoneScope, CallDescriptor* desc = Linkage::GetSimplifiedCDescriptor(zone, this->csig_); CompilationInfo info(ArrayVector("testing"), main_isolate(), main_zone(), - Code::ComputeFlags(Code::STUB)); + Code::STUB); code_ = Pipeline::GenerateCodeForTesting(&info, desc, graph()); #ifdef ENABLE_DISASSEMBLER if (!code_.is_null() && FLAG_print_opt_code) { diff --git a/deps/v8/test/cctest/compiler/test-code-assembler.cc b/deps/v8/test/cctest/compiler/test-code-assembler.cc index 43834ace6d..8661a5eb5c 100644 --- a/deps/v8/test/cctest/compiler/test-code-assembler.cc +++ b/deps/v8/test/cctest/compiler/test-code-assembler.cc @@ -4,6 +4,8 @@ #include "src/code-factory.h" #include "src/compiler/code-assembler.h" +#include "src/compiler/node-properties.h" +#include "src/compiler/opcodes.h" #include "src/isolate.h" #include "src/objects-inl.h" #include "test/cctest/compiler/code-assembler-tester.h" @@ -289,7 +291,7 @@ TEST(VariableMergeBindFirst) { m.Goto(&merge); m.Bind(&merge); CHECK(var1.value() != temp); - CHECK(var1.value() != nullptr); + CHECK_NOT_NULL(var1.value()); m.Goto(&end); m.Bind(&l2); Node* temp2 = m.Int32Constant(2); @@ -298,7 +300,7 @@ TEST(VariableMergeBindFirst) { m.Goto(&merge); m.Bind(&end); CHECK(var1.value() != temp); - CHECK(var1.value() != nullptr); + CHECK_NOT_NULL(var1.value()); } TEST(VariableMergeSwitch) { @@ -309,18 +311,23 @@ TEST(VariableMergeSwitch) { Label l1(&m), l2(&m), default_label(&m); Label* labels[] = {&l1, &l2}; int32_t values[] = {1, 2}; - Node* temp = m.Int32Constant(0); - var1.Bind(temp); + Node* temp1 = m.Int32Constant(0); + var1.Bind(temp1); m.Switch(m.Int32Constant(2), &default_label, values, labels, 2); m.Bind(&l1); - DCHECK_EQ(temp, var1.value()); - m.Return(temp); + CHECK_EQ(temp1, var1.value()); + m.Return(temp1); m.Bind(&l2); - DCHECK_EQ(temp, var1.value()); - m.Return(temp); + CHECK_EQ(temp1, var1.value()); + Node* temp2 = m.Int32Constant(7); + var1.Bind(temp2); + m.Goto(&default_label); m.Bind(&default_label); - DCHECK_EQ(temp, var1.value()); - m.Return(temp); + CHECK_EQ(IrOpcode::kPhi, var1.value()->opcode()); + CHECK_EQ(2, var1.value()->op()->ValueInputCount()); + CHECK_EQ(temp1, NodeProperties::GetValueInput(var1.value(), 0)); + CHECK_EQ(temp2, NodeProperties::GetValueInput(var1.value(), 1)); + m.Return(temp1); } TEST(SplitEdgeBranchMerge) { diff --git a/deps/v8/test/cctest/compiler/test-code-generator.cc b/deps/v8/test/cctest/compiler/test-code-generator.cc index d4856d5f45..3de36ac986 100644 --- a/deps/v8/test/cctest/compiler/test-code-generator.cc +++ b/deps/v8/test/cctest/compiler/test-code-generator.cc @@ -2,34 +2,155 @@ // 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/base/utils/random-number-generator.h" #include "src/codegen.h" #include "src/compilation-info.h" #include "src/compiler/code-generator.h" #include "src/compiler/instruction.h" #include "src/compiler/linkage.h" #include "src/isolate.h" +#include "src/objects-inl.h" #include "test/cctest/cctest.h" +#include "test/cctest/compiler/function-tester.h" namespace v8 { namespace internal { namespace compiler { -class CodeGeneratorTester : public InitializedHandleScope { +namespace { + +int GetSlotSizeInBytes(MachineRepresentation rep) { + switch (rep) { + case MachineRepresentation::kTagged: + case MachineRepresentation::kFloat32: + return kPointerSize; + case MachineRepresentation::kFloat64: + return kDoubleSize; + case MachineRepresentation::kSimd128: + return kSimd128Size; + default: + break; + } + UNREACHABLE(); +} + +} // namespace + +// Wrapper around the CodeGenerator with the ability to randomly generate moves +// and swaps which can then be executed. The `slots` map represents how many +// slots should be allocated per representation. Parallel moves will then be +// generated by randomly picking slots. Constants can be provided so that +// parallel moves may use them. +// +// At the moment, only the following representations are tested: +// - kTagged +// - kFloat32 +// - kFloat64 +// - kSimd128 +// There is no need to test using Word32 or Word64 as they are the same as +// Tagged as far as the code generator is concerned. +class CodeGeneratorTester : public HandleAndZoneScope { public: - CodeGeneratorTester() - : zone_(main_isolate()->allocator(), ZONE_NAME), - info_(ArrayVector("test"), main_isolate(), &zone_, - Code::ComputeFlags(Code::STUB)), - descriptor_(Linkage::GetJSCallDescriptor(&zone_, false, 0, - CallDescriptor::kNoFlags)), + CodeGeneratorTester(std::map<MachineRepresentation, int> slots = + std::map<MachineRepresentation, int>{}, + std::initializer_list<Constant> constants = {}) + : info_(ArrayVector("test"), main_isolate(), main_zone(), Code::STUB), + descriptor_(Linkage::GetStubCallDescriptor( + main_isolate(), main_zone(), VoidDescriptor(main_isolate()), 0, + CallDescriptor::kNoFlags, Operator::kNoProperties, + MachineType::AnyTagged(), 0)), linkage_(descriptor_), - blocks_(&zone_), - sequence_(main_isolate(), &zone_, &blocks_), + blocks_(main_zone()), + sequence_(main_isolate(), main_zone(), &blocks_), + rng_(CcTest::random_number_generator()), frame_(descriptor_->CalculateFixedFrameSize()), - generator_(&zone_, &frame_, &linkage_, &sequence_, &info_, + generator_(main_zone(), &frame_, &linkage_, &sequence_, &info_, base::Optional<OsrHelper>(), kNoSourcePosition, nullptr) { - info_.set_prologue_offset(generator_.tasm()->pc_offset()); + // Keep track of all supported representations depending on what kind of + // stack slots are supported. + for (const auto& slot : slots) { + supported_reps_.push_back(slot.first); + } + // Allocate new slots until we run out of them. + while (std::any_of(slots.cbegin(), slots.cend(), + [](const std::pair<MachineRepresentation, int>& entry) { + // True if there are slots left to allocate for this + // representation. + return entry.second > 0; + })) { + // Pick a random MachineRepresentation from supported_reps_. + MachineRepresentation rep = CreateRandomMachineRepresentation(); + auto entry = slots.find(rep); + DCHECK(entry != slots.end()); + // We may have picked a representation for which all slots have already + // been allocated. + if (entry->second > 0) { + // Keep a map of (MachineRepresentation . std::vector<int>) with + // allocated slots to pick from for each representation. + RegisterSlot(rep, frame_.AllocateSpillSlot(GetSlotSizeInBytes(rep))); + entry->second--; + } + } + for (auto constant : constants) { + int virtual_register = AllocateConstant(constant); + // Associate constants with their compatible representations. + // TODO(all): Test all types of constants. + switch (constant.type()) { + // Integer constants are always moved to a tagged location, whatever + // their sizes. + case Constant::kInt32: + case Constant::kInt64: + RegisterConstant(MachineRepresentation::kTagged, virtual_register); + break; + // FP constants may be moved to a tagged location using a heap number, + // or directly to a location of the same size. + case Constant::kFloat32: + RegisterConstant(MachineRepresentation::kTagged, virtual_register); + RegisterConstant(MachineRepresentation::kFloat32, virtual_register); + break; + case Constant::kFloat64: + RegisterConstant(MachineRepresentation::kTagged, virtual_register); + RegisterConstant(MachineRepresentation::kFloat64, virtual_register); + break; + default: + break; + } + } + // Force a frame to be created. + generator_.frame_access_state()->MarkHasFrame(true); + generator_.AssembleConstructFrame(); + // TODO(all): Generate a stack check here so that we fail gracefully if the + // frame is too big. + } + + int AllocateConstant(Constant constant) { + int virtual_register = sequence_.NextVirtualRegister(); + sequence_.AddConstant(virtual_register, constant); + return virtual_register; + } + + // Register a constant referenced by `virtual_register` as compatible with + // `rep`. + void RegisterConstant(MachineRepresentation rep, int virtual_register) { + auto entry = constants_.find(rep); + if (entry == constants_.end()) { + std::vector<int> vregs = {virtual_register}; + constants_.emplace(rep, vregs); + } else { + entry->second.push_back(virtual_register); + } + } + + void RegisterSlot(MachineRepresentation rep, int slot) { + auto entry = allocated_slots_.find(rep); + if (entry == allocated_slots_.end()) { + std::vector<int> slots = {slot}; + allocated_slots_.emplace(rep, slots); + } else { + entry->second.push_back(slot); + } } enum PushTypeFlag { @@ -38,6 +159,124 @@ class CodeGeneratorTester : public InitializedHandleScope { kScalarPush = CodeGenerator::kScalarPush }; + enum OperandConstraint { + kNone, + // Restrict operands to non-constants. This is useful when generating a + // destination. + kCannotBeConstant + }; + + // Generate parallel moves at random. Note that they may not be compatible + // between each other as this doesn't matter to the code generator. + ParallelMove* GenerateRandomMoves(int size) { + ParallelMove* parallel_move = new (main_zone()) ParallelMove(main_zone()); + + for (int i = 0; i < size;) { + MachineRepresentation rep = CreateRandomMachineRepresentation(); + MoveOperands mo(CreateRandomOperand(kNone, rep), + CreateRandomOperand(kCannotBeConstant, rep)); + // It isn't valid to call `AssembleMove` and `AssembleSwap` with redundant + // moves. + if (mo.IsRedundant()) continue; + parallel_move->AddMove(mo.source(), mo.destination()); + // Iterate only when a move was created. + i++; + } + + return parallel_move; + } + + ParallelMove* GenerateRandomSwaps(int size) { + ParallelMove* parallel_move = new (main_zone()) ParallelMove(main_zone()); + + for (int i = 0; i < size;) { + MachineRepresentation rep = CreateRandomMachineRepresentation(); + InstructionOperand lhs = CreateRandomOperand(kCannotBeConstant, rep); + InstructionOperand rhs = CreateRandomOperand(kCannotBeConstant, rep); + MoveOperands mo(lhs, rhs); + // It isn't valid to call `AssembleMove` and `AssembleSwap` with redundant + // moves. + if (mo.IsRedundant()) continue; + // Canonicalize the swap: the register operand has to be the left hand + // side. + if (lhs.IsStackSlot() || lhs.IsFPStackSlot()) { + std::swap(lhs, rhs); + } + parallel_move->AddMove(lhs, rhs); + // Iterate only when a swap was created. + i++; + } + + return parallel_move; + } + + MachineRepresentation CreateRandomMachineRepresentation() { + int index = rng_->NextInt(static_cast<int>(supported_reps_.size())); + return supported_reps_[index]; + } + + InstructionOperand CreateRandomOperand(OperandConstraint constraint, + MachineRepresentation rep) { + // Only generate a Constant if the operand is a source and we have a + // constant with a compatible representation in stock. + bool generate_constant = (constraint != kCannotBeConstant) && + (constants_.find(rep) != constants_.end()); + switch (rng_->NextInt(generate_constant ? 3 : 2)) { + case 0: + return CreateRandomStackSlotOperand(rep); + case 1: + return CreateRandomRegisterOperand(rep); + case 2: + return CreateRandomConstant(rep); + } + UNREACHABLE(); + } + + InstructionOperand CreateRandomRegisterOperand(MachineRepresentation rep) { + int code; + const RegisterConfiguration* conf = RegisterConfiguration::Default(); + switch (rep) { + case MachineRepresentation::kFloat32: { + int index = rng_->NextInt(conf->num_allocatable_float_registers()); + code = conf->RegisterConfiguration::GetAllocatableFloatCode(index); + break; + } + case MachineRepresentation::kFloat64: { + int index = rng_->NextInt(conf->num_allocatable_double_registers()); + code = conf->RegisterConfiguration::GetAllocatableDoubleCode(index); + break; + } + case MachineRepresentation::kSimd128: { + int index = rng_->NextInt(conf->num_allocatable_simd128_registers()); + code = conf->RegisterConfiguration::GetAllocatableSimd128Code(index); + break; + } + case MachineRepresentation::kTagged: { + // Pick an allocatable register that is not the return register. + do { + int index = rng_->NextInt(conf->num_allocatable_general_registers()); + code = conf->RegisterConfiguration::GetAllocatableGeneralCode(index); + } while (code == kReturnRegister0.code()); + break; + } + default: + UNREACHABLE(); + break; + } + return AllocatedOperand(LocationOperand::REGISTER, rep, code); + } + + InstructionOperand CreateRandomStackSlotOperand(MachineRepresentation rep) { + int index = rng_->NextInt(static_cast<int>(allocated_slots_[rep].size())); + return AllocatedOperand(LocationOperand::STACK_SLOT, rep, + allocated_slots_[rep][index]); + } + + InstructionOperand CreateRandomConstant(MachineRepresentation rep) { + int index = rng_->NextInt(static_cast<int>(constants_[rep].size())); + return ConstantOperand(constants_[rep][index]); + } + void CheckAssembleTailCallGaps(Instruction* instr, int first_unused_stack_slot, CodeGeneratorTester::PushTypeFlag push_type) { @@ -64,7 +303,24 @@ class CodeGeneratorTester : public InitializedHandleScope { generator_.AssembleTailCallAfterGap(instr, first_unused_stack_slot); } + void CheckAssembleMove(InstructionOperand* source, + InstructionOperand* destination) { + int start = generator_.tasm()->pc_offset(); + generator_.AssembleMove(source, destination); + CHECK(generator_.tasm()->pc_offset() > start); + } + + void CheckAssembleSwap(InstructionOperand* source, + InstructionOperand* destination) { + int start = generator_.tasm()->pc_offset(); + generator_.AssembleSwap(source, destination); + CHECK(generator_.tasm()->pc_offset() > start); + } + Handle<Code> Finalize() { + InstructionOperand zero = ImmediateOperand(ImmediateOperand::INLINE, 0); + generator_.AssembleReturn(&zero); + generator_.FinishCode(); generator_.safepoints()->Emit(generator_.tasm(), frame_.GetTotalFrameSlotCount()); @@ -79,24 +335,138 @@ class CodeGeneratorTester : public InitializedHandleScope { } } - Zone* zone() { return &zone_; } + void Run() { + HandleScope scope(main_isolate()); + Handle<Code> code = Finalize(); + if (FLAG_print_code) { + code->Print(); + } + FunctionTester ft(code); + ft.Call(); + } + + v8::base::RandomNumberGenerator* rng() const { return rng_; } private: - Zone zone_; CompilationInfo info_; CallDescriptor* descriptor_; Linkage linkage_; ZoneVector<InstructionBlock*> blocks_; InstructionSequence sequence_; + std::vector<MachineRepresentation> supported_reps_; + std::map<MachineRepresentation, std::vector<int>> allocated_slots_; + std::map<MachineRepresentation, std::vector<int>> constants_; + v8::base::RandomNumberGenerator* rng_; Frame frame_; CodeGenerator generator_; }; +// The following fuzz tests will assemble a lot of moves, wrap them in +// executable native code and run them. At this time, we only check that +// something is actually generated, and that it runs on hardware or the +// simulator. + +// TODO(all): It would be great to record the data on the stack after all moves +// are executed so that we could test the functionality in an architecture +// independent way. We would also have to make sure we generate moves compatible +// with each other as the gap-resolver tests do. + +TEST(FuzzAssembleMove) { + // Test small and potentially large ranges separately. Note that the number of + // slots affects how much stack is allocated when running the generated code. + // This means we have to be careful not to exceed the stack limit, which is + // lower on Windows. + for (auto n : {64, 500}) { + std::map<MachineRepresentation, int> slots = { + {MachineRepresentation::kTagged, n}, + {MachineRepresentation::kFloat32, n}, + {MachineRepresentation::kFloat64, n}}; + if (CpuFeatures::SupportsWasmSimd128()) { + // Generate fewer 128-bit slots. + slots.emplace(MachineRepresentation::kSimd128, n / 4); + } + CodeGeneratorTester c( + slots, + {Constant(0), Constant(1), Constant(2), Constant(3), Constant(4), + Constant(5), Constant(6), Constant(7), + Constant(static_cast<float>(0.1)), Constant(static_cast<float>(0.2)), + Constant(static_cast<float>(0.3)), Constant(static_cast<float>(0.4)), + Constant(static_cast<double>(0.5)), Constant(static_cast<double>(0.6)), + Constant(static_cast<double>(0.7)), + Constant(static_cast<double>(0.8))}); + ParallelMove* moves = c.GenerateRandomMoves(1000); + for (const auto m : *moves) { + c.CheckAssembleMove(&m->source(), &m->destination()); + } + c.Run(); + } +} + +TEST(FuzzAssembleSwap) { + // Test small and potentially large ranges separately. Note that the number of + // slots affects how much stack is allocated when running the generated code. + // This means we have to be careful not to exceed the stack limit, which is + // lower on Windows. + for (auto n : {64, 500}) { + std::map<MachineRepresentation, int> slots = { + {MachineRepresentation::kTagged, n}, + {MachineRepresentation::kFloat32, n}, + {MachineRepresentation::kFloat64, n}}; + if (CpuFeatures::SupportsWasmSimd128()) { + // Generate fewer 128-bit slots. + slots.emplace(MachineRepresentation::kSimd128, n / 4); + } + CodeGeneratorTester c(slots); + ParallelMove* moves = c.GenerateRandomSwaps(1000); + for (const auto m : *moves) { + c.CheckAssembleSwap(&m->source(), &m->destination()); + } + c.Run(); + } +} + +TEST(FuzzAssembleMoveAndSwap) { + // Test small and potentially large ranges separately. Note that the number of + // slots affects how much stack is allocated when running the generated code. + // This means we have to be careful not to exceed the stack limit, which is + // lower on Windows. + for (auto n : {64, 500}) { + std::map<MachineRepresentation, int> slots = { + {MachineRepresentation::kTagged, n}, + {MachineRepresentation::kFloat32, n}, + {MachineRepresentation::kFloat64, n}}; + if (CpuFeatures::SupportsWasmSimd128()) { + // Generate fewer 128-bit slots. + slots.emplace(MachineRepresentation::kSimd128, n / 4); + } + CodeGeneratorTester c( + slots, + {Constant(0), Constant(1), Constant(2), Constant(3), Constant(4), + Constant(5), Constant(6), Constant(7), + Constant(static_cast<float>(0.1)), Constant(static_cast<float>(0.2)), + Constant(static_cast<float>(0.3)), Constant(static_cast<float>(0.4)), + Constant(static_cast<double>(0.5)), Constant(static_cast<double>(0.6)), + Constant(static_cast<double>(0.7)), + Constant(static_cast<double>(0.8))}); + for (int i = 0; i < 1000; i++) { + // Randomly alternate between swaps and moves. + if (c.rng()->NextInt(2) == 0) { + MoveOperands* move = c.GenerateRandomMoves(1)->at(0); + c.CheckAssembleMove(&move->source(), &move->destination()); + } else { + MoveOperands* move = c.GenerateRandomSwaps(1)->at(0); + c.CheckAssembleSwap(&move->source(), &move->destination()); + } + } + c.Run(); + } +} + TEST(AssembleTailCallGap) { const RegisterConfiguration* conf = RegisterConfiguration::Default(); // This test assumes at least 4 registers are allocatable. - CHECK(conf->num_allocatable_general_registers() >= 4); + CHECK_LE(4, conf->num_allocatable_general_registers()); auto r0 = AllocatedOperand(LocationOperand::REGISTER, MachineRepresentation::kTagged, @@ -142,14 +512,22 @@ TEST(AssembleTailCallGap) { { // Generate a series of register pushes only. CodeGeneratorTester c; - Instruction* instr = Instruction::New(c.zone(), kArchNop); - instr->GetOrCreateParallelMove(Instruction::FIRST_GAP_POSITION, c.zone()) + Instruction* instr = Instruction::New(c.main_zone(), kArchNop); + instr + ->GetOrCreateParallelMove(Instruction::FIRST_GAP_POSITION, + c.main_zone()) ->AddMove(r3, slot_0); - instr->GetOrCreateParallelMove(Instruction::FIRST_GAP_POSITION, c.zone()) + instr + ->GetOrCreateParallelMove(Instruction::FIRST_GAP_POSITION, + c.main_zone()) ->AddMove(r2, slot_1); - instr->GetOrCreateParallelMove(Instruction::FIRST_GAP_POSITION, c.zone()) + instr + ->GetOrCreateParallelMove(Instruction::FIRST_GAP_POSITION, + c.main_zone()) ->AddMove(r1, slot_2); - instr->GetOrCreateParallelMove(Instruction::FIRST_GAP_POSITION, c.zone()) + instr + ->GetOrCreateParallelMove(Instruction::FIRST_GAP_POSITION, + c.main_zone()) ->AddMove(r0, slot_3); c.CheckAssembleTailCallGaps(instr, first_slot + 4, @@ -160,14 +538,22 @@ TEST(AssembleTailCallGap) { { // Generate a series of stack pushes only. CodeGeneratorTester c; - Instruction* instr = Instruction::New(c.zone(), kArchNop); - instr->GetOrCreateParallelMove(Instruction::FIRST_GAP_POSITION, c.zone()) + Instruction* instr = Instruction::New(c.main_zone(), kArchNop); + instr + ->GetOrCreateParallelMove(Instruction::FIRST_GAP_POSITION, + c.main_zone()) ->AddMove(slot_minus_4, slot_0); - instr->GetOrCreateParallelMove(Instruction::FIRST_GAP_POSITION, c.zone()) + instr + ->GetOrCreateParallelMove(Instruction::FIRST_GAP_POSITION, + c.main_zone()) ->AddMove(slot_minus_3, slot_1); - instr->GetOrCreateParallelMove(Instruction::FIRST_GAP_POSITION, c.zone()) + instr + ->GetOrCreateParallelMove(Instruction::FIRST_GAP_POSITION, + c.main_zone()) ->AddMove(slot_minus_2, slot_2); - instr->GetOrCreateParallelMove(Instruction::FIRST_GAP_POSITION, c.zone()) + instr + ->GetOrCreateParallelMove(Instruction::FIRST_GAP_POSITION, + c.main_zone()) ->AddMove(slot_minus_1, slot_3); c.CheckAssembleTailCallGaps(instr, first_slot + 4, @@ -178,14 +564,22 @@ TEST(AssembleTailCallGap) { { // Generate a mix of stack and register pushes. CodeGeneratorTester c; - Instruction* instr = Instruction::New(c.zone(), kArchNop); - instr->GetOrCreateParallelMove(Instruction::FIRST_GAP_POSITION, c.zone()) + Instruction* instr = Instruction::New(c.main_zone(), kArchNop); + instr + ->GetOrCreateParallelMove(Instruction::FIRST_GAP_POSITION, + c.main_zone()) ->AddMove(slot_minus_2, slot_0); - instr->GetOrCreateParallelMove(Instruction::FIRST_GAP_POSITION, c.zone()) + instr + ->GetOrCreateParallelMove(Instruction::FIRST_GAP_POSITION, + c.main_zone()) ->AddMove(r1, slot_1); - instr->GetOrCreateParallelMove(Instruction::FIRST_GAP_POSITION, c.zone()) + instr + ->GetOrCreateParallelMove(Instruction::FIRST_GAP_POSITION, + c.main_zone()) ->AddMove(slot_minus_1, slot_2); - instr->GetOrCreateParallelMove(Instruction::FIRST_GAP_POSITION, c.zone()) + instr + ->GetOrCreateParallelMove(Instruction::FIRST_GAP_POSITION, + c.main_zone()) ->AddMove(r0, slot_3); c.CheckAssembleTailCallGaps(instr, first_slot + 4, diff --git a/deps/v8/test/cctest/compiler/test-instruction.cc b/deps/v8/test/cctest/compiler/test-instruction.cc index 2d2546690b..a8d34434d3 100644 --- a/deps/v8/test/cctest/compiler/test-instruction.cc +++ b/deps/v8/test/cctest/compiler/test-instruction.cc @@ -205,7 +205,7 @@ TEST(InstructionIsGapAt) { R.code->AddInstruction(g); R.code->EndBlock(R.RpoFor(b0)); - CHECK(R.code->instructions().size() == 2); + CHECK_EQ(2, R.code->instructions().size()); } @@ -232,7 +232,7 @@ TEST(InstructionIsGapAt2) { R.code->AddInstruction(g1); R.code->EndBlock(R.RpoFor(b1)); - CHECK(R.code->instructions().size() == 4); + CHECK_EQ(4, R.code->instructions().size()); } @@ -250,7 +250,7 @@ TEST(InstructionAddGapMove) { R.code->AddInstruction(g); R.code->EndBlock(R.RpoFor(b0)); - CHECK(R.code->instructions().size() == 2); + CHECK_EQ(2, R.code->instructions().size()); int index = 0; for (auto instr : R.code->instructions()) { 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 94b846fa14..ee53f26245 100644 --- a/deps/v8/test/cctest/compiler/test-js-constant-cache.cc +++ b/deps/v8/test/cctest/compiler/test-js-constant-cache.cc @@ -5,14 +5,7 @@ #include "src/assembler.h" #include "src/compiler/js-graph.h" #include "src/compiler/node-properties.h" -#include "src/factory.h" -// FIXME(mstarzinger, marja): This is weird, but required because of the missing -// (disallowed) include: src/factory.h -> src/objects-inl.h -#include "src/objects-inl.h" -// FIXME(mstarzinger, marja): This is weird, but required because of the missing -// (disallowed) include: src/feedback-vector.h -> -// src/feedback-vector-inl.h -#include "src/feedback-vector-inl.h" +#include "src/factory-inl.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/value-helper.h" 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 8e24bac8fc..3944afee42 100644 --- a/deps/v8/test/cctest/compiler/test-js-typed-lowering.cc +++ b/deps/v8/test/cctest/compiler/test-js-typed-lowering.cc @@ -10,13 +10,9 @@ #include "src/compiler/operator-properties.h" #include "src/compiler/simplified-operator.h" #include "src/compiler/typer.h" -#include "src/factory.h" +#include "src/factory-inl.h" #include "src/isolate.h" -#include "src/objects-inl.h" -// FIXME(mstarzinger, marja): This is weird, but required because of the missing -// (disallowed) include: src/feedback-vector.h -> -// src/feedback-vector-inl.h -#include "src/feedback-vector-inl.h" +#include "src/objects.h" #include "test/cctest/cctest.h" namespace v8 { diff --git a/deps/v8/test/cctest/compiler/test-linkage.cc b/deps/v8/test/cctest/compiler/test-linkage.cc index 16a6a85ab7..57af474848 100644 --- a/deps/v8/test/cctest/compiler/test-linkage.cc +++ b/deps/v8/test/cctest/compiler/test-linkage.cc @@ -33,11 +33,13 @@ static Handle<JSFunction> Compile(const char* source) { Handle<String> source_code = isolate->factory() ->NewStringFromUtf8(CStrVector(source)) .ToHandleChecked(); - Handle<SharedFunctionInfo> shared = Compiler::GetSharedFunctionInfoForScript( - source_code, Handle<String>(), 0, 0, v8::ScriptOriginOptions(), - Handle<Object>(), Handle<Context>(isolate->native_context()), NULL, NULL, - v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE, - Handle<FixedArray>()); + Handle<SharedFunctionInfo> shared = + Compiler::GetSharedFunctionInfoForScript( + source_code, MaybeHandle<String>(), 0, 0, v8::ScriptOriginOptions(), + MaybeHandle<Object>(), Handle<Context>(isolate->native_context()), + NULL, NULL, v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE, + MaybeHandle<FixedArray>()) + .ToHandleChecked(); return isolate->factory()->NewFunctionFromSharedFunctionInfo( shared, isolate->native_context()); } @@ -47,9 +49,8 @@ TEST(TestLinkageCreate) { HandleAndZoneScope handles; Handle<JSFunction> function = Compile("a + b"); Handle<SharedFunctionInfo> shared(function->shared()); - Handle<Script> script(Script::cast(shared->script())); - CompilationInfo info(handles.main_zone(), function->GetIsolate(), script, - shared, function); + CompilationInfo info(handles.main_zone(), function->GetIsolate(), shared, + function); CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info); CHECK(descriptor); } @@ -65,9 +66,8 @@ TEST(TestLinkageJSFunctionIncoming) { Handle<JSFunction>::cast(v8::Utils::OpenHandle( *v8::Local<v8::Function>::Cast(CompileRun(sources[i])))); Handle<SharedFunctionInfo> shared(function->shared()); - Handle<Script> script(Script::cast(shared->script())); - CompilationInfo info(handles.main_zone(), function->GetIsolate(), script, - shared, function); + CompilationInfo info(handles.main_zone(), function->GetIsolate(), shared, + function); CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info); CHECK(descriptor); @@ -83,9 +83,8 @@ TEST(TestLinkageJSCall) { HandleAndZoneScope handles; Handle<JSFunction> function = Compile("a + c"); Handle<SharedFunctionInfo> shared(function->shared()); - Handle<Script> script(Script::cast(shared->script())); - CompilationInfo info(handles.main_zone(), function->GetIsolate(), script, - shared, function); + CompilationInfo info(handles.main_zone(), function->GetIsolate(), shared, + function); for (int i = 0; i < 32; i++) { CallDescriptor* descriptor = Linkage::GetJSCallDescriptor( @@ -108,8 +107,7 @@ TEST(TestLinkageStubCall) { Isolate* isolate = CcTest::InitIsolateOnce(); Zone zone(isolate->allocator(), ZONE_NAME); Callable callable = Builtins::CallableFor(isolate, Builtins::kToNumber); - CompilationInfo info(ArrayVector("test"), isolate, &zone, - Code::ComputeFlags(Code::STUB)); + CompilationInfo info(ArrayVector("test"), isolate, &zone, Code::STUB); CallDescriptor* descriptor = Linkage::GetStubCallDescriptor( isolate, &zone, callable.descriptor(), 0, CallDescriptor::kNoFlags, Operator::kNoProperties); diff --git a/deps/v8/test/cctest/compiler/test-multiple-return.cc b/deps/v8/test/cctest/compiler/test-multiple-return.cc index a016564fe0..25e5527f03 100644 --- a/deps/v8/test/cctest/compiler/test-multiple-return.cc +++ b/deps/v8/test/cctest/compiler/test-multiple-return.cc @@ -82,7 +82,7 @@ TEST(ReturnThreeValues) { m.Return(add, sub, mul); CompilationInfo info(ArrayVector("testing"), handles.main_isolate(), - handles.main_zone(), Code::ComputeFlags(Code::STUB)); + handles.main_zone(), Code::STUB); Handle<Code> code = Pipeline::GenerateCodeForTesting(&info, desc, m.graph(), m.Export()); #ifdef ENABLE_DISASSEMBLER 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 9189c7c502..a1dde0dc41 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,6 +4,7 @@ #include <utility> +#include "src/api.h" #include "src/compilation-info.h" #include "src/compiler/pipeline.h" #include "src/debug/debug-interface.h" @@ -118,11 +119,10 @@ class BytecodeGraphTester { Zone zone(function->GetIsolate()->allocator(), ZONE_NAME); Handle<SharedFunctionInfo> shared(function->shared()); - Handle<Script> script(Script::cast(shared->script())); - CompilationInfo compilation_info(&zone, function->GetIsolate(), script, - shared, function); + CompilationInfo compilation_info(&zone, function->GetIsolate(), shared, + function); Handle<Code> code = Pipeline::GenerateCodeForTesting(&compilation_info); - function->ReplaceCode(*code); + function->set_code(*code); return function; } @@ -2994,6 +2994,19 @@ TEST(BytecodeGraphBuilderDebuggerStatement) { CHECK_EQ(2, delegate.debug_break_count); } +#undef SHARD_TEST_BY_2 +#undef SHARD_TEST_BY_4 +#undef SPACE +#undef REPEAT_2 +#undef REPEAT_4 +#undef REPEAT_8 +#undef REPEAT_16 +#undef REPEAT_32 +#undef REPEAT_64 +#undef REPEAT_128 +#undef REPEAT_256 +#undef REPEAT_127 + } // namespace compiler } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-run-intrinsics.cc b/deps/v8/test/cctest/compiler/test-run-intrinsics.cc index 1015ca0989..3d6f1fbe0d 100644 --- a/deps/v8/test/cctest/compiler/test-run-intrinsics.cc +++ b/deps/v8/test/cctest/compiler/test-run-intrinsics.cc @@ -107,16 +107,6 @@ TEST(StringAdd) { } -TEST(StringCharCodeAt) { - FunctionTester T("(function(a,b) { return %_StringCharCodeAt(a,b); })", - flags); - - T.CheckCall(T.Val('e'), T.Val("huge fan!"), T.Val(3)); - T.CheckCall(T.Val('f'), T.Val("\xE2\x9D\x8A fan!"), T.Val(2)); - T.CheckCall(T.nan(), T.Val("not a fan!"), T.Val(23)); -} - - TEST(StringCompare) { FunctionTester T("(function(a,b) { return %_StringCompare(a,b); })", flags); diff --git a/deps/v8/test/cctest/compiler/test-run-jsobjects.cc b/deps/v8/test/cctest/compiler/test-run-jsobjects.cc index ce6756d6db..0c2912cbef 100644 --- a/deps/v8/test/cctest/compiler/test-run-jsobjects.cc +++ b/deps/v8/test/cctest/compiler/test-run-jsobjects.cc @@ -4,14 +4,7 @@ #include "src/factory.h" #include "src/isolate.h" -#include "src/objects.h" -// FIXME(mstarzinger, marja): This is weird, but required because of the missing -// (disallowed) include: src/factory.h -> src/objects-inl.h #include "src/objects-inl.h" -// FIXME(mstarzinger, marja): This is weird, but required because of the missing -// (disallowed) include: src/feedback-vector.h -> -// src/feedback-vector-inl.h -#include "src/feedback-vector-inl.h" #include "test/cctest/compiler/function-tester.h" namespace v8 { diff --git a/deps/v8/test/cctest/compiler/test-run-machops.cc b/deps/v8/test/cctest/compiler/test-run-machops.cc index a429973f0c..a2cc262fba 100644 --- a/deps/v8/test/cctest/compiler/test-run-machops.cc +++ b/deps/v8/test/cctest/compiler/test-run-machops.cc @@ -6902,16 +6902,17 @@ TEST(Regression6640) { int32_t old_value = 0; int32_t new_value = 1; - Node* c = m.RelocatableInt32Constant(old_value, - RelocInfo::WASM_MEMORY_SIZE_REFERENCE); + Node* c = m.RelocatableInt32Constant( + old_value, RelocInfo::WASM_FUNCTION_TABLE_SIZE_REFERENCE); m.Return(m.Word32Equal(c, c)); // Patch the code. Handle<Code> code = m.GetCode(); - for (RelocIterator it(*code, 1 << RelocInfo::WASM_MEMORY_SIZE_REFERENCE); + for (RelocIterator it(*code, + 1 << RelocInfo::WASM_FUNCTION_TABLE_SIZE_REFERENCE); !it.done(); it.next()) { - it.rinfo()->update_wasm_memory_size(code->GetIsolate(), old_value, - new_value, FLUSH_ICACHE_IF_NEEDED); + it.rinfo()->update_wasm_function_table_size_reference( + code->GetIsolate(), old_value, new_value, FLUSH_ICACHE_IF_NEEDED); } CHECK(m.Call()); diff --git a/deps/v8/test/cctest/compiler/test-run-native-calls.cc b/deps/v8/test/cctest/compiler/test-run-native-calls.cc index b95c530076..70a0455f20 100644 --- a/deps/v8/test/cctest/compiler/test-run-native-calls.cc +++ b/deps/v8/test/cctest/compiler/test-run-native-calls.cc @@ -18,6 +18,7 @@ namespace v8 { namespace internal { namespace compiler { +namespace test_run_native_calls { const auto GetRegConfig = RegisterConfiguration::Default; @@ -247,7 +248,7 @@ class Int32Signature : public MachineSignature { public: explicit Int32Signature(int param_count) : MachineSignature(1, param_count, kIntTypes) { - CHECK(param_count <= kMaxParamCount); + CHECK_GE(kMaxParamCount, param_count); } }; @@ -256,7 +257,7 @@ Handle<Code> CompileGraph(const char* name, CallDescriptor* desc, Graph* graph, Schedule* schedule = nullptr) { Isolate* isolate = CcTest::InitIsolateOnce(); CompilationInfo info(ArrayVector("testing"), isolate, graph->zone(), - Code::ComputeFlags(Code::STUB)); + Code::STUB); Handle<Code> code = Pipeline::GenerateCodeForTesting(&info, desc, graph, schedule); CHECK(!code.is_null()); @@ -323,7 +324,7 @@ class ArgsBuffer { public: explicit Sig(int param_count) : MachineSignature(1, param_count, MachTypes()) { - CHECK(param_count <= kMaxParamCount); + CHECK_GE(kMaxParamCount, param_count); } }; @@ -1225,6 +1226,8 @@ TEST(RunStackSlotFloat64) { double magic = 3456.375; TestStackSlot(MachineType::Float64(), magic); } + +} // namespace test_run_native_calls } // namespace compiler } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-run-stubs.cc b/deps/v8/test/cctest/compiler/test-run-stubs.cc index b0ddc71d87..d42a803c3e 100644 --- a/deps/v8/test/cctest/compiler/test-run-stubs.cc +++ b/deps/v8/test/cctest/compiler/test-run-stubs.cc @@ -24,8 +24,7 @@ class StubTester { public: StubTester(Isolate* isolate, Zone* zone, CodeStub* stub) : zone_(zone), - info_(ArrayVector("test"), isolate, zone, - Code::ComputeFlags(Code::HANDLER)), + info_(ArrayVector("test"), isolate, zone, Code::STUB), interface_descriptor_(stub->GetCallInterfaceDescriptor()), descriptor_(Linkage::GetStubCallDescriptor( isolate, zone, interface_descriptor_, @@ -38,8 +37,7 @@ class StubTester { StubTester(Isolate* isolate, Zone* zone, Builtins::Name name) : zone_(zone), - info_(ArrayVector("test"), isolate, zone, - Code::ComputeFlags(Code::HANDLER)), + info_(ArrayVector("test"), isolate, zone, Code::STUB), interface_descriptor_( Builtins::CallableFor(isolate, name).descriptor()), descriptor_(Linkage::GetStubCallDescriptor( @@ -108,8 +106,7 @@ TEST(RunStringLengthStub) { Isolate* isolate = scope.main_isolate(); Zone* zone = scope.main_zone(); - StringLengthStub stub(isolate); - StubTester tester(isolate, zone, &stub); + StubTester tester(isolate, zone, Builtins::kLoadIC_StringLength); // Actuall call through to the stub, verifying its result. const char* testString = "Und das Lamm schrie HURZ!"; diff --git a/deps/v8/test/cctest/compiler/test-run-wasm-machops.cc b/deps/v8/test/cctest/compiler/test-run-wasm-machops.cc index 93acc0889a..7f63484ba9 100644 --- a/deps/v8/test/cctest/compiler/test-run-wasm-machops.cc +++ b/deps/v8/test/cctest/compiler/test-run-wasm-machops.cc @@ -10,6 +10,7 @@ #include "src/base/utils/random-number-generator.h" #include "src/codegen.h" #include "src/objects-inl.h" +#include "src/wasm/wasm-objects.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/codegen-tester.h" #include "test/cctest/compiler/graph-builder-tester.h" @@ -19,29 +20,6 @@ namespace v8 { namespace internal { namespace compiler { -static void UpdateMemoryReferences(Handle<Code> code, Address old_base, - Address new_base, uint32_t old_size, - uint32_t new_size) { - Isolate* isolate = CcTest::i_isolate(); - bool modified = false; - int mode_mask = RelocInfo::ModeMask(RelocInfo::WASM_MEMORY_REFERENCE) | - RelocInfo::ModeMask(RelocInfo::WASM_MEMORY_SIZE_REFERENCE); - for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { - RelocInfo::Mode mode = it.rinfo()->rmode(); - if (RelocInfo::IsWasmMemoryReference(mode)) { - it.rinfo()->update_wasm_memory_reference(isolate, old_base, new_base); - } else { - DCHECK(RelocInfo::IsWasmMemorySizeReference(mode)); - it.rinfo()->update_wasm_memory_size(isolate, old_size, new_size); - } - modified = true; - } - if (modified) { - Assembler::FlushICache(isolate, code->instruction_start(), - code->instruction_size()); - } -} - static void UpdateFunctionTableSizeReferences(Handle<Code> code, uint32_t old_size, uint32_t new_size) { @@ -70,17 +48,19 @@ static void RunLoadStoreRelocation(MachineType rep) { CType new_buffer[kNumElems]; byte* raw = reinterpret_cast<byte*>(buffer); byte* new_raw = reinterpret_cast<byte*>(new_buffer); + WasmContext wasm_context = {raw, sizeof(buffer)}; for (size_t i = 0; i < sizeof(buffer); i++) { raw[i] = static_cast<byte>((i + sizeof(CType)) ^ 0xAA); new_raw[i] = static_cast<byte>((i + sizeof(CType)) ^ 0xAA); } uint32_t OK = 0x29000; RawMachineAssemblerTester<uint32_t> m; - Node* base = m.RelocatableIntPtrConstant(reinterpret_cast<intptr_t>(raw), - RelocInfo::WASM_MEMORY_REFERENCE); - Node* base1 = m.RelocatableIntPtrConstant( - reinterpret_cast<intptr_t>(raw + sizeof(CType)), - RelocInfo::WASM_MEMORY_REFERENCE); + Node* wasm_context_node = + m.RelocatableIntPtrConstant(reinterpret_cast<uintptr_t>(&wasm_context), + RelocInfo::WASM_CONTEXT_REFERENCE); + Node* offset = m.Int32Constant(offsetof(WasmContext, mem_start)); + Node* base = m.Load(MachineType::UintPtr(), wasm_context_node, offset); + Node* base1 = m.IntPtrAdd(base, m.Int32Constant(sizeof(CType))); Node* index = m.Int32Constant(0); Node* load = m.Load(rep, base, index); m.Store(rep.representation(), base1, index, load, kNoWriteBarrier); @@ -88,10 +68,8 @@ static void RunLoadStoreRelocation(MachineType rep) { CHECK(buffer[0] != buffer[1]); CHECK_EQ(OK, m.Call()); CHECK(buffer[0] == buffer[1]); - m.GenerateCode(); - Handle<Code> code = m.GetCode(); - UpdateMemoryReferences(code, raw, new_raw, sizeof(buffer), - sizeof(new_buffer)); + wasm_context.mem_size = sizeof(new_buffer); + wasm_context.mem_start = new_raw; CHECK(new_buffer[0] != new_buffer[1]); CHECK_EQ(OK, m.Call()); CHECK(new_buffer[0] == new_buffer[1]); @@ -115,19 +93,24 @@ static void RunLoadStoreRelocationOffset(MachineType rep) { const int kNumElems = 4; CType buffer[kNumElems]; CType new_buffer[kNumElems + 1]; + WasmContext wasm_context; for (int32_t x = 0; x < kNumElems; x++) { int32_t y = kNumElems - x - 1; // initialize the buffer with raw data. byte* raw = reinterpret_cast<byte*>(buffer); + wasm_context = {raw, sizeof(buffer)}; for (size_t i = 0; i < sizeof(buffer); i++) { raw[i] = static_cast<byte>((i + sizeof(buffer)) ^ 0xAA); } RawMachineAssemblerTester<int32_t> m; int32_t OK = 0x29000 + x; - Node* base = m.RelocatableIntPtrConstant(reinterpret_cast<intptr_t>(buffer), - RelocInfo::WASM_MEMORY_REFERENCE); + Node* wasm_context_node = + m.RelocatableIntPtrConstant(reinterpret_cast<uintptr_t>(&wasm_context), + RelocInfo::WASM_CONTEXT_REFERENCE); + Node* offset = m.Int32Constant(offsetof(WasmContext, mem_start)); + Node* base = m.Load(MachineType::UintPtr(), wasm_context_node, offset); Node* index0 = m.IntPtrConstant(x * sizeof(buffer[0])); Node* load = m.Load(rep, base, index0); Node* index1 = m.IntPtrConstant(y * sizeof(buffer[0])); @@ -137,7 +120,6 @@ static void RunLoadStoreRelocationOffset(MachineType rep) { CHECK(buffer[x] != buffer[y]); CHECK_EQ(OK, m.Call()); CHECK(buffer[x] == buffer[y]); - m.GenerateCode(); // Initialize new buffer and set old_buffer to 0 byte* new_raw = reinterpret_cast<byte*>(new_buffer); @@ -146,10 +128,8 @@ static void RunLoadStoreRelocationOffset(MachineType rep) { new_raw[i] = static_cast<byte>((i + sizeof(buffer)) ^ 0xAA); } - // Perform relocation on generated code - Handle<Code> code = m.GetCode(); - UpdateMemoryReferences(code, raw, new_raw, sizeof(buffer), - sizeof(new_buffer)); + wasm_context.mem_size = sizeof(new_buffer); + wasm_context.mem_start = new_raw; CHECK(new_buffer[x] != new_buffer[y]); CHECK_EQ(OK, m.Call()); @@ -172,9 +152,13 @@ TEST(RunLoadStoreRelocationOffset) { TEST(Uint32LessThanMemoryRelocation) { RawMachineAssemblerTester<uint32_t> m; RawMachineLabel within_bounds, out_of_bounds; + WasmContext wasm_context = {reinterpret_cast<Address>(1234), 0x200}; Node* index = m.Int32Constant(0x200); - Node* limit = - m.RelocatableInt32Constant(0x200, RelocInfo::WASM_MEMORY_SIZE_REFERENCE); + Node* wasm_context_node = + m.RelocatableIntPtrConstant(reinterpret_cast<uintptr_t>(&wasm_context), + RelocInfo::WASM_CONTEXT_REFERENCE); + Node* offset = m.Int32Constant(offsetof(WasmContext, mem_size)); + Node* limit = m.Load(MachineType::Uint32(), wasm_context_node, offset); Node* cond = m.AddNode(m.machine()->Uint32LessThan(), index, limit); m.Branch(cond, &within_bounds, &out_of_bounds); m.Bind(&within_bounds); @@ -183,11 +167,7 @@ TEST(Uint32LessThanMemoryRelocation) { m.Return(m.Int32Constant(0xdeadbeef)); // Check that index is out of bounds with current size CHECK_EQ(0xdeadbeef, m.Call()); - m.GenerateCode(); - - Handle<Code> code = m.GetCode(); - UpdateMemoryReferences(code, reinterpret_cast<Address>(1234), - reinterpret_cast<Address>(1234), 0x200, 0x400); + wasm_context.mem_size = 0x400; // Check that after limit is increased, index is within bounds. CHECK_EQ(0xacedu, m.Call()); } diff --git a/deps/v8/test/cctest/compiler/value-helper.h b/deps/v8/test/cctest/compiler/value-helper.h index 14bfaf9fe9..87cdb585da 100644 --- a/deps/v8/test/cctest/compiler/value-helper.h +++ b/deps/v8/test/cctest/compiler/value-helper.h @@ -332,9 +332,10 @@ class ValueHelper { // Helper macros that can be used in FOR_INT32_INPUTS(i) { ... *i ... } // Watch out, these macros aren't hygenic; they pollute your scope. Thanks STL. -#define FOR_INPUTS(ctype, itype, var) \ - std::vector<ctype> var##_vec = ValueHelper::itype##_vector(); \ - for (std::vector<ctype>::iterator var = var##_vec.begin(); \ +#define FOR_INPUTS(ctype, itype, var) \ + std::vector<ctype> var##_vec = \ + ::v8::internal::compiler::ValueHelper::itype##_vector(); \ + for (std::vector<ctype>::iterator var = var##_vec.begin(); \ var != var##_vec.end(); ++var) #define FOR_INT32_INPUTS(var) FOR_INPUTS(int32_t, int32, var) @@ -362,10 +363,10 @@ static inline void CheckFloatEq(volatile float x, volatile float y) { } } -#define CHECK_FLOAT_EQ(lhs, rhs) \ - do { \ - volatile float tmp = lhs; \ - CheckFloatEq(tmp, rhs); \ +#define CHECK_FLOAT_EQ(lhs, rhs) \ + do { \ + volatile float tmp = lhs; \ + ::v8::internal::compiler::CheckFloatEq(tmp, rhs); \ } while (0) static inline void CheckDoubleEq(volatile double x, volatile double y) { @@ -377,10 +378,10 @@ static inline void CheckDoubleEq(volatile double x, volatile double y) { } } -#define CHECK_DOUBLE_EQ(lhs, rhs) \ - do { \ - volatile double tmp = lhs; \ - CheckDoubleEq(tmp, rhs); \ +#define CHECK_DOUBLE_EQ(lhs, rhs) \ + do { \ + volatile double tmp = lhs; \ + ::v8::internal::compiler::CheckDoubleEq(tmp, rhs); \ } while (0) } // namespace compiler diff --git a/deps/v8/test/cctest/ffi/OWNERS b/deps/v8/test/cctest/ffi/OWNERS deleted file mode 100644 index f78789f5b5..0000000000 --- a/deps/v8/test/cctest/ffi/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -mattloring@google.com -ofrobots@google.com - -# COMPONENT: Blink>JavaScript>Compiler diff --git a/deps/v8/test/cctest/ffi/test-ffi.cc b/deps/v8/test/cctest/ffi/test-ffi.cc deleted file mode 100644 index 9d87244e94..0000000000 --- a/deps/v8/test/cctest/ffi/test-ffi.cc +++ /dev/null @@ -1,222 +0,0 @@ -// Copyright 2017 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.h" -#include "src/codegen.h" -#include "src/ffi/ffi-compiler.h" -#include "src/objects-inl.h" -#include "test/cctest/cctest.h" - -namespace v8 { -namespace internal { -namespace ffi { - -static void hello_world() { printf("hello world from native code\n"); } - -TEST(Run_FFI_Hello) { - Isolate* isolate = CcTest::InitIsolateOnce(); - HandleScope scope(isolate); - - Handle<String> name = - isolate->factory()->InternalizeUtf8String("hello_world"); - Handle<Object> undefined = isolate->factory()->undefined_value(); - - AccountingAllocator allocator; - Zone zone(&allocator, ZONE_NAME); - FFISignature::Builder sig_builder(&zone, 0, 0); - NativeFunction func = {sig_builder.Build(), - reinterpret_cast<uint8_t*>(hello_world)}; - - Handle<JSFunction> jsfunc = CompileJSToNativeWrapper(isolate, name, func); - - Handle<Object> result = - Execution::Call(isolate, jsfunc, undefined, 0, nullptr).ToHandleChecked(); - - CHECK(result->IsUndefined(isolate)); -} - -static int add2(int x, int y) { return x + y; } - -TEST(Run_FFI_add2) { - Isolate* isolate = CcTest::InitIsolateOnce(); - HandleScope scope(isolate); - - Handle<String> name = isolate->factory()->InternalizeUtf8String("add2"); - Handle<Object> undefined = isolate->factory()->undefined_value(); - - AccountingAllocator allocator; - Zone zone(&allocator, ZONE_NAME); - FFISignature::Builder sig_builder(&zone, 1, 2); - sig_builder.AddReturn(FFIType::kInt32); - sig_builder.AddParam(FFIType::kInt32); - sig_builder.AddParam(FFIType::kInt32); - NativeFunction func = {sig_builder.Build(), reinterpret_cast<uint8_t*>(add2)}; - - Handle<JSFunction> jsfunc = CompileJSToNativeWrapper(isolate, name, func); - - // Simple math should work. - { - Handle<Object> args[] = {isolate->factory()->NewNumber(1.0), - isolate->factory()->NewNumber(41.0)}; - Handle<Object> result = - Execution::Call(isolate, jsfunc, undefined, arraysize(args), args) - .ToHandleChecked(); - CHECK_EQ(42.0, result->Number()); - } - - // Truncate floating point to integer. - { - Handle<Object> args[] = {isolate->factory()->NewNumber(1.9), - isolate->factory()->NewNumber(41.0)}; - Handle<Object> result = - Execution::Call(isolate, jsfunc, undefined, arraysize(args), args) - .ToHandleChecked(); - CHECK_EQ(42.0, result->Number()); - } - - // INT_MAX + 1 should wrap. - { - Handle<Object> args[] = {isolate->factory()->NewNumber(kMaxInt), - isolate->factory()->NewNumber(1)}; - Handle<Object> result = - Execution::Call(isolate, jsfunc, undefined, arraysize(args), args) - .ToHandleChecked(); - CHECK_EQ(kMinInt, result->Number()); - } - - // INT_MIN + -1 should wrap. - { - Handle<Object> args[] = {isolate->factory()->NewNumber(kMinInt), - isolate->factory()->NewNumber(-1)}; - Handle<Object> result = - Execution::Call(isolate, jsfunc, undefined, arraysize(args), args) - .ToHandleChecked(); - CHECK_EQ(kMaxInt, result->Number()); - } - - // Numbers get truncated to the 32 least significant bits. - { - Handle<Object> args[] = {isolate->factory()->NewNumber(1ull << 40), - isolate->factory()->NewNumber(-1)}; - Handle<Object> result = - Execution::Call(isolate, jsfunc, undefined, arraysize(args), args) - .ToHandleChecked(); - CHECK_EQ(-1, result->Number()); - } - - // String '57' converts to 57. - { - Handle<Object> args[] = { - isolate->factory()->NewStringFromAsciiChecked("57"), - isolate->factory()->NewNumber(41.0)}; - Handle<Object> result = - Execution::Call(isolate, jsfunc, undefined, arraysize(args), args) - .ToHandleChecked(); - CHECK_EQ(98.0, result->Number()); - } - - // String 'foo' converts to 0. - { - Handle<Object> args[] = { - isolate->factory()->NewStringFromAsciiChecked("foo"), - isolate->factory()->NewNumber(41.0)}; - Handle<Object> result = - Execution::Call(isolate, jsfunc, undefined, arraysize(args), args) - .ToHandleChecked(); - CHECK_EQ(41.0, result->Number()); - } - - // String '58o' converts to 0. - { - Handle<Object> args[] = { - isolate->factory()->NewStringFromAsciiChecked("58o"), - isolate->factory()->NewNumber(41.0)}; - Handle<Object> result = - Execution::Call(isolate, jsfunc, undefined, arraysize(args), args) - .ToHandleChecked(); - CHECK_EQ(41.0, result->Number()); - } - - // NaN converts to 0. - { - Handle<Object> args[] = {isolate->factory()->nan_value(), - isolate->factory()->NewNumber(41.0)}; - Handle<Object> result = - Execution::Call(isolate, jsfunc, undefined, arraysize(args), args) - .ToHandleChecked(); - CHECK_EQ(41.0, result->Number()); - } - - // null converts to 0. - { - Handle<Object> args[] = {isolate->factory()->null_value(), - isolate->factory()->NewNumber(41.0)}; - Handle<Object> result = - Execution::Call(isolate, jsfunc, undefined, arraysize(args), args) - .ToHandleChecked(); - CHECK_EQ(41.0, result->Number()); - } -} - -static int add6(int a, int b, int c, int d, int e, int f) { - return a + b + c + d + e + f; -} - -TEST(Run_FFI_add6) { - Isolate* isolate = CcTest::InitIsolateOnce(); - HandleScope scope(isolate); - - Handle<String> name = isolate->factory()->InternalizeUtf8String("add6"); - Handle<Object> undefined = isolate->factory()->undefined_value(); - - AccountingAllocator allocator; - Zone zone(&allocator, ZONE_NAME); - FFISignature::Builder sig_builder(&zone, 1, 7); - sig_builder.AddReturn(FFIType::kInt32); - for (int i = 0; i < 7; i++) { - sig_builder.AddParam(FFIType::kInt32); - } - NativeFunction func = {sig_builder.Build(), reinterpret_cast<uint8_t*>(add6)}; - - Handle<JSFunction> jsfunc = CompileJSToNativeWrapper(isolate, name, func); - Handle<Object> args[] = { - isolate->factory()->NewNumber(1), isolate->factory()->NewNumber(2), - isolate->factory()->NewNumber(3), isolate->factory()->NewNumber(4), - isolate->factory()->NewNumber(5), isolate->factory()->NewNumber(6)}; - - Handle<Object> result = - Execution::Call(isolate, jsfunc, undefined, arraysize(args), args) - .ToHandleChecked(); - - CHECK_EQ(21.0, result->Number()); - - { - // Ensure builtin frames are generated - FLAG_allow_natives_syntax = true; - v8::Local<v8::Value> res = CompileRun( - "var o = { valueOf: function() { %DebugTrace(); return 1; } }; o;"); - Handle<JSReceiver> param(v8::Utils::OpenHandle(v8::Object::Cast(*res))); - Handle<Object> args[] = {param, - isolate->factory()->NewNumber(2), - isolate->factory()->NewNumber(3), - isolate->factory()->NewNumber(4), - isolate->factory()->NewNumber(5), - isolate->factory()->NewNumber(6), - isolate->factory()->NewNumber(21)}; - - Handle<Object> result = - Execution::Call(isolate, jsfunc, undefined, arraysize(args), args) - .ToHandleChecked(); - CHECK_EQ(21.0, result->Number()); - CHECK_EQ( - 1.0, - res->NumberValue( - reinterpret_cast<v8::Isolate*>(isolate)->GetCurrentContext()) - .ToChecked()); - } -} - -} // namespace ffi -} // namespace internal -} // namespace v8 diff --git a/deps/v8/test/cctest/heap/heap-utils.cc b/deps/v8/test/cctest/heap/heap-utils.cc index 1d936f7c5b..6e92b96da1 100644 --- a/deps/v8/test/cctest/heap/heap-utils.cc +++ b/deps/v8/test/cctest/heap/heap-utils.cc @@ -32,6 +32,7 @@ int FixedArrayLenFromSize(int size) { std::vector<Handle<FixedArray>> FillOldSpacePageWithFixedArrays(Heap* heap, int remainder) { + PauseAllocationObserversScope pause_observers(heap); std::vector<Handle<FixedArray>> handles; Isolate* isolate = heap->isolate(); const int kArraySize = 128; @@ -203,7 +204,7 @@ void ForceEvacuationCandidate(Page* page) { int remaining = static_cast<int>(limit - top); space->heap()->CreateFillerObjectAt(top, remaining, ClearRecordedSlots::kNo); - space->SetTopAndLimit(nullptr, nullptr); + space->EmptyAllocationInfo(); } } diff --git a/deps/v8/test/cctest/heap/test-alloc.cc b/deps/v8/test/cctest/heap/test-alloc.cc index d4abaa3a8a..06aec9ac6e 100644 --- a/deps/v8/test/cctest/heap/test-alloc.cc +++ b/deps/v8/test/cctest/heap/test-alloc.cc @@ -145,12 +145,12 @@ TEST(StressJS) { // Force the creation of an initial map and set the code to // something empty. factory->NewJSObject(function); - function->ReplaceCode(CcTest::i_isolate()->builtins()->builtin( - Builtins::kEmptyFunction)); + function->set_code( + CcTest::i_isolate()->builtins()->builtin(Builtins::kEmptyFunction)); // Patch the map to have an accessor for "get". Handle<Map> map(function->initial_map()); Handle<DescriptorArray> instance_descriptors(map->instance_descriptors()); - CHECK(instance_descriptors->IsEmpty()); + CHECK_EQ(0, instance_descriptors->number_of_descriptors()); PropertyAttributes attrs = NONE; Handle<AccessorInfo> foreign = TestAccessorInfo(isolate, attrs); 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 73286f3970..f3907a0bdc 100644 --- a/deps/v8/test/cctest/heap/test-array-buffer-tracker.cc +++ b/deps/v8/test/cctest/heap/test-array-buffer-tracker.cc @@ -335,6 +335,7 @@ UNINITIALIZED_TEST(ArrayBuffer_SemiSpaceCopyMultipleTasks) { Page::FromAddress(buf2->address())); heap::GcAndSweep(heap, OLD_SPACE); } + isolate->Dispose(); } TEST(ArrayBuffer_RetainedSizeIncreases) { diff --git a/deps/v8/test/cctest/heap/test-compaction.cc b/deps/v8/test/cctest/heap/test-compaction.cc index d98aa1fb56..e8c65d1110 100644 --- a/deps/v8/test/cctest/heap/test-compaction.cc +++ b/deps/v8/test/cctest/heap/test-compaction.cc @@ -5,13 +5,7 @@ #include "src/factory.h" #include "src/heap/mark-compact.h" #include "src/isolate.h" -// FIXME(mstarzinger, marja): This is weird, but required because of the missing -// (disallowed) include: src/factory.h -> src/objects-inl.h #include "src/objects-inl.h" -// FIXME(mstarzinger, marja): This is weird, but required because of the missing -// (disallowed) include: src/feedback-vector.h -> -// src/feedback-vector-inl.h -#include "src/feedback-vector-inl.h" #include "test/cctest/cctest.h" #include "test/cctest/heap/heap-tester.h" #include "test/cctest/heap/heap-utils.h" diff --git a/deps/v8/test/cctest/heap/test-concurrent-marking.cc b/deps/v8/test/cctest/heap/test-concurrent-marking.cc index 36bf49c2ff..5ee99c6320 100644 --- a/deps/v8/test/cctest/heap/test-concurrent-marking.cc +++ b/deps/v8/test/cctest/heap/test-concurrent-marking.cc @@ -31,12 +31,20 @@ TEST(ConcurrentMarking) { if (!i::FLAG_concurrent_marking) return; CcTest::InitializeVM(); Heap* heap = CcTest::heap(); - ConcurrentMarking::MarkingWorklist shared, bailout; + CcTest::CollectAllGarbage(); + if (!heap->incremental_marking()->IsStopped()) return; + MarkCompactCollector* collector = CcTest::heap()->mark_compact_collector(); + if (collector->sweeping_in_progress()) { + collector->EnsureSweepingCompleted(); + } + + ConcurrentMarking::MarkingWorklist shared, bailout, on_hold; WeakObjects weak_objects; ConcurrentMarking* concurrent_marking = - new ConcurrentMarking(heap, &shared, &bailout, &weak_objects); + new ConcurrentMarking(heap, &shared, &bailout, &on_hold, &weak_objects); PublishSegment(&shared, heap->undefined_value()); concurrent_marking->ScheduleTasks(); + concurrent_marking->WaitForTasks(); concurrent_marking->EnsureCompleted(); delete concurrent_marking; } @@ -45,19 +53,43 @@ TEST(ConcurrentMarkingReschedule) { if (!i::FLAG_concurrent_marking) return; CcTest::InitializeVM(); Heap* heap = CcTest::heap(); - ConcurrentMarking::MarkingWorklist shared, bailout; + CcTest::CollectAllGarbage(); + if (!heap->incremental_marking()->IsStopped()) return; + MarkCompactCollector* collector = CcTest::heap()->mark_compact_collector(); + if (collector->sweeping_in_progress()) { + collector->EnsureSweepingCompleted(); + } + + ConcurrentMarking::MarkingWorklist shared, bailout, on_hold; WeakObjects weak_objects; ConcurrentMarking* concurrent_marking = - new ConcurrentMarking(heap, &shared, &bailout, &weak_objects); + new ConcurrentMarking(heap, &shared, &bailout, &on_hold, &weak_objects); PublishSegment(&shared, heap->undefined_value()); concurrent_marking->ScheduleTasks(); + concurrent_marking->WaitForTasks(); concurrent_marking->EnsureCompleted(); PublishSegment(&shared, heap->undefined_value()); concurrent_marking->RescheduleTasksIfNeeded(); + concurrent_marking->WaitForTasks(); concurrent_marking->EnsureCompleted(); delete concurrent_marking; } +TEST(ConcurrentMarkingMarkedBytes) { + if (!i::FLAG_concurrent_marking) return; + CcTest::InitializeVM(); + Isolate* isolate = CcTest::i_isolate(); + Heap* heap = CcTest::heap(); + HandleScope sc(isolate); + Handle<FixedArray> root = isolate->factory()->NewFixedArray(1000000); + CcTest::CollectAllGarbage(); + if (!heap->incremental_marking()->IsStopped()) return; + heap::SimulateIncrementalMarking(heap, false); + heap->concurrent_marking()->WaitForTasks(); + heap->concurrent_marking()->EnsureCompleted(); + CHECK_GE(heap->concurrent_marking()->TotalMarkedBytes(), root->Size()); +} + } // namespace heap } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/heap/test-heap.cc b/deps/v8/test/cctest/heap/test-heap.cc index 89c074b3c3..ab2ba1a53b 100644 --- a/deps/v8/test/cctest/heap/test-heap.cc +++ b/deps/v8/test/cctest/heap/test-heap.cc @@ -197,8 +197,8 @@ HEAP_TEST(TestNewSpaceRefsInCopiedCode) { CodeDesc desc; masm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); Code* tmp = nullptr; heap->CopyCode(*code).To(&tmp); @@ -219,8 +219,8 @@ static void CheckFindCodeObject(Isolate* isolate) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); CHECK(code->IsCode()); HeapObject* obj = HeapObject::cast(*code); @@ -231,8 +231,8 @@ static void CheckFindCodeObject(Isolate* isolate) { CHECK_EQ(*code, found); } - Handle<Code> copy = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> copy = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); HeapObject* obj_copy = HeapObject::cast(*copy); Object* not_right = isolate->FindCodeObject(obj_copy->address() + obj_copy->Size() / 2); @@ -1367,22 +1367,6 @@ int CountNativeContexts() { return count; } - -// Count the number of user functions in the weak list of optimized -// functions attached to a native context. -static int CountOptimizedUserFunctions(v8::Local<v8::Context> context) { - int count = 0; - Handle<Context> icontext = v8::Utils::OpenHandle(*context); - Object* object = icontext->get(Context::OPTIMIZED_FUNCTIONS_LIST); - while (object->IsJSFunction() && - JSFunction::cast(object)->shared()->IsUserJavaScript()) { - count++; - object = JSFunction::cast(object)->next_function_link(); - } - return count; -} - - TEST(TestInternalWeakLists) { FLAG_always_opt = false; FLAG_allow_natives_syntax = true; @@ -1420,17 +1404,11 @@ TEST(TestInternalWeakLists) { // Create a handle scope so no function objects get stuck in the outer // handle scope. HandleScope scope(isolate); - CHECK_EQ(0, CountOptimizedUserFunctions(ctx[i])); OptimizeEmptyFunction("f1"); - CHECK_EQ(1, CountOptimizedUserFunctions(ctx[i])); OptimizeEmptyFunction("f2"); - CHECK_EQ(2, CountOptimizedUserFunctions(ctx[i])); OptimizeEmptyFunction("f3"); - CHECK_EQ(3, CountOptimizedUserFunctions(ctx[i])); OptimizeEmptyFunction("f4"); - CHECK_EQ(4, CountOptimizedUserFunctions(ctx[i])); OptimizeEmptyFunction("f5"); - CHECK_EQ(5, CountOptimizedUserFunctions(ctx[i])); // Remove function f1, and CompileRun("f1=null"); @@ -1438,29 +1416,23 @@ TEST(TestInternalWeakLists) { // Scavenge treats these references as strong. for (int j = 0; j < 10; j++) { CcTest::CollectGarbage(NEW_SPACE); - CHECK_EQ(5, CountOptimizedUserFunctions(ctx[i])); } // Mark compact handles the weak references. isolate->compilation_cache()->Clear(); CcTest::CollectAllGarbage(); - CHECK_EQ(4, CountOptimizedUserFunctions(ctx[i])); // Get rid of f3 and f5 in the same way. CompileRun("f3=null"); for (int j = 0; j < 10; j++) { CcTest::CollectGarbage(NEW_SPACE); - CHECK_EQ(4, CountOptimizedUserFunctions(ctx[i])); } CcTest::CollectAllGarbage(); - CHECK_EQ(3, CountOptimizedUserFunctions(ctx[i])); CompileRun("f5=null"); for (int j = 0; j < 10; j++) { CcTest::CollectGarbage(NEW_SPACE); - CHECK_EQ(3, CountOptimizedUserFunctions(ctx[i])); } CcTest::CollectAllGarbage(); - CHECK_EQ(2, CountOptimizedUserFunctions(ctx[i])); ctx[i]->Exit(); } @@ -1491,94 +1463,6 @@ TEST(TestInternalWeakLists) { } -// Count the number of native contexts in the weak list of native contexts -// causing a GC after the specified number of elements. -static int CountNativeContextsWithGC(Isolate* isolate, int n) { - Heap* heap = isolate->heap(); - int count = 0; - Handle<Object> object(heap->native_contexts_list(), isolate); - while (!object->IsUndefined(isolate)) { - count++; - if (count == n) CcTest::CollectAllGarbage(); - object = - Handle<Object>(Context::cast(*object)->next_context_link(), isolate); - } - return count; -} - - -// Count the number of user functions in the weak list of optimized -// functions attached to a native context causing a GC after the -// specified number of elements. -static int CountOptimizedUserFunctionsWithGC(v8::Local<v8::Context> context, - int n) { - int count = 0; - Handle<Context> icontext = v8::Utils::OpenHandle(*context); - Isolate* isolate = icontext->GetIsolate(); - Handle<Object> object(icontext->get(Context::OPTIMIZED_FUNCTIONS_LIST), - isolate); - while (object->IsJSFunction() && - Handle<JSFunction>::cast(object)->shared()->IsUserJavaScript()) { - count++; - if (count == n) - isolate->heap()->CollectAllGarbage( - i::Heap::kFinalizeIncrementalMarkingMask, - i::GarbageCollectionReason::kTesting); - object = Handle<Object>( - Object::cast(JSFunction::cast(*object)->next_function_link()), - isolate); - } - return count; -} - - -TEST(TestInternalWeakListsTraverseWithGC) { - FLAG_always_opt = false; - FLAG_allow_natives_syntax = true; - v8::V8::Initialize(); - - static const int kNumTestContexts = 10; - - Isolate* isolate = CcTest::i_isolate(); - HandleScope scope(isolate); - v8::Local<v8::Context> ctx[kNumTestContexts]; - if (!isolate->use_optimizer()) return; - - CHECK_EQ(0, CountNativeContexts()); - - // Create an number of contexts and check the length of the weak list both - // with and without GCs while iterating the list. - for (int i = 0; i < kNumTestContexts; i++) { - ctx[i] = v8::Context::New(CcTest::isolate()); - CHECK_EQ(i + 1, CountNativeContexts()); - CHECK_EQ(i + 1, CountNativeContextsWithGC(isolate, i / 2 + 1)); - } - - ctx[0]->Enter(); - - // Compile a number of functions the length of the weak list of optimized - // functions both with and without GCs while iterating the list. - CHECK_EQ(0, CountOptimizedUserFunctions(ctx[0])); - OptimizeEmptyFunction("f1"); - CHECK_EQ(1, CountOptimizedUserFunctions(ctx[0])); - CHECK_EQ(1, CountOptimizedUserFunctionsWithGC(ctx[0], 1)); - OptimizeEmptyFunction("f2"); - CHECK_EQ(2, CountOptimizedUserFunctions(ctx[0])); - CHECK_EQ(2, CountOptimizedUserFunctionsWithGC(ctx[0], 1)); - OptimizeEmptyFunction("f3"); - CHECK_EQ(3, CountOptimizedUserFunctions(ctx[0])); - CHECK_EQ(3, CountOptimizedUserFunctionsWithGC(ctx[0], 1)); - OptimizeEmptyFunction("f4"); - CHECK_EQ(4, CountOptimizedUserFunctions(ctx[0])); - CHECK_EQ(4, CountOptimizedUserFunctionsWithGC(ctx[0], 2)); - OptimizeEmptyFunction("f5"); - CHECK_EQ(5, CountOptimizedUserFunctions(ctx[0])); - CHECK_EQ(5, CountOptimizedUserFunctionsWithGC(ctx[0], 4)); - - ctx[0]->Exit(); -} - - TEST(TestSizeOfRegExpCode) { if (!FLAG_regexp_optimization) return; @@ -1825,11 +1709,8 @@ TEST(TestAlignedOverAllocation) { if (double_misalignment) { start = AlignOldSpace(kDoubleAligned, 0); obj = OldSpaceAllocateAligned(kPointerSize, kDoubleAligned); - // The object is aligned, and a filler object is created after. + // The object is aligned. CHECK(IsAddressAligned(obj->address(), kDoubleAlignment)); - filler = HeapObject::FromAddress(start + kPointerSize); - CHECK(obj != filler && filler->IsFiller() && - filler->Size() == kPointerSize); // Try the opposite alignment case. start = AlignOldSpace(kDoubleAligned, kPointerSize); obj = OldSpaceAllocateAligned(kPointerSize, kDoubleAligned); @@ -1837,18 +1718,15 @@ TEST(TestAlignedOverAllocation) { filler = HeapObject::FromAddress(start); CHECK(obj != filler); CHECK(filler->IsFiller()); - CHECK(filler->Size() == kPointerSize); + CHECK_EQ(kPointerSize, filler->Size()); CHECK(obj != filler && filler->IsFiller() && filler->Size() == kPointerSize); // Similarly for kDoubleUnaligned. start = AlignOldSpace(kDoubleUnaligned, 0); obj = OldSpaceAllocateAligned(kPointerSize, kDoubleUnaligned); - // The object is aligned, and a filler object is created after. + // The object is aligned. CHECK(IsAddressAligned(obj->address(), kDoubleAlignment, kPointerSize)); - filler = HeapObject::FromAddress(start + kPointerSize); - CHECK(obj != filler && filler->IsFiller() && - filler->Size() == kPointerSize); // Try the opposite alignment case. start = AlignOldSpace(kDoubleUnaligned, kPointerSize); obj = OldSpaceAllocateAligned(kPointerSize, kDoubleUnaligned); @@ -3493,7 +3371,7 @@ TEST(LargeObjectSlotRecording) { // Allocate a large object. int size = Max(1000000, kMaxRegularHeapObjectSize + KB); - CHECK(size > kMaxRegularHeapObjectSize); + CHECK_LT(kMaxRegularHeapObjectSize, size); Handle<FixedArray> lo = isolate->factory()->NewFixedArray(size, TENURED); CHECK(heap->lo_space()->Contains(*lo)); @@ -3663,10 +3541,8 @@ TEST(EnsureAllocationSiteDependentCodesProcessed) { dependency = dependency->next_link(); dependency_group_count++; } - - // TurboFan respects pretenuring feedback from allocation sites, Crankshaft - // does not. Either is fine for the purposes of this test. - CHECK(dependency_group_count == 1 || dependency_group_count == 2); + // Expect a dependent code object for transitioning and pretenuring. + CHECK_EQ(2, dependency_group_count); } // Now make sure that a gc should get rid of the function, even though we @@ -4039,8 +3915,8 @@ static Handle<Code> DummyOptimizedCode(Isolate* isolate) { masm.Drop(1); masm.GetCode(isolate, &desc); Handle<Object> undefined(isolate->heap()->undefined_value(), isolate); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::OPTIMIZED_FUNCTION), undefined); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::OPTIMIZED_FUNCTION, undefined); CHECK(code->IsCode()); return code; } @@ -4326,21 +4202,14 @@ Handle<JSFunction> GetFunctionByName(Isolate* isolate, const char* name) { return Handle<JSFunction>::cast(obj); } -void CheckIC(Handle<JSFunction> function, Code::Kind kind, int slot_index, +void CheckIC(Handle<JSFunction> function, int slot_index, InlineCacheState state) { - CHECK(kind == Code::LOAD_IC || kind == Code::KEYED_LOAD_IC); FeedbackVector* vector = function->feedback_vector(); FeedbackSlot slot(slot_index); - if (kind == Code::LOAD_IC) { - LoadICNexus nexus(vector, slot); - CHECK_EQ(nexus.StateFromFeedback(), state); - } else if (kind == Code::KEYED_LOAD_IC) { - KeyedLoadICNexus nexus(vector, slot); - CHECK_EQ(nexus.StateFromFeedback(), state); - } + LoadICNexus nexus(vector, slot); + CHECK_EQ(nexus.StateFromFeedback(), state); } - TEST(MonomorphicStaysMonomorphicAfterGC) { if (FLAG_always_opt) return; ManualGCScope manual_gc_scope; @@ -4365,12 +4234,12 @@ TEST(MonomorphicStaysMonomorphicAfterGC) { CompileRun("(testIC())"); } CcTest::CollectAllGarbage(); - CheckIC(loadIC, Code::LOAD_IC, 0, MONOMORPHIC); + CheckIC(loadIC, 0, MONOMORPHIC); { v8::HandleScope scope(CcTest::isolate()); CompileRun("(testIC())"); } - CheckIC(loadIC, Code::LOAD_IC, 0, MONOMORPHIC); + CheckIC(loadIC, 0, MONOMORPHIC); } @@ -4401,12 +4270,12 @@ TEST(PolymorphicStaysPolymorphicAfterGC) { CompileRun("(testIC())"); } CcTest::CollectAllGarbage(); - CheckIC(loadIC, Code::LOAD_IC, 0, POLYMORPHIC); + CheckIC(loadIC, 0, POLYMORPHIC); { v8::HandleScope scope(CcTest::isolate()); CompileRun("(testIC())"); } - CheckIC(loadIC, Code::LOAD_IC, 0, POLYMORPHIC); + CheckIC(loadIC, 0, POLYMORPHIC); } @@ -4637,7 +4506,7 @@ TEST(Regress507979) { for (HeapObject* obj = it.next(); obj != NULL; obj = it.next()) { // Let's not optimize the loop away. - CHECK(obj->address() != nullptr); + CHECK_NOT_NULL(obj->address()); } } @@ -5039,8 +4908,8 @@ TEST(Regress1878) { void AllocateInSpace(Isolate* isolate, size_t bytes, AllocationSpace space) { - CHECK(bytes >= FixedArray::kHeaderSize); - CHECK(bytes % kPointerSize == 0); + CHECK_LE(FixedArray::kHeaderSize, bytes); + CHECK_EQ(0, bytes % kPointerSize); Factory* factory = isolate->factory(); HandleScope scope(isolate); AlwaysAllocateScope always_allocate(isolate); @@ -5172,8 +5041,8 @@ static void RemoveCodeAndGC(const v8::FunctionCallbackInfo<v8::Value>& args) { Handle<Object> obj = v8::Utils::OpenHandle(*args[0]); Handle<JSFunction> fun = Handle<JSFunction>::cast(obj); fun->shared()->ClearBytecodeArray(); // Bytecode is code too. - fun->ReplaceCode(*BUILTIN_CODE(isolate, CompileLazy)); - fun->shared()->ReplaceCode(*BUILTIN_CODE(isolate, CompileLazy)); + fun->set_code(*BUILTIN_CODE(isolate, CompileLazy)); + fun->shared()->set_code(*BUILTIN_CODE(isolate, CompileLazy)); CcTest::CollectAllAvailableGarbage(); } @@ -5954,8 +5823,8 @@ Handle<Code> GenerateDummyImmovableCode(Isolate* isolate) { CodeDesc desc; assm.GetCode(isolate, &desc); const bool kImmovable = true; - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>(), kImmovable); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>(), kImmovable); CHECK(code->IsCode()); return code; @@ -5994,7 +5863,7 @@ HEAP_TEST(Regress5831) { // Generate the code. Handle<Code> code = GenerateDummyImmovableCode(isolate); - CHECK(code->Size() <= i::kMaxRegularHeapObjectSize); + CHECK_GE(i::kMaxRegularHeapObjectSize, code->Size()); CHECK(!heap->code_space()->FirstPage()->Contains(code->address())); // Ensure it's not in large object space. diff --git a/deps/v8/test/cctest/heap/test-invalidated-slots.cc b/deps/v8/test/cctest/heap/test-invalidated-slots.cc index 4353fb0bff..f7900cb116 100644 --- a/deps/v8/test/cctest/heap/test-invalidated-slots.cc +++ b/deps/v8/test/cctest/heap/test-invalidated-slots.cc @@ -20,6 +20,7 @@ namespace heap { Page* HeapTester::AllocateByteArraysOnPage( Heap* heap, std::vector<ByteArray*>* byte_arrays) { + PauseAllocationObserversScope pause_observers(heap); const int kLength = 256 - ByteArray::kHeaderSize; const int kSize = ByteArray::SizeFor(kLength); CHECK_EQ(kSize, 256); @@ -134,6 +135,7 @@ HEAP_TEST(InvalidatedSlotsAfterTrimming) { } HEAP_TEST(InvalidatedSlotsEvacuationCandidate) { + ManualGCScope manual_gc_scope; CcTest::InitializeVM(); Heap* heap = CcTest::heap(); std::vector<ByteArray*> byte_arrays; diff --git a/deps/v8/test/cctest/heap/test-lab.cc b/deps/v8/test/cctest/heap/test-lab.cc index d2f5ac2d54..f8ef6f5250 100644 --- a/deps/v8/test/cctest/heap/test-lab.cc +++ b/deps/v8/test/cctest/heap/test-lab.cc @@ -5,12 +5,9 @@ #include <vector> #include "src/globals.h" -#include "src/heap/heap.h" -#include "src/heap/spaces.h" +#include "src/heap/heap-inl.h" #include "src/heap/spaces-inl.h" -// FIXME(mstarzinger, marja): This is weird, but required because of the missing -// (disallowed) include: src/heap/incremental-marking.h -> src/objects-inl.h -#include "src/objects-inl.h" +#include "src/objects.h" #include "test/cctest/cctest.h" namespace v8 { diff --git a/deps/v8/test/cctest/heap/test-mark-compact.cc b/deps/v8/test/cctest/heap/test-mark-compact.cc index 6cf6fd1902..8f704b1a97 100644 --- a/deps/v8/test/cctest/heap/test-mark-compact.cc +++ b/deps/v8/test/cctest/heap/test-mark-compact.cc @@ -42,7 +42,6 @@ #include "src/global-handles.h" #include "src/heap/mark-compact-inl.h" #include "src/heap/mark-compact.h" -#include "src/heap/sequential-marking-deque.h" #include "src/objects-inl.h" #include "test/cctest/cctest.h" #include "test/cctest/heap/heap-tester.h" @@ -52,30 +51,6 @@ namespace v8 { namespace internal { namespace heap { -TEST(SequentialMarkingDeque) { - CcTest::InitializeVM(); - SequentialMarkingDeque s(CcTest::i_isolate()->heap()); - s.SetUp(); - s.StartUsing(); - Address original_address = reinterpret_cast<Address>(&s); - Address current_address = original_address; - while (!s.IsFull()) { - s.Push(HeapObject::FromAddress(current_address)); - current_address += kPointerSize; - } - - while (!s.IsEmpty()) { - Address value = s.Pop()->address(); - current_address -= kPointerSize; - CHECK_EQ(current_address, value); - } - - CHECK_EQ(original_address, current_address); - s.StopUsing(); - CcTest::i_isolate()->cancelable_task_manager()->CancelAndWait(); - s.TearDown(); -} - TEST(Promotion) { CcTest::InitializeVM(); Isolate* isolate = CcTest::i_isolate(); diff --git a/deps/v8/test/cctest/heap/test-page-promotion.cc b/deps/v8/test/cctest/heap/test-page-promotion.cc index 5eb2aec005..c9ad761b35 100644 --- a/deps/v8/test/cctest/heap/test-page-promotion.cc +++ b/deps/v8/test/cctest/heap/test-page-promotion.cc @@ -6,8 +6,6 @@ #include "src/heap/array-buffer-tracker.h" #include "src/heap/spaces-inl.h" #include "src/isolate.h" -// FIXME(mstarzinger, marja): This is weird, but required because of the missing -// (disallowed) include: src/factory.h -> src/objects-inl.h #include "src/objects-inl.h" #include "test/cctest/cctest.h" #include "test/cctest/heap/heap-tester.h" diff --git a/deps/v8/test/cctest/heap/test-spaces.cc b/deps/v8/test/cctest/heap/test-spaces.cc index 73ecb28efe..f5a0083771 100644 --- a/deps/v8/test/cctest/heap/test-spaces.cc +++ b/deps/v8/test/cctest/heap/test-spaces.cc @@ -30,11 +30,8 @@ #include "src/base/platform/platform.h" #include "src/factory.h" #include "src/heap/spaces-inl.h" -// FIXME(mstarzinger, marja): This is weird, but required because of the missing -// (disallowed) include: src/heap/incremental-marking.h -> src/objects-inl.h #include "src/objects-inl.h" #include "src/snapshot/snapshot.h" -#include "src/v8.h" #include "test/cctest/cctest.h" #include "test/cctest/heap/heap-tester.h" #include "test/cctest/heap/heap-utils.h" @@ -83,6 +80,7 @@ class TestCodeRangeScope { DISALLOW_COPY_AND_ASSIGN(TestCodeRangeScope); }; +namespace test_spaces { static void VerifyMemoryChunk(Isolate* isolate, Heap* heap, @@ -242,7 +240,7 @@ TEST(MemoryAllocator) { Heap* heap = isolate->heap(); MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); - CHECK(memory_allocator != nullptr); + CHECK_NOT_NULL(memory_allocator); CHECK(memory_allocator->SetUp(heap->MaxReserved(), 0)); TestMemoryAllocatorScope test_scope(isolate, memory_allocator); @@ -706,6 +704,7 @@ TEST(ShrinkPageToHighWaterMarkTwoWordFiller) { CHECK_EQ(0u, shrunk); } +} // namespace test_spaces } // namespace heap } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/interpreter/bytecode-expectations-printer.cc b/deps/v8/test/cctest/interpreter/bytecode-expectations-printer.cc index de6ad3a717..d6a93fdda2 100644 --- a/deps/v8/test/cctest/interpreter/bytecode-expectations-printer.cc +++ b/deps/v8/test/cctest/interpreter/bytecode-expectations-printer.cc @@ -181,12 +181,7 @@ void BytecodeExpectationsPrinter::PrintBytecodeOperand( break; case OperandType::kIdx: { stream << 'U' << size_tag << '('; - uint32_t idx = bytecode_iterator.GetIndexOperand(op_index); - if (bytecode == Bytecode::kCallJSRuntime && op_index == 0) { - stream << "%" << NameForNativeContextIntrinsicIndex(idx); - } else { - stream << idx; - } + stream << bytecode_iterator.GetIndexOperand(op_index); break; } case OperandType::kUImm: @@ -215,6 +210,12 @@ void BytecodeExpectationsPrinter::PrintBytecodeOperand( stream << "Runtime::k" << i::Runtime::FunctionForId(id)->name; break; } + case OperandType::kNativeContextIndex: { + stream << 'U' << size_tag << '('; + uint32_t idx = bytecode_iterator.GetNativeContextIndexOperand(op_index); + stream << "%" << NameForNativeContextIntrinsicIndex(idx); + break; + } default: UNREACHABLE(); } diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/ArrayLiterals.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/ArrayLiterals.golden index a5af50d6ca..e5de344960 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/ArrayLiterals.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/ArrayLiterals.golden @@ -39,12 +39,12 @@ bytecodes: [ B(LdaZero), B(Star), R(1), B(Ldar), R(0), - /* 54 E> */ B(StaKeyedPropertySloppy), R(2), R(1), U8(2), + /* 54 E> */ B(StaKeyedProperty), R(2), R(1), U8(2), B(LdaSmi), I8(1), B(Star), R(1), B(Ldar), R(0), /* 59 E> */ B(AddSmi), I8(1), U8(0), - B(StaKeyedPropertySloppy), R(2), R(1), U8(2), + B(StaKeyedProperty), R(2), R(1), U8(2), B(Ldar), R(2), /* 65 S> */ B(Return), ] @@ -92,9 +92,9 @@ bytecodes: [ B(LdaZero), B(Star), R(3), B(Ldar), R(0), - /* 56 E> */ B(StaKeyedPropertySloppy), R(4), R(3), U8(1), + /* 56 E> */ B(StaKeyedProperty), R(4), R(3), U8(1), B(Ldar), R(4), - B(StaKeyedPropertySloppy), R(2), R(1), U8(8), + B(StaKeyedProperty), R(2), R(1), U8(8), B(LdaSmi), I8(1), B(Star), R(1), B(CreateArrayLiteral), U8(2), U8(4), U8(37), @@ -103,9 +103,9 @@ bytecodes: [ B(Star), R(3), B(Ldar), R(0), /* 68 E> */ B(AddSmi), I8(2), U8(3), - B(StaKeyedPropertySloppy), R(4), R(3), U8(5), + B(StaKeyedProperty), R(4), R(3), U8(5), B(Ldar), R(4), - B(StaKeyedPropertySloppy), R(2), R(1), U8(8), + B(StaKeyedProperty), R(2), R(1), U8(8), B(Ldar), R(2), /* 76 S> */ B(Return), ] diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/AssignmentsInBinaryExpression.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/AssignmentsInBinaryExpression.golden index dd55ae9856..925795a673 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/AssignmentsInBinaryExpression.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/AssignmentsInBinaryExpression.golden @@ -238,7 +238,7 @@ snippet: " " frame size: 3 parameter count: 1 -bytecode array length: 44 +bytecode array length: 43 bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaSmi), I8(17), @@ -249,8 +249,8 @@ bytecodes: [ /* 55 E> */ B(Add), R(1), U8(0), B(Star), R(1), B(Ldar), R(0), - B(ToNumber), R(2), U8(1), - B(Ldar), R(2), + B(ToNumber), U8(1), + B(Star), R(2), B(Inc), U8(1), B(Star), R(0), B(Ldar), R(2), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/AsyncGenerators.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/AsyncGenerators.golden index 5ec4d045ec..84fdd0f715 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/AsyncGenerators.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/AsyncGenerators.golden @@ -14,18 +14,16 @@ snippet: " " frame size: 9 parameter count: 1 -bytecode array length: 237 +bytecode array length: 230 bytecodes: [ B(Ldar), R(0), - B(JumpIfUndefined), U8(25), + B(JumpIfUndefined), U8(18), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(0), U8(1), B(PushContext), R(2), B(RestoreGeneratorState), R(0), B(Star), R(1), B(SwitchOnSmiNoFeedback), U8(0), U8(2), I8(0), - B(LdaSmi), I8(45), - B(Star), R(2), - B(CallRuntime), U16(Runtime::kAbort), R(2), U8(1), + B(Abort), U8(43), B(LdaSmi), I8(-2), B(Star), R(1), B(Mov), R(closure), R(2), @@ -121,8 +119,8 @@ bytecodes: [ /* 22 S> */ B(Return), ] constant pool: [ - Smi [44], - Smi [93], + Smi [37], + Smi [86], Smi [15], Smi [7], ONE_BYTE_INTERNALIZED_STRING_TYPE [".catch"], @@ -132,8 +130,8 @@ constant pool: [ Smi [23], ] handlers: [ - [47, 182, 190], - [50, 143, 145], + [40, 175, 183], + [43, 136, 138], ] --- @@ -143,18 +141,16 @@ snippet: " " frame size: 9 parameter count: 1 -bytecode array length: 290 +bytecode array length: 283 bytecodes: [ B(Ldar), R(0), - B(JumpIfUndefined), U8(25), + B(JumpIfUndefined), U8(18), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(0), U8(1), B(PushContext), R(2), B(RestoreGeneratorState), R(0), B(Star), R(1), B(SwitchOnSmiNoFeedback), U8(0), U8(3), I8(0), - B(LdaSmi), I8(45), - B(Star), R(2), - B(CallRuntime), U16(Runtime::kAbort), R(2), U8(1), + B(Abort), U8(43), B(LdaSmi), I8(-2), B(Star), R(1), B(Mov), R(closure), R(2), @@ -271,9 +267,9 @@ bytecodes: [ /* 31 S> */ B(Return), ] constant pool: [ - Smi [44], - Smi [97], - Smi [146], + Smi [37], + Smi [90], + Smi [139], Smi [15], Smi [7], Smi [15], @@ -285,8 +281,8 @@ constant pool: [ Smi [23], ] handlers: [ - [47, 235, 243], - [50, 196, 198], + [40, 228, 236], + [43, 189, 191], ] --- @@ -296,18 +292,16 @@ snippet: " " frame size: 22 parameter count: 1 -bytecode array length: 585 +bytecode array length: 571 bytecodes: [ B(Ldar), R(2), - B(JumpIfUndefined), U8(25), + B(JumpIfUndefined), U8(18), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(2), U8(1), B(PushContext), R(11), B(RestoreGeneratorState), R(2), B(Star), R(10), B(SwitchOnSmiNoFeedback), U8(0), U8(3), I8(0), - B(LdaSmi), I8(45), - B(Star), R(11), - B(CallRuntime), U16(Runtime::kAbort), R(11), U8(1), + B(Abort), U8(43), B(LdaSmi), I8(-2), B(Star), R(10), B(Mov), R(closure), R(11), @@ -349,10 +343,8 @@ bytecodes: [ B(SwitchOnSmiNoFeedback), U8(7), U8(1), I8(1), B(LdaSmi), I8(-2), /* 36 E> */ B(TestEqualStrictNoFeedback), R(10), - B(JumpIfTrue), U8(11), - B(LdaSmi), I8(45), - B(Star), R(19), - B(CallRuntime), U16(Runtime::kAbort), R(19), U8(1), + B(JumpIfTrue), U8(4), + B(Abort), U8(43), /* 31 S> */ B(LdaNamedProperty), R(4), U8(8), U8(7), B(Star), R(19), B(CallProperty0), R(19), R(4), U8(5), @@ -392,7 +384,7 @@ bytecodes: [ B(Jump), U8(62), B(LdaZero), B(Star), R(6), - B(JumpLoop), U8(123), I8(0), + B(JumpLoop), U8(116), I8(0), B(Jump), U8(40), B(Star), R(19), B(Ldar), R(closure), @@ -436,7 +428,7 @@ bytecodes: [ B(TestTypeOf), U8(5), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(134), + B(Wide), B(LdaSmi), I16(137), B(Star), R(18), B(LdaConstant), U8(16), B(Star), R(19), @@ -546,14 +538,14 @@ bytecodes: [ /* 50 S> */ B(Return), ] constant pool: [ - Smi [44], - Smi [111], - Smi [441], + Smi [37], + Smi [104], + Smi [427], Smi [15], Smi [7], TUPLE2_TYPE, SYMBOL_TYPE, - Smi [85], + Smi [78], ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], @@ -567,17 +559,17 @@ constant pool: [ Smi [6], Smi [14], FIXED_ARRAY_TYPE, - Smi [455], + Smi [448], Smi [6], Smi [20], Smi [23], ] handlers: [ - [47, 530, 538], - [50, 491, 493], - [97, 291, 299], - [100, 251, 253], - [360, 370, 372], + [40, 516, 524], + [43, 477, 479], + [90, 277, 285], + [93, 237, 239], + [346, 356, 358], ] --- @@ -588,18 +580,16 @@ snippet: " " frame size: 17 parameter count: 1 -bytecode array length: 577 +bytecode array length: 560 bytecodes: [ B(Ldar), R(0), - B(JumpIfUndefined), U8(25), + B(JumpIfUndefined), U8(18), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(0), U8(1), B(PushContext), R(2), B(RestoreGeneratorState), R(0), B(Star), R(1), B(SwitchOnSmiNoFeedback), U8(0), U8(5), I8(0), - B(LdaSmi), I8(45), - B(Star), R(2), - B(CallRuntime), U16(Runtime::kAbort), R(2), U8(1), + B(Abort), U8(43), B(LdaSmi), I8(-2), B(Star), R(1), B(Mov), R(closure), R(2), @@ -650,10 +640,8 @@ bytecodes: [ B(SwitchOnSmiNoFeedback), U8(10), U8(3), I8(1), B(LdaSmi), I8(-2), B(TestEqualStrictNoFeedback), R(1), - B(JumpIfTrue), U8(11), - B(LdaSmi), I8(45), - B(Star), R(12), - B(CallRuntime), U16(Runtime::kAbort), R(12), U8(1), + B(JumpIfTrue), U8(4), + B(Abort), U8(43), B(Ldar), R(7), B(SwitchOnSmiNoFeedback), U8(13), U8(2), I8(1), B(LdaNamedProperty), R(8), U8(15), U8(8), @@ -725,7 +713,7 @@ bytecodes: [ B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(6), U8(1), B(LdaNamedProperty), R(6), U8(18), U8(12), - B(JumpIfToBooleanTrue), U8(50), + B(JumpIfToBooleanTrue), U8(47), B(LdaNamedProperty), R(6), U8(19), U8(14), B(Star), R(15), B(LdaFalse), @@ -741,7 +729,7 @@ bytecodes: [ B(Star), R(9), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1), B(Star), R(7), - B(Wide), B(JumpLoop), U16(260), I16(0), + B(JumpLoop), U8(252), I8(0), B(LdaNamedProperty), R(6), U8(19), U8(14), B(Star), R(8), B(LdaSmi), I8(1), @@ -821,19 +809,19 @@ bytecodes: [ /* 60 S> */ B(Return), ] constant pool: [ - Smi [44], - Smi [132], - Smi [132], - Smi [132], - Smi [433], + Smi [37], + Smi [125], + Smi [125], + Smi [125], + Smi [416], Smi [15], Smi [7], ONE_BYTE_INTERNALIZED_STRING_TYPE ["g"], SYMBOL_TYPE, SYMBOL_TYPE, - Smi [237], - Smi [109], - Smi [169], + Smi [230], + Smi [102], + Smi [162], Smi [17], Smi [42], ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], @@ -843,14 +831,14 @@ constant pool: [ ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], ONE_BYTE_INTERNALIZED_STRING_TYPE [".catch"], FIXED_ARRAY_TYPE, - Smi [447], - Smi [327], + Smi [437], + Smi [324], Smi [6], Smi [20], Smi [23], ] handlers: [ - [47, 522, 530], - [50, 483, 485], + [40, 505, 513], + [43, 466, 468], ] diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/CallAndSpread.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/CallAndSpread.golden index 751c4f27a4..1315be378b 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/CallAndSpread.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/CallAndSpread.golden @@ -65,33 +65,27 @@ handlers: [ snippet: " Math.max(0, ...[1, 2, 3], 4); " -frame size: 8 +frame size: 6 parameter count: 1 -bytecode array length: 60 +bytecode array length: 51 bytecodes: [ /* 30 E> */ B(StackCheck), - /* 34 S> */ B(LdaUndefined), - B(Star), R(1), - /* 34 E> */ B(LdaGlobal), U8(0), U8(0), + /* 34 S> */ B(LdaGlobal), U8(0), U8(0), B(Star), R(0), B(LdaNamedProperty), R(0), U8(1), U8(2), - B(Star), R(2), - B(LdaUndefined), - B(Star), R(4), + B(Star), R(1), B(CreateArrayLiteral), U8(2), U8(4), U8(37), - B(Star), R(5), - B(LdaUndefined), - B(Star), R(6), + B(Star), R(3), B(CreateArrayLiteral), U8(3), U8(5), U8(37), - B(Star), R(7), - B(CallJSRuntime), U8(%spread_iterable), R(6), U8(2), - B(Star), R(6), - B(CreateArrayLiteral), U8(4), U8(6), U8(37), - B(Star), R(7), - B(CallJSRuntime), U8(%spread_arguments), R(4), U8(4), B(Star), R(4), - B(Mov), R(0), R(3), - B(CallJSRuntime), U8(%reflect_apply), R(1), U8(4), + B(CallJSRuntime), U8(%spread_iterable), R(4), U8(1), + B(Star), R(4), + B(CreateArrayLiteral), U8(4), U8(6), U8(37), + B(Star), R(5), + B(CallJSRuntime), U8(%spread_arguments), R(3), U8(3), + B(Star), R(3), + B(Mov), R(0), R(2), + B(CallJSRuntime), U8(%reflect_apply), R(1), U8(3), B(LdaUndefined), /* 64 S> */ B(Return), ] diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/CallRuntime.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/CallRuntime.golden index 83911ce4e2..cb201ed8e6 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/CallRuntime.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/CallRuntime.golden @@ -70,16 +70,14 @@ snippet: " function f() { return %spread_iterable([1]) } f(); " -frame size: 2 +frame size: 1 parameter count: 1 -bytecode array length: 15 +bytecode array length: 12 bytecodes: [ /* 10 E> */ B(StackCheck), - /* 15 S> */ B(LdaUndefined), + /* 15 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(37), B(Star), R(0), - B(CreateArrayLiteral), U8(0), U8(0), U8(37), - B(Star), R(1), - B(CallJSRuntime), U8(%spread_iterable), R(0), U8(2), + B(CallJSRuntime), U8(%spread_iterable), R(0), U8(1), /* 43 S> */ B(Return), ] constant pool: [ diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/ClassAndSuperClass.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/ClassAndSuperClass.golden index db0f4772c3..ea44a8a040 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/ClassAndSuperClass.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/ClassAndSuperClass.golden @@ -123,7 +123,7 @@ bytecodes: [ /* 128 S> */ B(Ldar), R(this), B(ThrowSuperNotCalledIfHole), B(LdaSmi), I8(2), - /* 136 E> */ B(StaNamedPropertyStrict), R(2), U8(0), U8(2), + /* 136 E> */ B(StaNamedProperty), R(2), U8(0), U8(2), B(Ldar), R(this), B(ThrowSuperNotCalledIfHole), /* 141 S> */ B(Return), @@ -164,7 +164,7 @@ bytecodes: [ /* 126 S> */ B(Ldar), R(this), B(ThrowSuperNotCalledIfHole), B(LdaSmi), I8(2), - /* 134 E> */ B(StaNamedPropertyStrict), R(2), U8(0), U8(2), + /* 134 E> */ B(StaNamedProperty), R(2), U8(0), U8(2), B(Ldar), R(this), B(ThrowSuperNotCalledIfHole), /* 139 S> */ B(Return), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/CompoundExpressions.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/CompoundExpressions.golden index ea761f5dfa..f2d00b28e1 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/CompoundExpressions.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/CompoundExpressions.golden @@ -60,7 +60,7 @@ bytecodes: [ B(Mov), R(1), R(0), /* 54 S> */ B(LdaNamedProperty), R(1), U8(1), U8(1), B(MulSmi), I8(2), U8(3), - /* 61 E> */ B(StaNamedPropertySloppy), R(1), U8(1), U8(4), + /* 61 E> */ B(StaNamedProperty), R(1), U8(1), U8(4), B(LdaUndefined), /* 67 S> */ B(Return), ] @@ -86,7 +86,7 @@ bytecodes: [ B(Star), R(2), B(LdaKeyedProperty), R(1), U8(1), B(BitwiseXorSmi), I8(2), U8(3), - /* 57 E> */ B(StaKeyedPropertySloppy), R(1), R(2), U8(4), + /* 57 E> */ B(StaKeyedProperty), R(1), R(2), U8(4), B(LdaUndefined), /* 63 S> */ B(Return), ] diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/CountOperators.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/CountOperators.golden index c259f53f64..2aefc7a142 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/CountOperators.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/CountOperators.golden @@ -31,13 +31,13 @@ snippet: " " frame size: 2 parameter count: 1 -bytecode array length: 17 +bytecode array length: 16 bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), - /* 45 S> */ B(ToNumber), R(1), U8(0), - B(Ldar), R(1), + /* 45 S> */ B(ToNumber), U8(0), + B(Star), R(1), B(Inc), U8(0), B(Star), R(0), B(Ldar), R(1), @@ -74,13 +74,13 @@ snippet: " " frame size: 2 parameter count: 1 -bytecode array length: 17 +bytecode array length: 16 bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), - /* 45 S> */ B(ToNumber), R(1), U8(0), - B(Ldar), R(1), + /* 45 S> */ B(ToNumber), U8(0), + B(Star), R(1), B(Dec), U8(0), B(Star), R(0), B(Ldar), R(1), @@ -97,16 +97,16 @@ snippet: " " frame size: 3 parameter count: 1 -bytecode array length: 27 +bytecode array length: 26 bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(41), R(1), B(Mov), R(1), R(0), /* 54 S> */ B(LdaNamedProperty), R(1), U8(1), U8(1), - B(ToNumber), R(2), U8(5), - B(Ldar), R(2), + B(ToNumber), U8(5), + B(Star), R(2), B(Inc), U8(5), - /* 66 E> */ B(StaNamedPropertySloppy), R(1), U8(1), U8(3), + /* 66 E> */ B(StaNamedProperty), R(1), U8(1), U8(3), B(Ldar), R(2), /* 69 S> */ B(Return), ] @@ -130,7 +130,7 @@ bytecodes: [ B(Mov), R(1), R(0), /* 54 S> */ B(LdaNamedProperty), R(1), U8(1), U8(1), B(Dec), U8(5), - /* 65 E> */ B(StaNamedPropertySloppy), R(1), U8(1), U8(3), + /* 65 E> */ B(StaNamedProperty), R(1), U8(1), U8(3), /* 69 S> */ B(Return), ] constant pool: [ @@ -146,7 +146,7 @@ snippet: " " frame size: 5 parameter count: 1 -bytecode array length: 32 +bytecode array length: 31 bytecodes: [ /* 30 E> */ B(StackCheck), /* 45 S> */ B(LdaConstant), U8(0), @@ -155,10 +155,10 @@ bytecodes: [ B(Mov), R(2), R(1), /* 72 S> */ B(Ldar), R(0), /* 81 E> */ B(LdaKeyedProperty), R(2), U8(1), - B(ToNumber), R(4), U8(5), - B(Ldar), R(4), + B(ToNumber), U8(5), + B(Star), R(4), B(Dec), U8(5), - /* 86 E> */ B(StaKeyedPropertySloppy), R(2), R(0), U8(3), + /* 86 E> */ B(StaKeyedProperty), R(2), R(0), U8(3), B(Ldar), R(4), /* 89 S> */ B(Return), ] @@ -185,7 +185,7 @@ bytecodes: [ /* 72 S> */ B(Ldar), R(0), /* 83 E> */ B(LdaKeyedProperty), R(2), U8(1), B(Inc), U8(5), - /* 87 E> */ B(StaKeyedPropertySloppy), R(2), R(0), U8(3), + /* 87 E> */ B(StaKeyedProperty), R(2), R(0), U8(3), /* 89 S> */ B(Return), ] constant pool: [ @@ -227,7 +227,7 @@ snippet: " " frame size: 3 parameter count: 1 -bytecode array length: 29 +bytecode array length: 28 bytecodes: [ B(CreateFunctionContext), U8(1), B(PushContext), R(1), @@ -237,8 +237,8 @@ bytecodes: [ /* 53 S> */ B(CreateClosure), U8(0), U8(0), U8(2), B(Star), R(0), /* 78 S> */ B(LdaCurrentContextSlot), U8(4), - B(ToNumber), R(2), U8(1), - B(Ldar), R(2), + B(ToNumber), U8(1), + B(Star), R(2), B(Dec), U8(1), /* 86 E> */ B(StaCurrentContextSlot), U8(4), B(Ldar), R(2), @@ -256,7 +256,7 @@ snippet: " " frame size: 4 parameter count: 1 -bytecode array length: 29 +bytecode array length: 28 bytecodes: [ /* 30 E> */ B(StackCheck), /* 44 S> */ B(LdaSmi), I8(1), @@ -264,12 +264,12 @@ bytecodes: [ /* 55 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(37), B(Star), R(1), /* 63 S> */ B(Ldar), R(0), - B(ToNumber), R(3), U8(1), - B(Ldar), R(3), + B(ToNumber), U8(1), + B(Star), R(3), B(Inc), U8(1), B(Star), R(0), B(LdaSmi), I8(2), - /* 79 E> */ B(StaKeyedPropertySloppy), R(1), R(3), U8(2), + /* 79 E> */ B(StaKeyedProperty), R(1), R(3), U8(2), /* 83 S> */ B(Return), ] constant pool: [ diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/ForAwaitOf.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/ForAwaitOf.golden index f363e3d168..f02cb544d0 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/ForAwaitOf.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/ForAwaitOf.golden @@ -16,18 +16,16 @@ snippet: " " frame size: 23 parameter count: 1 -bytecode array length: 618 +bytecode array length: 589 bytecodes: [ B(Ldar), R(2), - B(JumpIfUndefined), U8(25), + B(JumpIfUndefined), U8(18), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(2), U8(1), B(PushContext), R(12), B(RestoreGeneratorState), R(2), B(Star), R(11), B(SwitchOnSmiNoFeedback), U8(0), U8(3), I8(0), - B(LdaSmi), I8(45), - B(Star), R(12), - B(CallRuntime), U16(Runtime::kAbort), R(12), U8(1), + B(Abort), U8(43), B(LdaSmi), I8(-2), B(Star), R(11), B(Mov), R(closure), R(12), @@ -35,9 +33,7 @@ bytecodes: [ B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(12), U8(2), B(Star), R(2), /* 16 E> */ B(StackCheck), - B(LdaUndefined), - B(Star), R(12), - B(CallJSRuntime), U8(%async_function_promise_create), R(12), U8(1), + B(CallJSRuntime), U8(%async_function_promise_create), R(0), U8(0), B(Star), R(10), B(Mov), R(context), R(14), B(Mov), R(context), R(15), @@ -64,10 +60,8 @@ bytecodes: [ B(SwitchOnSmiNoFeedback), U8(6), U8(1), I8(0), B(LdaSmi), I8(-2), /* 43 E> */ B(TestEqualStrictNoFeedback), R(11), - B(JumpIfTrue), U8(11), - B(LdaSmi), I8(45), - B(Star), R(20), - B(CallRuntime), U16(Runtime::kAbort), R(20), U8(1), + B(JumpIfTrue), U8(4), + B(Abort), U8(43), /* 40 S> */ B(LdaNamedProperty), R(4), U8(7), U8(11), B(Star), R(20), B(CallProperty0), R(20), R(4), U8(9), @@ -105,7 +99,7 @@ bytecodes: [ B(Mov), R(3), R(0), B(LdaZero), B(Star), R(6), - B(JumpLoop), U8(118), I8(0), + B(JumpLoop), U8(111), I8(0), B(Jump), U8(40), B(Star), R(20), B(Ldar), R(closure), @@ -149,7 +143,7 @@ bytecodes: [ B(TestTypeOf), U8(5), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(134), + B(Wide), B(LdaSmi), I16(137), B(Star), R(19), B(LdaConstant), U8(13), B(Star), R(20), @@ -223,16 +217,14 @@ bytecodes: [ B(Ldar), R(17), B(ReThrow), B(LdaUndefined), - B(Star), R(16), - B(LdaUndefined), - B(Star), R(18), - B(Mov), R(10), R(17), - B(CallJSRuntime), U8(%promise_resolve), R(16), U8(3), + B(Star), R(17), + B(Mov), R(10), R(16), + B(CallJSRuntime), U8(%promise_resolve), R(16), U8(2), B(LdaZero), B(Star), R(12), B(Mov), R(10), R(13), - B(Jump), U8(61), - B(Jump), U8(45), + B(Jump), U8(58), + B(Jump), U8(42), B(Star), R(16), B(Ldar), R(closure), B(CreateCatchContext), R(16), U8(10), U8(15), @@ -241,14 +233,12 @@ bytecodes: [ B(SetPendingMessage), B(Ldar), R(15), B(PushContext), R(16), - B(LdaUndefined), - B(Star), R(17), B(LdaImmutableCurrentContextSlot), U8(4), - B(Star), R(19), + B(Star), R(18), B(LdaFalse), - B(Star), R(20), - B(Mov), R(10), R(18), - B(CallJSRuntime), U8(%promise_internal_reject), R(17), U8(4), + B(Star), R(19), + B(Mov), R(10), R(17), + B(CallJSRuntime), U8(%promise_internal_reject), R(17), U8(3), B(PopContext), R(16), B(LdaZero), B(Star), R(12), @@ -264,10 +254,7 @@ bytecodes: [ B(LdaTheHole), B(SetPendingMessage), B(Star), R(14), - B(LdaUndefined), - B(Star), R(15), - B(Mov), R(10), R(16), - B(CallJSRuntime), U8(%async_function_promise_release), R(15), U8(2), + B(CallJSRuntime), U8(%async_function_promise_release), R(10), U8(1), B(Ldar), R(14), B(SetPendingMessage), B(Ldar), R(12), @@ -281,13 +268,13 @@ bytecodes: [ /* 57 S> */ B(Return), ] constant pool: [ - Smi [99], - Smi [356], - Smi [436], + Smi [89], + Smi [339], + Smi [419], TUPLE2_TYPE, SYMBOL_TYPE, SYMBOL_TYPE, - Smi [47], + Smi [40], ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], @@ -301,11 +288,11 @@ constant pool: [ Smi [9], ] handlers: [ - [56, 571, 579], - [59, 526, 528], - [65, 274, 282], - [68, 234, 236], - [342, 400, 402], + [46, 548, 556], + [49, 506, 508], + [55, 257, 265], + [58, 217, 219], + [325, 383, 385], ] --- @@ -317,18 +304,16 @@ snippet: " " frame size: 23 parameter count: 1 -bytecode array length: 650 +bytecode array length: 618 bytecodes: [ B(Ldar), R(2), - B(JumpIfUndefined), U8(25), + B(JumpIfUndefined), U8(18), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(2), U8(1), B(PushContext), R(12), B(RestoreGeneratorState), R(2), B(Star), R(11), B(SwitchOnSmiNoFeedback), U8(0), U8(3), I8(0), - B(LdaSmi), I8(45), - B(Star), R(12), - B(CallRuntime), U16(Runtime::kAbort), R(12), U8(1), + B(Abort), U8(43), B(LdaSmi), I8(-2), B(Star), R(11), B(Mov), R(closure), R(12), @@ -336,9 +321,7 @@ bytecodes: [ B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(12), U8(2), B(Star), R(2), /* 16 E> */ B(StackCheck), - B(LdaUndefined), - B(Star), R(12), - B(CallJSRuntime), U8(%async_function_promise_create), R(12), U8(1), + B(CallJSRuntime), U8(%async_function_promise_create), R(0), U8(0), B(Star), R(10), B(Mov), R(context), R(14), B(Mov), R(context), R(15), @@ -365,10 +348,8 @@ bytecodes: [ B(SwitchOnSmiNoFeedback), U8(6), U8(1), I8(0), B(LdaSmi), I8(-2), /* 43 E> */ B(TestEqualStrictNoFeedback), R(11), - B(JumpIfTrue), U8(11), - B(LdaSmi), I8(45), - B(Star), R(20), - B(CallRuntime), U16(Runtime::kAbort), R(20), U8(1), + B(JumpIfTrue), U8(4), + B(Abort), U8(43), /* 40 S> */ B(LdaNamedProperty), R(4), U8(7), U8(11), B(Star), R(20), B(CallProperty0), R(20), R(4), U8(9), @@ -451,7 +432,7 @@ bytecodes: [ B(TestTypeOf), U8(5), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(134), + B(Wide), B(LdaSmi), I16(137), B(Star), R(19), B(LdaConstant), U8(13), B(Star), R(20), @@ -525,20 +506,18 @@ bytecodes: [ B(LdaZero), B(Star), R(12), B(Mov), R(17), R(13), - B(Jump), U8(87), + B(Jump), U8(81), B(Ldar), R(17), B(ReThrow), B(LdaUndefined), - B(Star), R(16), - B(LdaUndefined), - B(Star), R(18), - B(Mov), R(10), R(17), - B(CallJSRuntime), U8(%promise_resolve), R(16), U8(3), + B(Star), R(17), + B(Mov), R(10), R(16), + B(CallJSRuntime), U8(%promise_resolve), R(16), U8(2), B(LdaSmi), I8(1), B(Star), R(12), B(Mov), R(10), R(13), - B(Jump), U8(62), - B(Jump), U8(46), + B(Jump), U8(59), + B(Jump), U8(43), B(Star), R(16), B(Ldar), R(closure), B(CreateCatchContext), R(16), U8(10), U8(17), @@ -547,14 +526,12 @@ bytecodes: [ B(SetPendingMessage), B(Ldar), R(15), B(PushContext), R(16), - B(LdaUndefined), - B(Star), R(17), B(LdaImmutableCurrentContextSlot), U8(4), - B(Star), R(19), + B(Star), R(18), B(LdaFalse), - B(Star), R(20), - B(Mov), R(10), R(18), - B(CallJSRuntime), U8(%promise_internal_reject), R(17), U8(4), + B(Star), R(19), + B(Mov), R(10), R(17), + B(CallJSRuntime), U8(%promise_internal_reject), R(17), U8(3), B(PopContext), R(16), B(LdaSmi), I8(1), B(Star), R(12), @@ -570,20 +547,15 @@ bytecodes: [ B(LdaTheHole), B(SetPendingMessage), B(Star), R(14), - B(LdaUndefined), - B(Star), R(15), - B(Mov), R(10), R(16), - B(CallJSRuntime), U8(%async_function_promise_release), R(15), U8(2), + B(CallJSRuntime), U8(%async_function_promise_release), R(10), U8(1), B(Ldar), R(14), B(SetPendingMessage), B(Ldar), R(12), B(SwitchOnSmiNoFeedback), U8(18), U8(3), I8(0), - B(Jump), U8(24), - B(LdaUndefined), - B(Star), R(15), - B(Mov), R(10), R(16), - B(Mov), R(13), R(17), - B(CallJSRuntime), U8(%promise_resolve), R(15), U8(3), + B(Jump), U8(21), + B(Mov), R(10), R(15), + B(Mov), R(13), R(16), + B(CallJSRuntime), U8(%promise_resolve), R(15), U8(2), B(Ldar), R(10), /* 68 S> */ B(Return), B(Ldar), R(13), @@ -594,13 +566,13 @@ bytecodes: [ /* 68 S> */ B(Return), ] constant pool: [ - Smi [99], - Smi [359], - Smi [439], + Smi [89], + Smi [342], + Smi [422], TUPLE2_TYPE, SYMBOL_TYPE, SYMBOL_TYPE, - Smi [47], + Smi [40], ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], @@ -613,15 +585,15 @@ constant pool: [ Smi [14], FIXED_ARRAY_TYPE, Smi [6], + Smi [19], Smi [22], - Smi [25], ] handlers: [ - [56, 587, 595], - [59, 541, 543], - [65, 276, 284], - [68, 236, 238], - [345, 403, 405], + [46, 564, 572], + [49, 521, 523], + [55, 259, 267], + [58, 219, 221], + [328, 386, 388], ] --- @@ -636,18 +608,16 @@ snippet: " " frame size: 23 parameter count: 1 -bytecode array length: 636 +bytecode array length: 607 bytecodes: [ B(Ldar), R(2), - B(JumpIfUndefined), U8(25), + B(JumpIfUndefined), U8(18), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(2), U8(1), B(PushContext), R(12), B(RestoreGeneratorState), R(2), B(Star), R(11), B(SwitchOnSmiNoFeedback), U8(0), U8(3), I8(0), - B(LdaSmi), I8(45), - B(Star), R(12), - B(CallRuntime), U16(Runtime::kAbort), R(12), U8(1), + B(Abort), U8(43), B(LdaSmi), I8(-2), B(Star), R(11), B(Mov), R(closure), R(12), @@ -655,9 +625,7 @@ bytecodes: [ B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(12), U8(2), B(Star), R(2), /* 16 E> */ B(StackCheck), - B(LdaUndefined), - B(Star), R(12), - B(CallJSRuntime), U8(%async_function_promise_create), R(12), U8(1), + B(CallJSRuntime), U8(%async_function_promise_create), R(0), U8(0), B(Star), R(10), B(Mov), R(context), R(14), B(Mov), R(context), R(15), @@ -684,10 +652,8 @@ bytecodes: [ B(SwitchOnSmiNoFeedback), U8(6), U8(1), I8(0), B(LdaSmi), I8(-2), /* 43 E> */ B(TestEqualStrictNoFeedback), R(11), - B(JumpIfTrue), U8(11), - B(LdaSmi), I8(45), - B(Star), R(20), - B(CallRuntime), U16(Runtime::kAbort), R(20), U8(1), + B(JumpIfTrue), U8(4), + B(Abort), U8(43), /* 40 S> */ B(LdaNamedProperty), R(4), U8(7), U8(11), B(Star), R(20), B(CallProperty0), R(20), R(4), U8(9), @@ -733,7 +699,7 @@ bytecodes: [ /* 103 S> */ B(Jump), U8(8), B(LdaZero), B(Star), R(6), - B(JumpLoop), U8(136), I8(0), + B(JumpLoop), U8(129), I8(0), B(Jump), U8(40), B(Star), R(20), B(Ldar), R(closure), @@ -777,7 +743,7 @@ bytecodes: [ B(TestTypeOf), U8(5), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(134), + B(Wide), B(LdaSmi), I16(137), B(Star), R(19), B(LdaConstant), U8(13), B(Star), R(20), @@ -851,16 +817,14 @@ bytecodes: [ B(Ldar), R(17), B(ReThrow), B(LdaUndefined), - B(Star), R(16), - B(LdaUndefined), - B(Star), R(18), - B(Mov), R(10), R(17), - B(CallJSRuntime), U8(%promise_resolve), R(16), U8(3), + B(Star), R(17), + B(Mov), R(10), R(16), + B(CallJSRuntime), U8(%promise_resolve), R(16), U8(2), B(LdaZero), B(Star), R(12), B(Mov), R(10), R(13), - B(Jump), U8(61), - B(Jump), U8(45), + B(Jump), U8(58), + B(Jump), U8(42), B(Star), R(16), B(Ldar), R(closure), B(CreateCatchContext), R(16), U8(10), U8(15), @@ -869,14 +833,12 @@ bytecodes: [ B(SetPendingMessage), B(Ldar), R(15), B(PushContext), R(16), - B(LdaUndefined), - B(Star), R(17), B(LdaImmutableCurrentContextSlot), U8(4), - B(Star), R(19), + B(Star), R(18), B(LdaFalse), - B(Star), R(20), - B(Mov), R(10), R(18), - B(CallJSRuntime), U8(%promise_internal_reject), R(17), U8(4), + B(Star), R(19), + B(Mov), R(10), R(17), + B(CallJSRuntime), U8(%promise_internal_reject), R(17), U8(3), B(PopContext), R(16), B(LdaZero), B(Star), R(12), @@ -892,10 +854,7 @@ bytecodes: [ B(LdaTheHole), B(SetPendingMessage), B(Star), R(14), - B(LdaUndefined), - B(Star), R(15), - B(Mov), R(10), R(16), - B(CallJSRuntime), U8(%async_function_promise_release), R(15), U8(2), + B(CallJSRuntime), U8(%async_function_promise_release), R(10), U8(1), B(Ldar), R(14), B(SetPendingMessage), B(Ldar), R(12), @@ -909,13 +868,13 @@ bytecodes: [ /* 114 S> */ B(Return), ] constant pool: [ - Smi [99], - Smi [374], - Smi [454], + Smi [89], + Smi [357], + Smi [437], TUPLE2_TYPE, SYMBOL_TYPE, SYMBOL_TYPE, - Smi [47], + Smi [40], ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], @@ -929,11 +888,11 @@ constant pool: [ Smi [9], ] handlers: [ - [56, 589, 597], - [59, 544, 546], - [65, 292, 300], - [68, 252, 254], - [360, 418, 420], + [46, 566, 574], + [49, 524, 526], + [55, 275, 283], + [58, 235, 237], + [343, 401, 403], ] --- @@ -946,12 +905,10 @@ snippet: " " frame size: 19 parameter count: 1 -bytecode array length: 435 +bytecode array length: 417 bytecodes: [ /* 16 E> */ B(StackCheck), - B(LdaUndefined), - B(Star), R(9), - B(CallJSRuntime), U8(%async_function_promise_create), R(9), U8(1), + B(CallJSRuntime), U8(%async_function_promise_create), R(0), U8(0), B(Star), R(8), B(Mov), R(context), R(11), B(Mov), R(context), R(12), @@ -984,7 +941,7 @@ bytecodes: [ B(LdaSmi), I8(2), B(Star), R(4), B(Ldar), R(5), - B(StaNamedPropertySloppy), R(1), U8(6), U8(14), + B(StaNamedProperty), R(1), U8(6), U8(14), /* 53 E> */ B(StackCheck), /* 87 S> */ B(LdaNamedProperty), R(1), U8(6), U8(16), B(Star), R(14), @@ -1034,7 +991,7 @@ bytecodes: [ B(TestTypeOf), U8(5), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(134), + B(Wide), B(LdaSmi), I16(137), B(Star), R(16), B(LdaConstant), U8(10), B(Star), R(17), @@ -1071,20 +1028,18 @@ bytecodes: [ B(LdaZero), B(Star), R(9), B(Mov), R(14), R(10), - B(Jump), U8(87), + B(Jump), U8(81), B(Ldar), R(14), B(ReThrow), B(LdaUndefined), - B(Star), R(13), - B(LdaUndefined), - B(Star), R(15), - B(Mov), R(8), R(14), - B(CallJSRuntime), U8(%promise_resolve), R(13), U8(3), + B(Star), R(14), + B(Mov), R(8), R(13), + B(CallJSRuntime), U8(%promise_resolve), R(13), U8(2), B(LdaSmi), I8(1), B(Star), R(9), B(Mov), R(8), R(10), - B(Jump), U8(62), - B(Jump), U8(46), + B(Jump), U8(59), + B(Jump), U8(43), B(Star), R(13), B(Ldar), R(closure), B(CreateCatchContext), R(13), U8(7), U8(14), @@ -1093,14 +1048,12 @@ bytecodes: [ B(SetPendingMessage), B(Ldar), R(12), B(PushContext), R(13), - B(LdaUndefined), - B(Star), R(14), B(LdaImmutableCurrentContextSlot), U8(4), - B(Star), R(16), + B(Star), R(15), B(LdaFalse), - B(Star), R(17), - B(Mov), R(8), R(15), - B(CallJSRuntime), U8(%promise_internal_reject), R(14), U8(4), + B(Star), R(16), + B(Mov), R(8), R(14), + B(CallJSRuntime), U8(%promise_internal_reject), R(14), U8(3), B(PopContext), R(13), B(LdaSmi), I8(1), B(Star), R(9), @@ -1116,20 +1069,15 @@ bytecodes: [ B(LdaTheHole), B(SetPendingMessage), B(Star), R(11), - B(LdaUndefined), - B(Star), R(12), - B(Mov), R(8), R(13), - B(CallJSRuntime), U8(%async_function_promise_release), R(12), U8(2), + B(CallJSRuntime), U8(%async_function_promise_release), R(8), U8(1), B(Ldar), R(11), B(SetPendingMessage), B(Ldar), R(9), B(SwitchOnSmiNoFeedback), U8(15), U8(3), I8(0), - B(Jump), U8(24), - B(LdaUndefined), - B(Star), R(12), - B(Mov), R(8), R(13), - B(Mov), R(10), R(14), - B(CallJSRuntime), U8(%promise_resolve), R(12), U8(3), + B(Jump), U8(21), + B(Mov), R(8), R(12), + B(Mov), R(10), R(13), + B(CallJSRuntime), U8(%promise_resolve), R(12), U8(2), B(Ldar), R(8), /* 96 S> */ B(Return), B(Ldar), R(10), @@ -1156,14 +1104,14 @@ constant pool: [ Smi [14], FIXED_ARRAY_TYPE, Smi [6], + Smi [19], Smi [22], - Smi [25], ] handlers: [ - [13, 372, 380], - [16, 326, 328], - [30, 156, 164], - [33, 116, 118], - [225, 235, 237], + [10, 363, 371], + [13, 320, 322], + [27, 153, 161], + [30, 113, 115], + [222, 232, 234], ] diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/ForIn.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/ForIn.golden index 4bca1ed747..55f94ab321 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/ForIn.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/ForIn.golden @@ -63,15 +63,16 @@ snippet: " " frame size: 8 parameter count: 1 -bytecode array length: 44 +bytecode array length: 46 bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaConstant), U8(0), B(Star), R(0), - /* 68 S> */ B(JumpIfUndefined), U8(37), - B(JumpIfNull), U8(35), + /* 68 S> */ B(JumpIfUndefined), U8(39), + B(JumpIfNull), U8(37), B(ToObject), R(3), - B(ForInPrepare), R(3), R(4), + B(ForInEnumerate), R(3), + B(ForInPrepare), R(4), U8(0), B(LdaZero), B(Star), R(7), /* 63 S> */ B(ForInContinue), R(7), R(6), @@ -101,16 +102,17 @@ snippet: " " frame size: 9 parameter count: 1 -bytecode array length: 56 +bytecode array length: 58 bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaZero), B(Star), R(0), /* 59 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(37), - B(JumpIfUndefined), U8(46), - B(JumpIfNull), U8(44), + B(JumpIfUndefined), U8(48), + B(JumpIfNull), U8(46), B(ToObject), R(3), - B(ForInPrepare), R(3), R(4), + B(ForInEnumerate), R(3), + B(ForInPrepare), R(4), U8(2), B(LdaZero), B(Star), R(7), /* 54 S> */ B(ForInContinue), R(7), R(6), @@ -146,16 +148,17 @@ snippet: " " frame size: 7 parameter count: 1 -bytecode array length: 85 +bytecode array length: 87 bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(41), R(1), B(Mov), R(1), R(0), /* 77 S> */ B(CreateArrayLiteral), U8(1), U8(1), U8(37), - B(JumpIfUndefined), U8(70), - B(JumpIfNull), U8(68), + B(JumpIfUndefined), U8(72), + B(JumpIfNull), U8(70), B(ToObject), R(1), - B(ForInPrepare), R(1), R(2), + B(ForInEnumerate), R(1), + B(ForInPrepare), R(2), U8(12), B(LdaZero), B(Star), R(5), /* 68 S> */ B(ForInContinue), R(5), R(4), @@ -164,7 +167,7 @@ bytecodes: [ B(JumpIfUndefined), U8(41), B(Star), R(6), B(Ldar), R(6), - /* 67 E> */ B(StaNamedPropertySloppy), R(0), U8(2), U8(10), + /* 67 E> */ B(StaNamedProperty), R(0), U8(2), U8(10), /* 62 E> */ B(StackCheck), /* 100 S> */ B(LdaNamedProperty), R(0), U8(2), U8(4), B(Star), R(6), @@ -199,16 +202,17 @@ snippet: " " frame size: 9 parameter count: 1 -bytecode array length: 62 +bytecode array length: 64 bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(37), B(Star), R(0), /* 72 S> */ B(CreateArrayLiteral), U8(1), U8(1), U8(37), - B(JumpIfUndefined), U8(49), - B(JumpIfNull), U8(47), + B(JumpIfUndefined), U8(51), + B(JumpIfNull), U8(49), B(ToObject), R(1), - B(ForInPrepare), R(1), R(2), + B(ForInEnumerate), R(1), + B(ForInPrepare), R(2), U8(8), B(LdaZero), B(Star), R(5), /* 65 S> */ B(ForInContinue), R(5), R(4), @@ -219,7 +223,7 @@ bytecodes: [ B(LdaZero), B(Star), R(8), B(Ldar), R(6), - /* 64 E> */ B(StaKeyedPropertySloppy), R(0), R(8), U8(6), + /* 64 E> */ B(StaKeyedProperty), R(0), R(8), U8(6), /* 59 E> */ B(StackCheck), /* 83 S> */ B(LdaSmi), I8(3), /* 91 E> */ B(LdaKeyedProperty), R(0), U8(4), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOf.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOf.golden index 91aace0208..9ef001a264 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOf.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOf.golden @@ -86,7 +86,7 @@ bytecodes: [ B(TestTypeOf), U8(5), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(134), + B(Wide), B(LdaSmi), I16(137), B(Star), R(11), B(LdaConstant), U8(8), B(Star), R(12), @@ -227,7 +227,7 @@ bytecodes: [ B(TestTypeOf), U8(5), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(134), + B(Wide), B(LdaSmi), I16(137), B(Star), R(12), B(LdaConstant), U8(8), B(Star), R(13), @@ -380,7 +380,7 @@ bytecodes: [ B(TestTypeOf), U8(5), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(134), + B(Wide), B(LdaSmi), I16(137), B(Star), R(11), B(LdaConstant), U8(8), B(Star), R(12), @@ -476,7 +476,7 @@ bytecodes: [ B(LdaSmi), I8(2), B(Star), R(3), B(Ldar), R(4), - B(StaNamedPropertySloppy), R(0), U8(6), U8(14), + B(StaNamedProperty), R(0), U8(6), U8(14), /* 62 E> */ B(StackCheck), /* 96 S> */ B(LdaNamedProperty), R(0), U8(6), U8(16), B(Star), R(8), @@ -523,7 +523,7 @@ bytecodes: [ B(TestTypeOf), U8(5), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(134), + B(Wide), B(LdaSmi), I16(137), B(Star), R(10), B(LdaConstant), U8(10), B(Star), R(11), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOfLoop.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOfLoop.golden index 3363e94ee9..af992d39ec 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOfLoop.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOfLoop.golden @@ -90,7 +90,7 @@ bytecodes: [ B(TestTypeOf), U8(5), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(134), + B(Wide), B(LdaSmi), I16(137), B(Star), R(13), B(LdaConstant), U8(7), B(Star), R(14), @@ -268,7 +268,7 @@ bytecodes: [ B(TestTypeOf), U8(5), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(134), + B(Wide), B(LdaSmi), I16(137), B(Star), R(13), B(LdaConstant), U8(11), B(Star), R(14), @@ -422,7 +422,7 @@ bytecodes: [ B(TestTypeOf), U8(5), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(134), + B(Wide), B(LdaSmi), I16(137), B(Star), R(11), B(LdaConstant), U8(9), B(Star), R(12), @@ -524,7 +524,7 @@ bytecodes: [ B(JumpIfUndefined), U8(6), B(Ldar), R(6), B(JumpIfNotNull), U8(16), - B(LdaSmi), I8(63), + B(LdaSmi), I8(67), B(Star), R(17), B(LdaConstant), U8(4), B(Star), R(18), @@ -580,7 +580,7 @@ bytecodes: [ B(TestTypeOf), U8(5), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(134), + B(Wide), B(LdaSmi), I16(137), B(Star), R(16), B(LdaConstant), U8(9), B(Star), R(17), @@ -647,18 +647,16 @@ snippet: " " frame size: 19 parameter count: 2 -bytecode array length: 348 +bytecode array length: 341 bytecodes: [ B(Ldar), R(3), - B(JumpIfUndefined), U8(25), + B(JumpIfUndefined), U8(18), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(3), U8(1), B(PushContext), R(12), B(RestoreGeneratorState), R(3), B(Star), R(11), B(SwitchOnSmiNoFeedback), U8(0), U8(1), I8(0), - B(LdaSmi), I8(45), - B(Star), R(12), - B(CallRuntime), U16(Runtime::kAbort), R(12), U8(1), + B(Abort), U8(43), B(LdaSmi), I8(-2), B(Star), R(11), B(CreateFunctionContext), U8(1), @@ -756,7 +754,7 @@ bytecodes: [ B(TestTypeOf), U8(5), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(134), + B(Wide), B(LdaSmi), I16(137), B(Star), R(16), B(LdaConstant), U8(10), B(Star), R(17), @@ -796,7 +794,7 @@ bytecodes: [ /* 55 S> */ B(Return), ] constant pool: [ - Smi [44], + Smi [37], Smi [10], Smi [7], SYMBOL_TYPE, @@ -810,9 +808,9 @@ constant pool: [ FIXED_ARRAY_TYPE, ] handlers: [ - [92, 210, 218], - [95, 174, 176], - [278, 288, 290], + [85, 203, 211], + [88, 167, 169], + [271, 281, 283], ] --- @@ -824,18 +822,16 @@ snippet: " " frame size: 18 parameter count: 2 -bytecode array length: 422 +bytecode array length: 408 bytecodes: [ B(Ldar), R(2), - B(JumpIfUndefined), U8(25), + B(JumpIfUndefined), U8(18), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(2), U8(1), B(PushContext), R(11), B(RestoreGeneratorState), R(2), B(Star), R(10), B(SwitchOnSmiNoFeedback), U8(0), U8(2), I8(0), - B(LdaSmi), I8(45), - B(Star), R(11), - B(CallRuntime), U16(Runtime::kAbort), R(11), U8(1), + B(Abort), U8(43), B(LdaSmi), I8(-2), B(Star), R(10), B(CreateFunctionContext), U8(1), @@ -876,10 +872,8 @@ bytecodes: [ B(SwitchOnSmiNoFeedback), U8(5), U8(1), I8(1), B(LdaSmi), I8(-2), /* 35 E> */ B(TestEqualStrictNoFeedback), R(10), - B(JumpIfTrue), U8(11), - B(LdaSmi), I8(45), - B(Star), R(16), - B(CallRuntime), U16(Runtime::kAbort), R(16), U8(1), + B(JumpIfTrue), U8(4), + B(Abort), U8(43), /* 30 S> */ B(LdaNamedProperty), R(4), U8(6), U8(6), B(Star), R(16), B(CallProperty0), R(16), R(4), U8(4), @@ -918,7 +912,7 @@ bytecodes: [ B(Jump), U8(58), B(LdaZero), B(Star), R(6), - B(JumpLoop), U8(120), I8(0), + B(JumpLoop), U8(113), I8(0), B(Jump), U8(36), B(Star), R(16), B(Ldar), R(closure), @@ -959,7 +953,7 @@ bytecodes: [ B(TestTypeOf), U8(5), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(134), + B(Wide), B(LdaSmi), I16(137), B(Star), R(15), B(LdaConstant), U8(14), B(Star), R(16), @@ -1001,12 +995,12 @@ bytecodes: [ /* 49 S> */ B(Return), ] constant pool: [ - Smi [44], - Smi [104], + Smi [37], + Smi [97], Smi [10], Smi [7], SYMBOL_TYPE, - Smi [82], + Smi [75], ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], @@ -1021,9 +1015,9 @@ constant pool: [ Smi [9], ] handlers: [ - [92, 277, 285], - [95, 241, 243], - [346, 356, 358], + [85, 263, 271], + [88, 227, 229], + [332, 342, 344], ] --- @@ -1035,16 +1029,14 @@ snippet: " " frame size: 23 parameter count: 2 -bytecode array length: 401 +bytecode array length: 386 bytecodes: [ B(CreateFunctionContext), U8(1), B(PushContext), R(12), B(Ldar), R(arg0), B(StaCurrentContextSlot), U8(4), /* 16 E> */ B(StackCheck), - B(LdaUndefined), - B(Star), R(13), - B(CallJSRuntime), U8(%async_function_promise_create), R(13), U8(1), + B(CallJSRuntime), U8(%async_function_promise_create), R(0), U8(0), B(Star), R(11), B(Mov), R(context), R(15), B(Mov), R(context), R(16), @@ -1124,7 +1116,7 @@ bytecodes: [ B(TestTypeOf), U8(5), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(134), + B(Wide), B(LdaSmi), I16(137), B(Star), R(20), B(LdaConstant), U8(7), B(Star), R(21), @@ -1161,16 +1153,14 @@ bytecodes: [ B(Ldar), R(18), B(ReThrow), B(LdaUndefined), - B(Star), R(17), - B(LdaUndefined), - B(Star), R(19), - B(Mov), R(11), R(18), - B(CallJSRuntime), U8(%promise_resolve), R(17), U8(3), + B(Star), R(18), + B(Mov), R(11), R(17), + B(CallJSRuntime), U8(%promise_resolve), R(17), U8(2), B(LdaZero), B(Star), R(13), B(Mov), R(11), R(14), - B(Jump), U8(61), - B(Jump), U8(45), + B(Jump), U8(58), + B(Jump), U8(42), B(Star), R(17), B(Ldar), R(closure), B(CreateCatchContext), R(17), U8(4), U8(9), @@ -1179,14 +1169,12 @@ bytecodes: [ B(SetPendingMessage), B(Ldar), R(16), B(PushContext), R(17), - B(LdaUndefined), - B(Star), R(18), B(LdaImmutableCurrentContextSlot), U8(4), - B(Star), R(20), + B(Star), R(19), B(LdaFalse), - B(Star), R(21), - B(Mov), R(11), R(19), - B(CallJSRuntime), U8(%promise_internal_reject), R(18), U8(4), + B(Star), R(20), + B(Mov), R(11), R(18), + B(CallJSRuntime), U8(%promise_internal_reject), R(18), U8(3), B(PopContext), R(17), B(LdaZero), B(Star), R(13), @@ -1202,10 +1190,7 @@ bytecodes: [ B(LdaTheHole), B(SetPendingMessage), B(Star), R(15), - B(LdaUndefined), - B(Star), R(16), - B(Mov), R(11), R(17), - B(CallJSRuntime), U8(%async_function_promise_release), R(16), U8(2), + B(CallJSRuntime), U8(%async_function_promise_release), R(11), U8(1), B(Ldar), R(15), B(SetPendingMessage), B(Ldar), R(13), @@ -1233,11 +1218,11 @@ constant pool: [ Smi [9], ] handlers: [ - [21, 354, 362], - [24, 309, 311], - [30, 152, 160], - [33, 112, 114], - [220, 230, 232], + [18, 345, 353], + [21, 303, 305], + [27, 149, 157], + [30, 109, 111], + [217, 227, 229], ] --- @@ -1249,18 +1234,16 @@ snippet: " " frame size: 24 parameter count: 2 -bytecode array length: 509 +bytecode array length: 480 bytecodes: [ B(Ldar), R(2), - B(JumpIfUndefined), U8(25), + B(JumpIfUndefined), U8(18), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(2), U8(1), B(PushContext), R(12), B(RestoreGeneratorState), R(2), B(Star), R(11), B(SwitchOnSmiNoFeedback), U8(0), U8(1), I8(0), - B(LdaSmi), I8(45), - B(Star), R(12), - B(CallRuntime), U16(Runtime::kAbort), R(12), U8(1), + B(Abort), U8(43), B(LdaSmi), I8(-2), B(Star), R(11), B(CreateFunctionContext), U8(1), @@ -1272,9 +1255,7 @@ bytecodes: [ B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(13), U8(2), B(Star), R(2), /* 16 E> */ B(StackCheck), - B(LdaUndefined), - B(Star), R(13), - B(CallJSRuntime), U8(%async_function_promise_create), R(13), U8(1), + B(CallJSRuntime), U8(%async_function_promise_create), R(0), U8(0), B(Star), R(10), B(Mov), R(context), R(15), B(Mov), R(context), R(16), @@ -1294,10 +1275,8 @@ bytecodes: [ B(SwitchOnSmiNoFeedback), U8(2), U8(1), I8(0), B(LdaSmi), I8(-2), /* 40 E> */ B(TestEqualStrictNoFeedback), R(11), - B(JumpIfTrue), U8(11), - B(LdaSmi), I8(45), - B(Star), R(21), - B(CallRuntime), U16(Runtime::kAbort), R(21), U8(1), + B(JumpIfTrue), U8(4), + B(Abort), U8(43), /* 35 S> */ B(LdaNamedProperty), R(4), U8(3), U8(6), B(Star), R(21), B(CallProperty0), R(21), R(4), U8(4), @@ -1335,7 +1314,7 @@ bytecodes: [ B(ReThrow), B(LdaZero), B(Star), R(6), - B(JumpLoop), U8(118), I8(0), + B(JumpLoop), U8(111), I8(0), B(Jump), U8(40), B(Star), R(21), B(Ldar), R(closure), @@ -1379,7 +1358,7 @@ bytecodes: [ B(TestTypeOf), U8(5), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(134), + B(Wide), B(LdaSmi), I16(137), B(Star), R(20), B(LdaConstant), U8(9), B(Star), R(21), @@ -1416,16 +1395,14 @@ bytecodes: [ B(Ldar), R(18), B(ReThrow), B(LdaUndefined), - B(Star), R(17), - B(LdaUndefined), - B(Star), R(19), - B(Mov), R(10), R(18), - B(CallJSRuntime), U8(%promise_resolve), R(17), U8(3), + B(Star), R(18), + B(Mov), R(10), R(17), + B(CallJSRuntime), U8(%promise_resolve), R(17), U8(2), B(LdaZero), B(Star), R(13), B(Mov), R(10), R(14), - B(Jump), U8(61), - B(Jump), U8(45), + B(Jump), U8(58), + B(Jump), U8(42), B(Star), R(17), B(Ldar), R(closure), B(CreateCatchContext), R(17), U8(6), U8(11), @@ -1434,14 +1411,12 @@ bytecodes: [ B(SetPendingMessage), B(Ldar), R(16), B(PushContext), R(17), - B(LdaUndefined), - B(Star), R(18), B(LdaImmutableCurrentContextSlot), U8(4), - B(Star), R(20), + B(Star), R(19), B(LdaFalse), - B(Star), R(21), - B(Mov), R(10), R(19), - B(CallJSRuntime), U8(%promise_internal_reject), R(18), U8(4), + B(Star), R(20), + B(Mov), R(10), R(18), + B(CallJSRuntime), U8(%promise_internal_reject), R(18), U8(3), B(PopContext), R(17), B(LdaZero), B(Star), R(13), @@ -1457,10 +1432,7 @@ bytecodes: [ B(LdaTheHole), B(SetPendingMessage), B(Star), R(15), - B(LdaUndefined), - B(Star), R(16), - B(Mov), R(10), R(17), - B(CallJSRuntime), U8(%async_function_promise_release), R(16), U8(2), + B(CallJSRuntime), U8(%async_function_promise_release), R(10), U8(1), B(Ldar), R(15), B(SetPendingMessage), B(Ldar), R(13), @@ -1474,9 +1446,9 @@ bytecodes: [ /* 54 S> */ B(Return), ] constant pool: [ - Smi [85], + Smi [75], SYMBOL_TYPE, - Smi [85], + Smi [78], ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], @@ -1490,10 +1462,10 @@ constant pool: [ Smi [9], ] handlers: [ - [64, 462, 470], - [67, 417, 419], - [73, 260, 268], - [76, 220, 222], - [328, 338, 340], + [54, 439, 447], + [57, 397, 399], + [63, 243, 251], + [66, 203, 205], + [311, 321, 323], ] diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/Generators.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/Generators.golden index afb949fe0a..bf2eb53a4f 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/Generators.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/Generators.golden @@ -13,18 +13,16 @@ snippet: " " frame size: 4 parameter count: 1 -bytecode array length: 80 +bytecode array length: 73 bytecodes: [ B(Ldar), R(0), - B(JumpIfUndefined), U8(25), + B(JumpIfUndefined), U8(18), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(0), U8(1), B(PushContext), R(2), B(RestoreGeneratorState), R(0), B(Star), R(1), B(SwitchOnSmiNoFeedback), U8(0), U8(1), I8(0), - B(LdaSmi), I8(45), - B(Star), R(2), - B(CallRuntime), U16(Runtime::kAbort), R(2), U8(1), + B(Abort), U8(43), B(LdaSmi), I8(-2), B(Star), R(1), B(Mov), R(closure), R(2), @@ -49,7 +47,7 @@ bytecodes: [ /* 16 S> */ B(Return), ] constant pool: [ - Smi [36], + Smi [29], Smi [10], Smi [7], ] @@ -63,18 +61,16 @@ snippet: " " frame size: 4 parameter count: 1 -bytecode array length: 125 +bytecode array length: 118 bytecodes: [ B(Ldar), R(0), - B(JumpIfUndefined), U8(25), + B(JumpIfUndefined), U8(18), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(0), U8(1), B(PushContext), R(2), B(RestoreGeneratorState), R(0), B(Star), R(1), B(SwitchOnSmiNoFeedback), U8(0), U8(2), I8(0), - B(LdaSmi), I8(45), - B(Star), R(2), - B(CallRuntime), U16(Runtime::kAbort), R(2), U8(1), + B(Abort), U8(43), B(LdaSmi), I8(-2), B(Star), R(1), B(Mov), R(closure), R(2), @@ -117,8 +113,8 @@ bytecodes: [ /* 25 S> */ B(Return), ] constant pool: [ - Smi [36], - Smi [81], + Smi [29], + Smi [74], Smi [10], Smi [7], Smi [10], @@ -134,18 +130,16 @@ snippet: " " frame size: 17 parameter count: 1 -bytecode array length: 416 +bytecode array length: 402 bytecodes: [ B(Ldar), R(2), - B(JumpIfUndefined), U8(25), + B(JumpIfUndefined), U8(18), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(2), U8(1), B(PushContext), R(11), B(RestoreGeneratorState), R(2), B(Star), R(10), B(SwitchOnSmiNoFeedback), U8(0), U8(2), I8(0), - B(LdaSmi), I8(45), - B(Star), R(11), - B(CallRuntime), U16(Runtime::kAbort), R(11), U8(1), + B(Abort), U8(43), B(LdaSmi), I8(-2), B(Star), R(10), B(Mov), R(closure), R(11), @@ -182,10 +176,8 @@ bytecodes: [ B(SwitchOnSmiNoFeedback), U8(6), U8(1), I8(1), B(LdaSmi), I8(-2), /* 30 E> */ B(TestEqualStrictNoFeedback), R(10), - B(JumpIfTrue), U8(11), - B(LdaSmi), I8(45), - B(Star), R(15), - B(CallRuntime), U16(Runtime::kAbort), R(15), U8(1), + B(JumpIfTrue), U8(4), + B(Abort), U8(43), /* 25 S> */ B(LdaNamedProperty), R(4), U8(7), U8(7), B(Star), R(15), B(CallProperty0), R(15), R(4), U8(5), @@ -224,7 +216,7 @@ bytecodes: [ B(Jump), U8(58), B(LdaZero), B(Star), R(6), - B(JumpLoop), U8(120), I8(0), + B(JumpLoop), U8(113), I8(0), B(Jump), U8(36), B(Star), R(15), B(Ldar), R(closure), @@ -265,7 +257,7 @@ bytecodes: [ B(TestTypeOf), U8(5), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(134), + B(Wide), B(LdaSmi), I16(137), B(Star), R(14), B(LdaConstant), U8(15), B(Star), R(15), @@ -307,13 +299,13 @@ bytecodes: [ /* 44 S> */ B(Return), ] constant pool: [ - Smi [36], - Smi [98], + Smi [29], + Smi [91], Smi [10], Smi [7], TUPLE2_TYPE, SYMBOL_TYPE, - Smi [82], + Smi [75], ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], @@ -328,9 +320,9 @@ constant pool: [ Smi [9], ] handlers: [ - [84, 271, 279], - [87, 235, 237], - [340, 350, 352], + [77, 257, 265], + [80, 221, 223], + [326, 336, 338], ] --- @@ -341,18 +333,16 @@ snippet: " " frame size: 9 parameter count: 1 -bytecode array length: 279 +bytecode array length: 265 bytecodes: [ B(Ldar), R(0), - B(JumpIfUndefined), U8(25), + B(JumpIfUndefined), U8(18), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(0), U8(1), B(PushContext), R(2), B(RestoreGeneratorState), R(0), B(Star), R(1), B(SwitchOnSmiNoFeedback), U8(0), U8(2), I8(0), - B(LdaSmi), I8(45), - B(Star), R(2), - B(CallRuntime), U16(Runtime::kAbort), R(2), U8(1), + B(Abort), U8(43), B(LdaSmi), I8(-2), B(Star), R(1), B(Mov), R(closure), R(2), @@ -391,10 +381,8 @@ bytecodes: [ B(SwitchOnSmiNoFeedback), U8(6), U8(1), I8(1), B(LdaSmi), I8(-2), B(TestEqualStrictNoFeedback), R(1), - B(JumpIfTrue), U8(11), - B(LdaSmi), I8(45), - B(Star), R(8), - B(CallRuntime), U16(Runtime::kAbort), R(8), U8(1), + B(JumpIfTrue), U8(4), + B(Abort), U8(43), B(Ldar), R(3), B(SwitchOnSmiNoFeedback), U8(7), U8(2), I8(1), B(LdaNamedProperty), R(4), U8(9), U8(8), @@ -438,7 +426,7 @@ bytecodes: [ B(Star), R(5), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1), B(Star), R(3), - B(JumpLoop), U8(146), I8(0), + B(JumpLoop), U8(139), I8(0), B(LdaNamedProperty), R(2), U8(13), U8(14), B(Star), R(4), B(LdaSmi), I8(1), @@ -450,13 +438,13 @@ bytecodes: [ /* 54 S> */ B(Return), ] constant pool: [ - Smi [36], - Smi [99], + Smi [29], + Smi [92], Smi [10], Smi [7], ONE_BYTE_INTERNALIZED_STRING_TYPE ["g"], SYMBOL_TYPE, - Smi [124], + Smi [117], Smi [17], Smi [37], ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/GlobalCountOperators.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/GlobalCountOperators.golden index 0068d80e71..2e0b987b22 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/GlobalCountOperators.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/GlobalCountOperators.golden @@ -36,12 +36,12 @@ snippet: " " frame size: 1 parameter count: 1 -bytecode array length: 17 +bytecode array length: 16 bytecodes: [ /* 26 E> */ B(StackCheck), /* 31 S> */ B(LdaGlobal), U8(0), U8(0), - B(ToNumber), R(0), U8(4), - B(Ldar), R(0), + B(ToNumber), U8(4), + B(Star), R(0), B(Dec), U8(4), /* 44 E> */ B(StaGlobalSloppy), U8(0), U8(2), B(Ldar), R(0), @@ -83,12 +83,12 @@ snippet: " " frame size: 1 parameter count: 1 -bytecode array length: 17 +bytecode array length: 16 bytecodes: [ /* 27 E> */ B(StackCheck), /* 32 S> */ B(LdaGlobal), U8(0), U8(0), - B(ToNumber), R(0), U8(4), - B(Ldar), R(0), + B(ToNumber), U8(4), + B(Star), R(0), B(Inc), U8(4), /* 50 E> */ B(StaGlobalSloppy), U8(0), U8(2), B(Ldar), R(0), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/Modules.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/Modules.golden index b38d352ec6..7ee726bb85 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/Modules.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/Modules.golden @@ -13,18 +13,16 @@ snippet: " " frame size: 5 parameter count: 2 -bytecode array length: 103 +bytecode array length: 96 bytecodes: [ B(Ldar), R(1), - B(JumpIfUndefined), U8(25), + B(JumpIfUndefined), U8(18), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(1), U8(1), B(PushContext), R(2), B(RestoreGeneratorState), R(1), B(Star), R(0), B(SwitchOnSmiNoFeedback), U8(0), U8(1), I8(0), - B(LdaSmi), I8(45), - B(Star), R(2), - B(CallRuntime), U16(Runtime::kAbort), R(2), U8(1), + B(Abort), U8(43), B(LdaSmi), I8(-2), B(Star), R(0), B(LdaConstant), U8(1), @@ -58,7 +56,7 @@ bytecodes: [ /* 13 S> */ B(Return), ] constant pool: [ - Smi [54], + Smi [47], FIXED_ARRAY_TYPE, Smi [10], Smi [7], @@ -72,18 +70,16 @@ snippet: " " frame size: 5 parameter count: 2 -bytecode array length: 103 +bytecode array length: 96 bytecodes: [ B(Ldar), R(1), - B(JumpIfUndefined), U8(25), + B(JumpIfUndefined), U8(18), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(1), U8(1), B(PushContext), R(2), B(RestoreGeneratorState), R(1), B(Star), R(0), B(SwitchOnSmiNoFeedback), U8(0), U8(1), I8(0), - B(LdaSmi), I8(45), - B(Star), R(2), - B(CallRuntime), U16(Runtime::kAbort), R(2), U8(1), + B(Abort), U8(43), B(LdaSmi), I8(-2), B(Star), R(0), B(LdaConstant), U8(1), @@ -117,7 +113,7 @@ bytecodes: [ /* 24 S> */ B(Return), ] constant pool: [ - Smi [54], + Smi [47], FIXED_ARRAY_TYPE, Smi [10], Smi [7], @@ -133,18 +129,16 @@ snippet: " " frame size: 6 parameter count: 2 -bytecode array length: 147 +bytecode array length: 140 bytecodes: [ B(Ldar), R(1), - B(JumpIfUndefined), U8(25), + B(JumpIfUndefined), U8(18), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(1), U8(1), B(PushContext), R(2), B(RestoreGeneratorState), R(1), B(Star), R(0), B(SwitchOnSmiNoFeedback), U8(0), U8(1), I8(0), - B(LdaSmi), I8(45), - B(Star), R(2), - B(CallRuntime), U16(Runtime::kAbort), R(2), U8(1), + B(Abort), U8(43), B(LdaSmi), I8(-2), B(Star), R(0), B(LdaConstant), U8(1), @@ -197,7 +191,7 @@ bytecodes: [ /* 64 S> */ B(Return), ] constant pool: [ - Smi [54], + Smi [47], FIXED_ARRAY_TYPE, Smi [10], Smi [7], @@ -215,18 +209,16 @@ snippet: " " frame size: 5 parameter count: 2 -bytecode array length: 145 +bytecode array length: 137 bytecodes: [ B(Ldar), R(1), - B(JumpIfUndefined), U8(25), + B(JumpIfUndefined), U8(18), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(1), U8(1), B(PushContext), R(2), B(RestoreGeneratorState), R(1), B(Star), R(0), B(SwitchOnSmiNoFeedback), U8(0), U8(1), I8(0), - B(LdaSmi), I8(45), - B(Star), R(2), - B(CallRuntime), U16(Runtime::kAbort), R(2), U8(1), + B(Abort), U8(43), B(LdaSmi), I8(-2), B(Star), R(0), B(LdaConstant), U8(1), @@ -267,8 +259,8 @@ bytecodes: [ /* 34 S> */ B(LdaUndefined), /* 34 E> */ B(StaCurrentContextSlot), U8(4), /* 39 S> */ B(LdaModuleVariable), I8(1), U8(1), - B(ToNumber), R(4), U8(1), - B(Ldar), R(4), + B(ToNumber), U8(1), + B(Star), R(4), B(Inc), U8(1), /* 42 E> */ B(StaModuleVariable), I8(1), U8(1), B(Ldar), R(4), @@ -278,7 +270,7 @@ bytecodes: [ /* 49 S> */ B(Return), ] constant pool: [ - Smi [54], + Smi [47], FIXED_ARRAY_TYPE, Smi [10], Smi [7], @@ -295,18 +287,16 @@ snippet: " " frame size: 5 parameter count: 2 -bytecode array length: 149 +bytecode array length: 141 bytecodes: [ B(Ldar), R(1), - B(JumpIfUndefined), U8(25), + B(JumpIfUndefined), U8(18), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(1), U8(1), B(PushContext), R(2), B(RestoreGeneratorState), R(1), B(Star), R(0), B(SwitchOnSmiNoFeedback), U8(0), U8(1), I8(0), - B(LdaSmi), I8(45), - B(Star), R(2), - B(CallRuntime), U16(Runtime::kAbort), R(2), U8(1), + B(Abort), U8(43), B(LdaSmi), I8(-2), B(Star), R(0), B(LdaConstant), U8(1), @@ -349,8 +339,8 @@ bytecodes: [ /* 34 S> */ B(LdaUndefined), /* 34 E> */ B(StaCurrentContextSlot), U8(4), /* 39 S> */ B(LdaModuleVariable), I8(1), U8(1), - B(ToNumber), R(4), U8(1), - B(Ldar), R(4), + B(ToNumber), U8(1), + B(Star), R(4), B(Inc), U8(1), /* 42 E> */ B(StaModuleVariable), I8(1), U8(1), B(Ldar), R(4), @@ -360,7 +350,7 @@ bytecodes: [ /* 49 S> */ B(Return), ] constant pool: [ - Smi [58], + Smi [51], FIXED_ARRAY_TYPE, Smi [10], Smi [7], @@ -377,18 +367,16 @@ snippet: " " frame size: 5 parameter count: 2 -bytecode array length: 153 +bytecode array length: 145 bytecodes: [ B(Ldar), R(1), - B(JumpIfUndefined), U8(25), + B(JumpIfUndefined), U8(18), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(1), U8(1), B(PushContext), R(2), B(RestoreGeneratorState), R(1), B(Star), R(0), B(SwitchOnSmiNoFeedback), U8(0), U8(1), I8(0), - B(LdaSmi), I8(45), - B(Star), R(2), - B(CallRuntime), U16(Runtime::kAbort), R(2), U8(1), + B(Abort), U8(43), B(LdaSmi), I8(-2), B(Star), R(0), B(LdaConstant), U8(1), @@ -431,8 +419,8 @@ bytecodes: [ /* 36 S> */ B(LdaUndefined), /* 36 E> */ B(StaCurrentContextSlot), U8(4), /* 41 S> */ B(LdaModuleVariable), I8(1), U8(1), - B(ToNumber), R(4), U8(1), - B(Ldar), R(4), + B(ToNumber), U8(1), + B(Star), R(4), B(Inc), U8(1), /* 44 E> */ B(CallRuntime), U16(Runtime::kThrowConstAssignError), R(0), U8(0), B(Ldar), R(4), @@ -442,7 +430,7 @@ bytecodes: [ /* 51 S> */ B(Return), ] constant pool: [ - Smi [58], + Smi [51], FIXED_ARRAY_TYPE, Smi [10], Smi [7], @@ -457,18 +445,16 @@ snippet: " " frame size: 5 parameter count: 2 -bytecode array length: 114 +bytecode array length: 107 bytecodes: [ B(Ldar), R(1), - B(JumpIfUndefined), U8(25), + B(JumpIfUndefined), U8(18), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(1), U8(1), B(PushContext), R(2), B(RestoreGeneratorState), R(1), B(Star), R(0), B(SwitchOnSmiNoFeedback), U8(0), U8(1), I8(0), - B(LdaSmi), I8(45), - B(Star), R(2), - B(CallRuntime), U16(Runtime::kAbort), R(2), U8(1), + B(Abort), U8(43), B(LdaSmi), I8(-2), B(Star), R(0), B(LdaConstant), U8(1), @@ -506,7 +492,7 @@ bytecodes: [ /* 32 S> */ B(Return), ] constant pool: [ - Smi [58], + Smi [51], FIXED_ARRAY_TYPE, Smi [10], Smi [7], @@ -521,18 +507,16 @@ snippet: " " frame size: 8 parameter count: 2 -bytecode array length: 147 +bytecode array length: 140 bytecodes: [ B(Ldar), R(1), - B(JumpIfUndefined), U8(25), + B(JumpIfUndefined), U8(18), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(1), U8(1), B(PushContext), R(2), B(RestoreGeneratorState), R(1), B(Star), R(0), B(SwitchOnSmiNoFeedback), U8(0), U8(1), I8(0), - B(LdaSmi), I8(45), - B(Star), R(2), - B(CallRuntime), U16(Runtime::kAbort), R(2), U8(1), + B(Abort), U8(43), B(LdaSmi), I8(-2), B(Star), R(0), B(LdaConstant), U8(1), @@ -582,7 +566,7 @@ bytecodes: [ /* 26 S> */ B(Return), ] constant pool: [ - Smi [58], + Smi [51], FIXED_ARRAY_TYPE, Smi [10], Smi [7], @@ -597,18 +581,16 @@ snippet: " " frame size: 5 parameter count: 2 -bytecode array length: 103 +bytecode array length: 96 bytecodes: [ B(Ldar), R(1), - B(JumpIfUndefined), U8(25), + B(JumpIfUndefined), U8(18), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(1), U8(1), B(PushContext), R(2), B(RestoreGeneratorState), R(1), B(Star), R(0), B(SwitchOnSmiNoFeedback), U8(0), U8(1), I8(0), - B(LdaSmi), I8(45), - B(Star), R(2), - B(CallRuntime), U16(Runtime::kAbort), R(2), U8(1), + B(Abort), U8(43), B(LdaSmi), I8(-2), B(Star), R(0), B(LdaConstant), U8(1), @@ -642,7 +624,7 @@ bytecodes: [ /* 30 S> */ B(Return), ] constant pool: [ - Smi [54], + Smi [47], FIXED_ARRAY_TYPE, Smi [10], Smi [7], @@ -656,18 +638,16 @@ snippet: " " frame size: 5 parameter count: 2 -bytecode array length: 103 +bytecode array length: 96 bytecodes: [ B(Ldar), R(1), - B(JumpIfUndefined), U8(25), + B(JumpIfUndefined), U8(18), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(1), U8(1), B(PushContext), R(2), B(RestoreGeneratorState), R(1), B(Star), R(0), B(SwitchOnSmiNoFeedback), U8(0), U8(1), I8(0), - B(LdaSmi), I8(45), - B(Star), R(2), - B(CallRuntime), U16(Runtime::kAbort), R(2), U8(1), + B(Abort), U8(43), B(LdaSmi), I8(-2), B(Star), R(0), B(LdaConstant), U8(1), @@ -701,7 +681,7 @@ bytecodes: [ /* 19 S> */ B(Return), ] constant pool: [ - Smi [54], + Smi [47], FIXED_ARRAY_TYPE, Smi [10], Smi [7], @@ -716,18 +696,16 @@ snippet: " " frame size: 7 parameter count: 2 -bytecode array length: 141 +bytecode array length: 134 bytecodes: [ B(Ldar), R(1), - B(JumpIfUndefined), U8(25), + B(JumpIfUndefined), U8(18), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(1), U8(1), B(PushContext), R(2), B(RestoreGeneratorState), R(1), B(Star), R(0), B(SwitchOnSmiNoFeedback), U8(0), U8(1), I8(0), - B(LdaSmi), I8(45), - B(Star), R(2), - B(CallRuntime), U16(Runtime::kAbort), R(2), U8(1), + B(Abort), U8(43), B(LdaSmi), I8(-2), B(Star), R(0), B(LdaConstant), U8(1), @@ -775,7 +753,7 @@ bytecodes: [ /* 45 S> */ B(Return), ] constant pool: [ - Smi [64], + Smi [57], FIXED_ARRAY_TYPE, Smi [10], Smi [7], diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/NewAndSpread.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/NewAndSpread.golden index 683b091356..9f701feb05 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/NewAndSpread.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/NewAndSpread.golden @@ -90,9 +90,9 @@ snippet: " class A { constructor(...args) { this.args = args; } } new A(0, ...[1, 2, 3], 4); " -frame size: 8 +frame size: 7 parameter count: 1 -bytecode array length: 90 +bytecode array length: 81 bytecodes: [ /* 30 E> */ B(StackCheck), B(CreateClosure), U8(0), U8(0), U8(2), @@ -110,24 +110,18 @@ bytecodes: [ B(CallRuntime), U16(Runtime::kToFastProperties), R(2), U8(1), B(Star), R(0), B(Star), R(1), - /* 89 S> */ B(LdaUndefined), - B(Star), R(2), - B(LdaUndefined), - B(Star), R(4), - /* 93 E> */ B(CreateArrayLiteral), U8(1), U8(1), U8(37), - B(Star), R(5), - B(LdaUndefined), - B(Star), R(6), + /* 89 S> */ B(CreateArrayLiteral), U8(1), U8(1), U8(37), + B(Star), R(3), B(CreateArrayLiteral), U8(2), U8(2), U8(37), - B(Star), R(7), - B(CallJSRuntime), U8(%spread_iterable), R(6), U8(2), - B(Star), R(6), - B(CreateArrayLiteral), U8(3), U8(3), U8(37), - B(Star), R(7), - B(CallJSRuntime), U8(%spread_arguments), R(4), U8(4), B(Star), R(4), - B(Mov), R(0), R(3), - B(CallJSRuntime), U8(%reflect_construct), R(2), U8(3), + B(CallJSRuntime), U8(%spread_iterable), R(4), U8(1), + B(Star), R(4), + B(CreateArrayLiteral), U8(3), U8(3), U8(37), + B(Star), R(5), + B(CallJSRuntime), U8(%spread_arguments), R(3), U8(3), + B(Star), R(3), + B(Mov), R(1), R(2), + B(CallJSRuntime), U8(%reflect_construct), R(2), U8(2), B(LdaUndefined), /* 116 S> */ B(Return), ] diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/ObjectLiterals.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/ObjectLiterals.golden index 5aab58c78f..242d988f63 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/ObjectLiterals.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/ObjectLiterals.golden @@ -338,10 +338,10 @@ bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaConstant), U8(0), B(Star), R(0), - /* 50 S> */ B(CreateObjectLiteral), U8(1), U8(1), U8(41), R(1), + /* 50 S> */ B(CreateObjectLiteral), U8(1), U8(0), U8(41), R(1), /* 60 E> */ B(ToName), R(2), B(LdaSmi), I8(1), - B(StaDataPropertyInLiteral), R(1), R(2), U8(0), U8(2), + B(StaDataPropertyInLiteral), R(1), R(2), U8(0), U8(1), B(CreateEmptyObjectLiteral), B(Star), R(3), B(Mov), R(1), R(2), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/PropertyStores.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/PropertyStores.golden index 31036735ae..41f2290805 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/PropertyStores.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/PropertyStores.golden @@ -17,7 +17,7 @@ bytecode array length: 9 bytecodes: [ /* 10 E> */ B(StackCheck), /* 16 S> */ B(LdaConstant), U8(0), - /* 23 E> */ B(StaNamedPropertySloppy), R(arg0), U8(1), U8(0), + /* 23 E> */ B(StaNamedProperty), R(arg0), U8(1), U8(0), B(LdaUndefined), /* 32 S> */ B(Return), ] @@ -39,7 +39,7 @@ bytecode array length: 9 bytecodes: [ /* 10 E> */ B(StackCheck), /* 16 S> */ B(LdaConstant), U8(0), - /* 25 E> */ B(StaNamedPropertySloppy), R(arg0), U8(1), U8(0), + /* 25 E> */ B(StaNamedProperty), R(arg0), U8(1), U8(0), B(LdaUndefined), /* 34 S> */ B(Return), ] @@ -63,7 +63,7 @@ bytecodes: [ /* 16 S> */ B(LdaSmi), I8(100), B(Star), R(1), B(LdaConstant), U8(0), - /* 23 E> */ B(StaKeyedPropertySloppy), R(arg0), R(1), U8(0), + /* 23 E> */ B(StaKeyedProperty), R(arg0), R(1), U8(0), B(LdaUndefined), /* 32 S> */ B(Return), ] @@ -84,7 +84,7 @@ bytecode array length: 9 bytecodes: [ /* 10 E> */ B(StackCheck), /* 19 S> */ B(LdaConstant), U8(0), - /* 24 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(0), + /* 24 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(0), B(LdaUndefined), /* 33 S> */ B(Return), ] @@ -106,7 +106,7 @@ bytecodes: [ /* 10 E> */ B(StackCheck), /* 16 S> */ B(LdaSmi), I8(-124), /* 26 E> */ B(LdaKeyedProperty), R(arg0), U8(0), - /* 23 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(2), + /* 23 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(2), B(LdaUndefined), /* 34 S> */ B(Return), ] @@ -127,7 +127,7 @@ bytecode array length: 9 bytecodes: [ /* 10 E> */ B(StackCheck), /* 30 S> */ B(LdaConstant), U8(0), - /* 37 E> */ B(StaNamedPropertyStrict), R(arg0), U8(1), U8(0), + /* 37 E> */ B(StaNamedProperty), R(arg0), U8(1), U8(0), B(LdaUndefined), /* 46 S> */ B(Return), ] @@ -149,7 +149,7 @@ bytecode array length: 9 bytecodes: [ /* 10 E> */ B(StackCheck), /* 33 S> */ B(LdaConstant), U8(0), - /* 38 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(0), + /* 38 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(0), B(LdaUndefined), /* 47 S> */ B(Return), ] @@ -300,263 +300,263 @@ bytecode array length: 781 bytecodes: [ /* 10 E> */ B(StackCheck), /* 18 S> */ B(LdaSmi), I8(1), - /* 25 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(0), + /* 25 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(0), /* 32 S> */ B(LdaSmi), I8(1), - /* 39 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(2), + /* 39 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(2), /* 46 S> */ B(LdaSmi), I8(1), - /* 53 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(4), + /* 53 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(4), /* 60 S> */ B(LdaSmi), I8(1), - /* 67 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(6), + /* 67 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(6), /* 74 S> */ B(LdaSmi), I8(1), - /* 81 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(8), + /* 81 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(8), /* 88 S> */ B(LdaSmi), I8(1), - /* 95 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(10), + /* 95 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(10), /* 102 S> */ B(LdaSmi), I8(1), - /* 109 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(12), + /* 109 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(12), /* 116 S> */ B(LdaSmi), I8(1), - /* 123 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(14), + /* 123 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(14), /* 130 S> */ B(LdaSmi), I8(1), - /* 137 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(16), + /* 137 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(16), /* 144 S> */ B(LdaSmi), I8(1), - /* 151 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(18), + /* 151 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(18), /* 158 S> */ B(LdaSmi), I8(1), - /* 165 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(20), + /* 165 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(20), /* 172 S> */ B(LdaSmi), I8(1), - /* 179 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(22), + /* 179 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(22), /* 186 S> */ B(LdaSmi), I8(1), - /* 193 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(24), + /* 193 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(24), /* 200 S> */ B(LdaSmi), I8(1), - /* 207 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(26), + /* 207 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(26), /* 214 S> */ B(LdaSmi), I8(1), - /* 221 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(28), + /* 221 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(28), /* 228 S> */ B(LdaSmi), I8(1), - /* 235 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(30), + /* 235 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(30), /* 242 S> */ B(LdaSmi), I8(1), - /* 249 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(32), + /* 249 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(32), /* 256 S> */ B(LdaSmi), I8(1), - /* 263 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(34), + /* 263 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(34), /* 270 S> */ B(LdaSmi), I8(1), - /* 277 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(36), + /* 277 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(36), /* 284 S> */ B(LdaSmi), I8(1), - /* 291 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(38), + /* 291 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(38), /* 298 S> */ B(LdaSmi), I8(1), - /* 305 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(40), + /* 305 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(40), /* 312 S> */ B(LdaSmi), I8(1), - /* 319 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(42), + /* 319 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(42), /* 326 S> */ B(LdaSmi), I8(1), - /* 333 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(44), + /* 333 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(44), /* 340 S> */ B(LdaSmi), I8(1), - /* 347 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(46), + /* 347 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(46), /* 354 S> */ B(LdaSmi), I8(1), - /* 361 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(48), + /* 361 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(48), /* 368 S> */ B(LdaSmi), I8(1), - /* 375 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(50), + /* 375 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(50), /* 382 S> */ B(LdaSmi), I8(1), - /* 389 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(52), + /* 389 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(52), /* 396 S> */ B(LdaSmi), I8(1), - /* 403 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(54), + /* 403 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(54), /* 410 S> */ B(LdaSmi), I8(1), - /* 417 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(56), + /* 417 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(56), /* 424 S> */ B(LdaSmi), I8(1), - /* 431 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(58), + /* 431 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(58), /* 438 S> */ B(LdaSmi), I8(1), - /* 445 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(60), + /* 445 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(60), /* 452 S> */ B(LdaSmi), I8(1), - /* 459 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(62), + /* 459 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(62), /* 466 S> */ B(LdaSmi), I8(1), - /* 473 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(64), + /* 473 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(64), /* 480 S> */ B(LdaSmi), I8(1), - /* 487 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(66), + /* 487 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(66), /* 494 S> */ B(LdaSmi), I8(1), - /* 501 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(68), + /* 501 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(68), /* 508 S> */ B(LdaSmi), I8(1), - /* 515 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(70), + /* 515 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(70), /* 522 S> */ B(LdaSmi), I8(1), - /* 529 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(72), + /* 529 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(72), /* 536 S> */ B(LdaSmi), I8(1), - /* 543 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(74), + /* 543 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(74), /* 550 S> */ B(LdaSmi), I8(1), - /* 557 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(76), + /* 557 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(76), /* 564 S> */ B(LdaSmi), I8(1), - /* 571 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(78), + /* 571 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(78), /* 578 S> */ B(LdaSmi), I8(1), - /* 585 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(80), + /* 585 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(80), /* 592 S> */ B(LdaSmi), I8(1), - /* 599 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(82), + /* 599 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(82), /* 606 S> */ B(LdaSmi), I8(1), - /* 613 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(84), + /* 613 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(84), /* 620 S> */ B(LdaSmi), I8(1), - /* 627 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(86), + /* 627 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(86), /* 634 S> */ B(LdaSmi), I8(1), - /* 641 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(88), + /* 641 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(88), /* 648 S> */ B(LdaSmi), I8(1), - /* 655 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(90), + /* 655 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(90), /* 662 S> */ B(LdaSmi), I8(1), - /* 669 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(92), + /* 669 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(92), /* 676 S> */ B(LdaSmi), I8(1), - /* 683 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(94), + /* 683 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(94), /* 690 S> */ B(LdaSmi), I8(1), - /* 697 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(96), + /* 697 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(96), /* 704 S> */ B(LdaSmi), I8(1), - /* 711 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(98), + /* 711 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(98), /* 718 S> */ B(LdaSmi), I8(1), - /* 725 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(100), + /* 725 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(100), /* 732 S> */ B(LdaSmi), I8(1), - /* 739 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(102), + /* 739 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(102), /* 746 S> */ B(LdaSmi), I8(1), - /* 753 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(104), + /* 753 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(104), /* 760 S> */ B(LdaSmi), I8(1), - /* 767 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(106), + /* 767 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(106), /* 774 S> */ B(LdaSmi), I8(1), - /* 781 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(108), + /* 781 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(108), /* 788 S> */ B(LdaSmi), I8(1), - /* 795 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(110), + /* 795 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(110), /* 802 S> */ B(LdaSmi), I8(1), - /* 809 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(112), + /* 809 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(112), /* 816 S> */ B(LdaSmi), I8(1), - /* 823 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(114), + /* 823 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(114), /* 830 S> */ B(LdaSmi), I8(1), - /* 837 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(116), + /* 837 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(116), /* 844 S> */ B(LdaSmi), I8(1), - /* 851 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(118), + /* 851 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(118), /* 858 S> */ B(LdaSmi), I8(1), - /* 865 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(120), + /* 865 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(120), /* 872 S> */ B(LdaSmi), I8(1), - /* 879 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(122), + /* 879 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(122), /* 886 S> */ B(LdaSmi), I8(1), - /* 893 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(124), + /* 893 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(124), /* 900 S> */ B(LdaSmi), I8(1), - /* 907 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(126), + /* 907 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(126), /* 914 S> */ B(LdaSmi), I8(1), - /* 921 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(128), + /* 921 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(128), /* 928 S> */ B(LdaSmi), I8(1), - /* 935 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(130), + /* 935 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(130), /* 942 S> */ B(LdaSmi), I8(1), - /* 949 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(132), + /* 949 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(132), /* 956 S> */ B(LdaSmi), I8(1), - /* 963 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(134), + /* 963 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(134), /* 970 S> */ B(LdaSmi), I8(1), - /* 977 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(136), + /* 977 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(136), /* 984 S> */ B(LdaSmi), I8(1), - /* 991 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(138), + /* 991 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(138), /* 998 S> */ B(LdaSmi), I8(1), - /* 1005 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(140), + /* 1005 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(140), /* 1012 S> */ B(LdaSmi), I8(1), - /* 1019 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(142), + /* 1019 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(142), /* 1026 S> */ B(LdaSmi), I8(1), - /* 1033 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(144), + /* 1033 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(144), /* 1040 S> */ B(LdaSmi), I8(1), - /* 1047 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(146), + /* 1047 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(146), /* 1054 S> */ B(LdaSmi), I8(1), - /* 1061 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(148), + /* 1061 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(148), /* 1068 S> */ B(LdaSmi), I8(1), - /* 1075 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(150), + /* 1075 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(150), /* 1082 S> */ B(LdaSmi), I8(1), - /* 1089 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(152), + /* 1089 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(152), /* 1096 S> */ B(LdaSmi), I8(1), - /* 1103 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(154), + /* 1103 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(154), /* 1110 S> */ B(LdaSmi), I8(1), - /* 1117 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(156), + /* 1117 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(156), /* 1124 S> */ B(LdaSmi), I8(1), - /* 1131 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(158), + /* 1131 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(158), /* 1138 S> */ B(LdaSmi), I8(1), - /* 1145 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(160), + /* 1145 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(160), /* 1152 S> */ B(LdaSmi), I8(1), - /* 1159 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(162), + /* 1159 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(162), /* 1166 S> */ B(LdaSmi), I8(1), - /* 1173 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(164), + /* 1173 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(164), /* 1180 S> */ B(LdaSmi), I8(1), - /* 1187 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(166), + /* 1187 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(166), /* 1194 S> */ B(LdaSmi), I8(1), - /* 1201 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(168), + /* 1201 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(168), /* 1208 S> */ B(LdaSmi), I8(1), - /* 1215 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(170), + /* 1215 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(170), /* 1222 S> */ B(LdaSmi), I8(1), - /* 1229 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(172), + /* 1229 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(172), /* 1236 S> */ B(LdaSmi), I8(1), - /* 1243 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(174), + /* 1243 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(174), /* 1250 S> */ B(LdaSmi), I8(1), - /* 1257 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(176), + /* 1257 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(176), /* 1264 S> */ B(LdaSmi), I8(1), - /* 1271 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(178), + /* 1271 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(178), /* 1278 S> */ B(LdaSmi), I8(1), - /* 1285 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(180), + /* 1285 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(180), /* 1292 S> */ B(LdaSmi), I8(1), - /* 1299 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(182), + /* 1299 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(182), /* 1306 S> */ B(LdaSmi), I8(1), - /* 1313 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(184), + /* 1313 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(184), /* 1320 S> */ B(LdaSmi), I8(1), - /* 1327 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(186), + /* 1327 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(186), /* 1334 S> */ B(LdaSmi), I8(1), - /* 1341 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(188), + /* 1341 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(188), /* 1348 S> */ B(LdaSmi), I8(1), - /* 1355 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(190), + /* 1355 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(190), /* 1362 S> */ B(LdaSmi), I8(1), - /* 1369 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(192), + /* 1369 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(192), /* 1376 S> */ B(LdaSmi), I8(1), - /* 1383 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(194), + /* 1383 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(194), /* 1390 S> */ B(LdaSmi), I8(1), - /* 1397 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(196), + /* 1397 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(196), /* 1404 S> */ B(LdaSmi), I8(1), - /* 1411 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(198), + /* 1411 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(198), /* 1418 S> */ B(LdaSmi), I8(1), - /* 1425 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(200), + /* 1425 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(200), /* 1432 S> */ B(LdaSmi), I8(1), - /* 1439 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(202), + /* 1439 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(202), /* 1446 S> */ B(LdaSmi), I8(1), - /* 1453 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(204), + /* 1453 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(204), /* 1460 S> */ B(LdaSmi), I8(1), - /* 1467 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(206), + /* 1467 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(206), /* 1474 S> */ B(LdaSmi), I8(1), - /* 1481 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(208), + /* 1481 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(208), /* 1488 S> */ B(LdaSmi), I8(1), - /* 1495 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(210), + /* 1495 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(210), /* 1502 S> */ B(LdaSmi), I8(1), - /* 1509 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(212), + /* 1509 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(212), /* 1516 S> */ B(LdaSmi), I8(1), - /* 1523 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(214), + /* 1523 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(214), /* 1530 S> */ B(LdaSmi), I8(1), - /* 1537 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(216), + /* 1537 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(216), /* 1544 S> */ B(LdaSmi), I8(1), - /* 1551 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(218), + /* 1551 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(218), /* 1558 S> */ B(LdaSmi), I8(1), - /* 1565 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(220), + /* 1565 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(220), /* 1572 S> */ B(LdaSmi), I8(1), - /* 1579 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(222), + /* 1579 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(222), /* 1586 S> */ B(LdaSmi), I8(1), - /* 1593 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(224), + /* 1593 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(224), /* 1600 S> */ B(LdaSmi), I8(1), - /* 1607 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(226), + /* 1607 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(226), /* 1614 S> */ B(LdaSmi), I8(1), - /* 1621 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(228), + /* 1621 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(228), /* 1628 S> */ B(LdaSmi), I8(1), - /* 1635 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(230), + /* 1635 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(230), /* 1642 S> */ B(LdaSmi), I8(1), - /* 1649 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(232), + /* 1649 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(232), /* 1656 S> */ B(LdaSmi), I8(1), - /* 1663 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(234), + /* 1663 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(234), /* 1670 S> */ B(LdaSmi), I8(1), - /* 1677 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(236), + /* 1677 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(236), /* 1684 S> */ B(LdaSmi), I8(1), - /* 1691 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(238), + /* 1691 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(238), /* 1698 S> */ B(LdaSmi), I8(1), - /* 1705 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(240), + /* 1705 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(240), /* 1712 S> */ B(LdaSmi), I8(1), - /* 1719 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(242), + /* 1719 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(242), /* 1726 S> */ B(LdaSmi), I8(1), - /* 1733 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(244), + /* 1733 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(244), /* 1740 S> */ B(LdaSmi), I8(1), - /* 1747 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(246), + /* 1747 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(246), /* 1754 S> */ B(LdaSmi), I8(1), - /* 1761 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(248), + /* 1761 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(248), /* 1768 S> */ B(LdaSmi), I8(1), - /* 1775 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(250), + /* 1775 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(250), /* 1782 S> */ B(LdaSmi), I8(1), - /* 1789 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(252), + /* 1789 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(252), /* 1796 S> */ B(LdaSmi), I8(1), - /* 1803 E> */ B(StaNamedPropertySloppy), R(arg0), U8(0), U8(254), + /* 1803 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(254), /* 1810 S> */ B(LdaSmi), I8(2), - /* 1817 E> */ B(Wide), B(StaNamedPropertySloppy), R16(arg0), U16(0), U16(256), + /* 1817 E> */ B(Wide), B(StaNamedProperty), R16(arg0), U16(0), U16(256), B(LdaUndefined), /* 1822 S> */ B(Return), ] @@ -708,263 +708,263 @@ bytecode array length: 781 bytecodes: [ /* 10 E> */ B(StackCheck), /* 33 S> */ B(LdaSmi), I8(1), - /* 40 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(0), + /* 40 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(0), /* 47 S> */ B(LdaSmi), I8(1), - /* 54 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(2), + /* 54 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(2), /* 61 S> */ B(LdaSmi), I8(1), - /* 68 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(4), + /* 68 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(4), /* 75 S> */ B(LdaSmi), I8(1), - /* 82 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(6), + /* 82 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(6), /* 89 S> */ B(LdaSmi), I8(1), - /* 96 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(8), + /* 96 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(8), /* 103 S> */ B(LdaSmi), I8(1), - /* 110 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(10), + /* 110 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(10), /* 117 S> */ B(LdaSmi), I8(1), - /* 124 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(12), + /* 124 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(12), /* 131 S> */ B(LdaSmi), I8(1), - /* 138 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(14), + /* 138 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(14), /* 145 S> */ B(LdaSmi), I8(1), - /* 152 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(16), + /* 152 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(16), /* 159 S> */ B(LdaSmi), I8(1), - /* 166 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(18), + /* 166 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(18), /* 173 S> */ B(LdaSmi), I8(1), - /* 180 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(20), + /* 180 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(20), /* 187 S> */ B(LdaSmi), I8(1), - /* 194 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(22), + /* 194 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(22), /* 201 S> */ B(LdaSmi), I8(1), - /* 208 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(24), + /* 208 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(24), /* 215 S> */ B(LdaSmi), I8(1), - /* 222 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(26), + /* 222 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(26), /* 229 S> */ B(LdaSmi), I8(1), - /* 236 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(28), + /* 236 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(28), /* 243 S> */ B(LdaSmi), I8(1), - /* 250 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(30), + /* 250 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(30), /* 257 S> */ B(LdaSmi), I8(1), - /* 264 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(32), + /* 264 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(32), /* 271 S> */ B(LdaSmi), I8(1), - /* 278 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(34), + /* 278 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(34), /* 285 S> */ B(LdaSmi), I8(1), - /* 292 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(36), + /* 292 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(36), /* 299 S> */ B(LdaSmi), I8(1), - /* 306 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(38), + /* 306 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(38), /* 313 S> */ B(LdaSmi), I8(1), - /* 320 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(40), + /* 320 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(40), /* 327 S> */ B(LdaSmi), I8(1), - /* 334 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(42), + /* 334 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(42), /* 341 S> */ B(LdaSmi), I8(1), - /* 348 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(44), + /* 348 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(44), /* 355 S> */ B(LdaSmi), I8(1), - /* 362 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(46), + /* 362 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(46), /* 369 S> */ B(LdaSmi), I8(1), - /* 376 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(48), + /* 376 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(48), /* 383 S> */ B(LdaSmi), I8(1), - /* 390 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(50), + /* 390 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(50), /* 397 S> */ B(LdaSmi), I8(1), - /* 404 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(52), + /* 404 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(52), /* 411 S> */ B(LdaSmi), I8(1), - /* 418 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(54), + /* 418 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(54), /* 425 S> */ B(LdaSmi), I8(1), - /* 432 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(56), + /* 432 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(56), /* 439 S> */ B(LdaSmi), I8(1), - /* 446 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(58), + /* 446 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(58), /* 453 S> */ B(LdaSmi), I8(1), - /* 460 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(60), + /* 460 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(60), /* 467 S> */ B(LdaSmi), I8(1), - /* 474 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(62), + /* 474 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(62), /* 481 S> */ B(LdaSmi), I8(1), - /* 488 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(64), + /* 488 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(64), /* 495 S> */ B(LdaSmi), I8(1), - /* 502 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(66), + /* 502 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(66), /* 509 S> */ B(LdaSmi), I8(1), - /* 516 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(68), + /* 516 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(68), /* 523 S> */ B(LdaSmi), I8(1), - /* 530 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(70), + /* 530 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(70), /* 537 S> */ B(LdaSmi), I8(1), - /* 544 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(72), + /* 544 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(72), /* 551 S> */ B(LdaSmi), I8(1), - /* 558 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(74), + /* 558 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(74), /* 565 S> */ B(LdaSmi), I8(1), - /* 572 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(76), + /* 572 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(76), /* 579 S> */ B(LdaSmi), I8(1), - /* 586 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(78), + /* 586 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(78), /* 593 S> */ B(LdaSmi), I8(1), - /* 600 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(80), + /* 600 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(80), /* 607 S> */ B(LdaSmi), I8(1), - /* 614 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(82), + /* 614 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(82), /* 621 S> */ B(LdaSmi), I8(1), - /* 628 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(84), + /* 628 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(84), /* 635 S> */ B(LdaSmi), I8(1), - /* 642 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(86), + /* 642 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(86), /* 649 S> */ B(LdaSmi), I8(1), - /* 656 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(88), + /* 656 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(88), /* 663 S> */ B(LdaSmi), I8(1), - /* 670 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(90), + /* 670 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(90), /* 677 S> */ B(LdaSmi), I8(1), - /* 684 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(92), + /* 684 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(92), /* 691 S> */ B(LdaSmi), I8(1), - /* 698 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(94), + /* 698 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(94), /* 705 S> */ B(LdaSmi), I8(1), - /* 712 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(96), + /* 712 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(96), /* 719 S> */ B(LdaSmi), I8(1), - /* 726 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(98), + /* 726 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(98), /* 733 S> */ B(LdaSmi), I8(1), - /* 740 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(100), + /* 740 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(100), /* 747 S> */ B(LdaSmi), I8(1), - /* 754 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(102), + /* 754 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(102), /* 761 S> */ B(LdaSmi), I8(1), - /* 768 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(104), + /* 768 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(104), /* 775 S> */ B(LdaSmi), I8(1), - /* 782 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(106), + /* 782 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(106), /* 789 S> */ B(LdaSmi), I8(1), - /* 796 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(108), + /* 796 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(108), /* 803 S> */ B(LdaSmi), I8(1), - /* 810 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(110), + /* 810 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(110), /* 817 S> */ B(LdaSmi), I8(1), - /* 824 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(112), + /* 824 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(112), /* 831 S> */ B(LdaSmi), I8(1), - /* 838 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(114), + /* 838 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(114), /* 845 S> */ B(LdaSmi), I8(1), - /* 852 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(116), + /* 852 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(116), /* 859 S> */ B(LdaSmi), I8(1), - /* 866 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(118), + /* 866 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(118), /* 873 S> */ B(LdaSmi), I8(1), - /* 880 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(120), + /* 880 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(120), /* 887 S> */ B(LdaSmi), I8(1), - /* 894 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(122), + /* 894 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(122), /* 901 S> */ B(LdaSmi), I8(1), - /* 908 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(124), + /* 908 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(124), /* 915 S> */ B(LdaSmi), I8(1), - /* 922 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(126), + /* 922 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(126), /* 929 S> */ B(LdaSmi), I8(1), - /* 936 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(128), + /* 936 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(128), /* 943 S> */ B(LdaSmi), I8(1), - /* 950 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(130), + /* 950 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(130), /* 957 S> */ B(LdaSmi), I8(1), - /* 964 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(132), + /* 964 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(132), /* 971 S> */ B(LdaSmi), I8(1), - /* 978 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(134), + /* 978 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(134), /* 985 S> */ B(LdaSmi), I8(1), - /* 992 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(136), + /* 992 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(136), /* 999 S> */ B(LdaSmi), I8(1), - /* 1006 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(138), + /* 1006 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(138), /* 1013 S> */ B(LdaSmi), I8(1), - /* 1020 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(140), + /* 1020 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(140), /* 1027 S> */ B(LdaSmi), I8(1), - /* 1034 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(142), + /* 1034 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(142), /* 1041 S> */ B(LdaSmi), I8(1), - /* 1048 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(144), + /* 1048 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(144), /* 1055 S> */ B(LdaSmi), I8(1), - /* 1062 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(146), + /* 1062 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(146), /* 1069 S> */ B(LdaSmi), I8(1), - /* 1076 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(148), + /* 1076 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(148), /* 1083 S> */ B(LdaSmi), I8(1), - /* 1090 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(150), + /* 1090 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(150), /* 1097 S> */ B(LdaSmi), I8(1), - /* 1104 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(152), + /* 1104 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(152), /* 1111 S> */ B(LdaSmi), I8(1), - /* 1118 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(154), + /* 1118 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(154), /* 1125 S> */ B(LdaSmi), I8(1), - /* 1132 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(156), + /* 1132 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(156), /* 1139 S> */ B(LdaSmi), I8(1), - /* 1146 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(158), + /* 1146 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(158), /* 1153 S> */ B(LdaSmi), I8(1), - /* 1160 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(160), + /* 1160 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(160), /* 1167 S> */ B(LdaSmi), I8(1), - /* 1174 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(162), + /* 1174 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(162), /* 1181 S> */ B(LdaSmi), I8(1), - /* 1188 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(164), + /* 1188 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(164), /* 1195 S> */ B(LdaSmi), I8(1), - /* 1202 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(166), + /* 1202 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(166), /* 1209 S> */ B(LdaSmi), I8(1), - /* 1216 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(168), + /* 1216 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(168), /* 1223 S> */ B(LdaSmi), I8(1), - /* 1230 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(170), + /* 1230 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(170), /* 1237 S> */ B(LdaSmi), I8(1), - /* 1244 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(172), + /* 1244 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(172), /* 1251 S> */ B(LdaSmi), I8(1), - /* 1258 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(174), + /* 1258 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(174), /* 1265 S> */ B(LdaSmi), I8(1), - /* 1272 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(176), + /* 1272 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(176), /* 1279 S> */ B(LdaSmi), I8(1), - /* 1286 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(178), + /* 1286 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(178), /* 1293 S> */ B(LdaSmi), I8(1), - /* 1300 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(180), + /* 1300 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(180), /* 1307 S> */ B(LdaSmi), I8(1), - /* 1314 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(182), + /* 1314 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(182), /* 1321 S> */ B(LdaSmi), I8(1), - /* 1328 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(184), + /* 1328 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(184), /* 1335 S> */ B(LdaSmi), I8(1), - /* 1342 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(186), + /* 1342 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(186), /* 1349 S> */ B(LdaSmi), I8(1), - /* 1356 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(188), + /* 1356 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(188), /* 1363 S> */ B(LdaSmi), I8(1), - /* 1370 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(190), + /* 1370 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(190), /* 1377 S> */ B(LdaSmi), I8(1), - /* 1384 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(192), + /* 1384 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(192), /* 1391 S> */ B(LdaSmi), I8(1), - /* 1398 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(194), + /* 1398 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(194), /* 1405 S> */ B(LdaSmi), I8(1), - /* 1412 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(196), + /* 1412 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(196), /* 1419 S> */ B(LdaSmi), I8(1), - /* 1426 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(198), + /* 1426 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(198), /* 1433 S> */ B(LdaSmi), I8(1), - /* 1440 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(200), + /* 1440 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(200), /* 1447 S> */ B(LdaSmi), I8(1), - /* 1454 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(202), + /* 1454 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(202), /* 1461 S> */ B(LdaSmi), I8(1), - /* 1468 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(204), + /* 1468 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(204), /* 1475 S> */ B(LdaSmi), I8(1), - /* 1482 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(206), + /* 1482 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(206), /* 1489 S> */ B(LdaSmi), I8(1), - /* 1496 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(208), + /* 1496 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(208), /* 1503 S> */ B(LdaSmi), I8(1), - /* 1510 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(210), + /* 1510 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(210), /* 1517 S> */ B(LdaSmi), I8(1), - /* 1524 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(212), + /* 1524 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(212), /* 1531 S> */ B(LdaSmi), I8(1), - /* 1538 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(214), + /* 1538 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(214), /* 1545 S> */ B(LdaSmi), I8(1), - /* 1552 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(216), + /* 1552 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(216), /* 1559 S> */ B(LdaSmi), I8(1), - /* 1566 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(218), + /* 1566 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(218), /* 1573 S> */ B(LdaSmi), I8(1), - /* 1580 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(220), + /* 1580 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(220), /* 1587 S> */ B(LdaSmi), I8(1), - /* 1594 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(222), + /* 1594 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(222), /* 1601 S> */ B(LdaSmi), I8(1), - /* 1608 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(224), + /* 1608 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(224), /* 1615 S> */ B(LdaSmi), I8(1), - /* 1622 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(226), + /* 1622 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(226), /* 1629 S> */ B(LdaSmi), I8(1), - /* 1636 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(228), + /* 1636 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(228), /* 1643 S> */ B(LdaSmi), I8(1), - /* 1650 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(230), + /* 1650 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(230), /* 1657 S> */ B(LdaSmi), I8(1), - /* 1664 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(232), + /* 1664 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(232), /* 1671 S> */ B(LdaSmi), I8(1), - /* 1678 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(234), + /* 1678 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(234), /* 1685 S> */ B(LdaSmi), I8(1), - /* 1692 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(236), + /* 1692 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(236), /* 1699 S> */ B(LdaSmi), I8(1), - /* 1706 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(238), + /* 1706 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(238), /* 1713 S> */ B(LdaSmi), I8(1), - /* 1720 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(240), + /* 1720 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(240), /* 1727 S> */ B(LdaSmi), I8(1), - /* 1734 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(242), + /* 1734 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(242), /* 1741 S> */ B(LdaSmi), I8(1), - /* 1748 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(244), + /* 1748 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(244), /* 1755 S> */ B(LdaSmi), I8(1), - /* 1762 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(246), + /* 1762 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(246), /* 1769 S> */ B(LdaSmi), I8(1), - /* 1776 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(248), + /* 1776 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(248), /* 1783 S> */ B(LdaSmi), I8(1), - /* 1790 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(250), + /* 1790 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(250), /* 1797 S> */ B(LdaSmi), I8(1), - /* 1804 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(252), + /* 1804 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(252), /* 1811 S> */ B(LdaSmi), I8(1), - /* 1818 E> */ B(StaNamedPropertyStrict), R(arg0), U8(0), U8(254), + /* 1818 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(254), /* 1825 S> */ B(LdaSmi), I8(2), - /* 1832 E> */ B(Wide), B(StaNamedPropertyStrict), R16(arg0), U16(0), U16(256), + /* 1832 E> */ B(Wide), B(StaNamedProperty), R16(arg0), U16(0), U16(256), B(LdaUndefined), /* 1837 S> */ B(Return), ] @@ -1115,263 +1115,263 @@ bytecode array length: 781 bytecodes: [ /* 10 E> */ B(StackCheck), /* 21 S> */ B(LdaSmi), I8(1), - /* 26 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(0), + /* 26 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(0), /* 33 S> */ B(LdaSmi), I8(1), - /* 38 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(2), + /* 38 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(2), /* 45 S> */ B(LdaSmi), I8(1), - /* 50 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(4), + /* 50 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(4), /* 57 S> */ B(LdaSmi), I8(1), - /* 62 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(6), + /* 62 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(6), /* 69 S> */ B(LdaSmi), I8(1), - /* 74 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(8), + /* 74 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(8), /* 81 S> */ B(LdaSmi), I8(1), - /* 86 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(10), + /* 86 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(10), /* 93 S> */ B(LdaSmi), I8(1), - /* 98 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(12), + /* 98 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(12), /* 105 S> */ B(LdaSmi), I8(1), - /* 110 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(14), + /* 110 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(14), /* 117 S> */ B(LdaSmi), I8(1), - /* 122 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(16), + /* 122 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(16), /* 129 S> */ B(LdaSmi), I8(1), - /* 134 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(18), + /* 134 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(18), /* 141 S> */ B(LdaSmi), I8(1), - /* 146 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(20), + /* 146 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(20), /* 153 S> */ B(LdaSmi), I8(1), - /* 158 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(22), + /* 158 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(22), /* 165 S> */ B(LdaSmi), I8(1), - /* 170 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(24), + /* 170 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(24), /* 177 S> */ B(LdaSmi), I8(1), - /* 182 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(26), + /* 182 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(26), /* 189 S> */ B(LdaSmi), I8(1), - /* 194 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(28), + /* 194 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(28), /* 201 S> */ B(LdaSmi), I8(1), - /* 206 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(30), + /* 206 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(30), /* 213 S> */ B(LdaSmi), I8(1), - /* 218 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(32), + /* 218 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(32), /* 225 S> */ B(LdaSmi), I8(1), - /* 230 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(34), + /* 230 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(34), /* 237 S> */ B(LdaSmi), I8(1), - /* 242 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(36), + /* 242 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(36), /* 249 S> */ B(LdaSmi), I8(1), - /* 254 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(38), + /* 254 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(38), /* 261 S> */ B(LdaSmi), I8(1), - /* 266 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(40), + /* 266 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(40), /* 273 S> */ B(LdaSmi), I8(1), - /* 278 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(42), + /* 278 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(42), /* 285 S> */ B(LdaSmi), I8(1), - /* 290 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(44), + /* 290 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(44), /* 297 S> */ B(LdaSmi), I8(1), - /* 302 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(46), + /* 302 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(46), /* 309 S> */ B(LdaSmi), I8(1), - /* 314 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(48), + /* 314 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(48), /* 321 S> */ B(LdaSmi), I8(1), - /* 326 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(50), + /* 326 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(50), /* 333 S> */ B(LdaSmi), I8(1), - /* 338 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(52), + /* 338 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(52), /* 345 S> */ B(LdaSmi), I8(1), - /* 350 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(54), + /* 350 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(54), /* 357 S> */ B(LdaSmi), I8(1), - /* 362 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(56), + /* 362 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(56), /* 369 S> */ B(LdaSmi), I8(1), - /* 374 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(58), + /* 374 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(58), /* 381 S> */ B(LdaSmi), I8(1), - /* 386 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(60), + /* 386 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(60), /* 393 S> */ B(LdaSmi), I8(1), - /* 398 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(62), + /* 398 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(62), /* 405 S> */ B(LdaSmi), I8(1), - /* 410 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(64), + /* 410 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(64), /* 417 S> */ B(LdaSmi), I8(1), - /* 422 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(66), + /* 422 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(66), /* 429 S> */ B(LdaSmi), I8(1), - /* 434 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(68), + /* 434 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(68), /* 441 S> */ B(LdaSmi), I8(1), - /* 446 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(70), + /* 446 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(70), /* 453 S> */ B(LdaSmi), I8(1), - /* 458 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(72), + /* 458 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(72), /* 465 S> */ B(LdaSmi), I8(1), - /* 470 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(74), + /* 470 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(74), /* 477 S> */ B(LdaSmi), I8(1), - /* 482 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(76), + /* 482 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(76), /* 489 S> */ B(LdaSmi), I8(1), - /* 494 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(78), + /* 494 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(78), /* 501 S> */ B(LdaSmi), I8(1), - /* 506 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(80), + /* 506 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(80), /* 513 S> */ B(LdaSmi), I8(1), - /* 518 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(82), + /* 518 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(82), /* 525 S> */ B(LdaSmi), I8(1), - /* 530 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(84), + /* 530 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(84), /* 537 S> */ B(LdaSmi), I8(1), - /* 542 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(86), + /* 542 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(86), /* 549 S> */ B(LdaSmi), I8(1), - /* 554 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(88), + /* 554 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(88), /* 561 S> */ B(LdaSmi), I8(1), - /* 566 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(90), + /* 566 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(90), /* 573 S> */ B(LdaSmi), I8(1), - /* 578 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(92), + /* 578 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(92), /* 585 S> */ B(LdaSmi), I8(1), - /* 590 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(94), + /* 590 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(94), /* 597 S> */ B(LdaSmi), I8(1), - /* 602 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(96), + /* 602 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(96), /* 609 S> */ B(LdaSmi), I8(1), - /* 614 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(98), + /* 614 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(98), /* 621 S> */ B(LdaSmi), I8(1), - /* 626 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(100), + /* 626 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(100), /* 633 S> */ B(LdaSmi), I8(1), - /* 638 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(102), + /* 638 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(102), /* 645 S> */ B(LdaSmi), I8(1), - /* 650 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(104), + /* 650 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(104), /* 657 S> */ B(LdaSmi), I8(1), - /* 662 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(106), + /* 662 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(106), /* 669 S> */ B(LdaSmi), I8(1), - /* 674 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(108), + /* 674 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(108), /* 681 S> */ B(LdaSmi), I8(1), - /* 686 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(110), + /* 686 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(110), /* 693 S> */ B(LdaSmi), I8(1), - /* 698 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(112), + /* 698 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(112), /* 705 S> */ B(LdaSmi), I8(1), - /* 710 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(114), + /* 710 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(114), /* 717 S> */ B(LdaSmi), I8(1), - /* 722 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(116), + /* 722 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(116), /* 729 S> */ B(LdaSmi), I8(1), - /* 734 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(118), + /* 734 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(118), /* 741 S> */ B(LdaSmi), I8(1), - /* 746 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(120), + /* 746 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(120), /* 753 S> */ B(LdaSmi), I8(1), - /* 758 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(122), + /* 758 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(122), /* 765 S> */ B(LdaSmi), I8(1), - /* 770 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(124), + /* 770 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(124), /* 777 S> */ B(LdaSmi), I8(1), - /* 782 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(126), + /* 782 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(126), /* 789 S> */ B(LdaSmi), I8(1), - /* 794 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(128), + /* 794 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(128), /* 801 S> */ B(LdaSmi), I8(1), - /* 806 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(130), + /* 806 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(130), /* 813 S> */ B(LdaSmi), I8(1), - /* 818 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(132), + /* 818 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(132), /* 825 S> */ B(LdaSmi), I8(1), - /* 830 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(134), + /* 830 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(134), /* 837 S> */ B(LdaSmi), I8(1), - /* 842 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(136), + /* 842 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(136), /* 849 S> */ B(LdaSmi), I8(1), - /* 854 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(138), + /* 854 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(138), /* 861 S> */ B(LdaSmi), I8(1), - /* 866 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(140), + /* 866 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(140), /* 873 S> */ B(LdaSmi), I8(1), - /* 878 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(142), + /* 878 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(142), /* 885 S> */ B(LdaSmi), I8(1), - /* 890 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(144), + /* 890 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(144), /* 897 S> */ B(LdaSmi), I8(1), - /* 902 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(146), + /* 902 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(146), /* 909 S> */ B(LdaSmi), I8(1), - /* 914 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(148), + /* 914 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(148), /* 921 S> */ B(LdaSmi), I8(1), - /* 926 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(150), + /* 926 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(150), /* 933 S> */ B(LdaSmi), I8(1), - /* 938 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(152), + /* 938 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(152), /* 945 S> */ B(LdaSmi), I8(1), - /* 950 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(154), + /* 950 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(154), /* 957 S> */ B(LdaSmi), I8(1), - /* 962 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(156), + /* 962 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(156), /* 969 S> */ B(LdaSmi), I8(1), - /* 974 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(158), + /* 974 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(158), /* 981 S> */ B(LdaSmi), I8(1), - /* 986 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(160), + /* 986 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(160), /* 993 S> */ B(LdaSmi), I8(1), - /* 998 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(162), + /* 998 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(162), /* 1005 S> */ B(LdaSmi), I8(1), - /* 1010 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(164), + /* 1010 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(164), /* 1017 S> */ B(LdaSmi), I8(1), - /* 1022 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(166), + /* 1022 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(166), /* 1029 S> */ B(LdaSmi), I8(1), - /* 1034 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(168), + /* 1034 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(168), /* 1041 S> */ B(LdaSmi), I8(1), - /* 1046 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(170), + /* 1046 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(170), /* 1053 S> */ B(LdaSmi), I8(1), - /* 1058 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(172), + /* 1058 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(172), /* 1065 S> */ B(LdaSmi), I8(1), - /* 1070 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(174), + /* 1070 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(174), /* 1077 S> */ B(LdaSmi), I8(1), - /* 1082 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(176), + /* 1082 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(176), /* 1089 S> */ B(LdaSmi), I8(1), - /* 1094 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(178), + /* 1094 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(178), /* 1101 S> */ B(LdaSmi), I8(1), - /* 1106 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(180), + /* 1106 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(180), /* 1113 S> */ B(LdaSmi), I8(1), - /* 1118 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(182), + /* 1118 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(182), /* 1125 S> */ B(LdaSmi), I8(1), - /* 1130 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(184), + /* 1130 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(184), /* 1137 S> */ B(LdaSmi), I8(1), - /* 1142 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(186), + /* 1142 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(186), /* 1149 S> */ B(LdaSmi), I8(1), - /* 1154 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(188), + /* 1154 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(188), /* 1161 S> */ B(LdaSmi), I8(1), - /* 1166 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(190), + /* 1166 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(190), /* 1173 S> */ B(LdaSmi), I8(1), - /* 1178 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(192), + /* 1178 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(192), /* 1185 S> */ B(LdaSmi), I8(1), - /* 1190 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(194), + /* 1190 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(194), /* 1197 S> */ B(LdaSmi), I8(1), - /* 1202 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(196), + /* 1202 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(196), /* 1209 S> */ B(LdaSmi), I8(1), - /* 1214 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(198), + /* 1214 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(198), /* 1221 S> */ B(LdaSmi), I8(1), - /* 1226 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(200), + /* 1226 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(200), /* 1233 S> */ B(LdaSmi), I8(1), - /* 1238 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(202), + /* 1238 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(202), /* 1245 S> */ B(LdaSmi), I8(1), - /* 1250 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(204), + /* 1250 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(204), /* 1257 S> */ B(LdaSmi), I8(1), - /* 1262 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(206), + /* 1262 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(206), /* 1269 S> */ B(LdaSmi), I8(1), - /* 1274 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(208), + /* 1274 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(208), /* 1281 S> */ B(LdaSmi), I8(1), - /* 1286 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(210), + /* 1286 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(210), /* 1293 S> */ B(LdaSmi), I8(1), - /* 1298 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(212), + /* 1298 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(212), /* 1305 S> */ B(LdaSmi), I8(1), - /* 1310 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(214), + /* 1310 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(214), /* 1317 S> */ B(LdaSmi), I8(1), - /* 1322 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(216), + /* 1322 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(216), /* 1329 S> */ B(LdaSmi), I8(1), - /* 1334 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(218), + /* 1334 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(218), /* 1341 S> */ B(LdaSmi), I8(1), - /* 1346 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(220), + /* 1346 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(220), /* 1353 S> */ B(LdaSmi), I8(1), - /* 1358 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(222), + /* 1358 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(222), /* 1365 S> */ B(LdaSmi), I8(1), - /* 1370 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(224), + /* 1370 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(224), /* 1377 S> */ B(LdaSmi), I8(1), - /* 1382 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(226), + /* 1382 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(226), /* 1389 S> */ B(LdaSmi), I8(1), - /* 1394 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(228), + /* 1394 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(228), /* 1401 S> */ B(LdaSmi), I8(1), - /* 1406 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(230), + /* 1406 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(230), /* 1413 S> */ B(LdaSmi), I8(1), - /* 1418 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(232), + /* 1418 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(232), /* 1425 S> */ B(LdaSmi), I8(1), - /* 1430 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(234), + /* 1430 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(234), /* 1437 S> */ B(LdaSmi), I8(1), - /* 1442 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(236), + /* 1442 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(236), /* 1449 S> */ B(LdaSmi), I8(1), - /* 1454 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(238), + /* 1454 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(238), /* 1461 S> */ B(LdaSmi), I8(1), - /* 1466 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(240), + /* 1466 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(240), /* 1473 S> */ B(LdaSmi), I8(1), - /* 1478 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(242), + /* 1478 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(242), /* 1485 S> */ B(LdaSmi), I8(1), - /* 1490 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(244), + /* 1490 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(244), /* 1497 S> */ B(LdaSmi), I8(1), - /* 1502 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(246), + /* 1502 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(246), /* 1509 S> */ B(LdaSmi), I8(1), - /* 1514 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(248), + /* 1514 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(248), /* 1521 S> */ B(LdaSmi), I8(1), - /* 1526 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(250), + /* 1526 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(250), /* 1533 S> */ B(LdaSmi), I8(1), - /* 1538 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(252), + /* 1538 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(252), /* 1545 S> */ B(LdaSmi), I8(1), - /* 1550 E> */ B(StaKeyedPropertySloppy), R(arg0), R(arg1), U8(254), + /* 1550 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(254), /* 1557 S> */ B(LdaSmi), I8(2), - /* 1562 E> */ B(Wide), B(StaKeyedPropertySloppy), R16(arg0), R16(arg1), U16(256), + /* 1562 E> */ B(Wide), B(StaKeyedProperty), R16(arg0), R16(arg1), U16(256), B(LdaUndefined), /* 1567 S> */ B(Return), ] @@ -1522,263 +1522,263 @@ bytecode array length: 781 bytecodes: [ /* 10 E> */ B(StackCheck), /* 37 S> */ B(LdaSmi), I8(1), - /* 42 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(0), + /* 42 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(0), /* 49 S> */ B(LdaSmi), I8(1), - /* 54 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(2), + /* 54 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(2), /* 61 S> */ B(LdaSmi), I8(1), - /* 66 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(4), + /* 66 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(4), /* 73 S> */ B(LdaSmi), I8(1), - /* 78 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(6), + /* 78 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(6), /* 85 S> */ B(LdaSmi), I8(1), - /* 90 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(8), + /* 90 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(8), /* 97 S> */ B(LdaSmi), I8(1), - /* 102 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(10), + /* 102 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(10), /* 109 S> */ B(LdaSmi), I8(1), - /* 114 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(12), + /* 114 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(12), /* 121 S> */ B(LdaSmi), I8(1), - /* 126 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(14), + /* 126 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(14), /* 133 S> */ B(LdaSmi), I8(1), - /* 138 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(16), + /* 138 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(16), /* 145 S> */ B(LdaSmi), I8(1), - /* 150 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(18), + /* 150 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(18), /* 157 S> */ B(LdaSmi), I8(1), - /* 162 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(20), + /* 162 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(20), /* 169 S> */ B(LdaSmi), I8(1), - /* 174 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(22), + /* 174 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(22), /* 181 S> */ B(LdaSmi), I8(1), - /* 186 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(24), + /* 186 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(24), /* 193 S> */ B(LdaSmi), I8(1), - /* 198 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(26), + /* 198 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(26), /* 205 S> */ B(LdaSmi), I8(1), - /* 210 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(28), + /* 210 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(28), /* 217 S> */ B(LdaSmi), I8(1), - /* 222 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(30), + /* 222 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(30), /* 229 S> */ B(LdaSmi), I8(1), - /* 234 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(32), + /* 234 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(32), /* 241 S> */ B(LdaSmi), I8(1), - /* 246 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(34), + /* 246 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(34), /* 253 S> */ B(LdaSmi), I8(1), - /* 258 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(36), + /* 258 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(36), /* 265 S> */ B(LdaSmi), I8(1), - /* 270 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(38), + /* 270 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(38), /* 277 S> */ B(LdaSmi), I8(1), - /* 282 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(40), + /* 282 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(40), /* 289 S> */ B(LdaSmi), I8(1), - /* 294 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(42), + /* 294 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(42), /* 301 S> */ B(LdaSmi), I8(1), - /* 306 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(44), + /* 306 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(44), /* 313 S> */ B(LdaSmi), I8(1), - /* 318 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(46), + /* 318 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(46), /* 325 S> */ B(LdaSmi), I8(1), - /* 330 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(48), + /* 330 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(48), /* 337 S> */ B(LdaSmi), I8(1), - /* 342 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(50), + /* 342 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(50), /* 349 S> */ B(LdaSmi), I8(1), - /* 354 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(52), + /* 354 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(52), /* 361 S> */ B(LdaSmi), I8(1), - /* 366 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(54), + /* 366 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(54), /* 373 S> */ B(LdaSmi), I8(1), - /* 378 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(56), + /* 378 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(56), /* 385 S> */ B(LdaSmi), I8(1), - /* 390 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(58), + /* 390 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(58), /* 397 S> */ B(LdaSmi), I8(1), - /* 402 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(60), + /* 402 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(60), /* 409 S> */ B(LdaSmi), I8(1), - /* 414 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(62), + /* 414 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(62), /* 421 S> */ B(LdaSmi), I8(1), - /* 426 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(64), + /* 426 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(64), /* 433 S> */ B(LdaSmi), I8(1), - /* 438 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(66), + /* 438 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(66), /* 445 S> */ B(LdaSmi), I8(1), - /* 450 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(68), + /* 450 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(68), /* 457 S> */ B(LdaSmi), I8(1), - /* 462 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(70), + /* 462 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(70), /* 469 S> */ B(LdaSmi), I8(1), - /* 474 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(72), + /* 474 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(72), /* 481 S> */ B(LdaSmi), I8(1), - /* 486 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(74), + /* 486 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(74), /* 493 S> */ B(LdaSmi), I8(1), - /* 498 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(76), + /* 498 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(76), /* 505 S> */ B(LdaSmi), I8(1), - /* 510 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(78), + /* 510 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(78), /* 517 S> */ B(LdaSmi), I8(1), - /* 522 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(80), + /* 522 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(80), /* 529 S> */ B(LdaSmi), I8(1), - /* 534 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(82), + /* 534 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(82), /* 541 S> */ B(LdaSmi), I8(1), - /* 546 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(84), + /* 546 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(84), /* 553 S> */ B(LdaSmi), I8(1), - /* 558 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(86), + /* 558 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(86), /* 565 S> */ B(LdaSmi), I8(1), - /* 570 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(88), + /* 570 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(88), /* 577 S> */ B(LdaSmi), I8(1), - /* 582 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(90), + /* 582 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(90), /* 589 S> */ B(LdaSmi), I8(1), - /* 594 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(92), + /* 594 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(92), /* 601 S> */ B(LdaSmi), I8(1), - /* 606 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(94), + /* 606 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(94), /* 613 S> */ B(LdaSmi), I8(1), - /* 618 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(96), + /* 618 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(96), /* 625 S> */ B(LdaSmi), I8(1), - /* 630 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(98), + /* 630 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(98), /* 637 S> */ B(LdaSmi), I8(1), - /* 642 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(100), + /* 642 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(100), /* 649 S> */ B(LdaSmi), I8(1), - /* 654 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(102), + /* 654 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(102), /* 661 S> */ B(LdaSmi), I8(1), - /* 666 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(104), + /* 666 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(104), /* 673 S> */ B(LdaSmi), I8(1), - /* 678 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(106), + /* 678 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(106), /* 685 S> */ B(LdaSmi), I8(1), - /* 690 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(108), + /* 690 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(108), /* 697 S> */ B(LdaSmi), I8(1), - /* 702 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(110), + /* 702 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(110), /* 709 S> */ B(LdaSmi), I8(1), - /* 714 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(112), + /* 714 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(112), /* 721 S> */ B(LdaSmi), I8(1), - /* 726 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(114), + /* 726 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(114), /* 733 S> */ B(LdaSmi), I8(1), - /* 738 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(116), + /* 738 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(116), /* 745 S> */ B(LdaSmi), I8(1), - /* 750 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(118), + /* 750 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(118), /* 757 S> */ B(LdaSmi), I8(1), - /* 762 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(120), + /* 762 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(120), /* 769 S> */ B(LdaSmi), I8(1), - /* 774 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(122), + /* 774 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(122), /* 781 S> */ B(LdaSmi), I8(1), - /* 786 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(124), + /* 786 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(124), /* 793 S> */ B(LdaSmi), I8(1), - /* 798 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(126), + /* 798 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(126), /* 805 S> */ B(LdaSmi), I8(1), - /* 810 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(128), + /* 810 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(128), /* 817 S> */ B(LdaSmi), I8(1), - /* 822 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(130), + /* 822 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(130), /* 829 S> */ B(LdaSmi), I8(1), - /* 834 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(132), + /* 834 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(132), /* 841 S> */ B(LdaSmi), I8(1), - /* 846 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(134), + /* 846 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(134), /* 853 S> */ B(LdaSmi), I8(1), - /* 858 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(136), + /* 858 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(136), /* 865 S> */ B(LdaSmi), I8(1), - /* 870 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(138), + /* 870 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(138), /* 877 S> */ B(LdaSmi), I8(1), - /* 882 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(140), + /* 882 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(140), /* 889 S> */ B(LdaSmi), I8(1), - /* 894 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(142), + /* 894 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(142), /* 901 S> */ B(LdaSmi), I8(1), - /* 906 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(144), + /* 906 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(144), /* 913 S> */ B(LdaSmi), I8(1), - /* 918 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(146), + /* 918 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(146), /* 925 S> */ B(LdaSmi), I8(1), - /* 930 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(148), + /* 930 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(148), /* 937 S> */ B(LdaSmi), I8(1), - /* 942 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(150), + /* 942 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(150), /* 949 S> */ B(LdaSmi), I8(1), - /* 954 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(152), + /* 954 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(152), /* 961 S> */ B(LdaSmi), I8(1), - /* 966 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(154), + /* 966 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(154), /* 973 S> */ B(LdaSmi), I8(1), - /* 978 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(156), + /* 978 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(156), /* 985 S> */ B(LdaSmi), I8(1), - /* 990 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(158), + /* 990 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(158), /* 997 S> */ B(LdaSmi), I8(1), - /* 1002 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(160), + /* 1002 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(160), /* 1009 S> */ B(LdaSmi), I8(1), - /* 1014 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(162), + /* 1014 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(162), /* 1021 S> */ B(LdaSmi), I8(1), - /* 1026 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(164), + /* 1026 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(164), /* 1033 S> */ B(LdaSmi), I8(1), - /* 1038 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(166), + /* 1038 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(166), /* 1045 S> */ B(LdaSmi), I8(1), - /* 1050 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(168), + /* 1050 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(168), /* 1057 S> */ B(LdaSmi), I8(1), - /* 1062 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(170), + /* 1062 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(170), /* 1069 S> */ B(LdaSmi), I8(1), - /* 1074 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(172), + /* 1074 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(172), /* 1081 S> */ B(LdaSmi), I8(1), - /* 1086 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(174), + /* 1086 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(174), /* 1093 S> */ B(LdaSmi), I8(1), - /* 1098 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(176), + /* 1098 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(176), /* 1105 S> */ B(LdaSmi), I8(1), - /* 1110 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(178), + /* 1110 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(178), /* 1117 S> */ B(LdaSmi), I8(1), - /* 1122 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(180), + /* 1122 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(180), /* 1129 S> */ B(LdaSmi), I8(1), - /* 1134 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(182), + /* 1134 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(182), /* 1141 S> */ B(LdaSmi), I8(1), - /* 1146 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(184), + /* 1146 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(184), /* 1153 S> */ B(LdaSmi), I8(1), - /* 1158 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(186), + /* 1158 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(186), /* 1165 S> */ B(LdaSmi), I8(1), - /* 1170 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(188), + /* 1170 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(188), /* 1177 S> */ B(LdaSmi), I8(1), - /* 1182 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(190), + /* 1182 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(190), /* 1189 S> */ B(LdaSmi), I8(1), - /* 1194 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(192), + /* 1194 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(192), /* 1201 S> */ B(LdaSmi), I8(1), - /* 1206 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(194), + /* 1206 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(194), /* 1213 S> */ B(LdaSmi), I8(1), - /* 1218 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(196), + /* 1218 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(196), /* 1225 S> */ B(LdaSmi), I8(1), - /* 1230 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(198), + /* 1230 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(198), /* 1237 S> */ B(LdaSmi), I8(1), - /* 1242 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(200), + /* 1242 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(200), /* 1249 S> */ B(LdaSmi), I8(1), - /* 1254 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(202), + /* 1254 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(202), /* 1261 S> */ B(LdaSmi), I8(1), - /* 1266 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(204), + /* 1266 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(204), /* 1273 S> */ B(LdaSmi), I8(1), - /* 1278 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(206), + /* 1278 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(206), /* 1285 S> */ B(LdaSmi), I8(1), - /* 1290 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(208), + /* 1290 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(208), /* 1297 S> */ B(LdaSmi), I8(1), - /* 1302 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(210), + /* 1302 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(210), /* 1309 S> */ B(LdaSmi), I8(1), - /* 1314 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(212), + /* 1314 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(212), /* 1321 S> */ B(LdaSmi), I8(1), - /* 1326 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(214), + /* 1326 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(214), /* 1333 S> */ B(LdaSmi), I8(1), - /* 1338 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(216), + /* 1338 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(216), /* 1345 S> */ B(LdaSmi), I8(1), - /* 1350 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(218), + /* 1350 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(218), /* 1357 S> */ B(LdaSmi), I8(1), - /* 1362 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(220), + /* 1362 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(220), /* 1369 S> */ B(LdaSmi), I8(1), - /* 1374 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(222), + /* 1374 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(222), /* 1381 S> */ B(LdaSmi), I8(1), - /* 1386 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(224), + /* 1386 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(224), /* 1393 S> */ B(LdaSmi), I8(1), - /* 1398 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(226), + /* 1398 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(226), /* 1405 S> */ B(LdaSmi), I8(1), - /* 1410 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(228), + /* 1410 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(228), /* 1417 S> */ B(LdaSmi), I8(1), - /* 1422 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(230), + /* 1422 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(230), /* 1429 S> */ B(LdaSmi), I8(1), - /* 1434 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(232), + /* 1434 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(232), /* 1441 S> */ B(LdaSmi), I8(1), - /* 1446 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(234), + /* 1446 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(234), /* 1453 S> */ B(LdaSmi), I8(1), - /* 1458 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(236), + /* 1458 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(236), /* 1465 S> */ B(LdaSmi), I8(1), - /* 1470 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(238), + /* 1470 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(238), /* 1477 S> */ B(LdaSmi), I8(1), - /* 1482 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(240), + /* 1482 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(240), /* 1489 S> */ B(LdaSmi), I8(1), - /* 1494 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(242), + /* 1494 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(242), /* 1501 S> */ B(LdaSmi), I8(1), - /* 1506 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(244), + /* 1506 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(244), /* 1513 S> */ B(LdaSmi), I8(1), - /* 1518 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(246), + /* 1518 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(246), /* 1525 S> */ B(LdaSmi), I8(1), - /* 1530 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(248), + /* 1530 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(248), /* 1537 S> */ B(LdaSmi), I8(1), - /* 1542 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(250), + /* 1542 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(250), /* 1549 S> */ B(LdaSmi), I8(1), - /* 1554 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(252), + /* 1554 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(252), /* 1561 S> */ B(LdaSmi), I8(1), - /* 1566 E> */ B(StaKeyedPropertyStrict), R(arg0), R(arg1), U8(254), + /* 1566 E> */ B(StaKeyedProperty), R(arg0), R(arg1), U8(254), /* 1573 S> */ B(LdaSmi), I8(2), - /* 1578 E> */ B(Wide), B(StaKeyedPropertyStrict), R16(arg0), R16(arg1), U16(256), + /* 1578 E> */ B(Wide), B(StaKeyedProperty), R16(arg0), R16(arg1), U16(256), B(LdaUndefined), /* 1583 S> */ B(Return), ] diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/StandardForLoop.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/StandardForLoop.golden index 8e16be3dc6..4194925e41 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/StandardForLoop.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/StandardForLoop.golden @@ -231,7 +231,7 @@ bytecodes: [ B(JumpIfUndefined), U8(6), B(Ldar), R(3), B(JumpIfNotNull), U8(16), - B(LdaSmi), I8(63), + B(LdaSmi), I8(67), B(Star), R(4), B(LdaConstant), U8(1), B(Star), R(5), @@ -272,18 +272,16 @@ snippet: " " frame size: 6 parameter count: 1 -bytecode array length: 103 +bytecode array length: 96 bytecodes: [ B(Ldar), R(2), - B(JumpIfUndefined), U8(25), + B(JumpIfUndefined), U8(18), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(2), U8(1), B(PushContext), R(4), B(RestoreGeneratorState), R(2), B(Star), R(3), B(SwitchOnSmiNoFeedback), U8(0), U8(1), I8(0), - B(LdaSmi), I8(45), - B(Star), R(4), - B(CallRuntime), U16(Runtime::kAbort), R(4), U8(1), + B(Abort), U8(43), B(LdaSmi), I8(-2), B(Star), R(3), B(Mov), R(closure), R(4), @@ -319,7 +317,7 @@ bytecodes: [ /* 62 S> */ B(Return), ] constant pool: [ - Smi [36], + Smi [29], Smi [10], Smi [7], ] @@ -335,18 +333,16 @@ snippet: " " frame size: 5 parameter count: 1 -bytecode array length: 165 +bytecode array length: 151 bytecodes: [ B(Ldar), R(1), - B(JumpIfUndefined), U8(25), + B(JumpIfUndefined), U8(18), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(1), U8(1), B(PushContext), R(3), B(RestoreGeneratorState), R(1), B(Star), R(2), B(SwitchOnSmiNoFeedback), U8(0), U8(2), I8(0), - B(LdaSmi), I8(45), - B(Star), R(3), - B(CallRuntime), U16(Runtime::kAbort), R(3), U8(1), + B(Abort), U8(43), B(LdaSmi), I8(-2), B(Star), R(2), B(Mov), R(closure), R(3), @@ -373,10 +369,8 @@ bytecodes: [ B(SwitchOnSmiNoFeedback), U8(4), U8(1), I8(1), B(LdaSmi), I8(-2), /* 31 E> */ B(TestEqualStrictNoFeedback), R(2), - B(JumpIfTrue), U8(11), - B(LdaSmi), I8(45), - B(Star), R(3), - B(CallRuntime), U16(Runtime::kAbort), R(3), U8(1), + B(JumpIfTrue), U8(4), + B(Abort), U8(43), /* 36 S> */ B(LdaSmi), I8(10), /* 36 E> */ B(TestLessThan), R(0), U8(0), B(JumpIfFalse), U8(56), @@ -401,16 +395,16 @@ bytecodes: [ /* 44 S> */ B(Ldar), R(0), B(Inc), U8(1), B(Star), R(0), - B(JumpLoop), U8(79), I8(0), + B(JumpLoop), U8(72), I8(0), B(LdaUndefined), /* 56 S> */ B(Return), ] constant pool: [ - Smi [36], - Smi [67], + Smi [29], + Smi [60], Smi [10], Smi [7], - Smi [43], + Smi [36], Smi [10], Smi [7], ] @@ -424,14 +418,12 @@ snippet: " } f(); " -frame size: 13 +frame size: 12 parameter count: 1 -bytecode array length: 152 +bytecode array length: 137 bytecodes: [ /* 16 E> */ B(StackCheck), - B(LdaUndefined), - B(Star), R(4), - B(CallJSRuntime), U8(%async_function_promise_create), R(4), U8(1), + B(CallJSRuntime), U8(%async_function_promise_create), R(0), U8(0), B(Star), R(3), B(Mov), R(context), R(6), B(Mov), R(context), R(7), @@ -447,16 +439,14 @@ bytecodes: [ B(Star), R(1), B(JumpLoop), U8(17), I8(0), B(LdaUndefined), - B(Star), R(8), - B(LdaUndefined), - B(Star), R(10), - B(Mov), R(3), R(9), - /* 49 E> */ B(CallJSRuntime), U8(%promise_resolve), R(8), U8(3), + B(Star), R(9), + B(Mov), R(3), R(8), + /* 49 E> */ B(CallJSRuntime), U8(%promise_resolve), R(8), U8(2), B(LdaZero), B(Star), R(4), B(Mov), R(3), R(5), - B(Jump), U8(61), - B(Jump), U8(45), + B(Jump), U8(58), + B(Jump), U8(42), B(Star), R(8), B(Ldar), R(closure), B(CreateCatchContext), R(8), U8(0), U8(1), @@ -465,14 +455,12 @@ bytecodes: [ B(SetPendingMessage), B(Ldar), R(7), B(PushContext), R(8), - B(LdaUndefined), - B(Star), R(9), B(LdaImmutableCurrentContextSlot), U8(4), - B(Star), R(11), + B(Star), R(10), B(LdaFalse), - B(Star), R(12), - B(Mov), R(3), R(10), - B(CallJSRuntime), U8(%promise_internal_reject), R(9), U8(4), + B(Star), R(11), + B(Mov), R(3), R(9), + B(CallJSRuntime), U8(%promise_internal_reject), R(9), U8(3), B(PopContext), R(8), B(LdaZero), B(Star), R(4), @@ -488,10 +476,7 @@ bytecodes: [ B(LdaTheHole), B(SetPendingMessage), B(Star), R(6), - B(LdaUndefined), - B(Star), R(7), - B(Mov), R(3), R(8), - B(CallJSRuntime), U8(%async_function_promise_release), R(7), U8(2), + B(CallJSRuntime), U8(%async_function_promise_release), R(3), U8(1), B(Ldar), R(6), B(SetPendingMessage), B(Ldar), R(4), @@ -511,8 +496,8 @@ constant pool: [ Smi [9], ] handlers: [ - [13, 105, 113], - [16, 60, 62], + [10, 96, 104], + [13, 54, 56], ] --- @@ -522,20 +507,18 @@ snippet: " } f(); " -frame size: 13 +frame size: 12 parameter count: 1 -bytecode array length: 260 +bytecode array length: 231 bytecodes: [ B(Ldar), R(1), - B(JumpIfUndefined), U8(25), + B(JumpIfUndefined), U8(18), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(1), U8(1), B(PushContext), R(4), B(RestoreGeneratorState), R(1), B(Star), R(3), B(SwitchOnSmiNoFeedback), U8(0), U8(1), I8(0), - B(LdaSmi), I8(45), - B(Star), R(4), - B(CallRuntime), U16(Runtime::kAbort), R(4), U8(1), + B(Abort), U8(43), B(LdaSmi), I8(-2), B(Star), R(3), B(Mov), R(closure), R(4), @@ -543,9 +526,7 @@ bytecodes: [ B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(4), U8(2), B(Star), R(1), /* 16 E> */ B(StackCheck), - B(LdaUndefined), - B(Star), R(4), - B(CallJSRuntime), U8(%async_function_promise_create), R(4), U8(1), + B(CallJSRuntime), U8(%async_function_promise_create), R(0), U8(0), B(Star), R(2), B(Mov), R(context), R(6), B(Mov), R(context), R(7), @@ -555,10 +536,8 @@ bytecodes: [ B(SwitchOnSmiNoFeedback), U8(1), U8(1), I8(0), B(LdaSmi), I8(-2), /* 36 E> */ B(TestEqualStrictNoFeedback), R(3), - B(JumpIfTrue), U8(11), - B(LdaSmi), I8(45), - B(Star), R(8), - B(CallRuntime), U16(Runtime::kAbort), R(8), U8(1), + B(JumpIfTrue), U8(4), + B(Abort), U8(43), /* 41 S> */ B(LdaSmi), I8(10), /* 41 E> */ B(TestLessThan), R(0), U8(0), B(JumpIfFalse), U8(59), @@ -584,18 +563,16 @@ bytecodes: [ /* 49 S> */ B(Ldar), R(0), B(Inc), U8(1), B(Star), R(0), - B(JumpLoop), U8(82), I8(0), - B(LdaUndefined), - B(Star), R(8), + B(JumpLoop), U8(75), I8(0), B(LdaUndefined), - B(Star), R(10), - B(Mov), R(2), R(9), - /* 49 E> */ B(CallJSRuntime), U8(%promise_resolve), R(8), U8(3), + B(Star), R(9), + B(Mov), R(2), R(8), + /* 49 E> */ B(CallJSRuntime), U8(%promise_resolve), R(8), U8(2), B(LdaZero), B(Star), R(4), B(Mov), R(2), R(5), - B(Jump), U8(61), - B(Jump), U8(45), + B(Jump), U8(58), + B(Jump), U8(42), B(Star), R(8), B(Ldar), R(closure), B(CreateCatchContext), R(8), U8(2), U8(3), @@ -604,14 +581,12 @@ bytecodes: [ B(SetPendingMessage), B(Ldar), R(7), B(PushContext), R(8), - B(LdaUndefined), - B(Star), R(9), B(LdaImmutableCurrentContextSlot), U8(4), - B(Star), R(11), + B(Star), R(10), B(LdaFalse), - B(Star), R(12), - B(Mov), R(2), R(10), - B(CallJSRuntime), U8(%promise_internal_reject), R(9), U8(4), + B(Star), R(11), + B(Mov), R(2), R(9), + B(CallJSRuntime), U8(%promise_internal_reject), R(9), U8(3), B(PopContext), R(8), B(LdaZero), B(Star), R(4), @@ -627,10 +602,7 @@ bytecodes: [ B(LdaTheHole), B(SetPendingMessage), B(Star), R(6), - B(LdaUndefined), - B(Star), R(7), - B(Mov), R(2), R(8), - B(CallJSRuntime), U8(%async_function_promise_release), R(7), U8(2), + B(CallJSRuntime), U8(%async_function_promise_release), R(2), U8(1), B(Ldar), R(6), B(SetPendingMessage), B(Ldar), R(4), @@ -644,15 +616,15 @@ bytecodes: [ /* 61 S> */ B(Return), ] constant pool: [ - Smi [48], - Smi [46], + Smi [38], + Smi [39], ONE_BYTE_INTERNALIZED_STRING_TYPE [".catch"], FIXED_ARRAY_TYPE, Smi [6], Smi [9], ] handlers: [ - [56, 213, 221], - [59, 168, 170], + [46, 190, 198], + [49, 148, 150], ] diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/SuperCallAndSpread.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/SuperCallAndSpread.golden index 7c5e447a81..0d36442d47 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/SuperCallAndSpread.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/SuperCallAndSpread.golden @@ -91,34 +91,27 @@ snippet: " test = new B(1, 2, 3).constructor; })(); " -frame size: 10 +frame size: 8 parameter count: 1 -bytecode array length: 72 +bytecode array length: 60 bytecodes: [ B(CreateRestParameter), B(Star), R(2), B(Mov), R(closure), R(1), /* 128 E> */ B(StackCheck), B(Mov), R(2), R(3), - /* 140 S> */ B(LdaUndefined), + /* 140 S> */ B(CallRuntime), U16(Runtime::k_GetSuperConstructor), R(closure), U8(1), B(Star), R(4), - /* 140 E> */ B(CallRuntime), U16(Runtime::k_GetSuperConstructor), R(closure), U8(1), + B(CreateArrayLiteral), U8(0), U8(0), U8(37), B(Star), R(5), - B(LdaUndefined), + /* 152 E> */ B(CallJSRuntime), U8(%spread_iterable), R(2), U8(1), B(Star), R(6), - B(CreateArrayLiteral), U8(0), U8(0), U8(37), - B(Star), R(7), - B(LdaUndefined), - B(Star), R(8), - B(Mov), R(2), R(9), - /* 152 E> */ B(CallJSRuntime), U8(%spread_iterable), R(8), U8(2), - B(Star), R(8), B(CreateArrayLiteral), U8(1), U8(1), U8(37), - B(Star), R(9), - B(CallJSRuntime), U8(%spread_arguments), R(6), U8(4), - B(Star), R(6), - B(Mov), R(0), R(7), - /* 140 E> */ B(CallJSRuntime), U8(%reflect_construct), R(4), U8(4), + B(Star), R(7), + B(CallJSRuntime), U8(%spread_arguments), R(5), U8(3), + B(Star), R(5), + B(Mov), R(0), R(6), + /* 140 E> */ B(CallJSRuntime), U8(%reflect_construct), R(4), U8(3), B(Star), R(4), B(Ldar), R(this), /* 140 E> */ B(ThrowSuperAlreadyCalledIfNotHole), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/Switch.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/Switch.golden index 0aa21aba35..a853183351 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/Switch.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/Switch.golden @@ -13,20 +13,19 @@ snippet: " case 2: return 3; } " -frame size: 3 +frame size: 2 parameter count: 1 -bytecode array length: 34 +bytecode array length: 32 bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), - B(Star), R(1), /* 45 S> */ B(LdaSmi), I8(1), - B(TestEqualStrict), R(1), U8(0), - B(Mov), R(0), R(2), + B(TestEqualStrict), R(0), U8(0), + B(Mov), R(0), R(1), B(JumpIfTrue), U8(11), B(LdaSmi), I8(2), - B(TestEqualStrict), R(2), U8(1), + B(TestEqualStrict), R(1), U8(1), B(JumpIfTrue), U8(7), B(Jump), U8(8), /* 66 S> */ B(LdaSmi), I8(2), @@ -49,20 +48,19 @@ snippet: " case 2: a = 3; break; } " -frame size: 3 +frame size: 2 parameter count: 1 -bytecode array length: 40 +bytecode array length: 38 bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), - B(Star), R(1), /* 45 S> */ B(LdaSmi), I8(1), - B(TestEqualStrict), R(1), U8(0), - B(Mov), R(0), R(2), + B(TestEqualStrict), R(0), U8(0), + B(Mov), R(0), R(1), B(JumpIfTrue), U8(11), B(LdaSmi), I8(2), - B(TestEqualStrict), R(2), U8(1), + B(TestEqualStrict), R(1), U8(1), B(JumpIfTrue), U8(10), B(Jump), U8(14), /* 66 S> */ B(LdaSmi), I8(2), @@ -87,20 +85,19 @@ snippet: " case 2: a = 3; break; } " -frame size: 3 +frame size: 2 parameter count: 1 -bytecode array length: 38 +bytecode array length: 36 bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), - B(Star), R(1), /* 45 S> */ B(LdaSmi), I8(1), - B(TestEqualStrict), R(1), U8(0), - B(Mov), R(0), R(2), + B(TestEqualStrict), R(0), U8(0), + B(Mov), R(0), R(1), B(JumpIfTrue), U8(11), B(LdaSmi), I8(2), - B(TestEqualStrict), R(2), U8(1), + B(TestEqualStrict), R(1), U8(1), B(JumpIfTrue), U8(8), B(Jump), U8(12), /* 66 S> */ B(LdaSmi), I8(2), @@ -125,20 +122,19 @@ snippet: " default: a = 1; break; } " -frame size: 3 +frame size: 2 parameter count: 1 -bytecode array length: 38 +bytecode array length: 36 bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), - B(Star), R(1), /* 45 S> */ B(LdaSmi), I8(2), - B(TestEqualStrict), R(1), U8(0), - B(Mov), R(0), R(2), + B(TestEqualStrict), R(0), U8(0), + B(Mov), R(0), R(1), B(JumpIfTrue), U8(11), B(LdaSmi), I8(3), - B(TestEqualStrict), R(2), U8(1), + B(TestEqualStrict), R(1), U8(1), B(JumpIfTrue), U8(6), B(Jump), U8(6), /* 66 S> */ B(Jump), U8(10), @@ -163,21 +159,20 @@ snippet: " default: a = 3; break; } " -frame size: 3 +frame size: 2 parameter count: 1 -bytecode array length: 47 +bytecode array length: 44 bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), - /* 42 E> */ B(TypeOf), + /* 45 S> */ B(TypeOf), B(Star), R(1), - /* 45 S> */ B(LdaSmi), I8(2), + B(LdaSmi), I8(2), B(TestEqualStrict), R(1), U8(0), - B(Mov), R(1), R(2), B(JumpIfTrue), U8(11), B(LdaSmi), I8(3), - B(TestEqualStrict), R(2), U8(1), + B(TestEqualStrict), R(1), U8(1), B(JumpIfTrue), U8(10), B(Jump), U8(14), /* 74 S> */ B(LdaSmi), I8(1), @@ -205,17 +200,16 @@ snippet: " default: a = 2; break; } " -frame size: 3 +frame size: 2 parameter count: 1 -bytecode array length: 32 +bytecode array length: 30 bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), - B(Star), R(1), /* 45 S> */ B(TypeOf), - B(TestEqualStrict), R(1), U8(0), - B(Mov), R(0), R(2), + B(TestEqualStrict), R(0), U8(0), + B(Mov), R(0), R(1), B(JumpIfTrue), U8(4), B(Jump), U8(8), /* 74 S> */ B(LdaSmi), I8(1), @@ -307,20 +301,19 @@ snippet: " break; } " -frame size: 3 +frame size: 2 parameter count: 1 -bytecode array length: 292 +bytecode array length: 290 bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), - B(Star), R(1), /* 45 S> */ B(LdaSmi), I8(1), - B(TestEqualStrict), R(1), U8(0), - B(Mov), R(0), R(2), + B(TestEqualStrict), R(0), U8(0), + B(Mov), R(0), R(1), B(JumpIfTrue), U8(11), B(LdaSmi), I8(2), - B(TestEqualStrict), R(2), U8(1), + B(TestEqualStrict), R(1), U8(1), B(JumpIfTrueConstant), U8(0), B(JumpConstant), U8(1), /* 68 S> */ B(LdaSmi), I8(2), @@ -477,28 +470,26 @@ snippet: " case 2: a = 3; } " -frame size: 5 +frame size: 3 parameter count: 1 -bytecode array length: 63 +bytecode array length: 58 bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), - B(Star), R(2), /* 45 S> */ B(LdaSmi), I8(1), - B(TestEqualStrict), R(2), U8(3), - B(Mov), R(0), R(3), + B(TestEqualStrict), R(0), U8(3), + B(Mov), R(0), R(1), B(JumpIfTrue), U8(11), B(LdaSmi), I8(2), - B(TestEqualStrict), R(3), U8(4), - B(JumpIfTrue), U8(35), - B(Jump), U8(37), - B(Ldar), R(0), + B(TestEqualStrict), R(1), U8(4), + B(JumpIfTrue), U8(32), + B(Jump), U8(34), + /* 70 S> */ B(Ldar), R(0), /* 79 E> */ B(AddSmi), I8(1), U8(0), - B(Star), R(1), - /* 70 S> */ B(LdaSmi), I8(2), - B(TestEqualStrict), R(1), U8(1), - B(Mov), R(1), R(4), + B(Star), R(2), + B(LdaSmi), I8(2), + B(TestEqualStrict), R(2), U8(1), B(JumpIfTrue), U8(4), B(Jump), U8(8), /* 101 S> */ B(LdaSmi), I8(1), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/UnaryOperators.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/UnaryOperators.golden index 8c6dc7d450..2297a7fdc2 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/UnaryOperators.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/UnaryOperators.golden @@ -119,12 +119,12 @@ snippet: " " frame size: 1 parameter count: 1 -bytecode array length: 9 +bytecode array length: 8 bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaSmi), I8(13), B(Star), R(0), - /* 53 S> */ B(BitwiseXorSmi), I8(-1), U8(0), + /* 53 S> */ B(BitwiseNot), U8(0), /* 56 S> */ B(Return), ] constant pool: [ @@ -139,12 +139,12 @@ snippet: " " frame size: 1 parameter count: 1 -bytecode array length: 9 +bytecode array length: 8 bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaSmi), I8(13), B(Star), R(0), - /* 53 S> */ B(MulSmi), I8(1), U8(0), + /* 53 S> */ B(ToNumber), U8(0), /* 56 S> */ B(Return), ] constant pool: [ @@ -159,12 +159,12 @@ snippet: " " frame size: 1 parameter count: 1 -bytecode array length: 9 +bytecode array length: 8 bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaSmi), I8(13), B(Star), R(0), - /* 53 S> */ B(MulSmi), I8(-1), U8(0), + /* 53 S> */ B(Negate), U8(0), /* 56 S> */ B(Return), ] constant pool: [ diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/WideRegisters.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/WideRegisters.golden index b0a0f72acb..94450515ce 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/WideRegisters.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/WideRegisters.golden @@ -1085,7 +1085,7 @@ snippet: " " frame size: 163 parameter count: 1 -bytecode array length: 85 +bytecode array length: 89 bytecodes: [ /* 30 E> */ B(StackCheck), /* 1503 S> */ B(Wide), B(LdaSmi), I16(1234), @@ -1093,10 +1093,11 @@ bytecodes: [ /* 1518 S> */ B(LdaZero), B(Star), R(1), /* 1534 S> */ B(Ldar), R(0), - B(JumpIfUndefined), U8(70), - B(JumpIfNull), U8(68), + B(JumpIfUndefined), U8(74), + B(JumpIfNull), U8(72), B(Wide), B(ToObject), R16(157), - B(Wide), B(ForInPrepare), R16(157), R16(158), + B(Wide), B(ForInEnumerate), R16(157), + B(Wide), B(ForInPrepare), R16(158), U16(1), B(LdaZero), B(Wide), B(Star), R16(161), /* 1526 S> */ B(Wide), B(ForInContinue), R16(161), R16(160), diff --git a/deps/v8/test/cctest/interpreter/interpreter-tester.cc b/deps/v8/test/cctest/interpreter/interpreter-tester.cc index fe50f1f12f..d112511d22 100644 --- a/deps/v8/test/cctest/interpreter/interpreter-tester.cc +++ b/deps/v8/test/cctest/interpreter/interpreter-tester.cc @@ -68,6 +68,8 @@ std::string InterpreterTester::function_name() { return std::string(kFunctionName); } +const char InterpreterTester::kFunctionName[] = "f"; + } // namespace interpreter } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/interpreter/interpreter-tester.h b/deps/v8/test/cctest/interpreter/interpreter-tester.h index 01831e8918..8bc6e67a32 100644 --- a/deps/v8/test/cctest/interpreter/interpreter-tester.h +++ b/deps/v8/test/cctest/interpreter/interpreter-tester.h @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#ifndef V8_TEST_CCTEST_INTERPRETER_INTERPRETER_TESTER_H_ +#define V8_TEST_CCTEST_INTERPRETER_INTERPRETER_TESTER_H_ + #include "src/v8.h" #include "src/api.h" @@ -46,10 +49,6 @@ class InterpreterCallable { Handle<JSFunction> function_; }; -namespace { -const char kFunctionName[] = "f"; -} // namespace - class InterpreterTester { public: InterpreterTester(Isolate* isolate, const char* source, @@ -82,6 +81,8 @@ class InterpreterTester { static std::string function_name(); + static const char kFunctionName[]; + private: Isolate* isolate_; const char* source_; @@ -109,8 +110,7 @@ class InterpreterTester { source += "){})"; function = Handle<JSFunction>::cast(v8::Utils::OpenHandle( *v8::Local<v8::Function>::Cast(CompileRun(source.c_str())))); - function->ReplaceCode( - *BUILTIN_CODE(isolate_, InterpreterEntryTrampoline)); + function->set_code(*BUILTIN_CODE(isolate_, InterpreterEntryTrampoline)); } if (!bytecode_.is_null()) { @@ -131,3 +131,5 @@ class InterpreterTester { } // namespace interpreter } // namespace internal } // namespace v8 + +#endif // V8_TEST_CCTEST_INTERPRETER_INTERPRETER_TESTER_H_ diff --git a/deps/v8/test/cctest/interpreter/test-bytecode-generator.cc b/deps/v8/test/cctest/interpreter/test-bytecode-generator.cc index 69ae4bb297..50e7034686 100644 --- a/deps/v8/test/cctest/interpreter/test-bytecode-generator.cc +++ b/deps/v8/test/cctest/interpreter/test-bytecode-generator.cc @@ -2675,6 +2675,29 @@ TEST(StringConcat) { LoadGolden("StringConcat.golden"))); } +#undef XSTR +#undef STR +#undef UNIQUE_VAR +#undef REPEAT_2 +#undef REPEAT_4 +#undef REPEAT_8 +#undef REPEAT_16 +#undef REPEAT_32 +#undef REPEAT_64 +#undef REPEAT_128 +#undef REPEAT_256 +#undef REPEAT_127 +#undef REPEAT_249 +#undef REPEAT_2_UNIQUE_VARS +#undef REPEAT_4_UNIQUE_VARS +#undef REPEAT_8_UNIQUE_VARS +#undef REPEAT_16_UNIQUE_VARS +#undef REPEAT_32_UNIQUE_VARS +#undef REPEAT_64_UNIQUE_VARS +#undef REPEAT_128_UNIQUE_VARS +#undef REPEAT_250_UNIQUE_VARS +#undef FUNC_ARG + } // namespace interpreter } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/interpreter/test-interpreter.cc b/deps/v8/test/cctest/interpreter/test-interpreter.cc index 69839d4d68..e1134e85b1 100644 --- a/deps/v8/test/cctest/interpreter/test-interpreter.cc +++ b/deps/v8/test/cctest/interpreter/test-interpreter.cc @@ -811,8 +811,8 @@ TEST(InterpreterUnaryOpFeedback) { Handle<Object> any_feedback_value; }; TestCase const kTestCases[] = { - {Token::Value::ADD, smi_one, smi_max, number, str}, - {Token::Value::SUB, smi_one, smi_min, number, str}}; + {Token::Value::INC, smi_one, smi_max, number, str}, + {Token::Value::DEC, smi_one, smi_min, number, str}}; for (TestCase const& test_case : kTestCases) { BytecodeArrayBuilder builder(isolate, zone, 4, 0); @@ -826,13 +826,13 @@ TEST(InterpreterUnaryOpFeedback) { i::NewFeedbackMetadata(isolate, &feedback_spec); builder.LoadAccumulatorWithRegister(builder.Receiver()) - .CountOperation(test_case.op, GetIndex(slot0)) + .UnaryOperation(test_case.op, GetIndex(slot0)) .LoadAccumulatorWithRegister(builder.Parameter(0)) - .CountOperation(test_case.op, GetIndex(slot1)) + .UnaryOperation(test_case.op, GetIndex(slot1)) .LoadAccumulatorWithRegister(builder.Parameter(1)) - .CountOperation(test_case.op, GetIndex(slot2)) + .UnaryOperation(test_case.op, GetIndex(slot2)) .LoadAccumulatorWithRegister(builder.Parameter(2)) - .CountOperation(test_case.op, GetIndex(slot3)) + .UnaryOperation(test_case.op, GetIndex(slot3)) .Return(); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); diff --git a/deps/v8/test/cctest/interpreter/test-source-positions.cc b/deps/v8/test/cctest/interpreter/test-source-positions.cc index 4e8e37ec8f..6d9eff8685 100644 --- a/deps/v8/test/cctest/interpreter/test-source-positions.cc +++ b/deps/v8/test/cctest/interpreter/test-source-positions.cc @@ -4,6 +4,7 @@ #include "src/v8.h" +#include "src/api.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-preparser.cc b/deps/v8/test/cctest/parsing/test-preparser.cc index 97e4b28e5e..3db7fb99d6 100644 --- a/deps/v8/test/cctest/parsing/test-preparser.cc +++ b/deps/v8/test/cctest/parsing/test-preparser.cc @@ -182,6 +182,14 @@ TEST(PreParserScopeAnalysis) { {"let var1 = function() { let var2; }"}, {"const var1 = function() { let var2; }"}, + {"function *f1() { let var2; }"}, + {"let var1 = function *f1() { let var2; }"}, + {"let var1 = function*() { let var2; }"}, + + {"async function f1() { let var2; }"}, + {"let var1 = async function f1() { let var2; }"}, + {"let var1 = async function() { let var2; }"}, + // Redeclarations. {"var var1; var var1;"}, {"var var1; var var1; var1 = 5;"}, @@ -451,6 +459,12 @@ TEST(PreParserScopeAnalysis) { {"if (true) { function f1() {} function f2() { f1(); } }"}, + {"if (true) { function *f1() {} }"}, + {"if (true) { async function f1() {} }"}, + + // (Potentially sloppy) block function shadowing a catch variable. + {"try { } catch(var1) { if (true) { function var1() {} } }"}, + // Simple parameters. {"var1", ""}, {"var1", "var1;"}, @@ -788,3 +802,35 @@ TEST(Regress753896) { // error is not detected inside lazy functions, but it might be in the future. i::parsing::ParseProgram(&info, isolate); } + +TEST(ProducingAndConsumingByteData) { + i::Isolate* isolate = CcTest::i_isolate(); + i::HandleScope scope(isolate); + LocalContext env; + + i::Zone zone(isolate->allocator(), ZONE_NAME); + i::ProducedPreParsedScopeData::ByteData bytes(&zone); + // Write some data. + bytes.WriteUint32(1983); // This will be overwritten. + bytes.WriteUint32(2147483647); + bytes.WriteUint8(4); + bytes.WriteUint8(255); + bytes.WriteUint32(0); + bytes.WriteUint8(0); + bytes.OverwriteFirstUint32(2017); + bytes.WriteUint8(100); + + i::Handle<i::PodArray<uint8_t>> data_on_heap = bytes.Serialize(isolate); + i::ConsumedPreParsedScopeData::ByteData bytes_for_reading; + i::ConsumedPreParsedScopeData::ByteData::ReadingScope reading_scope( + &bytes_for_reading, *data_on_heap); + + // Read the data back. + CHECK_EQ(bytes_for_reading.ReadUint32(), 2017); + CHECK_EQ(bytes_for_reading.ReadUint32(), 2147483647); + CHECK_EQ(bytes_for_reading.ReadUint8(), 4); + CHECK_EQ(bytes_for_reading.ReadUint8(), 255); + CHECK_EQ(bytes_for_reading.ReadUint32(), 0); + CHECK_EQ(bytes_for_reading.ReadUint8(), 0); + CHECK_EQ(bytes_for_reading.ReadUint8(), 100); +} diff --git a/deps/v8/test/cctest/parsing/test-scanner-streams.cc b/deps/v8/test/cctest/parsing/test-scanner-streams.cc index d892442c35..27fc086487 100644 --- a/deps/v8/test/cctest/parsing/test-scanner-streams.cc +++ b/deps/v8/test/cctest/parsing/test-scanner-streams.cc @@ -461,6 +461,25 @@ TEST(Regress651333) { } } +void TestChunkStreamAgainstReference( + const char* cases[], + const std::vector<std::vector<uint16_t>>& unicode_expected) { + for (size_t c = 0; c < unicode_expected.size(); ++c) { + ChunkSource chunk_source(cases[c]); + std::unique_ptr<i::Utf16CharacterStream> stream(i::ScannerStream::For( + &chunk_source, v8::ScriptCompiler::StreamedSource::UTF8, nullptr)); + for (size_t i = 0; i < unicode_expected[c].size(); i++) { + CHECK_EQ(unicode_expected[c][i], stream->Advance()); + } + CHECK_EQ(i::Utf16CharacterStream::kEndOfInput, stream->Advance()); + stream->Seek(0); + for (size_t i = 0; i < unicode_expected[c].size(); i++) { + CHECK_EQ(unicode_expected[c][i], stream->Advance()); + } + CHECK_EQ(i::Utf16CharacterStream::kEndOfInput, stream->Advance()); + } +} + TEST(Regress6377) { const char* cases[] = { "\xf0\x90\0" // first chunk - start of 4-byte seq @@ -480,22 +499,54 @@ TEST(Regress6377) { "a\xc3\0" // and an 'a' + start of 2-byte seq "\xbf\0", // third chunk - end of 2-byte seq }; - const std::vector<std::vector<uint16_t>> unicode = { + const std::vector<std::vector<uint16_t>> unicode_expected = { {0xd800, 0xdc00, 97}, {0xfff, 97}, {0xff, 97}, {0xd800, 0xdc00, 97, 0xff}, }; - CHECK_EQ(unicode.size(), sizeof(cases) / sizeof(cases[0])); - for (size_t c = 0; c < unicode.size(); ++c) { - ChunkSource chunk_source(cases[c]); - std::unique_ptr<i::Utf16CharacterStream> stream(i::ScannerStream::For( - &chunk_source, v8::ScriptCompiler::StreamedSource::UTF8, nullptr)); - for (size_t i = 0; i < unicode[c].size(); i++) { - CHECK_EQ(unicode[c][i], stream->Advance()); - } - CHECK_EQ(i::Utf16CharacterStream::kEndOfInput, stream->Advance()); - stream->Seek(0); - for (size_t i = 0; i < unicode[c].size(); i++) { - CHECK_EQ(unicode[c][i], stream->Advance()); - } - CHECK_EQ(i::Utf16CharacterStream::kEndOfInput, stream->Advance()); - } + CHECK_EQ(unicode_expected.size(), arraysize(cases)); + TestChunkStreamAgainstReference(cases, unicode_expected); +} + +TEST(Regress6836) { + const char* cases[] = { + // 0xc2 is a lead byte, but there's no continuation. The bug occurs when + // this happens near the chunk end. + "X\xc2Y\0", + // Last chunk ends with a 2-byte char lead. + "X\xc2\0", + // Last chunk ends with a 3-byte char lead and only one continuation + // character. + "X\xe0\xbf\0", + }; + const std::vector<std::vector<uint16_t>> unicode_expected = { + {0x58, 0xfffd, 0x59}, {0x58, 0xfffd}, {0x58, 0xfffd}, + }; + CHECK_EQ(unicode_expected.size(), arraysize(cases)); + TestChunkStreamAgainstReference(cases, unicode_expected); +} + +TEST(TestOverlongAndInvalidSequences) { + const char* cases[] = { + // Overlong 2-byte sequence. + "X\xc0\xbfY\0", + // Another overlong 2-byte sequence. + "X\xc1\xbfY\0", + // Overlong 3-byte sequence. + "X\xe0\x9f\xbfY\0", + // Overlong 4-byte sequence. + "X\xf0\x89\xbf\xbfY\0", + // Invalid 3-byte sequence (reserved for surrogates). + "X\xed\xa0\x80Y\0", + // Invalid 4-bytes sequence (value out of range). + "X\xf4\x90\x80\x80Y\0", + }; + const std::vector<std::vector<uint16_t>> unicode_expected = { + {0x58, 0xfffd, 0xfffd, 0x59}, + {0x58, 0xfffd, 0xfffd, 0x59}, + {0x58, 0xfffd, 0xfffd, 0xfffd, 0x59}, + {0x58, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0x59}, + {0x58, 0xfffd, 0xfffd, 0xfffd, 0x59}, + {0x58, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0x59}, + }; + CHECK_EQ(unicode_expected.size(), arraysize(cases)); + TestChunkStreamAgainstReference(cases, unicode_expected); } diff --git a/deps/v8/test/cctest/parsing/test-scanner.cc b/deps/v8/test/cctest/parsing/test-scanner.cc index ea7a8fbaa2..9c18bfb1ae 100644 --- a/deps/v8/test/cctest/parsing/test-scanner.cc +++ b/deps/v8/test/cctest/parsing/test-scanner.cc @@ -29,6 +29,7 @@ struct ScannerTestHelper { std::unique_ptr<UnicodeCache> unicode_cache; std::unique_ptr<Utf16CharacterStream> stream; std::unique_ptr<Scanner> scanner; + int use_counts[v8::Isolate::kUseCounterFeatureCount]; Scanner* operator->() const { return scanner.get(); } Scanner* get() const { return scanner.get(); } @@ -38,8 +39,11 @@ 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())); + for (int i = 0; i < v8::Isolate::kUseCounterFeatureCount; i++) { + helper.use_counts[i] = 0; + } + helper.scanner = std::unique_ptr<Scanner>( + new Scanner(helper.unicode_cache.get(), helper.use_counts)); helper.scanner->Initialize(helper.stream.get(), false); return helper; } diff --git a/deps/v8/test/cctest/setup-isolate-for-tests.cc b/deps/v8/test/cctest/setup-isolate-for-tests.cc index c09a362eff..ba9c4fb488 100644 --- a/deps/v8/test/cctest/setup-isolate-for-tests.cc +++ b/deps/v8/test/cctest/setup-isolate-for-tests.cc @@ -9,19 +9,25 @@ namespace v8 { namespace internal { -void SetupIsolateDelegateForTests::SetupBuiltins(Isolate* isolate, - bool create_heap_objects) { - if (create_heap_objects) { +void SetupIsolateDelegateForTests::SetupBuiltins(Isolate* isolate) { + if (create_heap_objects_) { SetupBuiltinsInternal(isolate); } } void SetupIsolateDelegateForTests::SetupInterpreter( - interpreter::Interpreter* interpreter, bool create_heap_objects) { - if (create_heap_objects) { + interpreter::Interpreter* interpreter) { + if (create_heap_objects_) { interpreter::SetupInterpreter::InstallBytecodeHandlers(interpreter); } } +bool SetupIsolateDelegateForTests::SetupHeap(Heap* heap) { + if (create_heap_objects_) { + return SetupHeapInternal(heap); + } + return true; +} + } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/setup-isolate-for-tests.h b/deps/v8/test/cctest/setup-isolate-for-tests.h index 6a49aa13cc..e3d34725f0 100644 --- a/deps/v8/test/cctest/setup-isolate-for-tests.h +++ b/deps/v8/test/cctest/setup-isolate-for-tests.h @@ -12,13 +12,15 @@ namespace internal { class SetupIsolateDelegateForTests : public SetupIsolateDelegate { public: - SetupIsolateDelegateForTests() : SetupIsolateDelegate() {} + explicit SetupIsolateDelegateForTests(bool create_heap_objects) + : SetupIsolateDelegate(create_heap_objects) {} virtual ~SetupIsolateDelegateForTests() {} - void SetupBuiltins(Isolate* isolate, bool create_heap_objects) override; + void SetupBuiltins(Isolate* isolate) override; - void SetupInterpreter(interpreter::Interpreter* interpreter, - bool create_heap_objects) override; + void SetupInterpreter(interpreter::Interpreter* interpreter) override; + + bool SetupHeap(Heap* heap) override; }; } // namespace internal diff --git a/deps/v8/test/cctest/test-accessor-assembler.cc b/deps/v8/test/cctest/test-accessor-assembler.cc index 17617affee..0afdde390b 100644 --- a/deps/v8/test/cctest/test-accessor-assembler.cc +++ b/deps/v8/test/cctest/test-accessor-assembler.cc @@ -106,9 +106,9 @@ TEST(StubCacheSecondaryOffset) { namespace { -Handle<Code> CreateCodeWithFlags(Code::Flags flags) { +Handle<Code> CreateCodeOfKind(Code::Kind kind) { Isolate* isolate(CcTest::InitIsolateOnce()); - CodeAssemblerTester data(isolate, flags); + CodeAssemblerTester data(isolate, kind); CodeStubAssembler m(data.state()); m.Return(m.UndefinedConstant()); return data.GenerateCodeCloseAndEscape(); @@ -124,8 +124,7 @@ TEST(TryProbeStubCache) { CodeAssemblerTester data(isolate, kNumParams); AccessorAssembler m(data.state()); - Code::Kind ic_kind = Code::LOAD_IC; - StubCache stub_cache(isolate, ic_kind); + StubCache stub_cache(isolate); stub_cache.Clear(); { @@ -204,8 +203,7 @@ TEST(TryProbeStubCache) { // Generate some number of handlers. for (int i = 0; i < 30; i++) { - Code::Flags flags = Code::ComputeHandlerFlags(ic_kind); - handlers.push_back(CreateCodeWithFlags(flags)); + handlers.push_back(CreateCodeOfKind(Code::STUB)); } // Ensure that GC does happen because from now on we are going to fill our diff --git a/deps/v8/test/cctest/test-allocation.cc b/deps/v8/test/cctest/test-allocation.cc index c06dcc575a..f31b03670a 100644 --- a/deps/v8/test/cctest/test-allocation.cc +++ b/deps/v8/test/cctest/test-allocation.cc @@ -54,7 +54,7 @@ size_t GetHugeMemoryAmount() { static size_t huge_memory = 0; if (!huge_memory) { for (int i = 0; i < 100; i++) { - huge_memory |= bit_cast<size_t>(v8::base::OS::GetRandomMmapAddr()); + huge_memory |= bit_cast<size_t>(v8::internal::GetRandomMmapAddr()); } // Make it larger than the available address space. huge_memory *= 2; @@ -130,7 +130,7 @@ TEST(AlignedAllocOOM) { TEST(AllocVirtualMemoryOOM) { AllocationPlatform platform; CHECK(!platform.oom_callback_called); - v8::base::VirtualMemory result; + v8::internal::VirtualMemory result; bool success = v8::internal::AllocVirtualMemory(GetHugeMemoryAmount(), nullptr, &result); // On a few systems, allocation somehow succeeds. @@ -141,7 +141,7 @@ TEST(AllocVirtualMemoryOOM) { TEST(AlignedAllocVirtualMemoryOOM) { AllocationPlatform platform; CHECK(!platform.oom_callback_called); - v8::base::VirtualMemory result; + v8::internal::VirtualMemory result; bool success = v8::internal::AlignedAllocVirtualMemory( GetHugeMemoryAmount(), v8::base::OS::AllocateAlignment(), nullptr, &result); diff --git a/deps/v8/test/cctest/test-api-interceptors.cc b/deps/v8/test/cctest/test-api-interceptors.cc index ca9b18016d..48809506f1 100644 --- a/deps/v8/test/cctest/test-api-interceptors.cc +++ b/deps/v8/test/cctest/test-api-interceptors.cc @@ -716,21 +716,20 @@ bool define_was_called_in_order = false; void GetterCallbackOrder(Local<Name> property, const v8::PropertyCallbackInfo<v8::Value>& info) { get_was_called_in_order = true; - CHECK(!define_was_called_in_order); + CHECK(define_was_called_in_order); info.GetReturnValue().Set(property); } void DefinerCallbackOrder(Local<Name> property, const v8::PropertyDescriptor& desc, const v8::PropertyCallbackInfo<v8::Value>& info) { - // Get called before DefineProperty because we query the descriptor first. - CHECK(get_was_called_in_order); + CHECK(!get_was_called_in_order); // Define called before get. define_was_called_in_order = true; } } // namespace -// Check that getter callback is called before definer callback. +// Check that definer callback is called before getter callback. THREADED_TEST(DefinerCallbackGetAndDefine) { v8::HandleScope scope(CcTest::isolate()); v8::Local<v8::FunctionTemplate> templ = @@ -3327,12 +3326,18 @@ static void NamedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { ApiTestFuzzer::Fuzz(); v8::Local<v8::Array> result = v8::Array::New(info.GetIsolate(), 3); v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext(); - result->Set(context, v8::Integer::New(info.GetIsolate(), 0), v8_str("foo")) - .FromJust(); - result->Set(context, v8::Integer::New(info.GetIsolate(), 1), v8_str("bar")) - .FromJust(); - result->Set(context, v8::Integer::New(info.GetIsolate(), 2), v8_str("baz")) - .FromJust(); + CHECK( + result + ->Set(context, v8::Integer::New(info.GetIsolate(), 0), v8_str("foo")) + .FromJust()); + CHECK( + result + ->Set(context, v8::Integer::New(info.GetIsolate(), 1), v8_str("bar")) + .FromJust()); + CHECK( + result + ->Set(context, v8::Integer::New(info.GetIsolate(), 2), v8_str("baz")) + .FromJust()); info.GetReturnValue().Set(result); } @@ -3341,10 +3346,12 @@ static void IndexedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { ApiTestFuzzer::Fuzz(); v8::Local<v8::Array> result = v8::Array::New(info.GetIsolate(), 2); v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext(); - result->Set(context, v8::Integer::New(info.GetIsolate(), 0), v8_str("0")) - .FromJust(); - result->Set(context, v8::Integer::New(info.GetIsolate(), 1), v8_str("1")) - .FromJust(); + CHECK( + result->Set(context, v8::Integer::New(info.GetIsolate(), 0), v8_str("0")) + .FromJust()); + CHECK( + result->Set(context, v8::Integer::New(info.GetIsolate(), 1), v8_str("1")) + .FromJust()); info.GetReturnValue().Set(result); } @@ -4965,6 +4972,262 @@ THREADED_TEST(NonMaskingInterceptorPrototypePropertyIC) { ExpectInt32("f(outer)", 4); } +namespace { + +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>())); +} + +void ConcatIndexedPropertyGetter( + uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info) { + info.GetReturnValue().Set( + // Return the double value of the index. + v8_num(index + index)); +} + +void EnumCallbackWithNames(const v8::PropertyCallbackInfo<v8::Array>& info) { + ApiTestFuzzer::Fuzz(); + v8::Local<v8::Array> result = v8::Array::New(info.GetIsolate(), 4); + v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext(); + CHECK( + result + ->Set(context, v8::Integer::New(info.GetIsolate(), 0), v8_str("foo")) + .FromJust()); + CHECK( + result + ->Set(context, v8::Integer::New(info.GetIsolate(), 1), v8_str("bar")) + .FromJust()); + CHECK( + result + ->Set(context, v8::Integer::New(info.GetIsolate(), 2), v8_str("baz")) + .FromJust()); + CHECK( + result->Set(context, v8::Integer::New(info.GetIsolate(), 3), v8_str("10")) + .FromJust()); + + // Create a holey array. + CHECK(result->Delete(context, v8::Integer::New(info.GetIsolate(), 1)) + .FromJust()); + info.GetReturnValue().Set(result); +} + +void EnumCallbackWithIndices(const v8::PropertyCallbackInfo<v8::Array>& info) { + ApiTestFuzzer::Fuzz(); + v8::Local<v8::Array> result = v8::Array::New(info.GetIsolate(), 4); + v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext(); + + CHECK(result->Set(context, v8::Integer::New(info.GetIsolate(), 0), v8_num(10)) + .FromJust()); + CHECK(result->Set(context, v8::Integer::New(info.GetIsolate(), 1), v8_num(11)) + .FromJust()); + CHECK(result->Set(context, v8::Integer::New(info.GetIsolate(), 2), v8_num(12)) + .FromJust()); + CHECK(result->Set(context, v8::Integer::New(info.GetIsolate(), 3), v8_num(14)) + .FromJust()); + + // Create a holey array. + CHECK(result->Delete(context, v8::Integer::New(info.GetIsolate(), 1)) + .FromJust()); + info.GetReturnValue().Set(result); +} + +void RestrictiveNamedQuery(Local<Name> property, + const v8::PropertyCallbackInfo<v8::Integer>& info) { + // Only "foo" is enumerable. + if (v8_str("foo") + ->Equals(info.GetIsolate()->GetCurrentContext(), property) + .FromJust()) { + info.GetReturnValue().Set(v8::PropertyAttribute::None); + return; + } + info.GetReturnValue().Set(v8::PropertyAttribute::DontEnum); +} + +void RestrictiveIndexedQuery( + uint32_t index, const v8::PropertyCallbackInfo<v8::Integer>& info) { + // Only index 2 and 12 are enumerable. + if (index == 2 || index == 12) { + info.GetReturnValue().Set(v8::PropertyAttribute::None); + return; + } + info.GetReturnValue().Set(v8::PropertyAttribute::DontEnum); +} +} // namespace + +// Regression test for V8 bug 6627. +// Object.keys() must return enumerable keys only. +THREADED_TEST(EnumeratorsAndUnenumerableNamedProperties) { + // The enumerator interceptor returns a list + // of items which are filtered according to the + // properties defined in the query interceptor. + v8::Isolate* isolate = CcTest::isolate(); + v8::HandleScope scope(isolate); + v8::Local<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); + obj->SetHandler(v8::NamedPropertyHandlerConfiguration( + ConcatNamedPropertyGetter, NULL, RestrictiveNamedQuery, NULL, + EnumCallbackWithNames)); + LocalContext context; + context->Global() + ->Set(context.local(), v8_str("obj"), + obj->NewInstance(context.local()).ToLocalChecked()) + .FromJust(); + + ExpectInt32("Object.getOwnPropertyNames(obj).length", 3); + ExpectString("Object.getOwnPropertyNames(obj)[0]", "foo"); + ExpectString("Object.getOwnPropertyNames(obj)[1]", "baz"); + ExpectString("Object.getOwnPropertyNames(obj)[2]", "10"); + + ExpectTrue("Object.getOwnPropertyDescriptor(obj, 'foo').enumerable"); + ExpectFalse("Object.getOwnPropertyDescriptor(obj, 'baz').enumerable"); + + ExpectInt32("Object.entries(obj).length", 1); + ExpectString("Object.entries(obj)[0][0]", "foo"); + ExpectString("Object.entries(obj)[0][1]", "foofoo"); + + ExpectInt32("Object.keys(obj).length", 1); + ExpectString("Object.keys(obj)[0]", "foo"); + + ExpectInt32("Object.values(obj).length", 1); + ExpectString("Object.values(obj)[0]", "foofoo"); +} + +namespace { +void QueryInterceptorForFoo(Local<Name> property, + const v8::PropertyCallbackInfo<v8::Integer>& info) { + // Don't intercept anything except "foo." + if (!v8_str("foo") + ->Equals(info.GetIsolate()->GetCurrentContext(), property) + .FromJust()) { + return; + } + // "foo" is enumerable. + info.GetReturnValue().Set(v8::PropertyAttribute::None); +} +} // namespace + +// Test that calls to the query interceptor are independent of each +// other. +THREADED_TEST(EnumeratorsAndUnenumerableNamedPropertiesWithoutSet) { + // The enumerator interceptor returns a list + // of items which are filtered according to the + // properties defined in the query interceptor. + v8::Isolate* isolate = CcTest::isolate(); + v8::HandleScope scope(isolate); + v8::Local<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); + obj->SetHandler(v8::NamedPropertyHandlerConfiguration( + ConcatNamedPropertyGetter, NULL, QueryInterceptorForFoo, NULL, + EnumCallbackWithNames)); + LocalContext context; + context->Global() + ->Set(context.local(), v8_str("obj"), + obj->NewInstance(context.local()).ToLocalChecked()) + .FromJust(); + + ExpectInt32("Object.getOwnPropertyNames(obj).length", 3); + ExpectString("Object.getOwnPropertyNames(obj)[0]", "foo"); + ExpectString("Object.getOwnPropertyNames(obj)[1]", "baz"); + ExpectString("Object.getOwnPropertyNames(obj)[2]", "10"); + + ExpectTrue("Object.getOwnPropertyDescriptor(obj, 'foo').enumerable"); + ExpectInt32("Object.keys(obj).length", 1); +} + +THREADED_TEST(EnumeratorsAndUnenumerableIndexedPropertiesArgumentsElements) { + v8::Isolate* isolate = CcTest::isolate(); + v8::HandleScope scope(isolate); + v8::Local<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); + obj->SetHandler(v8::IndexedPropertyHandlerConfiguration( + ConcatIndexedPropertyGetter, NULL, RestrictiveIndexedQuery, NULL, + SloppyArgsIndexedPropertyEnumerator)); + LocalContext context; + context->Global() + ->Set(context.local(), v8_str("obj"), + obj->NewInstance(context.local()).ToLocalChecked()) + .FromJust(); + + ExpectInt32("Object.getOwnPropertyNames(obj).length", 4); + ExpectString("Object.getOwnPropertyNames(obj)[0]", "0"); + ExpectString("Object.getOwnPropertyNames(obj)[1]", "1"); + ExpectString("Object.getOwnPropertyNames(obj)[2]", "2"); + ExpectString("Object.getOwnPropertyNames(obj)[3]", "3"); + + ExpectTrue("Object.getOwnPropertyDescriptor(obj, '2').enumerable"); + + ExpectInt32("Object.entries(obj).length", 1); + ExpectString("Object.entries(obj)[0][0]", "2"); + ExpectInt32("Object.entries(obj)[0][1]", 4); + + ExpectInt32("Object.keys(obj).length", 1); + ExpectString("Object.keys(obj)[0]", "2"); + + ExpectInt32("Object.values(obj).length", 1); + ExpectInt32("Object.values(obj)[0]", 4); +} + +THREADED_TEST(EnumeratorsAndUnenumerableIndexedProperties) { + // The enumerator interceptor returns a list + // of items which are filtered according to the + // properties defined in the query interceptor. + v8::Isolate* isolate = CcTest::isolate(); + v8::HandleScope scope(isolate); + v8::Local<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); + obj->SetHandler(v8::IndexedPropertyHandlerConfiguration( + ConcatIndexedPropertyGetter, NULL, RestrictiveIndexedQuery, NULL, + EnumCallbackWithIndices)); + LocalContext context; + context->Global() + ->Set(context.local(), v8_str("obj"), + obj->NewInstance(context.local()).ToLocalChecked()) + .FromJust(); + + ExpectInt32("Object.getOwnPropertyNames(obj).length", 3); + ExpectString("Object.getOwnPropertyNames(obj)[0]", "10"); + ExpectString("Object.getOwnPropertyNames(obj)[1]", "12"); + ExpectString("Object.getOwnPropertyNames(obj)[2]", "14"); + + ExpectFalse("Object.getOwnPropertyDescriptor(obj, '10').enumerable"); + ExpectTrue("Object.getOwnPropertyDescriptor(obj, '12').enumerable"); + + ExpectInt32("Object.entries(obj).length", 1); + ExpectString("Object.entries(obj)[0][0]", "12"); + ExpectInt32("Object.entries(obj)[0][1]", 24); + + ExpectInt32("Object.keys(obj).length", 1); + ExpectString("Object.keys(obj)[0]", "12"); + + ExpectInt32("Object.values(obj).length", 1); + ExpectInt32("Object.values(obj)[0]", 24); +} + +THREADED_TEST(EnumeratorsAndForIn) { + v8::Isolate* isolate = CcTest::isolate(); + v8::HandleScope scope(isolate); + v8::Local<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); + obj->SetHandler(v8::NamedPropertyHandlerConfiguration( + ConcatNamedPropertyGetter, NULL, RestrictiveNamedQuery, NULL, NamedEnum)); + LocalContext context; + context->Global() + ->Set(context.local(), v8_str("obj"), + obj->NewInstance(context.local()).ToLocalChecked()) + .FromJust(); + + ExpectInt32("Object.getOwnPropertyNames(obj).length", 3); + ExpectString("Object.getOwnPropertyNames(obj)[0]", "foo"); + + ExpectTrue("Object.getOwnPropertyDescriptor(obj, 'foo').enumerable"); + + CompileRun( + "let concat = '';" + "for(var prop in obj) {" + " concat += `key:${prop}:value:${obj[prop]}`;" + "}"); + + // Check that for...in only iterates over enumerable properties. + ExpectString("concat", "key:foo:value:foofoo"); +} namespace { diff --git a/deps/v8/test/cctest/test-api.cc b/deps/v8/test/cctest/test-api.cc index cf5be0fa9c..99ab0bfaa1 100644 --- a/deps/v8/test/cctest/test-api.cc +++ b/deps/v8/test/cctest/test-api.cc @@ -2536,10 +2536,9 @@ THREADED_TEST(AccessorIsPreservedOnAttributeChange) { LocalContext env; v8::Local<v8::Value> res = CompileRun("var a = []; a;"); i::Handle<i::JSReceiver> a(v8::Utils::OpenHandle(v8::Object::Cast(*res))); - CHECK(a->map()->instance_descriptors()->IsFixedArray()); - CHECK_GT(i::FixedArray::cast(a->map()->instance_descriptors())->length(), 0); + CHECK_EQ(1, a->map()->instance_descriptors()->number_of_descriptors()); CompileRun("Object.defineProperty(a, 'length', { writable: false });"); - CHECK_EQ(0, i::FixedArray::cast(a->map()->instance_descriptors())->length()); + CHECK_EQ(0, a->map()->instance_descriptors()->number_of_descriptors()); // But we should still have an AccessorInfo. i::Handle<i::String> name(v8::Utils::OpenHandle(*v8_str("length"))); i::LookupIterator it(a, name, i::LookupIterator::OWN_SKIP_INTERCEPTOR); @@ -5781,23 +5780,55 @@ TEST(CustomErrorMessage) { static void check_custom_rethrowing_message(v8::Local<v8::Message> message, v8::Local<v8::Value> data) { + CHECK(data->IsExternal()); + int* callcount = static_cast<int*>(data.As<v8::External>()->Value()); + ++*callcount; + const char* uncaught_error = "Uncaught exception"; CHECK(message->Get() ->Equals(CcTest::isolate()->GetCurrentContext(), v8_str(uncaught_error)) .FromJust()); + // Test that compiling code inside a message handler works. + CHECK(CompileRunChecked(CcTest::isolate(), "(function(a) { return a; })(42)") + ->Equals(CcTest::isolate()->GetCurrentContext(), + v8::Integer::NewFromUnsigned(CcTest::isolate(), 42)) + .FromJust()); } TEST(CustomErrorRethrowsOnToString) { + int callcount = 0; LocalContext context; - v8::HandleScope scope(context->GetIsolate()); - context->GetIsolate()->AddMessageListener(check_custom_rethrowing_message); + v8::Isolate* isolate = context->GetIsolate(); + v8::HandleScope scope(isolate); + context->GetIsolate()->AddMessageListener( + check_custom_rethrowing_message, v8::External::New(isolate, &callcount)); CompileRun( "var e = { toString: function() { throw e; } };" "try { throw e; } finally {}"); + CHECK_EQ(callcount, 1); + context->GetIsolate()->RemoveMessageListeners( + check_custom_rethrowing_message); +} + +TEST(CustomErrorRethrowsOnToStringInsideVerboseTryCatch) { + int callcount = 0; + LocalContext context; + v8::Isolate* isolate = context->GetIsolate(); + v8::HandleScope scope(isolate); + v8::TryCatch try_catch(isolate); + try_catch.SetVerbose(true); + context->GetIsolate()->AddMessageListener( + check_custom_rethrowing_message, v8::External::New(isolate, &callcount)); + + CompileRun( + "var e = { toString: function() { throw e; } };" + "try { throw e; } finally {}"); + + CHECK_EQ(callcount, 1); context->GetIsolate()->RemoveMessageListeners( check_custom_rethrowing_message); } @@ -7613,6 +7644,28 @@ TEST(ErrorReporting) { CHECK(last_location); } +static size_t dcheck_count; +void DcheckErrorCallback(const char* file, int line, const char* message) { + last_message = message; + ++dcheck_count; +} + +TEST(DcheckErrorHandler) { + V8::SetDcheckErrorHandler(DcheckErrorCallback); + + last_message = nullptr; + dcheck_count = 0; + + DCHECK(false && "w00t"); +#ifdef DEBUG + CHECK_EQ(dcheck_count, 1); + CHECK(last_message); + CHECK(std::string(last_message).find("w00t") != std::string::npos); +#else + // The DCHECK should be a noop in non-DEBUG builds. + CHECK_EQ(dcheck_count, 0); +#endif +} static void MissingScriptInfoMessageListener(v8::Local<v8::Message> message, v8::Local<Value> data) { @@ -8490,6 +8543,66 @@ static void Utf16Helper( } } +void TestUtf8DecodingAgainstReference( + 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); + + for (size_t i = 0; i < unicode_expected[test_ix].size(); ++i) { + CHECK_EQ(unicode_expected[test_ix][i], buffer[i]); + } + } +} + +THREADED_TEST(OverlongSequencesAndSurrogates) { + LocalContext context; + v8::HandleScope scope(context->GetIsolate()); + + const char* cases[] = { + // Overlong 2-byte sequence. + "X\xc0\xbfY\0", + // Another overlong 2-byte sequence. + "X\xc1\xbfY\0", + // Overlong 3-byte sequence. + "X\xe0\x9f\xbfY\0", + // Overlong 4-byte sequence. + "X\xf0\x89\xbf\xbfY\0", + // Invalid 3-byte sequence (reserved for surrogates). + "X\xed\xa0\x80Y\0", + // Invalid 4-bytes sequence (value out of range). + "X\xf4\x90\x80\x80Y\0", + + // Start of an overlong 3-byte sequence but not enough continuation bytes. + "X\xe0\x9fY\0", + // Start of an overlong 4-byte sequence but not enough continuation bytes. + "X\xf0\x89\xbfY\0", + // Start of an invalid 3-byte sequence (reserved for surrogates) but not + // enough continuation bytes. + "X\xed\xa0Y\0", + // Start of an invalid 4-bytes sequence (value out of range) but not + // enough continuation bytes. + "X\xf4\x90\x80Y\0", + }; + const std::vector<std::vector<uint16_t>> unicode_expected = { + {0x58, 0xfffd, 0xfffd, 0x59}, + {0x58, 0xfffd, 0xfffd, 0x59}, + {0x58, 0xfffd, 0xfffd, 0xfffd, 0x59}, + {0x58, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0x59}, + {0x58, 0xfffd, 0xfffd, 0xfffd, 0x59}, + {0x58, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0x59}, + {0x58, 0xfffd, 0xfffd, 0x59}, + {0x58, 0xfffd, 0xfffd, 0xfffd, 0x59}, + {0x58, 0xfffd, 0xfffd, 0x59}, + {0x58, 0xfffd, 0xfffd, 0xfffd, 0x59}, + }; + CHECK_EQ(unicode_expected.size(), arraysize(cases)); + TestUtf8DecodingAgainstReference(cases, unicode_expected); +} THREADED_TEST(Utf16) { LocalContext context; @@ -17525,6 +17638,8 @@ int promise_reject_frame_count = -1; void PromiseRejectCallback(v8::PromiseRejectMessage reject_message) { v8::Local<v8::Object> global = CcTest::global(); v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext(); + CHECK_EQ(v8::Promise::PromiseState::kRejected, + reject_message.GetPromise()->State()); if (reject_message.GetEvent() == v8::kPromiseRejectWithNoHandler) { promise_reject_counter++; global->Set(context, v8_str("rejected"), reject_message.GetPromise()) @@ -22227,21 +22342,19 @@ const char* kMegamorphicTestProgram = "}\n"; void TestStubCache(bool primary) { - using namespace i; - - FLAG_native_code_counters = true; + i::FLAG_native_code_counters = true; if (primary) { - FLAG_test_primary_stub_cache = true; + i::FLAG_test_primary_stub_cache = true; } else { - FLAG_test_secondary_stub_cache = true; + i::FLAG_test_secondary_stub_cache = true; } - FLAG_opt = false; + i::FLAG_opt = false; v8::Isolate::CreateParams create_params; create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); create_params.counter_lookup_callback = LookupCounter; v8::Isolate* isolate = v8::Isolate::New(create_params); - Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate); + i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); { v8::Isolate::Scope isolate_scope(isolate); @@ -23177,16 +23290,14 @@ TEST(AccessCheckThrows) { } TEST(AccessCheckInIC) { - using namespace i; - - FLAG_native_code_counters = true; - FLAG_opt = false; + i::FLAG_native_code_counters = true; + i::FLAG_opt = false; v8::Isolate::CreateParams create_params; create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); create_params.counter_lookup_callback = LookupCounter; v8::Isolate* isolate = v8::Isolate::New(create_params); - Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate); + i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); { v8::Isolate::Scope isolate_scope(isolate); @@ -26948,20 +27059,19 @@ THREADED_TEST(GlobalAccessorInfo) { } UNINITIALIZED_TEST(IncreaseHeapLimitForDebugging) { - using namespace i; v8::Isolate::CreateParams create_params; create_params.constraints.set_max_old_space_size(16); create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); v8::Isolate* isolate = v8::Isolate::New(create_params); - Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate); + i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); { size_t limit_before = i_isolate->heap()->MaxOldGenerationSize(); - CHECK_EQ(16 * MB, limit_before); + CHECK_EQ(16 * i::MB, limit_before); CHECK(!isolate->IsHeapLimitIncreasedForDebugging()); isolate->IncreaseHeapLimitForDebugging(); CHECK(isolate->IsHeapLimitIncreasedForDebugging()); size_t limit_after = i_isolate->heap()->MaxOldGenerationSize(); - CHECK_EQ(4 * 16 * MB, limit_after); + CHECK_EQ(4 * 16 * i::MB, limit_after); isolate->RestoreOriginalHeapLimit(); CHECK(!isolate->IsHeapLimitIncreasedForDebugging()); CHECK_EQ(limit_before, i_isolate->heap()->MaxOldGenerationSize()); @@ -26995,12 +27105,11 @@ TEST(DeterministicRandomNumberGeneration) { } UNINITIALIZED_TEST(AllowAtomicsWait) { - using namespace i; v8::Isolate::CreateParams create_params; create_params.allow_atomics_wait = false; create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); v8::Isolate* isolate = v8::Isolate::New(create_params); - Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate); + i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); { CHECK_EQ(false, i_isolate->allow_atomics_wait()); isolate->SetAllowAtomicsWait(true); diff --git a/deps/v8/test/cctest/test-array-list.cc b/deps/v8/test/cctest/test-array-list.cc index 9532554416..91882cd1da 100644 --- a/deps/v8/test/cctest/test-array-list.cc +++ b/deps/v8/test/cctest/test-array-list.cc @@ -4,22 +4,12 @@ #include <stdlib.h> -#include "src/v8.h" - #include "src/factory.h" -// FIXME(mstarzinger, marja): This is weird, but required because of the missing -// (disallowed) include: src/factory.h -> src/objects-inl.h #include "src/objects-inl.h" -// FIXME(mstarzinger, marja): This is weird, but required because of the missing -// (disallowed) include: src/feedback-vector.h -> -// src/feedback-vector-inl.h -#include "src/feedback-vector-inl.h" #include "test/cctest/cctest.h" -namespace { - -using namespace v8::internal; - +namespace v8 { +namespace internal { TEST(ArrayList) { LocalContext context; @@ -46,4 +36,5 @@ TEST(ArrayList) { CHECK_EQ(200, Smi::ToInt(array->Get(1))); } -} // namespace +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-assembler-arm.cc b/deps/v8/test/cctest/test-assembler-arm.cc index 5483698975..5f405548f0 100644 --- a/deps/v8/test/cctest/test-assembler-arm.cc +++ b/deps/v8/test/cctest/test-assembler-arm.cc @@ -38,9 +38,11 @@ #include "src/v8.h" #include "test/cctest/cctest.h" -using namespace v8::base; -using namespace v8::internal; +namespace v8 { +namespace internal { +namespace test_assembler_arm { +using base::RandomNumberGenerator; // Define these function prototypes to match JSEntryFunction in execution.cc. typedef Object* (*F1)(int x, int p1, int p2, int p3, int p4); @@ -63,8 +65,8 @@ TEST(0) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG OFStream os(stdout); code->Print(os); @@ -100,8 +102,8 @@ TEST(1) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG OFStream os(stdout); code->Print(os); @@ -146,8 +148,8 @@ TEST(2) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG OFStream os(stdout); code->Print(os); @@ -194,8 +196,8 @@ TEST(3) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG OFStream os(stdout); code->Print(os); @@ -326,8 +328,8 @@ TEST(4) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG OFStream os(stdout); code->Print(os); @@ -389,8 +391,8 @@ TEST(5) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG OFStream os(stdout); code->Print(os); @@ -421,8 +423,8 @@ TEST(6) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG OFStream os(stdout); code->Print(os); @@ -490,8 +492,8 @@ static void TestRoundingMode(VCVTTypes types, CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG OFStream os(stdout); code->Print(os); @@ -673,8 +675,8 @@ TEST(8) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG OFStream os(stdout); code->Print(os); @@ -783,8 +785,8 @@ TEST(9) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG OFStream os(stdout); code->Print(os); @@ -889,8 +891,8 @@ TEST(10) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG OFStream os(stdout); code->Print(os); @@ -984,8 +986,8 @@ TEST(11) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG OFStream os(stdout); code->Print(os); @@ -1111,8 +1113,8 @@ TEST(13) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG OFStream os(stdout); code->Print(os); @@ -1184,8 +1186,8 @@ TEST(14) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG OFStream os(stdout); code->Print(os); @@ -2065,8 +2067,8 @@ TEST(15) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG OFStream os(stdout); code->Print(os); @@ -2342,8 +2344,8 @@ TEST(16) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG OFStream os(stdout); code->Print(os); @@ -2423,8 +2425,8 @@ TEST(sdiv) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG OFStream os(stdout); code->Print(os); @@ -2487,8 +2489,8 @@ TEST(udiv) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG OFStream os(stdout); code->Print(os); @@ -2518,8 +2520,8 @@ TEST(smmla) { __ bx(lr); CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -2527,7 +2529,7 @@ TEST(smmla) { for (size_t i = 0; i < 128; ++i) { int32_t r, x = rng->NextInt(), y = rng->NextInt(), z = rng->NextInt(); Object* dummy = CALL_GENERATED_CODE(isolate, f, &r, x, y, z, 0); - CHECK_EQ(bits::SignedMulHighAndAdd32(x, y, z), r); + CHECK_EQ(base::bits::SignedMulHighAndAdd32(x, y, z), r); USE(dummy); } } @@ -2544,8 +2546,8 @@ TEST(smmul) { __ bx(lr); CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -2553,7 +2555,7 @@ TEST(smmul) { for (size_t i = 0; i < 128; ++i) { int32_t r, x = rng->NextInt(), y = rng->NextInt(); Object* dummy = CALL_GENERATED_CODE(isolate, f, &r, x, y, 0, 0); - CHECK_EQ(bits::SignedMulHigh32(x, y), r); + CHECK_EQ(base::bits::SignedMulHigh32(x, y), r); USE(dummy); } } @@ -2570,8 +2572,8 @@ TEST(sxtb) { __ bx(lr); CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -2596,8 +2598,8 @@ TEST(sxtab) { __ bx(lr); CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -2622,8 +2624,8 @@ TEST(sxth) { __ bx(lr); CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -2648,8 +2650,8 @@ TEST(sxtah) { __ bx(lr); CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -2674,8 +2676,8 @@ TEST(uxtb) { __ bx(lr); CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -2700,8 +2702,8 @@ TEST(uxtab) { __ bx(lr); CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -2726,8 +2728,8 @@ TEST(uxth) { __ bx(lr); CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -2752,8 +2754,8 @@ TEST(uxtah) { __ bx(lr); CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -2794,8 +2796,8 @@ TEST(rbit) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); @@ -2876,8 +2878,8 @@ TEST(code_relative_offset) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), code_object); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, code_object); F1 f = FUNCTION_CAST<F1>(code->entry()); int res = reinterpret_cast<int>(CALL_GENERATED_CODE(isolate, f, 21, 0, 0, 0, 0)); @@ -2916,8 +2918,8 @@ TEST(msr_mrs) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG OFStream os(stdout); code->Print(os); @@ -3017,8 +3019,8 @@ TEST(ARMv8_float32_vrintX) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG OFStream os(stdout); code->Print(os); @@ -3122,8 +3124,8 @@ TEST(ARMv8_vrintX) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG OFStream os(stdout); code->Print(os); @@ -3262,8 +3264,8 @@ TEST(ARMv8_vsel) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG OFStream os(stdout); code->Print(os); @@ -3356,8 +3358,8 @@ TEST(ARMv8_vminmax_f64) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG OFStream os(stdout); code->Print(os); @@ -3438,8 +3440,8 @@ TEST(ARMv8_vminmax_f32) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG OFStream os(stdout); code->Print(os); @@ -3570,8 +3572,8 @@ static F4 GenerateMacroFloatMinMax(MacroAssembler& assm) { CodeDesc desc; assm.GetCode(assm.isolate(), &desc); - Handle<Code> code = assm.isolate()->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + assm.isolate()->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG OFStream os(stdout); code->Print(os); @@ -3738,8 +3740,8 @@ TEST(unaligned_loads) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG OFStream os(stdout); code->Print(os); @@ -3784,8 +3786,8 @@ TEST(unaligned_stores) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG OFStream os(stdout); code->Print(os); @@ -3887,8 +3889,8 @@ TEST(vswp) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG OFStream os(stdout); code->Print(os); @@ -3992,3 +3994,7 @@ TEST(use_scratch_register_scope) { } #undef __ + +} // namespace test_assembler_arm +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-assembler-arm64.cc b/deps/v8/test/cctest/test-assembler-arm64.cc index 47b7c6c964..9ebe524a6f 100644 --- a/deps/v8/test/cctest/test-assembler-arm64.cc +++ b/deps/v8/test/cctest/test-assembler-arm64.cc @@ -46,7 +46,8 @@ #include "test/cctest/cctest.h" #include "test/cctest/test-utils-arm64.h" -using namespace v8::internal; +namespace v8 { +namespace internal { // Test infrastructure. // @@ -12365,10 +12366,10 @@ static void PushPopJsspSimpleHelper(int reg_count, reg_count = CountSetBits(allowed, kNumberOfRegisters); } // Work out which registers to use, based on reg_size. - Register r[kNumberOfRegisters]; - Register x[kNumberOfRegisters]; - RegList list = PopulateRegisterArray(NULL, x, r, reg_size, reg_count, - allowed); + auto r = CreateRegisterArray<Register, kNumberOfRegisters>(); + auto x = CreateRegisterArray<Register, kNumberOfRegisters>(); + RegList list = PopulateRegisterArray(NULL, x.data(), r.data(), reg_size, + reg_count, allowed); // The literal base is chosen to have two useful properties: // * When multiplied by small values (such as a register index), this value @@ -12549,10 +12550,10 @@ static void PushPopFPJsspSimpleHelper(int reg_count, reg_count = CountSetBits(allowed, kNumberOfVRegisters); } // Work out which registers to use, based on reg_size. - VRegister v[kNumberOfRegisters]; - VRegister d[kNumberOfRegisters]; - RegList list = - PopulateVRegisterArray(NULL, d, v, reg_size, reg_count, allowed); + auto v = CreateRegisterArray<VRegister, kNumberOfRegisters>(); + auto d = CreateRegisterArray<VRegister, kNumberOfRegisters>(); + RegList list = PopulateVRegisterArray(NULL, d.data(), v.data(), reg_size, + reg_count, allowed); // The literal base is chosen to have two useful properties: // * When multiplied (using an integer) by small values (such as a register @@ -12718,9 +12719,9 @@ static void PushPopJsspMixedMethodsHelper(int claim, int reg_size) { static RegList const allowed = ~(x8.bit() | x9.bit() | jssp.bit() | xzr.bit()); // Work out which registers to use, based on reg_size. - Register r[10]; - Register x[10]; - PopulateRegisterArray(NULL, x, r, reg_size, 10, allowed); + auto r = CreateRegisterArray<Register, 10>(); + auto x = CreateRegisterArray<Register, 10>(); + PopulateRegisterArray(NULL, x.data(), r.data(), reg_size, 10, allowed); // Calculate some handy register lists. RegList r0_to_r3 = 0; @@ -12823,9 +12824,10 @@ static void PushPopJsspWXOverlapHelper(int reg_count, int claim) { if (reg_count == kPushPopJsspMaxRegCount) { reg_count = CountSetBits(allowed, kNumberOfRegisters); } - Register w[kNumberOfRegisters]; - Register x[kNumberOfRegisters]; - RegList list = PopulateRegisterArray(w, x, NULL, 0, reg_count, allowed); + auto w = CreateRegisterArray<Register, kNumberOfRegisters>(); + auto x = CreateRegisterArray<Register, kNumberOfRegisters>(); + RegList list = + PopulateRegisterArray(w.data(), x.data(), NULL, 0, reg_count, allowed); // The number of W-sized slots we expect to pop. When we pop, we alternate // between W and X registers, so we need reg_count*1.5 W-sized slots. @@ -12905,13 +12907,9 @@ static void PushPopJsspWXOverlapHelper(int reg_count, int claim) { int times = i % 4 + 1; if (i & 1) { // Push odd-numbered registers as W registers. - if (i & 2) { - __ PushMultipleTimes(w[i], times); - } else { - // Use a register to specify the count. - __ Mov(tmp.W(), times); - __ PushMultipleTimes(w[i], tmp.W()); - } + __ Mov(tmp.W(), times); + __ PushMultipleTimes(w[i], tmp.W()); + // Fill in the expected stack slots. for (int j = 0; j < times; j++) { if (w[i].Is(wzr)) { @@ -12923,13 +12921,9 @@ static void PushPopJsspWXOverlapHelper(int reg_count, int claim) { } } else { // Push even-numbered registers as X registers. - if (i & 2) { - __ PushMultipleTimes(x[i], times); - } else { - // Use a register to specify the count. - __ Mov(tmp, times); - __ PushMultipleTimes(x[i], tmp); - } + __ Mov(tmp, times); + __ PushMultipleTimes(x[i], tmp); + // Fill in the expected stack slots. for (int j = 0; j < times; j++) { if (x[i].IsZero()) { @@ -13903,23 +13897,23 @@ TEST(isvalid) { CHECK(d31.IsValid()); CHECK(s31.IsValid()); - CHECK(x0.IsValidRegister()); - CHECK(w0.IsValidRegister()); - CHECK(xzr.IsValidRegister()); - CHECK(wzr.IsValidRegister()); - CHECK(csp.IsValidRegister()); - CHECK(wcsp.IsValidRegister()); - CHECK(!x0.IsValidVRegister()); - CHECK(!w0.IsValidVRegister()); - CHECK(!xzr.IsValidVRegister()); - CHECK(!wzr.IsValidVRegister()); - CHECK(!csp.IsValidVRegister()); - CHECK(!wcsp.IsValidVRegister()); - - CHECK(d0.IsValidVRegister()); - CHECK(s0.IsValidVRegister()); - CHECK(!d0.IsValidRegister()); - CHECK(!s0.IsValidRegister()); + CHECK(x0.IsRegister()); + CHECK(w0.IsRegister()); + CHECK(xzr.IsRegister()); + CHECK(wzr.IsRegister()); + CHECK(csp.IsRegister()); + CHECK(wcsp.IsRegister()); + CHECK(!x0.IsVRegister()); + CHECK(!w0.IsVRegister()); + CHECK(!xzr.IsVRegister()); + CHECK(!wzr.IsVRegister()); + CHECK(!csp.IsVRegister()); + CHECK(!wcsp.IsVRegister()); + + CHECK(d0.IsVRegister()); + CHECK(s0.IsVRegister()); + CHECK(!d0.IsRegister()); + CHECK(!s0.IsRegister()); // Test the same as before, but using CPURegister types. This shouldn't make // any difference. @@ -13938,23 +13932,23 @@ TEST(isvalid) { CHECK(static_cast<CPURegister>(d31).IsValid()); CHECK(static_cast<CPURegister>(s31).IsValid()); - CHECK(static_cast<CPURegister>(x0).IsValidRegister()); - CHECK(static_cast<CPURegister>(w0).IsValidRegister()); - CHECK(static_cast<CPURegister>(xzr).IsValidRegister()); - CHECK(static_cast<CPURegister>(wzr).IsValidRegister()); - CHECK(static_cast<CPURegister>(csp).IsValidRegister()); - CHECK(static_cast<CPURegister>(wcsp).IsValidRegister()); - CHECK(!static_cast<CPURegister>(x0).IsValidVRegister()); - CHECK(!static_cast<CPURegister>(w0).IsValidVRegister()); - CHECK(!static_cast<CPURegister>(xzr).IsValidVRegister()); - CHECK(!static_cast<CPURegister>(wzr).IsValidVRegister()); - CHECK(!static_cast<CPURegister>(csp).IsValidVRegister()); - CHECK(!static_cast<CPURegister>(wcsp).IsValidVRegister()); - - CHECK(static_cast<CPURegister>(d0).IsValidVRegister()); - CHECK(static_cast<CPURegister>(s0).IsValidVRegister()); - CHECK(!static_cast<CPURegister>(d0).IsValidRegister()); - CHECK(!static_cast<CPURegister>(s0).IsValidRegister()); + CHECK(static_cast<CPURegister>(x0).IsRegister()); + CHECK(static_cast<CPURegister>(w0).IsRegister()); + CHECK(static_cast<CPURegister>(xzr).IsRegister()); + CHECK(static_cast<CPURegister>(wzr).IsRegister()); + CHECK(static_cast<CPURegister>(csp).IsRegister()); + CHECK(static_cast<CPURegister>(wcsp).IsRegister()); + CHECK(!static_cast<CPURegister>(x0).IsVRegister()); + CHECK(!static_cast<CPURegister>(w0).IsVRegister()); + CHECK(!static_cast<CPURegister>(xzr).IsVRegister()); + CHECK(!static_cast<CPURegister>(wzr).IsVRegister()); + CHECK(!static_cast<CPURegister>(csp).IsVRegister()); + CHECK(!static_cast<CPURegister>(wcsp).IsVRegister()); + + CHECK(static_cast<CPURegister>(d0).IsVRegister()); + CHECK(static_cast<CPURegister>(s0).IsVRegister()); + CHECK(!static_cast<CPURegister>(d0).IsRegister()); + CHECK(!static_cast<CPURegister>(s0).IsRegister()); } TEST(areconsecutive) { @@ -15324,7 +15318,8 @@ TEST(pool_size) { HandleScope handle_scope(isolate); CodeDesc desc; masm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode(desc, 0, masm.CodeObject()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, masm.CodeObject()); unsigned pool_count = 0; int pool_mask = RelocInfo::ModeMask(RelocInfo::CONST_POOL) | @@ -15515,3 +15510,6 @@ TEST(internal_reference_linked) { TEARDOWN(); } + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-assembler-ia32.cc b/deps/v8/test/cctest/test-assembler-ia32.cc index 89908cbeb4..ab4a72f790 100644 --- a/deps/v8/test/cctest/test-assembler-ia32.cc +++ b/deps/v8/test/cctest/test-assembler-ia32.cc @@ -29,6 +29,7 @@ #include "src/v8.h" +#include "src/assembler-inl.h" #include "src/base/platform/platform.h" #include "src/base/utils/random-number-generator.h" #include "src/disassembler.h" @@ -37,8 +38,8 @@ #include "src/ostreams.h" #include "test/cctest/cctest.h" -using namespace v8::internal; - +namespace v8 { +namespace internal { typedef int (*F0)(); typedef int (*F1)(int x); @@ -61,8 +62,8 @@ TEST(AssemblerIa320) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT OFStream os(stdout); code->Print(os); @@ -98,8 +99,8 @@ TEST(AssemblerIa321) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT OFStream os(stdout); code->Print(os); @@ -139,8 +140,8 @@ TEST(AssemblerIa322) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT OFStream os(stdout); code->Print(os); @@ -168,8 +169,8 @@ TEST(AssemblerIa323) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT OFStream os(stdout); code->Print(os); @@ -197,8 +198,8 @@ TEST(AssemblerIa324) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT OFStream os(stdout); code->Print(os); @@ -224,8 +225,8 @@ TEST(AssemblerIa325) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F0 f = FUNCTION_CAST<F0>(code->entry()); int res = f(); CHECK_EQ(42, res); @@ -257,8 +258,8 @@ TEST(AssemblerIa326) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT OFStream os(stdout); code->Print(os); @@ -289,8 +290,8 @@ TEST(AssemblerIa328) { __ ret(0); CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT OFStream os(stdout); code->Print(os); @@ -371,8 +372,8 @@ TEST(AssemblerMultiByteNop) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); CHECK(code->IsCode()); F0 f = FUNCTION_CAST<F0>(code->entry()); @@ -421,8 +422,8 @@ void DoSSE2(const v8::FunctionCallbackInfo<v8::Value>& args) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F0 f = FUNCTION_CAST<F0>(code->entry()); int res = f(); @@ -486,8 +487,8 @@ TEST(AssemblerIa32Extractps) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT OFStream os(stdout); code->Print(os); @@ -526,8 +527,8 @@ TEST(AssemblerIa32SSE) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT OFStream os(stdout); code->Print(os); @@ -755,8 +756,8 @@ TEST(AssemblerX64FMA_sd) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT OFStream os(stdout); code->Print(os); @@ -984,8 +985,8 @@ TEST(AssemblerX64FMA_ss) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT OFStream os(stdout); code->Print(os); @@ -1092,8 +1093,8 @@ TEST(AssemblerIa32BMI1) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT OFStream os(stdout); code->Print(os); @@ -1140,8 +1141,8 @@ TEST(AssemblerIa32LZCNT) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT OFStream os(stdout); code->Print(os); @@ -1188,8 +1189,8 @@ TEST(AssemblerIa32POPCNT) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT OFStream os(stdout); code->Print(os); @@ -1334,8 +1335,8 @@ TEST(AssemblerIa32BMI2) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT OFStream os(stdout); code->Print(os); @@ -1378,8 +1379,8 @@ TEST(AssemblerIa32JumpTables1) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT OFStream os(stdout); code->Print(os); @@ -1426,8 +1427,8 @@ TEST(AssemblerIa32JumpTables2) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT OFStream os(stdout); code->Print(os); @@ -1469,8 +1470,8 @@ TEST(Regress621926) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT OFStream os(stdout); @@ -1482,3 +1483,6 @@ TEST(Regress621926) { } #undef __ + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-assembler-mips.cc b/deps/v8/test/cctest/test-assembler-mips.cc index 212e97229b..e191b1eb63 100644 --- a/deps/v8/test/cctest/test-assembler-mips.cc +++ b/deps/v8/test/cctest/test-assembler-mips.cc @@ -29,6 +29,7 @@ #include "src/v8.h" +#include "src/assembler-inl.h" #include "src/base/utils/random-number-generator.h" #include "src/disassembler.h" #include "src/factory.h" @@ -38,9 +39,8 @@ #include "test/cctest/cctest.h" - -using namespace v8::internal; - +namespace v8 { +namespace internal { // Define these function prototypes to match JSEntryFunction in execution.cc. typedef Object* (*F1)(int x, int p1, int p2, int p3, int p4); @@ -64,8 +64,8 @@ TEST(MIPS0) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); int res = reinterpret_cast<int>( CALL_GENERATED_CODE(isolate, f, 0xab0, 0xc, 0, 0, 0)); @@ -100,8 +100,8 @@ TEST(MIPS1) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F1 f = FUNCTION_CAST<F1>(code->entry()); int res = reinterpret_cast<int>( CALL_GENERATED_CODE(isolate, f, 50, 0, 0, 0, 0)); @@ -238,8 +238,8 @@ TEST(MIPS2) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); int res = reinterpret_cast<int>( CALL_GENERATED_CODE(isolate, f, 0xab0, 0xc, 0, 0, 0)); @@ -340,8 +340,8 @@ TEST(MIPS3) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); // Double test values. t.a = 1.5e14; @@ -444,8 +444,8 @@ TEST(MIPS4) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); t.a = 1.5e22; t.b = 2.75e11; @@ -507,8 +507,8 @@ TEST(MIPS5) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); t.a = 1.5e4; t.b = 2.75e8; @@ -577,8 +577,8 @@ TEST(MIPS6) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); t.ui = 0x11223344; t.si = 0x99aabbcc; @@ -670,8 +670,8 @@ TEST(MIPS7) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); t.a = 1.5e14; t.b = 2.75e11; @@ -768,8 +768,8 @@ TEST(MIPS8) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); t.input = 0x12345678; Object* dummy = CALL_GENERATED_CODE(isolate, f, &t, 0x0, 0, 0, 0); @@ -814,8 +814,7 @@ TEST(MIPS9) { CodeDesc desc; assm.GetCode(isolate, &desc); - isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); } @@ -865,8 +864,8 @@ TEST(MIPS10) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); t.a = 2.147483646e+09; // 0x7FFFFFFE -> 0xFF80000041DFFFFF as double. t.b_word = 0x0ff00ff0; // 0x0FF00FF0 -> 0x as double. @@ -993,8 +992,8 @@ TEST(MIPS11) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); t.reg_init = 0xaabbccdd; t.mem_init = 0x11223344; @@ -1119,8 +1118,8 @@ TEST(MIPS12) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); t.x = 1; t.y = 2; @@ -1173,8 +1172,8 @@ TEST(MIPS13) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); t.cvt_big_in = 0xFFFFFFFF; @@ -1294,8 +1293,8 @@ TEST(MIPS14) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); t.round_up_in = 123.51; @@ -1400,8 +1399,8 @@ TEST(seleqz_selnez) { __ nop(); CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); @@ -1515,8 +1514,8 @@ TEST(min_max) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 0; i < kTableLength; i++) { test.a = inputsa[i]; @@ -1626,8 +1625,8 @@ TEST(rint_d) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int j = 0; j < 4; j++) { @@ -1674,8 +1673,8 @@ TEST(sel) { __ nop(); CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); const int test_size = 3; @@ -1807,8 +1806,8 @@ TEST(rint_s) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int j = 0; j < 4; j++) { @@ -1856,8 +1855,8 @@ TEST(Cvt_d_uw) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 0; i < kTableLength; i++) { test.input = inputs[i]; @@ -1938,8 +1937,8 @@ TEST(mina_maxa) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 0; i < kTableLength; i++) { test.a = inputsa[i]; @@ -2019,8 +2018,8 @@ TEST(trunc_l) { Test test; CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 0; i < kTableLength; i++) { test.a = inputs_D[i]; @@ -2100,8 +2099,8 @@ TEST(movz_movn) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 0; i < kTableLength; i++) { test.a = inputs_D[i]; @@ -2202,8 +2201,8 @@ TEST(movt_movd) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); @@ -2287,8 +2286,8 @@ TEST(cvt_w_d) { Test test; CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int j = 0; j < 4; j++) { test.fcsr = fcsr_inputs[j]; @@ -2354,8 +2353,8 @@ TEST(trunc_w) { Test test; CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 0; i < kTableLength; i++) { test.a = inputs_D[i]; @@ -2423,8 +2422,8 @@ TEST(round_w) { Test test; CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 0; i < kTableLength; i++) { test.a = inputs_D[i]; @@ -2495,8 +2494,8 @@ TEST(round_l) { Test test; CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 0; i < kTableLength; i++) { test.a = inputs_D[i]; @@ -2568,8 +2567,8 @@ TEST(sub) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 0; i < kTableLength; i++) { test.a = inputfs_S[i]; @@ -2647,8 +2646,8 @@ TEST(sqrt_rsqrt_recip) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 0; i < kTableLength; i++) { @@ -2727,8 +2726,8 @@ TEST(neg) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 0; i < kTableLength; i++) { test.a = inputs_S[i]; @@ -2784,8 +2783,8 @@ TEST(mul) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 0; i < kTableLength; i++) { test.a = inputfs_S[i]; @@ -2840,8 +2839,8 @@ TEST(mov) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 0; i < kTableLength; i++) { test.a = inputs_D[i]; @@ -2907,8 +2906,8 @@ TEST(floor_w) { Test test; CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 0; i < kTableLength; i++) { test.a = inputs_D[i]; @@ -2979,8 +2978,8 @@ TEST(floor_l) { Test test; CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 0; i < kTableLength; i++) { test.a = inputs_D[i]; @@ -3051,8 +3050,8 @@ TEST(ceil_w) { Test test; CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 0; i < kTableLength; i++) { test.a = inputs_D[i]; @@ -3123,8 +3122,8 @@ TEST(ceil_l) { Test test; CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 0; i < kTableLength; i++) { test.a = inputs_D[i]; @@ -3195,8 +3194,8 @@ TEST(jump_tables1) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -3265,8 +3264,8 @@ TEST(jump_tables2) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -3342,8 +3341,8 @@ TEST(jump_tables3) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -3393,8 +3392,8 @@ TEST(BITSWAP) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); t.r1 = 0x781A15C3; t.r2 = 0x8B71FCDE; @@ -3528,8 +3527,8 @@ TEST(class_fmt) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); t.dSignalingNan = std::numeric_limits<double>::signaling_NaN(); @@ -3620,8 +3619,8 @@ TEST(ABS) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); test.a = -2.0; test.b = -2.0; @@ -3713,8 +3712,8 @@ TEST(ADD_FMT) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); test.a = 2.0; test.b = 3.0; @@ -3868,8 +3867,8 @@ TEST(C_COND_FMT) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); test.dOp1 = 2.0; test.dOp2 = 3.0; @@ -4069,8 +4068,8 @@ TEST(CMP_COND_FMT) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); uint64_t dTrue = 0xFFFFFFFFFFFFFFFF; uint64_t dFalse = 0x0000000000000000; @@ -4255,8 +4254,8 @@ TEST(CVT) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); test.cvt_d_s_in = -0.51; @@ -4467,8 +4466,8 @@ TEST(DIV_FMT) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); @@ -4559,8 +4558,8 @@ uint32_t run_align(uint32_t rs_value, uint32_t rt_value, uint8_t bp) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); @@ -4612,8 +4611,8 @@ uint32_t run_aluipc(int16_t offset) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); PC = (uint32_t) f; // Set the program counter. @@ -4666,8 +4665,8 @@ uint32_t run_auipc(int16_t offset) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); PC = (uint32_t) f; // Set the program counter. @@ -4742,8 +4741,8 @@ uint32_t run_lwpc(int offset) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); @@ -4826,8 +4825,8 @@ uint32_t run_jic(int16_t offset) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); @@ -4898,8 +4897,8 @@ uint64_t run_beqzc(int32_t value, int32_t offset) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); @@ -4992,8 +4991,8 @@ uint32_t run_jialc(int16_t offset) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); @@ -5041,8 +5040,8 @@ static uint32_t run_addiupc(int32_t imm19) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); PC = (uint32_t) f; // Set the program counter. @@ -5124,8 +5123,8 @@ int32_t run_bc(int32_t offset) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); @@ -5206,8 +5205,8 @@ int32_t run_balc(int32_t offset) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); @@ -5231,8 +5230,8 @@ uint32_t run_aui(uint32_t rs, uint16_t offset) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); @@ -5322,8 +5321,8 @@ uint32_t run_bal(int16_t offset) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); @@ -5376,8 +5375,8 @@ TEST(Trampoline) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); int32_t res = reinterpret_cast<int32_t>( @@ -5443,8 +5442,8 @@ void helper_madd_msub_maddf_msubf(F func) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); const size_t kTableLength = sizeof(test_cases) / sizeof(TestCaseMaddMsub<T>); @@ -5529,8 +5528,8 @@ uint32_t run_Subu(uint32_t imm, int32_t num_instr) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); uint32_t res = reinterpret_cast<uint32_t>( @@ -5587,6 +5586,65 @@ TEST(Subu) { } } +void load_uint64_elements_of_vector(MacroAssembler& assm, + const uint64_t elements[], MSARegister w, + Register t0, Register t1) { + __ li(t0, static_cast<uint32_t>(elements[0] & 0xffffffff)); + __ li(t1, static_cast<uint32_t>((elements[0] >> 32) & 0xffffffff)); + __ insert_w(w, 0, t0); + __ insert_w(w, 1, t1); + __ li(t0, static_cast<uint32_t>(elements[1] & 0xffffffff)); + __ li(t1, static_cast<uint32_t>((elements[1] >> 32) & 0xffffffff)); + __ insert_w(w, 2, t0); + __ insert_w(w, 3, t1); +} + +void load_uint32_elements_of_vector(MacroAssembler& assm, + const uint64_t elements[], MSARegister w, + Register t0, Register t1) { + const uint32_t* const element = reinterpret_cast<const uint32_t*>(elements); + __ li(t0, element[0]); + __ li(t1, element[1]); + __ insert_w(w, 0, t0); + __ insert_w(w, 1, t1); + __ li(t0, element[2]); + __ li(t1, element[3]); + __ insert_w(w, 2, t0); + __ insert_w(w, 3, t1); +} + +void load_uint16_elements_of_vector(MacroAssembler& assm, + const uint64_t elements[], MSARegister w, + Register t0, Register t1) { + const uint16_t* const element = reinterpret_cast<const uint16_t*>(elements); + __ li(t0, element[0]); + __ li(t1, element[1]); + __ insert_h(w, 0, t0); + __ insert_h(w, 1, t1); + __ li(t0, element[2]); + __ li(t1, element[3]); + __ insert_h(w, 2, t0); + __ insert_h(w, 3, t1); + __ li(t0, element[4]); + __ li(t1, element[5]); + __ insert_h(w, 4, t0); + __ insert_h(w, 5, t1); + __ li(t0, element[6]); + __ li(t1, element[7]); + __ insert_h(w, 6, t0); + __ insert_h(w, 7, t1); +} + +inline void store_uint64_elements_of_vector(MacroAssembler& assm, MSARegister w, + Register a, Register t) { + __ st_d(w, MemOperand(a, 0)); +} + +inline void store_uint32_elements_of_vector(MacroAssembler& assm, MSARegister w, + Register a, Register t) { + __ st_w(w, MemOperand(a, 0)); +} + TEST(MSA_fill_copy) { CcTest::InitializeVM(); Isolate* isolate = CcTest::i_isolate(); @@ -5634,8 +5692,8 @@ TEST(MSA_fill_copy) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -5703,8 +5761,8 @@ TEST(MSA_fill_copy_2) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -5761,8 +5819,8 @@ TEST(MSA_fill_copy_3) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -5807,22 +5865,15 @@ void run_msa_insert(int32_t rs_value, int n, msa_reg_t* w) { UNREACHABLE(); } - __ copy_u_w(t2, w0, 0); - __ sw(t2, MemOperand(a0, 0)); - __ copy_u_w(t2, w0, 1); - __ sw(t2, MemOperand(a0, 4)); - __ copy_u_w(t2, w0, 2); - __ sw(t2, MemOperand(a0, 8)); - __ copy_u_w(t2, w0, 3); - __ sw(t2, MemOperand(a0, 12)); + store_uint64_elements_of_vector(assm, w0, a0, t2); __ jr(ra); __ nop(); CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -5887,6 +5938,60 @@ TEST(MSA_insert) { } } +void run_msa_ctc_cfc(uint32_t value) { + Isolate* isolate = CcTest::i_isolate(); + HandleScope scope(isolate); + + MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); + CpuFeatureScope fscope(&assm, MIPS_SIMD); + + MSAControlRegister msareg = {kMSACSRRegister}; + __ li(t0, value); + __ li(t2, 0); + __ cfcmsa(t1, msareg); + __ ctcmsa(msareg, t0); + __ cfcmsa(t2, msareg); + __ ctcmsa(msareg, t1); + __ sw(t2, MemOperand(a0, 0)); + __ jr(ra); + __ nop(); + + CodeDesc desc; + assm.GetCode(isolate, &desc); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); +#ifdef OBJECT_PRINT + code->Print(std::cout); +#endif + F3 f = FUNCTION_CAST<F3>(code->entry()); + + uint32_t res; + (CALL_GENERATED_CODE(isolate, f, &res, 0, 0, 0, 0)); + + CHECK_EQ(value & 0x0167ffff, res); +} + +TEST(MSA_cfc_ctc) { + if (!IsMipsArchVariant(kMips32r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + + const uint32_t mask_without_cause = 0xff9c0fff; + const uint32_t mask_always_zero = 0x0167ffff; + const uint32_t mask_enables = 0x00000f80; + uint32_t test_case[] = {0x2d5ede31, 0x07955425, 0x15b7dbe3, 0x2bf8bc37, + 0xe6aae923, 0x24d0f68d, 0x41afa84c, 0x2d6bf64f, + 0x925014bd, 0x4dba7e61}; + for (unsigned i = 0; i < arraysize(test_case); i++) { + // Setting enable bits and corresponding cause bits could result in + // exception raised and this prevents that from happening + test_case[i] = (~test_case[i] & mask_enables) << 5 | + (test_case[i] & mask_without_cause); + run_msa_ctc_cfc(test_case[i] & mask_always_zero); + } +} + struct ExpResShf { uint8_t i8; uint64_t lo; @@ -5954,14 +6059,7 @@ void run_msa_i8(SecondaryField opcode, uint64_t ws_lo, uint64_t ws_hi, UNREACHABLE(); } - __ copy_u_w(t2, w2, 0); - __ sw(t2, MemOperand(a0, 0)); - __ copy_u_w(t2, w2, 1); - __ sw(t2, MemOperand(a0, 4)); - __ copy_u_w(t2, w2, 2); - __ sw(t2, MemOperand(a0, 8)); - __ copy_u_w(t2, w2, 3); - __ sw(t2, MemOperand(a0, 12)); + store_uint64_elements_of_vector(assm, w2, a0, t2); __ jr(ra); __ nop(); @@ -5970,8 +6068,8 @@ void run_msa_i8(SecondaryField opcode, uint64_t ws_lo, uint64_t ws_hi, CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -6148,8 +6246,8 @@ uint32_t run_Ins(uint32_t imm, uint32_t source, uint16_t pos, uint16_t size) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); uint32_t res = reinterpret_cast<uint32_t>( @@ -6199,8 +6297,8 @@ uint32_t run_Ext(uint32_t source, uint16_t pos, uint16_t size) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); uint32_t res = reinterpret_cast<uint32_t>( @@ -6251,33 +6349,19 @@ void run_msa_i5(struct TestCaseMsaI5* input, bool i5_sign_ext, int32_t i5 = i5_sign_ext ? static_cast<int32_t>(input->i5 << 27) >> 27 : input->i5; - __ li(t0, static_cast<uint32_t>(input->ws_lo & 0xffffffff)); - __ li(t1, static_cast<uint32_t>((input->ws_lo >> 32) & 0xffffffff)); - __ insert_w(w0, 0, t0); - __ insert_w(w0, 1, t1); - __ li(t0, static_cast<uint32_t>(input->ws_hi & 0xffffffff)); - __ li(t1, static_cast<uint32_t>((input->ws_hi >> 32) & 0xffffffff)); - __ insert_w(w0, 2, t0); - __ insert_w(w0, 3, t1); + load_uint64_elements_of_vector(assm, &(input->ws_lo), w0, t0, t1); GenerateI5InstructionFunc(assm, i5); - __ copy_u_w(t2, w2, 0); - __ sw(t2, MemOperand(a0, 0)); - __ copy_u_w(t2, w2, 1); - __ sw(t2, MemOperand(a0, 4)); - __ copy_u_w(t2, w2, 2); - __ sw(t2, MemOperand(a0, 8)); - __ copy_u_w(t2, w2, 3); - __ sw(t2, MemOperand(a0, 12)); + store_uint64_elements_of_vector(assm, w2, a0, t2); __ jr(ra); __ nop(); CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -6676,8 +6760,11 @@ struct TestCaseMsa2R { uint64_t exp_res_hi; }; -template <typename Func> -void run_msa_2r(struct TestCaseMsa2R* input, Func Generate2RInstructionFunc) { +template <typename Func, typename FuncLoad, typename FuncStore> +void run_msa_2r(const struct TestCaseMsa2R* input, + Func Generate2RInstructionFunc, + FuncLoad load_elements_of_vector, + FuncStore store_elements_of_vector) { Isolate* isolate = CcTest::i_isolate(); HandleScope scope(isolate); @@ -6685,33 +6772,18 @@ void run_msa_2r(struct TestCaseMsa2R* input, Func Generate2RInstructionFunc) { CpuFeatureScope fscope(&assm, MIPS_SIMD); msa_reg_t res; - __ li(t0, static_cast<uint32_t>(input->ws_lo & 0xffffffff)); - __ li(t1, static_cast<uint32_t>((input->ws_lo >> 32) & 0xffffffff)); - __ insert_w(w0, 0, t0); - __ insert_w(w0, 1, t1); - __ li(t0, static_cast<uint32_t>(input->ws_hi & 0xffffffff)); - __ li(t1, static_cast<uint32_t>((input->ws_hi >> 32) & 0xffffffff)); - __ insert_w(w0, 2, t0); - __ insert_w(w0, 3, t1); - + load_elements_of_vector(assm, reinterpret_cast<const uint64_t*>(input), w0, + t0, t1); Generate2RInstructionFunc(assm); - - __ copy_u_w(t2, w2, 0); - __ sw(t2, MemOperand(a0, 0)); - __ copy_u_w(t2, w2, 1); - __ sw(t2, MemOperand(a0, 4)); - __ copy_u_w(t2, w2, 2); - __ sw(t2, MemOperand(a0, 8)); - __ copy_u_w(t2, w2, 3); - __ sw(t2, MemOperand(a0, 12)); + store_elements_of_vector(assm, w2, a0, t2); __ jr(ra); __ nop(); CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -6719,8 +6791,17 @@ void run_msa_2r(struct TestCaseMsa2R* input, Func Generate2RInstructionFunc) { (CALL_GENERATED_CODE(isolate, f, &res, 0, 0, 0, 0)); - CHECK_EQ(input->exp_res_lo, res.d[0]); - CHECK_EQ(input->exp_res_hi, res.d[1]); + if (store_elements_of_vector == store_uint64_elements_of_vector) { + CHECK_EQ(input->exp_res_lo, res.d[0]); + CHECK_EQ(input->exp_res_hi, res.d[1]); + } else if (store_elements_of_vector == store_uint32_elements_of_vector) { + const uint32_t* exp_res = + reinterpret_cast<const uint32_t*>(&input->exp_res_lo); + CHECK_EQ(exp_res[0], res.w[0]); + CHECK_EQ(exp_res[1], res.w[1]); + CHECK_EQ(exp_res[2], res.w[2]); + CHECK_EQ(exp_res[3], res.w[3]); + } } TEST(MSA_pcnt) { @@ -6771,10 +6852,14 @@ TEST(MSA_pcnt) { {0xf35862e13e38f8b0, 0x4f41ffdef2bfe636, 0x20, 0x2a}}; for (size_t i = 0; i < sizeof(tc_b) / sizeof(TestCaseMsa2R); ++i) { - run_msa_2r(&tc_b[i], [](MacroAssembler& assm) { __ pcnt_b(w2, w0); }); - run_msa_2r(&tc_h[i], [](MacroAssembler& assm) { __ pcnt_h(w2, w0); }); - run_msa_2r(&tc_w[i], [](MacroAssembler& assm) { __ pcnt_w(w2, w0); }); - run_msa_2r(&tc_d[i], [](MacroAssembler& assm) { __ pcnt_d(w2, w0); }); + run_msa_2r(&tc_b[i], [](MacroAssembler& assm) { __ pcnt_b(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + run_msa_2r(&tc_h[i], [](MacroAssembler& assm) { __ pcnt_h(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + run_msa_2r(&tc_w[i], [](MacroAssembler& assm) { __ pcnt_w(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + run_msa_2r(&tc_d[i], [](MacroAssembler& assm) { __ pcnt_d(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); } } @@ -6826,10 +6911,14 @@ TEST(MSA_nlzc) { {0x00000000e338f8b0, 0x0754534acab32654, 0x20, 0x5}}; for (size_t i = 0; i < sizeof(tc_b) / sizeof(TestCaseMsa2R); ++i) { - run_msa_2r(&tc_b[i], [](MacroAssembler& assm) { __ nlzc_b(w2, w0); }); - run_msa_2r(&tc_h[i], [](MacroAssembler& assm) { __ nlzc_h(w2, w0); }); - run_msa_2r(&tc_w[i], [](MacroAssembler& assm) { __ nlzc_w(w2, w0); }); - run_msa_2r(&tc_d[i], [](MacroAssembler& assm) { __ nlzc_d(w2, w0); }); + run_msa_2r(&tc_b[i], [](MacroAssembler& assm) { __ nlzc_b(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + run_msa_2r(&tc_h[i], [](MacroAssembler& assm) { __ nlzc_h(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + run_msa_2r(&tc_w[i], [](MacroAssembler& assm) { __ nlzc_w(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + run_msa_2r(&tc_d[i], [](MacroAssembler& assm) { __ nlzc_d(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); } } @@ -6881,10 +6970,885 @@ TEST(MSA_nloc) { {0xFFFFFFFF1CC7074F, 0xF8ABACB5354CD9AB, 0x20, 0x5}}; for (size_t i = 0; i < sizeof(tc_b) / sizeof(TestCaseMsa2R); ++i) { - run_msa_2r(&tc_b[i], [](MacroAssembler& assm) { __ nloc_b(w2, w0); }); - run_msa_2r(&tc_h[i], [](MacroAssembler& assm) { __ nloc_h(w2, w0); }); - run_msa_2r(&tc_w[i], [](MacroAssembler& assm) { __ nloc_w(w2, w0); }); - run_msa_2r(&tc_d[i], [](MacroAssembler& assm) { __ nloc_d(w2, w0); }); + run_msa_2r(&tc_b[i], [](MacroAssembler& assm) { __ nloc_b(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + run_msa_2r(&tc_h[i], [](MacroAssembler& assm) { __ nloc_h(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + run_msa_2r(&tc_w[i], [](MacroAssembler& assm) { __ nloc_w(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + run_msa_2r(&tc_d[i], [](MacroAssembler& assm) { __ nloc_d(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + } +} + +struct TestCaseMsa2RF_F_U { + float ws1; + float ws2; + float ws3; + float ws4; + uint32_t exp_res_1; + uint32_t exp_res_2; + uint32_t exp_res_3; + uint32_t exp_res_4; +}; + +struct TestCaseMsa2RF_D_U { + double ws1; + double ws2; + uint64_t exp_res_1; + uint64_t exp_res_2; +}; + +TEST(MSA_fclass) { + if (!IsMipsArchVariant(kMips32r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + +#define BIT(n) (0x1 << n) +#define SNAN BIT(0) +#define QNAN BIT(1) +#define NEG_INFINITY BIT((2)) +#define NEG_NORMAL BIT(3) +#define NEG_SUBNORMAL BIT(4) +#define NEG_ZERO BIT(5) +#define POS_INFINITY BIT(6) +#define POS_NORMAL BIT(7) +#define POS_SUBNORMAL BIT(8) +#define POS_ZERO BIT(9) + + const float inf_float = std::numeric_limits<float>::infinity(); + const double inf_double = std::numeric_limits<double>::infinity(); + + const struct TestCaseMsa2RF_F_U tc_s[] = { + {1.f, -0.00001, 208e10f, -34.8e-30f, POS_NORMAL, NEG_NORMAL, POS_NORMAL, + NEG_NORMAL}, + {inf_float, -inf_float, 0, -0.f, POS_INFINITY, NEG_INFINITY, POS_ZERO, + NEG_ZERO}, + {3.036e-40f, -6.392e-43f, 1.41e-45f, -1.17e-38f, POS_SUBNORMAL, + NEG_SUBNORMAL, POS_SUBNORMAL, NEG_SUBNORMAL}}; + + const struct TestCaseMsa2RF_D_U tc_d[] = { + {1., -0.00000001, POS_NORMAL, NEG_NORMAL}, + {208e10, -34.8e-300, POS_NORMAL, NEG_NORMAL}, + {inf_double, -inf_double, POS_INFINITY, NEG_INFINITY}, + {0, -0., POS_ZERO, NEG_ZERO}, + {1.036e-308, -6.392e-309, POS_SUBNORMAL, NEG_SUBNORMAL}, + {1.41e-323, -3.17e208, POS_SUBNORMAL, NEG_NORMAL}}; + + for (size_t i = 0; i < sizeof(tc_s) / sizeof(TestCaseMsa2RF_F_U); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_s[i]), + [](MacroAssembler& assm) { __ fclass_w(w2, w0); }, + load_uint32_elements_of_vector, store_uint32_elements_of_vector); + } + for (size_t i = 0; i < sizeof(tc_d) / sizeof(TestCaseMsa2RF_D_U); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [](MacroAssembler& assm) { __ fclass_d(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + } + +#undef BIT +#undef SNAN +#undef QNAN +#undef NEG_INFINITY +#undef NEG_NORMAL +#undef NEG_SUBNORMAL +#undef NEG_ZERO +#undef POS_INFINITY +#undef POS_NORMAL +#undef POS_SUBNORMAL +#undef POS_ZERO +} + +struct TestCaseMsa2RF_F_I { + float ws1; + float ws2; + float ws3; + float ws4; + int32_t exp_res_1; + int32_t exp_res_2; + int32_t exp_res_3; + int32_t exp_res_4; +}; + +struct TestCaseMsa2RF_D_I { + double ws1; + double ws2; + int64_t exp_res_1; + int64_t exp_res_2; +}; + +TEST(MSA_ftrunc_s) { + if (!IsMipsArchVariant(kMips32r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + + const float inf_float = std::numeric_limits<float>::infinity(); + const float qNaN_float = std::numeric_limits<float>::quiet_NaN(); + const double inf_double = std::numeric_limits<double>::infinity(); + const double qNaN_double = std::numeric_limits<double>::quiet_NaN(); + const int32_t max_int32 = std::numeric_limits<int32_t>::max(); + const int32_t min_int32 = std::numeric_limits<int32_t>::min(); + const int64_t max_int64 = std::numeric_limits<int64_t>::max(); + const int64_t min_int64 = std::numeric_limits<int64_t>::min(); + + const struct TestCaseMsa2RF_F_I tc_s[] = { + {inf_float, 2.345f, -324.9235f, 30004.51f, max_int32, 2, -324, 30004}, + {-inf_float, -0.983f, 0.0832f, static_cast<float>(max_int32) * 3.f, + min_int32, 0, 0, max_int32}, + {-23.125f, qNaN_float, 2 * static_cast<float>(min_int32), -0.f, -23, 0, + min_int32, 0}}; + + const struct TestCaseMsa2RF_D_I tc_d[] = { + {inf_double, 2.345, max_int64, 2}, + {-324.9235, 246569139.51, -324, 246569139}, + {-inf_double, -0.983, min_int64, 0}, + {0.0832, 6 * static_cast<double>(max_int64), 0, max_int64}, + {-21453889872.94, qNaN_double, -21453889872, 0}, + {2 * static_cast<double>(min_int64), -0., min_int64, 0}}; + + for (size_t i = 0; i < sizeof(tc_s) / sizeof(TestCaseMsa2RF_F_I); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_s[i]), + [](MacroAssembler& assm) { __ ftrunc_s_w(w2, w0); }, + load_uint32_elements_of_vector, store_uint32_elements_of_vector); + } + for (size_t i = 0; i < sizeof(tc_d) / sizeof(TestCaseMsa2RF_D_I); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [](MacroAssembler& assm) { __ ftrunc_s_d(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + } +} + +TEST(MSA_ftrunc_u) { + if (!IsMipsArchVariant(kMips32r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + + const float inf_float = std::numeric_limits<float>::infinity(); + const float qNaN_float = std::numeric_limits<float>::quiet_NaN(); + const double inf_double = std::numeric_limits<double>::infinity(); + const double qNaN_double = std::numeric_limits<double>::quiet_NaN(); + const uint32_t max_uint32 = std::numeric_limits<uint32_t>::max(); + const uint64_t max_uint64 = std::numeric_limits<uint64_t>::max(); + + const struct TestCaseMsa2RF_F_U tc_s[] = { + {inf_float, 2.345f, -324.9235f, 30004.51f, max_uint32, 2, 0, 30004}, + {-inf_float, 0.983f, 0.0832f, static_cast<float>(max_uint32) * 3., 0, 0, + 0, max_uint32}, + {23.125f, qNaN_float, -0.982, -0.f, 23, 0, 0, 0}}; + + const struct TestCaseMsa2RF_D_U tc_d[] = { + {inf_double, 2.345, max_uint64, 2}, + {-324.9235, 246569139.51, 0, 246569139}, + {-inf_double, -0.983, 0, 0}, + {0.0832, 6 * static_cast<double>(max_uint64), 0, max_uint64}, + {21453889872.94, qNaN_double, 21453889872, 0}, + {0.9889, -0., 0, 0}}; + + for (size_t i = 0; i < sizeof(tc_s) / sizeof(TestCaseMsa2RF_F_U); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_s[i]), + [](MacroAssembler& assm) { __ ftrunc_u_w(w2, w0); }, + load_uint32_elements_of_vector, store_uint32_elements_of_vector); + } + for (size_t i = 0; i < sizeof(tc_d) / sizeof(TestCaseMsa2RF_D_U); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [](MacroAssembler& assm) { __ ftrunc_u_d(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + } +} + +struct TestCaseMsa2RF_F_F { + float ws1; + float ws2; + float ws3; + float ws4; + float exp_res_1; + float exp_res_2; + float exp_res_3; + float exp_res_4; +}; + +struct TestCaseMsa2RF_D_D { + double ws1; + double ws2; + double exp_res_1; + double exp_res_2; +}; + +TEST(MSA_fsqrt) { + if (!IsMipsArchVariant(kMips32r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + + const float inf_float = std::numeric_limits<float>::infinity(); + const double inf_double = std::numeric_limits<double>::infinity(); + + const struct TestCaseMsa2RF_F_F tc_s[] = { + {81.f, 576.f, inf_float, -0.f, 9.f, 24.f, inf_float, -0.f}}; + + const struct TestCaseMsa2RF_D_D tc_d[] = {{81., inf_double, 9., inf_double}, + {331776., -0., 576, -0.}}; + + for (size_t i = 0; i < sizeof(tc_s) / sizeof(TestCaseMsa2RF_F_F); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_s[i]), + [](MacroAssembler& assm) { __ fsqrt_w(w2, w0); }, + load_uint32_elements_of_vector, store_uint32_elements_of_vector); + } + for (size_t i = 0; i < sizeof(tc_d) / sizeof(TestCaseMsa2RF_D_D); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [](MacroAssembler& assm) { __ fsqrt_d(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + } +} + +TEST(MSA_frsqrt) { + if (!IsMipsArchVariant(kMips32r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + + const float inf_float = std::numeric_limits<float>::infinity(); + const double inf_double = std::numeric_limits<double>::infinity(); + + const struct TestCaseMsa2RF_F_F tc_s[] = { + {81.f, 576.f, inf_float, -0.f, 1.f / 9.f, 1.f / 24.f, 0.f, -inf_float}, + {0.f, 1.f / 576.f, 1.f / 81.f, 1.f / 4.f, inf_float, 24.f, 9.f, 2.f}}; + + const struct TestCaseMsa2RF_D_D tc_d[] = { + {81., inf_double, 1. / 9., 0.}, + {331776., -0., 1. / 576., -inf_double}, + {0., 1. / 81, inf_double, 9.}}; + + for (size_t i = 0; i < sizeof(tc_s) / sizeof(TestCaseMsa2RF_F_F); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_s[i]), + [](MacroAssembler& assm) { __ frsqrt_w(w2, w0); }, + load_uint32_elements_of_vector, store_uint32_elements_of_vector); + } + for (size_t i = 0; i < sizeof(tc_d) / sizeof(TestCaseMsa2RF_D_D); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [](MacroAssembler& assm) { __ frsqrt_d(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + } +} + +TEST(MSA_frcp) { + if (!IsMipsArchVariant(kMips32r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + + const float inf_float = std::numeric_limits<float>::infinity(); + const double inf_double = std::numeric_limits<double>::infinity(); + + const struct TestCaseMsa2RF_F_F tc_s[] = { + {12.f, 576.f, inf_float, -0.f, 1.f / 12.f, 1.f / 576.f, 0.f, -inf_float}, + {0.f, 1.f / 576.f, -inf_float, 1.f / 400.f, inf_float, 576.f, -0.f, + 400.f}}; + + const struct TestCaseMsa2RF_D_D tc_d[] = { + {81., inf_double, 1. / 81., 0.}, + {331777., -0., 1. / 331777., -inf_double}, + {0., 1. / 80, inf_double, 80.}, + {1. / 40000., -inf_double, 40000., -0.}}; + + for (size_t i = 0; i < sizeof(tc_s) / sizeof(TestCaseMsa2RF_F_F); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_s[i]), + [](MacroAssembler& assm) { __ frcp_w(w2, w0); }, + load_uint32_elements_of_vector, store_uint32_elements_of_vector); + } + for (size_t i = 0; i < sizeof(tc_d) / sizeof(TestCaseMsa2RF_D_D); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [](MacroAssembler& assm) { __ frcp_d(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + } +} + +void test_frint_s(size_t data_size, TestCaseMsa2RF_F_F tc_d[], + int rounding_mode) { + for (size_t i = 0; i < data_size / sizeof(TestCaseMsa2RF_F_F); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [&rounding_mode](MacroAssembler& assm) { + MSAControlRegister msareg = {kMSACSRRegister}; + __ li(t0, static_cast<uint32_t>(rounding_mode)); + __ cfcmsa(t1, msareg); + __ ctcmsa(msareg, t0); + __ frint_w(w2, w0); + __ ctcmsa(msareg, t1); + }, + load_uint32_elements_of_vector, store_uint32_elements_of_vector); + } +} + +void test_frint_d(size_t data_size, TestCaseMsa2RF_D_D tc_d[], + int rounding_mode) { + for (size_t i = 0; i < data_size / sizeof(TestCaseMsa2RF_D_D); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [&rounding_mode](MacroAssembler& assm) { + MSAControlRegister msareg = {kMSACSRRegister}; + __ li(t0, static_cast<uint32_t>(rounding_mode)); + __ cfcmsa(t1, msareg); + __ ctcmsa(msareg, t0); + __ frint_d(w2, w0); + __ ctcmsa(msareg, t1); + }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + } +} + +TEST(MSA_frint) { + if (!IsMipsArchVariant(kMips32r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + + struct TestCaseMsa2RF_F_F tc_s1[] = { + {0.f, 4.51f, 1.49f, -12.51f, 0.f, 5.f, 1.f, -13.f}, + {-1.32f, -23.38f, 2.8f, -32.5f, -1.f, -23.f, 3.f, -32.f}}; + + struct TestCaseMsa2RF_D_D tc_d1[] = {{0., 4.51, 0., 5.}, + {1.49, -12.51, 1., -13.}, + {-1.32, -23.38, -1., -23.}, + {2.8, -32.6, 3., -33.}}; + + test_frint_s(sizeof(tc_s1), tc_s1, kRoundToNearest); + test_frint_d(sizeof(tc_d1), tc_d1, kRoundToNearest); + + struct TestCaseMsa2RF_F_F tc_s2[] = { + {0.f, 4.5f, 1.49f, -12.51f, 0.f, 4.f, 1.f, -12.f}, + {-1.f, -23.38f, 2.8f, -32.6f, -1.f, -23.f, 2.f, -32.f}}; + + struct TestCaseMsa2RF_D_D tc_d2[] = {{0., 4.5, 0., 4.}, + {1.49, -12.51, 1., -12.}, + {-1., -23.38, -1., -23.}, + {2.8, -32.6, 2., -32.}}; + + test_frint_s(sizeof(tc_s2), tc_s2, kRoundToZero); + test_frint_d(sizeof(tc_d2), tc_d2, kRoundToZero); + + struct TestCaseMsa2RF_F_F tc_s3[] = { + {0.f, 4.5f, 1.49f, -12.51f, 0.f, 5.f, 2.f, -12.f}, + {-1.f, -23.38f, 2.8f, -32.6f, -1.f, -23.f, 3.f, -32.f}}; + + struct TestCaseMsa2RF_D_D tc_d3[] = {{0., 4.5, 0., 5.}, + {1.49, -12.51, 2., -12.}, + {-1., -23.38, -1., -23.}, + {2.8, -32.6, 3., -32.}}; + + test_frint_s(sizeof(tc_s3), tc_s3, kRoundToPlusInf); + test_frint_d(sizeof(tc_d3), tc_d3, kRoundToPlusInf); + + struct TestCaseMsa2RF_F_F tc_s4[] = { + {0.f, 4.5f, 1.49f, -12.51f, 0.f, 4.f, 1.f, -13.f}, + {-1.f, -23.38f, 2.8f, -32.6f, -1.f, -24.f, 2.f, -33.f}}; + + struct TestCaseMsa2RF_D_D tc_d4[] = {{0., 4.5, 0., 4.}, + {1.49, -12.51, 1., -13.}, + {-1., -23.38, -1., -24.}, + {2.8, -32.6, 2., -33.}}; + + test_frint_s(sizeof(tc_s4), tc_s4, kRoundToMinusInf); + test_frint_d(sizeof(tc_d4), tc_d4, kRoundToMinusInf); +} + +TEST(MSA_flog2) { + if (!IsMipsArchVariant(kMips32r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + + const float inf_float = std::numeric_limits<float>::infinity(); + const double inf_double = std::numeric_limits<double>::infinity(); + + struct TestCaseMsa2RF_F_F tc_s[] = { + {std::ldexp(0.58f, -48), std::ldexp(0.5f, 110), std::ldexp(1.11f, -130), + inf_float, -49.f, 109.f, -130.f, inf_float}, + {0.f, -0.f, std::ldexp(0.89f, -12), std::ldexp(0.32f, 126), -inf_float, + -inf_float, -13.f, 124.f}}; + + struct TestCaseMsa2RF_D_D tc_d[] = { + {std::ldexp(0.58, -48), std::ldexp(0.5, 110), -49., 109.}, + {std::ldexp(1.11, -1050), inf_double, -1050., inf_double}, + {0., -0., -inf_double, -inf_double}, + {std::ldexp(0.32, 1021), std::ldexp(1.23, -123), 1019., -123.}}; + + for (size_t i = 0; i < sizeof(tc_s) / sizeof(TestCaseMsa2RF_F_F); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_s[i]), + [](MacroAssembler& assm) { __ flog2_w(w2, w0); }, + load_uint32_elements_of_vector, store_uint32_elements_of_vector); + } + + for (size_t i = 0; i < sizeof(tc_d) / sizeof(TestCaseMsa2RF_D_D); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [](MacroAssembler& assm) { __ flog2_d(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + } +} + +void test_ftint_s_s(size_t data_size, TestCaseMsa2RF_F_I tc_d[], + int rounding_mode) { + for (size_t i = 0; i < data_size / sizeof(TestCaseMsa2RF_F_I); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [&rounding_mode](MacroAssembler& assm) { + MSAControlRegister msareg = {kMSACSRRegister}; + __ li(t0, static_cast<uint32_t>(rounding_mode)); + __ cfcmsa(t1, msareg); + __ ctcmsa(msareg, t0); + __ ftint_s_w(w2, w0); + __ ctcmsa(msareg, t1); + }, + load_uint32_elements_of_vector, store_uint32_elements_of_vector); + } +} + +void test_ftint_s_d(size_t data_size, TestCaseMsa2RF_D_I tc_d[], + int rounding_mode) { + for (size_t i = 0; i < data_size / sizeof(TestCaseMsa2RF_D_I); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [&rounding_mode](MacroAssembler& assm) { + MSAControlRegister msareg = {kMSACSRRegister}; + __ li(t0, static_cast<uint32_t>(rounding_mode)); + __ cfcmsa(t1, msareg); + __ ctcmsa(msareg, t0); + __ ftint_s_d(w2, w0); + __ ctcmsa(msareg, t1); + }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + } +} + +TEST(MSA_ftint_s) { + if (!IsMipsArchVariant(kMips32r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + + const float inf_float = std::numeric_limits<float>::infinity(); + const double inf_double = std::numeric_limits<double>::infinity(); + const int32_t int32_max = std::numeric_limits<int32_t>::max(); + const int32_t int32_min = std::numeric_limits<int32_t>::min(); + const int64_t int64_max = std::numeric_limits<int64_t>::max(); + const int64_t int64_min = std::numeric_limits<int64_t>::min(); + + struct TestCaseMsa2RF_F_I tc_s1[] = { + {0.f, 4.51f, 1.49f, -12.51f, 0, 5, 1, -13}, + {-0.32f, -23.38f, 2.8f, -32.6f, 0, -23, 3, -33}, + {inf_float, -inf_float, 3.f * int32_min, 4.f * int32_max, int32_max, + int32_min, int32_min, int32_max}}; + + struct TestCaseMsa2RF_D_I tc_d1[] = { + {0., 4.51, 0, 5}, + {1.49, -12.51, 1, -13}, + {-0.32, -23.38, 0, -23}, + {2.8, -32.6, 3, -33}, + {inf_double, -inf_double, int64_max, int64_min}, + {33.23 * int64_min, 4000. * int64_max, int64_min, int64_max}}; + + test_ftint_s_s(sizeof(tc_s1), tc_s1, kRoundToNearest); + test_ftint_s_d(sizeof(tc_d1), tc_d1, kRoundToNearest); + + struct TestCaseMsa2RF_F_I tc_s2[] = { + {0.f, 4.5f, 1.49f, -12.51f, 0, 4, 1, -12}, + {-0.f, -23.38f, 2.8f, -32.6f, -0, -23, 2, -32}, + {inf_float, -inf_float, 3.f * int32_min, 4.f * int32_max, int32_max, + int32_min, int32_min, int32_max}}; + + struct TestCaseMsa2RF_D_I tc_d2[] = { + {0., 4.5, 0, 4}, + {1.49, -12.51, 1, -12}, + {-0., -23.38, -0, -23}, + {2.8, -32.6, 2, -32}, + {inf_double, -inf_double, int64_max, int64_min}, + {33.23 * int64_min, 4000. * int64_max, int64_min, int64_max}}; + + test_ftint_s_s(sizeof(tc_s2), tc_s2, kRoundToZero); + test_ftint_s_d(sizeof(tc_d2), tc_d2, kRoundToZero); + + struct TestCaseMsa2RF_F_I tc_s3[] = { + {0.f, 4.5f, 1.49f, -12.51f, 0, 5, 2, -12}, + {-0.f, -23.38f, 2.8f, -32.6f, -0, -23, 3, -32}, + {inf_float, -inf_float, 3.f * int32_min, 4.f * int32_max, int32_max, + int32_min, int32_min, int32_max}}; + + struct TestCaseMsa2RF_D_I tc_d3[] = { + {0., 4.5, 0, 5}, + {1.49, -12.51, 2, -12}, + {-0., -23.38, -0, -23}, + {2.8, -32.6, 3, -32}, + {inf_double, -inf_double, int64_max, int64_min}, + {33.23 * int64_min, 4000. * int64_max, int64_min, int64_max}}; + + test_ftint_s_s(sizeof(tc_s3), tc_s3, kRoundToPlusInf); + test_ftint_s_d(sizeof(tc_d3), tc_d3, kRoundToPlusInf); + + struct TestCaseMsa2RF_F_I tc_s4[] = { + {0.f, 4.5f, 1.49f, -12.51f, 0, 4, 1, -13}, + {-0.f, -23.38f, 2.8f, -32.6f, -0, -24, 2, -33}, + {inf_float, -inf_float, 3.f * int32_min, 4.f * int32_max, int32_max, + int32_min, int32_min, int32_max}}; + + struct TestCaseMsa2RF_D_I tc_d4[] = { + {0., 4.5, 0, 4}, + {1.49, -12.51, 1, -13}, + {-0., -23.38, -0, -24}, + {2.8, -32.6, 2, -33}, + {inf_double, -inf_double, int64_max, int64_min}, + {33.23 * int64_min, 4000. * int64_max, int64_min, int64_max}}; + + test_ftint_s_s(sizeof(tc_s4), tc_s4, kRoundToMinusInf); + test_ftint_s_d(sizeof(tc_d4), tc_d4, kRoundToMinusInf); +} + +void test_ftint_u_s(size_t data_size, TestCaseMsa2RF_F_U tc_d[], + int rounding_mode) { + for (size_t i = 0; i < data_size / sizeof(TestCaseMsa2RF_F_U); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [&rounding_mode](MacroAssembler& assm) { + MSAControlRegister msareg = {kMSACSRRegister}; + __ li(t0, static_cast<uint32_t>(rounding_mode)); + __ cfcmsa(t1, msareg); + __ ctcmsa(msareg, t0); + __ ftint_u_w(w2, w0); + __ ctcmsa(msareg, t1); + }, + load_uint32_elements_of_vector, store_uint32_elements_of_vector); + } +} + +void test_ftint_u_d(size_t data_size, TestCaseMsa2RF_D_U tc_d[], + int rounding_mode) { + for (size_t i = 0; i < data_size / sizeof(TestCaseMsa2RF_D_U); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [&rounding_mode](MacroAssembler& assm) { + MSAControlRegister msareg = {kMSACSRRegister}; + __ li(t0, static_cast<uint32_t>(rounding_mode)); + __ cfcmsa(t1, msareg); + __ ctcmsa(msareg, t0); + __ ftint_u_d(w2, w0); + __ ctcmsa(msareg, t1); + }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + } +} + +TEST(MSA_ftint_u) { + if (!IsMipsArchVariant(kMips32r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + + const float inf_float = std::numeric_limits<float>::infinity(); + const double inf_double = std::numeric_limits<double>::infinity(); + const uint32_t uint32_max = std::numeric_limits<uint32_t>::max(); + const uint64_t uint64_max = std::numeric_limits<uint64_t>::max(); + + struct TestCaseMsa2RF_F_U tc_s1[] = { + {0.f, 4.51f, 1.49f, -12.51f, 0, 5, 1, 0}, + {-0.32f, 23.38f, 2.8f, 32.6f, 0, 23, 3, 33}, + {inf_float, -inf_float, 0, 4.f * uint32_max, uint32_max, 0, 0, + uint32_max}}; + + struct TestCaseMsa2RF_D_U tc_d1[] = { + {0., 4.51, 0, 5}, + {1.49, -12.51, 1, 0}, + {-0.32, 23.38, 0, 23}, + {2.8, 32.6, 3, 33}, + {inf_double, -inf_double, uint64_max, 0}, + {-0., 4000. * uint64_max, 0, uint64_max}}; + + test_ftint_u_s(sizeof(tc_s1), tc_s1, kRoundToNearest); + test_ftint_u_d(sizeof(tc_d1), tc_d1, kRoundToNearest); + + struct TestCaseMsa2RF_F_U tc_s2[] = { + {0.f, 4.5f, 1.49f, -12.51f, 0, 4, 1, 0}, + {-0.f, 23.38f, 2.8f, 32.6f, 0, 23, 2, 32}, + {inf_float, -inf_float, 0., 4.f * uint32_max, uint32_max, 0, 0, + uint32_max}}; + + struct TestCaseMsa2RF_D_U tc_d2[] = { + {0., 4.5, 0, 4}, + {1.49, -12.51, 1, 0}, + {-0., 23.38, 0, 23}, + {2.8, 32.6, 2, 32}, + {inf_double, -inf_double, uint64_max, 0}, + {-0.2345, 4000. * uint64_max, 0, uint64_max}}; + + test_ftint_u_s(sizeof(tc_s2), tc_s2, kRoundToZero); + test_ftint_u_d(sizeof(tc_d2), tc_d2, kRoundToZero); + + struct TestCaseMsa2RF_F_U tc_s3[] = { + {0.f, 4.5f, 1.49f, -12.51f, 0, 5, 2, 0}, + {-0.f, 23.38f, 2.8f, 32.6f, 0, 24, 3, 33}, + {inf_float, -inf_float, 0, 4.f * uint32_max, uint32_max, 0, 0, + uint32_max}}; + + struct TestCaseMsa2RF_D_U tc_d3[] = { + {0., 4.5, 0, 5}, + {1.49, -12.51, 2, 0}, + {-0., 23.38, -0, 24}, + {2.8, 32.6, 3, 33}, + {inf_double, -inf_double, uint64_max, 0}, + {-0.5252, 4000. * uint64_max, 0, uint64_max}}; + + test_ftint_u_s(sizeof(tc_s3), tc_s3, kRoundToPlusInf); + test_ftint_u_d(sizeof(tc_d3), tc_d3, kRoundToPlusInf); + + struct TestCaseMsa2RF_F_U tc_s4[] = { + {0.f, 4.5f, 1.49f, -12.51f, 0, 4, 1, 0}, + {-0.f, 23.38f, 2.8f, 32.6f, 0, 23, 2, 32}, + {inf_float, -inf_float, 0, 4.f * uint32_max, uint32_max, 0, 0, + uint32_max}}; + + struct TestCaseMsa2RF_D_U tc_d4[] = { + {0., 4.5, 0, 4}, + {1.49, -12.51, 1, 0}, + {-0., 23.38, -0, 23}, + {2.8, 32.6, 2, 32}, + {inf_double, -inf_double, uint64_max, 0}, + {-0.098797, 4000. * uint64_max, 0, uint64_max}}; + + test_ftint_u_s(sizeof(tc_s4), tc_s4, kRoundToMinusInf); + test_ftint_u_d(sizeof(tc_d4), tc_d4, kRoundToMinusInf); +} + +struct TestCaseMsa2RF_U_F { + uint32_t ws1; + uint32_t ws2; + uint32_t ws3; + uint32_t ws4; + float exp_res_1; + float exp_res_2; + float exp_res_3; + float exp_res_4; +}; + +struct TestCaseMsa2RF_U_D { + uint64_t ws1; + uint64_t ws2; + double exp_res_1; + double exp_res_2; +}; + +TEST(MSA_ffint_u) { + if (!IsMipsArchVariant(kMips32r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + + struct TestCaseMsa2RF_U_F tc_s[] = { + {0, 345, 234, 1000, 0.f, 345.f, 234.f, 1000.f}}; + + struct TestCaseMsa2RF_U_D tc_d[] = {{0, 345, 0., 345.}, + {234, 1000, 234., 1000.}}; + + for (size_t i = 0; i < sizeof(tc_s) / sizeof(TestCaseMsa2RF_U_F); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_s[i]), + [](MacroAssembler& assm) { __ ffint_u_w(w2, w0); }, + load_uint32_elements_of_vector, store_uint32_elements_of_vector); + } + for (size_t i = 0; i < sizeof(tc_d) / sizeof(TestCaseMsa2RF_U_D); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [](MacroAssembler& assm) { __ ffint_u_d(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + } +} + +struct TestCaseMsa2RF_I_F { + int32_t ws1; + int32_t ws2; + int32_t ws3; + int32_t ws4; + float exp_res_1; + float exp_res_2; + float exp_res_3; + float exp_res_4; +}; + +struct TestCaseMsa2RF_I_D { + int64_t ws1; + int64_t ws2; + double exp_res_1; + double exp_res_2; +}; + +TEST(MSA_ffint_s) { + if (!IsMipsArchVariant(kMips32r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + + struct TestCaseMsa2RF_I_F tc_s[] = { + {0, 345, -234, 1000, 0.f, 345.f, -234.f, 1000.f}}; + + struct TestCaseMsa2RF_I_D tc_d[] = {{0, 345, 0., 345.}, + {-234, 1000, -234., 1000.}}; + + for (size_t i = 0; i < sizeof(tc_s) / sizeof(TestCaseMsa2RF_I_F); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_s[i]), + [](MacroAssembler& assm) { __ ffint_s_w(w2, w0); }, + load_uint32_elements_of_vector, store_uint32_elements_of_vector); + } + for (size_t i = 0; i < sizeof(tc_d) / sizeof(TestCaseMsa2RF_I_D); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [](MacroAssembler& assm) { __ ffint_s_d(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + } +} + +struct TestCaseMsa2RF_U16_F { + uint16_t ws1; + uint16_t ws2; + uint16_t ws3; + uint16_t ws4; + uint16_t ws5; + uint16_t ws6; + uint16_t ws7; + uint16_t ws8; + float exp_res_1; + float exp_res_2; + float exp_res_3; + float exp_res_4; +}; + +struct TestCaseMsa2RF_F_D { + float ws1; + float ws2; + float ws3; + float ws4; + double exp_res_1; + double exp_res_2; +}; + +TEST(MSA_fexupl) { + if (!IsMipsArchVariant(kMips32r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + + const float inf_float = std::numeric_limits<float>::infinity(); + const double inf_double = std::numeric_limits<double>::infinity(); + + struct TestCaseMsa2RF_U16_F tc_s[] = { + {1, 2, 0x7c00, 0x0c00, 0, 0x7c00, 0xfc00, 0x8000, 0.f, inf_float, + -inf_float, -0.f}, + {0xfc00, 0xffff, 0x00ff, 0x8000, 0x81fe, 0x8000, 0x0345, 0xaaaa, + -3.0398368835e-5f, -0.f, 4.9889088e-5f, -5.2062988281e-2f}, + {3, 4, 0x5555, 6, 0x2aaa, 0x8700, 0x7777, 0x6a8b, 5.2062988281e-2f, + -1.06811523458e-4f, 3.0576e4f, 3.35e3f}}; + + struct TestCaseMsa2RF_F_D tc_d[] = { + {0.f, 123.456f, inf_float, -0.f, inf_double, -0.}, + {-inf_float, -3.f, 0.f, -inf_float, 0., -inf_double}, + {2.3f, 3., 1.37747639043129518071e-41f, -3.22084585277826e35f, + 1.37747639043129518071e-41, -3.22084585277826e35}}; + + for (size_t i = 0; i < sizeof(tc_s) / sizeof(TestCaseMsa2RF_U16_F); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_s[i]), + [](MacroAssembler& assm) { __ fexupl_w(w2, w0); }, + load_uint16_elements_of_vector, store_uint32_elements_of_vector); + } + for (size_t i = 0; i < sizeof(tc_d) / sizeof(TestCaseMsa2RF_F_D); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [](MacroAssembler& assm) { __ fexupl_d(w2, w0); }, + load_uint32_elements_of_vector, store_uint64_elements_of_vector); + } +} + +TEST(MSA_fexupr) { + if (!IsMipsArchVariant(kMips32r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + + const float inf_float = std::numeric_limits<float>::infinity(); + const double inf_double = std::numeric_limits<double>::infinity(); + + struct TestCaseMsa2RF_U16_F tc_s[] = { + {0, 0x7c00, 0xfc00, 0x8000, 1, 2, 0x7c00, 0x0c00, 0.f, inf_float, + -inf_float, -0.f}, + {0x81fe, 0x8000, 0x0345, 0xaaaa, 0xfc00, 0xffff, 0x00ff, 0x8000, + -3.0398368835e-5f, -0.f, 4.9889088e-5f, -5.2062988281e-2f}, + {0x2aaa, 0x8700, 0x7777, 0x6a8b, 3, 4, 0x5555, 6, 5.2062988281e-2f, + -1.06811523458e-4f, 3.0576e4f, 3.35e3f}}; + + struct TestCaseMsa2RF_F_D tc_d[] = { + {inf_float, -0.f, 0.f, 123.456f, inf_double, -0.}, + {0.f, -inf_float, -inf_float, -3.f, 0., -inf_double}, + {1.37747639043129518071e-41f, -3.22084585277826e35f, 2.3f, 3., + 1.37747639043129518071e-41, -3.22084585277826e35}}; + + for (size_t i = 0; i < sizeof(tc_s) / sizeof(TestCaseMsa2RF_U16_F); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_s[i]), + [](MacroAssembler& assm) { __ fexupr_w(w2, w0); }, + load_uint16_elements_of_vector, store_uint32_elements_of_vector); + } + for (size_t i = 0; i < sizeof(tc_d) / sizeof(TestCaseMsa2RF_F_D); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [](MacroAssembler& assm) { __ fexupr_d(w2, w0); }, + load_uint32_elements_of_vector, store_uint64_elements_of_vector); + } +} + +struct TestCaseMsa2RF_U32_D { + uint32_t ws1; + uint32_t ws2; + uint32_t ws3; + uint32_t ws4; + double exp_res_1; + double exp_res_2; +}; + +TEST(MSA_ffql) { + if (!IsMipsArchVariant(kMips32r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + + struct TestCaseMsa2RF_U16_F tc_s[] = {{0, 3, 0xffff, 0x8000, 0x8000, 0xe000, + 0x0FF0, 0, -1.f, -0.25f, + 0.12451171875f, 0.f}}; + + struct TestCaseMsa2RF_U32_D tc_d[] = { + {0, 45, 0x80000000, 0xe0000000, -1., -0.25}, + {0x28379, 0xaaaa5555, 0x024903d3, 0, 17.853239085525274277e-3, 0.}}; + + for (size_t i = 0; i < sizeof(tc_s) / sizeof(TestCaseMsa2RF_U16_F); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_s[i]), + [](MacroAssembler& assm) { __ ffql_w(w2, w0); }, + load_uint16_elements_of_vector, store_uint32_elements_of_vector); + } + for (size_t i = 0; i < sizeof(tc_d) / sizeof(TestCaseMsa2RF_U32_D); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [](MacroAssembler& assm) { __ ffql_d(w2, w0); }, + load_uint32_elements_of_vector, store_uint64_elements_of_vector); + } +} + +TEST(MSA_ffqr) { + if (!IsMipsArchVariant(kMips32r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + + struct TestCaseMsa2RF_U16_F tc_s[] = {{0x8000, 0xe000, 0x0FF0, 0, 0, 3, + 0xffff, 0x8000, -1.f, -0.25f, + 0.12451171875f, 0.f}}; + + struct TestCaseMsa2RF_U32_D tc_d[] = { + {0x80000000, 0xe0000000, 0, 45, -1., -0.25}, + {0x024903d3, 0, 0x28379, 0xaaaa5555, 17.853239085525274277e-3, 0.}}; + + for (size_t i = 0; i < sizeof(tc_s) / sizeof(TestCaseMsa2RF_U16_F); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_s[i]), + [](MacroAssembler& assm) { __ ffqr_w(w2, w0); }, + load_uint16_elements_of_vector, store_uint32_elements_of_vector); + } + for (size_t i = 0; i < sizeof(tc_d) / sizeof(TestCaseMsa2RF_U32_D); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [](MacroAssembler& assm) { __ ffqr_d(w2, w0); }, + load_uint32_elements_of_vector, store_uint64_elements_of_vector); } } @@ -6908,39 +7872,21 @@ void run_msa_vector(struct TestCaseMsaVector* input, CpuFeatureScope fscope(&assm, MIPS_SIMD); msa_reg_t res; -#define LOAD_W_REG(lo, hi, w_reg) \ - __ li(t0, static_cast<uint32_t>(lo & 0xffffffff)); \ - __ li(t1, static_cast<uint32_t>((lo >> 32) & 0xffffffff)); \ - __ insert_w(w_reg, 0, t0); \ - __ insert_w(w_reg, 1, t1); \ - __ li(t0, static_cast<uint32_t>(hi & 0xffffffff)); \ - __ li(t1, static_cast<uint32_t>((hi >> 32) & 0xffffffff)); \ - __ insert_w(w_reg, 2, t0); \ - __ insert_w(w_reg, 3, t1) - - LOAD_W_REG(input->ws_lo, input->ws_hi, w0); - LOAD_W_REG(input->wt_lo, input->wt_hi, w2); - LOAD_W_REG(input->wd_lo, input->wd_hi, w4); -#undef LOAD_W_REG + load_uint64_elements_of_vector(assm, &(input->ws_lo), w0, t0, t1); + load_uint64_elements_of_vector(assm, &(input->wt_lo), w2, t0, t1); + load_uint64_elements_of_vector(assm, &(input->wd_lo), w4, t0, t1); GenerateVectorInstructionFunc(assm); - __ copy_u_w(t2, w4, 0); - __ sw(t2, MemOperand(a0, 0)); - __ copy_u_w(t2, w4, 1); - __ sw(t2, MemOperand(a0, 4)); - __ copy_u_w(t2, w4, 2); - __ sw(t2, MemOperand(a0, 8)); - __ copy_u_w(t2, w4, 3); - __ sw(t2, MemOperand(a0, 12)); + store_uint64_elements_of_vector(assm, w4, a0, t2); __ jr(ra); __ nop(); CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -7015,38 +7961,20 @@ void run_msa_bit(struct TestCaseMsaBit* input, InstFunc GenerateInstructionFunc, CpuFeatureScope fscope(&assm, MIPS_SIMD); msa_reg_t res; -#define LOAD_W_REG(lo, hi, w_reg) \ - __ li(t0, static_cast<uint32_t>(lo & 0xffffffff)); \ - __ li(t1, static_cast<uint32_t>((lo >> 32) & 0xffffffff)); \ - __ insert_w(w_reg, 0, t0); \ - __ insert_w(w_reg, 1, t1); \ - __ li(t0, static_cast<uint32_t>(hi & 0xffffffff)); \ - __ li(t1, static_cast<uint32_t>((hi >> 32) & 0xffffffff)); \ - __ insert_w(w_reg, 2, t0); \ - __ insert_w(w_reg, 3, t1) - - LOAD_W_REG(input->ws_lo, input->ws_hi, w0); - LOAD_W_REG(input->wd_lo, input->wd_hi, w2); -#undef LOAD_W_REG + load_uint64_elements_of_vector(assm, &(input->ws_lo), w0, t0, t1); + load_uint64_elements_of_vector(assm, &(input->wd_lo), w2, t0, t1); GenerateInstructionFunc(assm, input->m); - __ copy_u_w(t2, w2, 0); - __ sw(t2, MemOperand(a0, 0)); - __ copy_u_w(t2, w2, 1); - __ sw(t2, MemOperand(a0, 4)); - __ copy_u_w(t2, w2, 2); - __ sw(t2, MemOperand(a0, 8)); - __ copy_u_w(t2, w2, 3); - __ sw(t2, MemOperand(a0, 12)); + store_uint64_elements_of_vector(assm, w2, a0, t2); __ jr(ra); __ nop(); CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -7511,22 +8439,15 @@ void run_msa_i10(int32_t input, InstFunc GenerateVectorInstructionFunc, GenerateVectorInstructionFunc(assm, input); - __ copy_u_w(t2, w0, 0); - __ sw(t2, MemOperand(a0, 0)); - __ copy_u_w(t2, w0, 1); - __ sw(t2, MemOperand(a0, 4)); - __ copy_u_w(t2, w0, 2); - __ sw(t2, MemOperand(a0, 8)); - __ copy_u_w(t2, w0, 3); - __ sw(t2, MemOperand(a0, 12)); + store_uint64_elements_of_vector(assm, w0, a0, t2); __ jr(ra); __ nop(); CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -7603,8 +8524,8 @@ void run_msa_mi10(InstFunc GenerateVectorInstructionFunc) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -7649,4 +8570,783 @@ TEST(MSA_load_store_vector) { #undef LDI_DF } +struct TestCaseMsa3R { + uint64_t ws_lo; + uint64_t ws_hi; + uint64_t wt_lo; + uint64_t wt_hi; + uint64_t wd_lo; + uint64_t wd_hi; +}; + +static const uint64_t Unpredictable = 0x312014017725ll; + +template <typename InstFunc, typename OperFunc> +void run_msa_3r(struct TestCaseMsa3R* input, InstFunc GenerateI5InstructionFunc, + OperFunc GenerateOperationFunc) { + Isolate* isolate = CcTest::i_isolate(); + HandleScope scope(isolate); + + MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); + CpuFeatureScope fscope(&assm, MIPS_SIMD); + msa_reg_t res; + uint64_t expected; + + load_uint64_elements_of_vector(assm, &(input->wt_lo), w0, t0, t1); + load_uint64_elements_of_vector(assm, &(input->ws_lo), w1, t0, t1); + load_uint64_elements_of_vector(assm, &(input->wd_lo), w2, t0, t1); + + GenerateI5InstructionFunc(assm); + + store_uint64_elements_of_vector(assm, w2, a0, t2); + + __ jr(ra); + __ nop(); + + CodeDesc desc; + assm.GetCode(isolate, &desc); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); +#ifdef OBJECT_PRINT + code->Print(std::cout); +#endif + F3 f = FUNCTION_CAST<F3>(code->entry()); + + (CALL_GENERATED_CODE(isolate, f, &res, 0, 0, 0, 0)); + + expected = GenerateOperationFunc(input->ws_lo, input->wt_lo, input->wd_lo); + if (expected != Unpredictable) { + CHECK_EQ(expected, res.d[0]); + } + + expected = GenerateOperationFunc(input->ws_hi, input->wt_hi, input->wd_hi); + if (expected != Unpredictable) { + CHECK_EQ(expected, res.d[1]); + } +} + +TEST(MSA_3R_instructions) { + if (!IsMipsArchVariant(kMips32r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + + struct TestCaseMsa3R tc[] = { + {0x1169751bb9a7d9c3, 0xf7a594aec8ef8a9c, 0x1169751bb9a7d9c3, + 0xf7a594aec8ef8a9c, 0x1169751bb9a7d9c3, 0xf7a594aec8ef8a9c}, + {0x2b665362c4e812df, 0x3a0d80d68b3f8bc8, 0x2b665362c4e812df, + 0x3a0d80d68b3f8bc8, 0x2b665362c4e812df, 0x3a0d80d68b3f8bc8}, + {0x1169751bb9a7d9c3, 0xf7a594aec8ef8a9c, 0x1169751bb9a7d9c3, + 0xf7a594aec8ef8a9c, 0x1169751bb9a7d9c3, 0xf7a594aec8ef8a9c}, + {0x2b665362c4e812df, 0x3a0d80d68b3f8bc8, 0x2b665362c4e812df, + 0x3a0d80d68b3f8bc8, 0x2b665362c4e812df, 0x3a0d80d68b3f8bc8}, + {0xffab807f807fffcd, 0x7f23ff80ff567f80, 0xffab807f807fffcd, + 0x7f23ff80ff567f80, 0xffab807f807fffcd, 0x7f23ff80ff567f80}, + {0x80ffefff7f12807f, 0x807f80ff7fdeff78, 0x80ffefff7f12807f, + 0x807f80ff7fdeff78, 0x80ffefff7f12807f, 0x807f80ff7fdeff78}, + {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, + 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}, + {0x0000000000000000, 0xffffffffffffffff, 0xffffffffffffffff, + 0x0000000000000000, 0x0000000000000000, 0xffffffffffffffff}, + {0xffff0000ffff0000, 0xffff0000ffff0000, 0xffff0000ffff0000, + 0xffff0000ffff0000, 0xffff0000ffff0000, 0xffff0000ffff0000}, + {0xff00ff00ff00ff00, 0xff00ff00ff00ff00, 0xff00ff00ff00ff00, + 0xff00ff00ff00ff00, 0xff00ff00ff00ff00, 0xff00ff00ff00ff00}, + {0xf0f0f0f0f0f0f0f0, 0xf0f0f0f0f0f0f0f0, 0xf0f0f0f0f0f0f0f0, + 0xf0f0f0f0f0f0f0f0, 0xf0f0f0f0f0f0f0f0, 0xf0f0f0f0f0f0f0f0}, + {0xff0000ffff0000ff, 0xff0000ffff0000ff, 0xff0000ffff0000ff, + 0xff0000ffff0000ff, 0xff0000ffff0000ff, 0xff0000ffff0000ff}, + {0xffff00000000ffff, 0xffff00000000ffff, 0xffff00000000ffff, + 0xffff00000000ffff, 0xffff00000000ffff, 0xffff00000000ffff}}; + +#define SLL_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T src_op = static_cast<T>((ws >> shift) & mask); \ + T shift_op = static_cast<T>((wt >> shift) & mask) % size_in_bits; \ + res |= (static_cast<uint64_t>(src_op << shift_op) & mask) << shift; \ + } \ + return res + +#define SRA_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T src_op = static_cast<T>((ws >> shift) & mask); \ + T shift_op = ((wt >> shift) & mask) % size_in_bits; \ + res |= \ + (static_cast<uint64_t>(ArithmeticShiftRight(src_op, shift_op) & mask)) \ + << shift; \ + } \ + return res + +#define SRL_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T src_op = static_cast<T>((ws >> shift) & mask); \ + T shift_op = static_cast<T>(((wt >> shift) & mask) % size_in_bits); \ + res |= (static_cast<uint64_t>(src_op >> shift_op) & mask) << shift; \ + } \ + return res + +#define BCRL_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T src_op = static_cast<T>((ws >> shift) & mask); \ + T shift_op = static_cast<T>(((wt >> shift) & mask) % size_in_bits); \ + T r = (static_cast<T>(~(1ull << shift_op)) & src_op) & mask; \ + res |= static_cast<uint64_t>(r) << shift; \ + } \ + return res + +#define BSET_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T src_op = static_cast<T>((ws >> shift) & mask); \ + T shift_op = static_cast<T>(((wt >> shift) & mask) % size_in_bits); \ + T r = (static_cast<T>(1ull << shift_op) | src_op) & mask; \ + res |= static_cast<uint64_t>(r) << shift; \ + } \ + return res + +#define BNEG_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T src_op = static_cast<T>((ws >> shift) & mask); \ + T shift_op = static_cast<T>(((wt >> shift) & mask) % size_in_bits); \ + T r = (static_cast<T>(1ull << shift_op) ^ src_op) & mask; \ + res |= static_cast<uint64_t>(r) << shift; \ + } \ + return res + +#define BINSL_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wd_op = static_cast<T>((wd >> shift) & mask); \ + T shift_op = static_cast<T>(((wt >> shift) & mask) % size_in_bits); \ + int bits = shift_op + 1; \ + T r; \ + if (bits == size_in_bits) { \ + r = static_cast<T>(ws_op); \ + } else { \ + uint64_t mask2 = ((1ull << bits) - 1) << (size_in_bits - bits); \ + r = static_cast<T>((static_cast<T>(mask2) & ws_op) | \ + (static_cast<T>(~mask2) & wd_op)); \ + } \ + res |= static_cast<uint64_t>(r) << shift; \ + } \ + return res + +#define BINSR_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wd_op = static_cast<T>((wd >> shift) & mask); \ + T shift_op = static_cast<T>(((wt >> shift) & mask) % size_in_bits); \ + int bits = shift_op + 1; \ + T r; \ + if (bits == size_in_bits) { \ + r = static_cast<T>(ws_op); \ + } else { \ + uint64_t mask2 = (1ull << bits) - 1; \ + r = static_cast<T>((static_cast<T>(mask2) & ws_op) | \ + (static_cast<T>(~mask2) & wd_op)); \ + } \ + res |= static_cast<uint64_t>(r) << shift; \ + } \ + return res + +#define ADDV_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + res |= (static_cast<uint64_t>(ws_op + wt_op) & mask) << shift; \ + } \ + return res + +#define SUBV_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + res |= (static_cast<uint64_t>(ws_op - wt_op) & mask) << shift; \ + } \ + return res + +#define MAX_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + res |= (static_cast<uint64_t>(Max<T>(ws_op, wt_op)) & mask) << shift; \ + } \ + return res + +#define MIN_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + res |= (static_cast<uint64_t>(Min<T>(ws_op, wt_op)) & mask) << shift; \ + } \ + return res + +#define MAXA_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + res |= (static_cast<uint64_t>(Nabs(ws_op) < Nabs(wt_op) ? ws_op : wt_op) & \ + mask) \ + << shift; \ + } \ + return res + +#define MINA_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + res |= (static_cast<uint64_t>(Nabs(ws_op) > Nabs(wt_op) ? ws_op : wt_op) & \ + mask) \ + << shift; \ + } \ + return res + +#define CEQ_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + res |= \ + (static_cast<uint64_t>(!Compare(ws_op, wt_op) ? -1ull : 0ull) & mask) \ + << shift; \ + } \ + return res + +#define CLT_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + res |= \ + (static_cast<uint64_t>((Compare(ws_op, wt_op) == -1) ? -1ull : 0ull) & \ + mask) \ + << shift; \ + } \ + return res + +#define CLE_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + res |= \ + (static_cast<uint64_t>((Compare(ws_op, wt_op) != 1) ? -1ull : 0ull) & \ + mask) \ + << shift; \ + } \ + return res + +#define ADD_A_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + res |= (static_cast<uint64_t>(Abs(ws_op) + Abs(wt_op)) & mask) << shift; \ + } \ + return res + +#define ADDS_A_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = Nabs(static_cast<T>((ws >> shift) & mask)); \ + T wt_op = Nabs(static_cast<T>((wt >> shift) & mask)); \ + T r; \ + if (ws_op < -std::numeric_limits<T>::max() - wt_op) { \ + r = std::numeric_limits<T>::max(); \ + } else { \ + r = -(ws_op + wt_op); \ + } \ + res |= (static_cast<uint64_t>(r) & mask) << shift; \ + } \ + return res + +#define ADDS_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + res |= (static_cast<uint64_t>(SaturateAdd(ws_op, wt_op)) & mask) << shift; \ + } \ + return res + +#define AVE_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + res |= (static_cast<uint64_t>(((wt_op & ws_op) + ((ws_op ^ wt_op) >> 1)) & \ + mask)) \ + << shift; \ + } \ + return res + +#define AVER_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + res |= (static_cast<uint64_t>(((wt_op | ws_op) - ((ws_op ^ wt_op) >> 1)) & \ + mask)) \ + << shift; \ + } \ + return res + +#define SUBS_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + res |= (static_cast<uint64_t>(SaturateSub(ws_op, wt_op)) & mask) << shift; \ + } \ + return res + +#define SUBSUS_U_DF(T, lanes, mask) \ + typedef typename std::make_unsigned<T>::type uT; \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + uT ws_op = static_cast<uT>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + T r; \ + if (wt_op > 0) { \ + uT wtu = static_cast<uT>(wt_op); \ + if (wtu > ws_op) { \ + r = 0; \ + } else { \ + r = static_cast<T>(ws_op - wtu); \ + } \ + } else { \ + if (ws_op > std::numeric_limits<uT>::max() + wt_op) { \ + r = static_cast<T>(std::numeric_limits<uT>::max()); \ + } else { \ + r = static_cast<T>(ws_op - wt_op); \ + } \ + } \ + res |= (static_cast<uint64_t>(r) & mask) << shift; \ + } \ + return res + +#define SUBSUU_S_DF(T, lanes, mask) \ + typedef typename std::make_unsigned<T>::type uT; \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + uT ws_op = static_cast<uT>((ws >> shift) & mask); \ + uT wt_op = static_cast<uT>((wt >> shift) & mask); \ + uT wdu; \ + T r; \ + if (ws_op > wt_op) { \ + wdu = ws_op - wt_op; \ + if (wdu > std::numeric_limits<T>::max()) { \ + r = std::numeric_limits<T>::max(); \ + } else { \ + r = static_cast<T>(wdu); \ + } \ + } else { \ + wdu = wt_op - ws_op; \ + CHECK(-std::numeric_limits<T>::max() == \ + std::numeric_limits<T>::min() + 1); \ + if (wdu <= std::numeric_limits<T>::max()) { \ + r = -static_cast<T>(wdu); \ + } else { \ + r = std::numeric_limits<T>::min(); \ + } \ + } \ + res |= (static_cast<uint64_t>(r) & mask) << shift; \ + } \ + return res + +#define ASUB_S_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + res |= (static_cast<uint64_t>(Abs(ws_op - wt_op)) & mask) << shift; \ + } \ + return res + +#define ASUB_U_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + res |= (static_cast<uint64_t>(ws_op > wt_op ? ws_op - wt_op \ + : wt_op - ws_op) & \ + mask) \ + << shift; \ + } \ + return res + +#define MULV_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + res |= (static_cast<uint64_t>(ws_op * wt_op) & mask) << shift; \ + } \ + return res + +#define MADDV_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + T wd_op = static_cast<T>((wd >> shift) & mask); \ + res |= (static_cast<uint64_t>(wd_op + ws_op * wt_op) & mask) << shift; \ + } \ + return res + +#define MSUBV_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + T wd_op = static_cast<T>((wd >> shift) & mask); \ + res |= (static_cast<uint64_t>(wd_op - ws_op * wt_op) & mask) << shift; \ + } \ + return res + +#define DIV_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + if (wt_op == 0) { \ + res = Unpredictable; \ + break; \ + } \ + res |= (static_cast<uint64_t>(ws_op / wt_op) & mask) << shift; \ + } \ + return res + +#define MOD_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + if (wt_op == 0) { \ + res = Unpredictable; \ + break; \ + } \ + res |= (static_cast<uint64_t>(wt_op != 0 ? ws_op % wt_op : 0) & mask) \ + << shift; \ + } \ + return res + +#define SRAR_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T src_op = static_cast<T>((ws >> shift) & mask); \ + T shift_op = ((wt >> shift) & mask) % size_in_bits; \ + uint32_t bit = shift_op == 0 ? 0 : src_op >> (shift_op - 1) & 1; \ + res |= \ + (static_cast<uint64_t>(ArithmeticShiftRight(src_op, shift_op) + bit) & \ + mask) \ + << shift; \ + } \ + return res + +#define TEST_CASE(V) \ + V(sll_b, SLL_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(sll_h, SLL_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(sll_w, SLL_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(sll_d, SLL_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(sra_b, SRA_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(sra_h, SRA_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(sra_w, SRA_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(sra_d, SRA_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(srl_b, SRL_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(srl_h, SRL_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(srl_w, SRL_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(srl_d, SRL_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(bclr_b, BCRL_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(bclr_h, BCRL_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(bclr_w, BCRL_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(bclr_d, BCRL_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(bset_b, BSET_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(bset_h, BSET_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(bset_w, BSET_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(bset_d, BSET_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(bneg_b, BNEG_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(bneg_h, BNEG_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(bneg_w, BNEG_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(bneg_d, BNEG_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(binsl_b, BINSL_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(binsl_h, BINSL_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(binsl_w, BINSL_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(binsl_d, BINSL_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(binsr_b, BINSR_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(binsr_h, BINSR_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(binsr_w, BINSR_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(binsr_d, BINSR_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(addv_b, ADDV_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(addv_h, ADDV_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(addv_w, ADDV_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(addv_d, ADDV_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(subv_b, SUBV_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(subv_h, SUBV_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(subv_w, SUBV_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(subv_d, SUBV_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(max_s_b, MAX_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(max_s_h, MAX_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(max_s_w, MAX_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(max_s_d, MAX_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(max_u_b, MAX_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(max_u_h, MAX_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(max_u_w, MAX_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(max_u_d, MAX_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(min_s_b, MIN_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(min_s_h, MIN_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(min_s_w, MIN_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(min_s_d, MIN_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(min_u_b, MIN_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(min_u_h, MIN_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(min_u_w, MIN_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(min_u_d, MIN_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(max_a_b, MAXA_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(max_a_h, MAXA_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(max_a_w, MAXA_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(max_a_d, MAXA_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(min_a_b, MINA_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(min_a_h, MINA_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(min_a_w, MINA_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(min_a_d, MINA_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(ceq_b, CEQ_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(ceq_h, CEQ_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(ceq_w, CEQ_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(ceq_d, CEQ_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(clt_s_b, CLT_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(clt_s_h, CLT_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(clt_s_w, CLT_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(clt_s_d, CLT_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(clt_u_b, CLT_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(clt_u_h, CLT_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(clt_u_w, CLT_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(clt_u_d, CLT_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(cle_s_b, CLE_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(cle_s_h, CLE_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(cle_s_w, CLE_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(cle_s_d, CLE_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(cle_u_b, CLE_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(cle_u_h, CLE_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(cle_u_w, CLE_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(cle_u_d, CLE_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(add_a_b, ADD_A_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(add_a_h, ADD_A_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(add_a_w, ADD_A_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(add_a_d, ADD_A_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(adds_a_b, ADDS_A_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(adds_a_h, ADDS_A_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(adds_a_w, ADDS_A_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(adds_a_d, ADDS_A_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(adds_s_b, ADDS_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(adds_s_h, ADDS_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(adds_s_w, ADDS_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(adds_s_d, ADDS_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(adds_u_b, ADDS_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(adds_u_h, ADDS_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(adds_u_w, ADDS_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(adds_u_d, ADDS_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(ave_s_b, AVE_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(ave_s_h, AVE_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(ave_s_w, AVE_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(ave_s_d, AVE_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(ave_u_b, AVE_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(ave_u_h, AVE_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(ave_u_w, AVE_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(ave_u_d, AVE_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(aver_s_b, AVER_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(aver_s_h, AVER_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(aver_s_w, AVER_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(aver_s_d, AVER_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(aver_u_b, AVER_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(aver_u_h, AVER_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(aver_u_w, AVER_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(aver_u_d, AVER_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(subs_s_b, SUBS_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(subs_s_h, SUBS_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(subs_s_w, SUBS_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(subs_s_d, SUBS_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(subs_u_b, SUBS_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(subs_u_h, SUBS_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(subs_u_w, SUBS_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(subs_u_d, SUBS_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(subsus_u_b, SUBSUS_U_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(subsus_u_h, SUBSUS_U_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(subsus_u_w, SUBSUS_U_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(subsus_u_d, SUBSUS_U_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(subsuu_s_b, SUBSUU_S_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(subsuu_s_h, SUBSUU_S_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(subsuu_s_w, SUBSUU_S_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(subsuu_s_d, SUBSUU_S_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(asub_s_b, ASUB_S_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(asub_s_h, ASUB_S_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(asub_s_w, ASUB_S_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(asub_s_d, ASUB_S_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(asub_u_b, ASUB_U_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(asub_u_h, ASUB_U_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(asub_u_w, ASUB_U_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(asub_u_d, ASUB_U_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(mulv_b, MULV_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(mulv_h, MULV_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(mulv_w, MULV_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(mulv_d, MULV_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(maddv_b, MADDV_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(maddv_h, MADDV_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(maddv_w, MADDV_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(maddv_d, MADDV_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(msubv_b, MSUBV_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(msubv_h, MSUBV_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(msubv_w, MSUBV_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(msubv_d, MSUBV_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(div_s_b, DIV_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(div_s_h, DIV_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(div_s_w, DIV_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(div_s_d, DIV_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(div_u_b, DIV_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(div_u_h, DIV_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(div_u_w, DIV_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(div_u_d, DIV_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(mod_s_b, MOD_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(mod_s_h, MOD_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(mod_s_w, MOD_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(mod_s_d, MOD_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(mod_u_b, MOD_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(mod_u_h, MOD_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(mod_u_w, MOD_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(mod_u_d, MOD_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(srar_b, SRAR_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(srar_h, SRAR_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(srar_w, SRAR_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(srar_d, SRAR_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(srlr_b, SRAR_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(srlr_h, SRAR_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(srlr_w, SRAR_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(srlr_d, SRAR_DF, uint64_t, kMSALanesDword, UINT64_MAX) + +#define RUN_TEST(instr, verify, type, lanes, mask) \ + run_msa_3r(&tc[i], [](MacroAssembler& assm) { __ instr(w2, w1, w0); }, \ + [](uint64_t ws, uint64_t wt, uint64_t wd) { \ + verify(type, lanes, mask); \ + }); + + for (size_t i = 0; i < arraysize(tc); ++i) { + TEST_CASE(RUN_TEST) + } + +#undef RUN_TEST +#undef SLL_DF +#undef SRL_DF +#undef BCRL_DF +#undef BSET_DF +#undef BNEG_DF +#undef BINSL_DF +#undef BINSR_DF +#undef ADDV_DF +#undef SUBV_DF +#undef MAX_DF +#undef MIN_DF +#undef MAXA_DF +#undef MINA_DF +#undef CEQ_DF +#undef CLT_DF +#undef CLE_DF +#undef ADD_A_DF +#undef ADDS_A_DF +#undef ADDS_DF +#undef AVE_DF +#undef AVER_DF +#undef SUBS_DF +#undef SUBSUS_U_DF +#undef SUBSUU_S_DF +#undef ASUB_S_DF +#undef ASUB_U_DF +#undef MULV_DF +#undef MADDV_DF +#undef MSUBV_DF +#undef DIV_DF +#undef MOD_DF +#undef SRAR_DF +} // namespace internal + #undef __ + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-assembler-mips64.cc b/deps/v8/test/cctest/test-assembler-mips64.cc index 4a828c9785..976bd02824 100644 --- a/deps/v8/test/cctest/test-assembler-mips64.cc +++ b/deps/v8/test/cctest/test-assembler-mips64.cc @@ -29,6 +29,7 @@ #include "src/v8.h" +#include "src/assembler-inl.h" #include "src/base/utils/random-number-generator.h" #include "src/disassembler.h" #include "src/factory.h" @@ -38,8 +39,8 @@ #include "test/cctest/cctest.h" -using namespace v8::internal; - +namespace v8 { +namespace internal { // Define these function prototypes to match JSEntryFunction in execution.cc. typedef Object* (*F1)(int x, int p1, int p2, int p3, int p4); @@ -64,8 +65,8 @@ TEST(MIPS0) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); int64_t res = reinterpret_cast<int64_t>( CALL_GENERATED_CODE(isolate, f, 0xab0, 0xc, 0, 0, 0)); @@ -100,8 +101,8 @@ TEST(MIPS1) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F1 f = FUNCTION_CAST<F1>(code->entry()); int64_t res = reinterpret_cast<int64_t>( CALL_GENERATED_CODE(isolate, f, 50, 0, 0, 0, 0)); @@ -246,8 +247,8 @@ TEST(MIPS2) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); int64_t res = reinterpret_cast<int64_t>( CALL_GENERATED_CODE(isolate, f, 0xab0, 0xc, 0, 0, 0)); @@ -349,8 +350,8 @@ TEST(MIPS3) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); // Double test values. t.a = 1.5e14; @@ -443,8 +444,8 @@ TEST(MIPS4) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); t.a = 1.5e22; t.b = 2.75e11; @@ -509,8 +510,8 @@ TEST(MIPS5) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); t.a = 1.5e4; t.b = 2.75e8; @@ -579,8 +580,8 @@ TEST(MIPS6) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); t.ui = 0x11223344; t.si = 0x99aabbcc; @@ -666,8 +667,8 @@ TEST(MIPS7) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); t.a = 1.5e14; t.b = 2.75e11; @@ -764,8 +765,8 @@ TEST(MIPS8) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); t.input = 0x12345678; Object* dummy = CALL_GENERATED_CODE(isolate, f, &t, 0x0, 0, 0, 0); @@ -810,8 +811,7 @@ TEST(MIPS9) { CodeDesc desc; assm.GetCode(isolate, &desc); - isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); } @@ -886,8 +886,8 @@ TEST(MIPS10) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); t.a = 2.147483647e9; // 0x7fffffff -> 0x41DFFFFFFFC00000 as double. t.b_long_hi = 0x000000ff; // 0xFF00FF00FF -> 0x426FE01FE01FE000 as double. @@ -1022,8 +1022,8 @@ TEST(MIPS11) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); t.reg_init = 0xaabbccdd; t.mem_init = 0x11223344; @@ -1147,8 +1147,8 @@ TEST(MIPS12) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); t.x = 1; t.y = 2; @@ -1201,8 +1201,8 @@ TEST(MIPS13) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); t.cvt_big_in = 0xFFFFFFFF; @@ -1322,8 +1322,8 @@ TEST(MIPS14) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); t.round_up_in = 123.51; @@ -1452,8 +1452,8 @@ TEST(MIPS16) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); t.ui = 0x44332211; t.si = 0x99aabbcc; @@ -1581,8 +1581,8 @@ TEST(seleqz_selnez) { __ nop(); CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); @@ -1697,8 +1697,8 @@ TEST(min_max) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 4; i < kTableLength; i++) { test.a = inputsa[i]; @@ -1806,8 +1806,8 @@ TEST(rint_d) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int j = 0; j < 4; j++) { @@ -1854,8 +1854,8 @@ TEST(sel) { __ nop(); CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); const int test_size = 3; @@ -1987,8 +1987,8 @@ TEST(rint_s) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int j = 0; j < 4; j++) { @@ -2073,8 +2073,8 @@ TEST(mina_maxa) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 0; i < kTableLength; i++) { test.a = inputsa[i]; @@ -2155,8 +2155,8 @@ TEST(trunc_l) { Test test; CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 0; i < kTableLength; i++) { test.a = inputs_D[i]; @@ -2236,8 +2236,8 @@ TEST(movz_movn) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 0; i < kTableLength; i++) { test.a = inputs_D[i]; @@ -2337,8 +2337,8 @@ TEST(movt_movd) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); @@ -2423,8 +2423,8 @@ TEST(cvt_w_d) { Test test; CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int j = 0; j < 4; j++) { test.fcsr = fcsr_inputs[j]; @@ -2490,8 +2490,8 @@ TEST(trunc_w) { Test test; CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 0; i < kTableLength; i++) { test.a = inputs_D[i]; @@ -2559,8 +2559,8 @@ TEST(round_w) { Test test; CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 0; i < kTableLength; i++) { test.a = inputs_D[i]; @@ -2630,8 +2630,8 @@ TEST(round_l) { Test test; CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 0; i < kTableLength; i++) { test.a = inputs_D[i]; @@ -2702,8 +2702,8 @@ TEST(sub) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 0; i < kTableLength; i++) { test.a = inputfs_S[i]; @@ -2774,8 +2774,8 @@ TEST(sqrt_rsqrt_recip) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 0; i < kTableLength; i++) { @@ -2852,8 +2852,8 @@ TEST(neg) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 0; i < kTableLength; i++) { test.a = inputs_S[i]; @@ -2910,8 +2910,8 @@ TEST(mul) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 0; i < kTableLength; i++) { test.a = inputfs_S[i]; @@ -2965,8 +2965,8 @@ TEST(mov) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 0; i < kTableLength; i++) { test.a = inputs_D[i]; @@ -3032,8 +3032,8 @@ TEST(floor_w) { Test test; CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 0; i < kTableLength; i++) { test.a = inputs_D[i]; @@ -3103,8 +3103,8 @@ TEST(floor_l) { Test test; CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 0; i < kTableLength; i++) { test.a = inputs_D[i]; @@ -3174,8 +3174,8 @@ TEST(ceil_w) { Test test; CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 0; i < kTableLength; i++) { test.a = inputs_D[i]; @@ -3245,8 +3245,8 @@ TEST(ceil_l) { Test test; CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 0; i < kTableLength; i++) { test.a = inputs_D[i]; @@ -3316,8 +3316,8 @@ TEST(jump_tables1) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -3386,8 +3386,8 @@ TEST(jump_tables2) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -3466,8 +3466,8 @@ TEST(jump_tables3) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -3540,8 +3540,8 @@ TEST(BITSWAP) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); t.r1 = 0x00102100781A15C3; t.r2 = 0x001021008B71FCDE; @@ -3683,8 +3683,8 @@ TEST(class_fmt) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); // Double test values. @@ -3777,8 +3777,8 @@ TEST(ABS) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); test.a = -2.0; test.b = -2.0; @@ -3870,8 +3870,8 @@ TEST(ADD_FMT) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); test.a = 2.0; test.b = 3.0; @@ -4025,8 +4025,8 @@ TEST(C_COND_FMT) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); test.dOp1 = 2.0; test.dOp2 = 3.0; @@ -4226,8 +4226,8 @@ TEST(CMP_COND_FMT) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); uint64_t dTrue = 0xFFFFFFFFFFFFFFFF; uint64_t dFalse = 0x0000000000000000; @@ -4404,8 +4404,8 @@ TEST(CVT) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); test.cvt_d_s_in = -0.51; @@ -4575,8 +4575,8 @@ TEST(DIV_FMT) { __ nop(); CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); @@ -4666,8 +4666,8 @@ uint64_t run_align(uint64_t rs_value, uint64_t rt_value, uint8_t bp) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F4 f = FUNCTION_CAST<F4>(code->entry()); @@ -4719,8 +4719,8 @@ uint64_t run_dalign(uint64_t rs_value, uint64_t rt_value, uint8_t bp) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F4 f = FUNCTION_CAST<F4>(code->entry()); uint64_t res = reinterpret_cast<uint64_t>( @@ -4777,8 +4777,8 @@ uint64_t run_aluipc(int16_t offset) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); PC = (uint64_t) f; // Set the program counter. @@ -4831,8 +4831,8 @@ uint64_t run_auipc(int16_t offset) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); PC = (uint64_t) f; // Set the program counter. @@ -4886,8 +4886,8 @@ uint64_t run_aui(uint64_t rs, uint16_t offset) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); @@ -4912,8 +4912,8 @@ uint64_t run_daui(uint64_t rs, uint16_t offset) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); @@ -4938,8 +4938,8 @@ uint64_t run_dahi(uint64_t rs, uint16_t offset) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); @@ -4964,8 +4964,8 @@ uint64_t run_dati(uint64_t rs, uint16_t offset) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); @@ -5069,8 +5069,8 @@ uint64_t run_li_macro(uint64_t imm, LiFlags mode, int32_t num_instr = 0) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -5282,8 +5282,8 @@ uint64_t run_lwpc(int offset) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); @@ -5358,8 +5358,8 @@ uint64_t run_lwupc(int offset) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); @@ -5442,8 +5442,8 @@ uint64_t run_jic(int16_t offset) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); @@ -5514,8 +5514,8 @@ uint64_t run_beqzc(int32_t value, int32_t offset) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); @@ -5608,8 +5608,8 @@ uint64_t run_jialc(int16_t offset) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); @@ -5660,8 +5660,8 @@ uint64_t run_addiupc(int32_t imm19) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); PC = (uint64_t) f; // Set the program counter. @@ -5736,8 +5736,8 @@ uint64_t run_ldpc(int offset) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); @@ -5825,8 +5825,8 @@ int64_t run_bc(int32_t offset) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); @@ -5907,8 +5907,8 @@ int64_t run_balc(int32_t offset) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); @@ -5957,8 +5957,8 @@ uint64_t run_dsll(uint64_t rt_value, uint16_t sa_value) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F4 f = FUNCTION_CAST<F4>(code->entry()); @@ -6013,8 +6013,8 @@ uint64_t run_bal(int16_t offset) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); @@ -6067,8 +6067,8 @@ TEST(Trampoline) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); int64_t res = reinterpret_cast<int64_t>( @@ -6134,8 +6134,8 @@ void helper_madd_msub_maddf_msubf(F func) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); const size_t kTableLength = sizeof(test_cases) / sizeof(TestCaseMaddMsub<T>); @@ -6217,8 +6217,8 @@ uint64_t run_Subu(uint64_t imm, int32_t num_instr) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -6299,8 +6299,8 @@ uint64_t run_Dsubu(uint64_t imm, int32_t num_instr) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -6394,8 +6394,8 @@ uint64_t run_Dins(uint64_t imm, uint64_t source, uint16_t pos, uint16_t size) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); uint64_t res = reinterpret_cast<uint64_t>( @@ -6453,8 +6453,8 @@ uint64_t run_Ins(uint64_t imm, uint64_t source, uint16_t pos, uint16_t size) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); uint64_t res = reinterpret_cast<uint64_t>( @@ -6522,8 +6522,8 @@ uint64_t run_Ext(uint64_t source, uint16_t pos, uint16_t size) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F2 f = FUNCTION_CAST<F2>(code->entry()); uint64_t res = reinterpret_cast<uint64_t>( @@ -6555,6 +6555,63 @@ TEST(Ext) { CHECK_EQ(run_Ext(0x0000000040000000, 31, 1), 0x0000000000000000); } +// Load elements in w0 MSA vector register +void load_uint64_elements_of_vector(MacroAssembler& assm, + const uint64_t elements[], MSARegister w, + Register t0, Register t1) { + __ li(t0, elements[0]); + __ li(t1, elements[1]); + __ insert_d(w, 0, t0); + __ insert_d(w, 1, t1); +} + +void load_uint32_elements_of_vector(MacroAssembler& assm, + const uint64_t elements[], MSARegister w, + Register t0, Register t1) { + const uint32_t* const element = reinterpret_cast<const uint32_t*>(elements); + __ li(t0, element[0]); + __ li(t1, element[1]); + __ insert_w(w, 0, t0); + __ insert_w(w, 1, t1); + __ li(t0, element[2]); + __ li(t1, element[3]); + __ insert_w(w, 2, t0); + __ insert_w(w, 3, t1); +} + +void load_uint16_elements_of_vector(MacroAssembler& assm, + const uint64_t elements[], MSARegister w, + Register t0, Register t1) { + const uint16_t* const element = reinterpret_cast<const uint16_t*>(elements); + __ li(t0, element[0]); + __ li(t1, element[1]); + __ insert_h(w, 0, t0); + __ insert_h(w, 1, t1); + __ li(t0, element[2]); + __ li(t1, element[3]); + __ insert_h(w, 2, t0); + __ insert_h(w, 3, t1); + __ li(t0, element[4]); + __ li(t1, element[5]); + __ insert_h(w, 4, t0); + __ insert_h(w, 5, t1); + __ li(t0, element[6]); + __ li(t1, element[7]); + __ insert_h(w, 6, t0); + __ insert_h(w, 7, t1); +} + +// Store vector elements from w2 to the memory pointed by a0 +void store_uint64_elements_of_vector(MacroAssembler& assm, MSARegister w, + Register a) { + __ st_d(w, MemOperand(a, 0)); +} + +void store_uint32_elements_of_vector(MacroAssembler& assm, MSARegister w, + Register a) { + __ st_w(w, MemOperand(a, 0)); +} + TEST(MSA_fill_copy) { CcTest::InitializeVM(); Isolate* isolate = CcTest::i_isolate(); @@ -6606,8 +6663,8 @@ TEST(MSA_fill_copy) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -6670,8 +6727,8 @@ TEST(MSA_fill_copy_2) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -6724,8 +6781,8 @@ TEST(MSA_fill_copy_3) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -6773,22 +6830,15 @@ void run_msa_insert(int64_t rs_value, int n, msa_reg_t* w) { UNREACHABLE(); } - __ copy_u_w(t2, w0, 0); - __ sw(t2, MemOperand(a0, 0)); - __ copy_u_w(t2, w0, 1); - __ sw(t2, MemOperand(a0, 4)); - __ copy_u_w(t2, w0, 2); - __ sw(t2, MemOperand(a0, 8)); - __ copy_u_w(t2, w0, 3); - __ sw(t2, MemOperand(a0, 12)); + store_uint64_elements_of_vector(assm, w0, a0); __ jr(ra); __ nop(); CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -6865,6 +6915,64 @@ TEST(MSA_insert) { } } +void run_msa_ctc_cfc(uint64_t value) { + Isolate* isolate = CcTest::i_isolate(); + HandleScope scope(isolate); + + MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); + CpuFeatureScope fscope(&assm, MIPS_SIMD); + + MSAControlRegister msareg = {kMSACSRRegister}; + __ li(t0, value); + __ li(t2, 0); + __ cfcmsa(t1, msareg); + __ ctcmsa(msareg, t0); + __ cfcmsa(t2, msareg); + __ ctcmsa(msareg, t1); + __ sd(t2, MemOperand(a0, 0)); + __ jr(ra); + __ nop(); + + CodeDesc desc; + assm.GetCode(isolate, &desc); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); +#ifdef OBJECT_PRINT + code->Print(std::cout); +#endif + F3 f = FUNCTION_CAST<F3>(code->entry()); + + uint64_t res; + (CALL_GENERATED_CODE(isolate, f, &res, 0, 0, 0, 0)); + + CHECK_EQ(bit_cast<uint64_t>(static_cast<int64_t>( + bit_cast<int32_t>(static_cast<uint32_t>(value & 0x0167ffff)))), + res); +} + +TEST(MSA_cfc_ctc) { + if ((kArchVariant != kMips64r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + + const uint64_t mask_without_cause = 0xffffffffff9c0fff; + const uint64_t mask_always_zero = 0x0167ffff; + const uint64_t mask_enables = 0x0000000000000f80; + uint64_t test_case[] = {0x30c6f6352d5ede31, 0xefc9fed507955425, + 0x64f2a3ff15b7dbe3, 0x6aa069352bf8bc37, + 0x7ea7ab2ae6aae923, 0xa10f5d4c24d0f68d, + 0x6dd14c9441afa84c, 0xc366373b2d6bf64f, + 0x6b35fb04925014bd, 0x9e3ea39a4dba7e61}; + for (unsigned i = 0; i < arraysize(test_case); i++) { + // Setting enable bits and corresponding cause bits could result in + // exception raised and this prevents that from happening + test_case[i] = (~test_case[i] & mask_enables) << 5 | + (test_case[i] & mask_without_cause); + run_msa_ctc_cfc(test_case[i] & mask_always_zero); + } +} + struct ExpResShf { uint8_t i8; uint64_t lo; @@ -6928,14 +7036,7 @@ void run_msa_i8(SecondaryField opcode, uint64_t ws_lo, uint64_t ws_hi, UNREACHABLE(); } - __ copy_u_w(t2, w2, 0); - __ sw(t2, MemOperand(a0, 0)); - __ copy_u_w(t2, w2, 1); - __ sw(t2, MemOperand(a0, 4)); - __ copy_u_w(t2, w2, 2); - __ sw(t2, MemOperand(a0, 8)); - __ copy_u_w(t2, w2, 3); - __ sw(t2, MemOperand(a0, 12)); + store_uint64_elements_of_vector(assm, w2, a0); __ jr(ra); __ nop(); @@ -6944,8 +7045,8 @@ void run_msa_i8(SecondaryField opcode, uint64_t ws_lo, uint64_t ws_hi, CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -7127,29 +7228,19 @@ void run_msa_i5(struct TestCaseMsaI5* input, bool i5_sign_ext, int32_t i5 = i5_sign_ext ? static_cast<int32_t>(input->i5 << 27) >> 27 : input->i5; - __ li(t0, input->ws_lo); - __ li(t1, input->ws_hi); - __ insert_d(w0, 0, t0); - __ insert_d(w0, 1, t1); + load_uint64_elements_of_vector(assm, &(input->ws_lo), w0, t0, t1); GenerateI5InstructionFunc(assm, i5); - __ copy_u_w(t2, w2, 0); - __ sw(t2, MemOperand(a0, 0)); - __ copy_u_w(t2, w2, 1); - __ sw(t2, MemOperand(a0, 4)); - __ copy_u_w(t2, w2, 2); - __ sw(t2, MemOperand(a0, 8)); - __ copy_u_w(t2, w2, 3); - __ sw(t2, MemOperand(a0, 12)); + store_uint64_elements_of_vector(assm, w2, a0); __ jr(ra); __ nop(); CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -7548,8 +7639,11 @@ struct TestCaseMsa2R { uint64_t exp_res_hi; }; -template <typename Func> -void run_msa_2r(struct TestCaseMsa2R* input, Func Generate2RInstructionFunc) { +template <typename Func, typename FuncLoad, typename FuncStore> +void run_msa_2r(const struct TestCaseMsa2R* input, + Func Generate2RInstructionFunc, + FuncLoad load_elements_of_vector, + FuncStore store_elements_of_vector) { Isolate* isolate = CcTest::i_isolate(); HandleScope scope(isolate); @@ -7557,29 +7651,18 @@ void run_msa_2r(struct TestCaseMsa2R* input, Func Generate2RInstructionFunc) { CpuFeatureScope fscope(&assm, MIPS_SIMD); msa_reg_t res; - __ li(t0, input->ws_lo); - __ li(t1, input->ws_hi); - __ insert_d(w0, 0, t0); - __ insert_d(w0, 1, t1); - + load_elements_of_vector(assm, reinterpret_cast<const uint64_t*>(input), w0, + t0, t1); Generate2RInstructionFunc(assm); - - __ copy_u_w(t2, w2, 0); - __ sw(t2, MemOperand(a0, 0)); - __ copy_u_w(t2, w2, 1); - __ sw(t2, MemOperand(a0, 4)); - __ copy_u_w(t2, w2, 2); - __ sw(t2, MemOperand(a0, 8)); - __ copy_u_w(t2, w2, 3); - __ sw(t2, MemOperand(a0, 12)); + store_elements_of_vector(assm, w2, a0); __ jr(ra); __ nop(); CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -7587,8 +7670,17 @@ void run_msa_2r(struct TestCaseMsa2R* input, Func Generate2RInstructionFunc) { (CALL_GENERATED_CODE(isolate, f, &res, 0, 0, 0, 0)); - CHECK_EQ(input->exp_res_lo, res.d[0]); - CHECK_EQ(input->exp_res_hi, res.d[1]); + if (store_elements_of_vector == store_uint64_elements_of_vector) { + CHECK_EQ(input->exp_res_lo, res.d[0]); + CHECK_EQ(input->exp_res_hi, res.d[1]); + } else if (store_elements_of_vector == store_uint32_elements_of_vector) { + const uint32_t* exp_res = + reinterpret_cast<const uint32_t*>(&input->exp_res_lo); + CHECK_EQ(exp_res[0], res.w[0]); + CHECK_EQ(exp_res[1], res.w[1]); + CHECK_EQ(exp_res[2], res.w[2]); + CHECK_EQ(exp_res[3], res.w[3]); + } } TEST(MSA_pcnt) { @@ -7639,10 +7731,14 @@ TEST(MSA_pcnt) { {0xf35862e13e38f8b0, 0x4f41ffdef2bfe636, 0x20, 0x2a}}; for (size_t i = 0; i < sizeof(tc_b) / sizeof(TestCaseMsa2R); ++i) { - run_msa_2r(&tc_b[i], [](MacroAssembler& assm) { __ pcnt_b(w2, w0); }); - run_msa_2r(&tc_h[i], [](MacroAssembler& assm) { __ pcnt_h(w2, w0); }); - run_msa_2r(&tc_w[i], [](MacroAssembler& assm) { __ pcnt_w(w2, w0); }); - run_msa_2r(&tc_d[i], [](MacroAssembler& assm) { __ pcnt_d(w2, w0); }); + run_msa_2r(&tc_b[i], [](MacroAssembler& assm) { __ pcnt_b(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + run_msa_2r(&tc_h[i], [](MacroAssembler& assm) { __ pcnt_h(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + run_msa_2r(&tc_w[i], [](MacroAssembler& assm) { __ pcnt_w(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + run_msa_2r(&tc_d[i], [](MacroAssembler& assm) { __ pcnt_d(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); } } @@ -7694,10 +7790,14 @@ TEST(MSA_nlzc) { {0x00000000e338f8b0, 0x0754534acab32654, 0x20, 0x5}}; for (size_t i = 0; i < sizeof(tc_b) / sizeof(TestCaseMsa2R); ++i) { - run_msa_2r(&tc_b[i], [](MacroAssembler& assm) { __ nlzc_b(w2, w0); }); - run_msa_2r(&tc_h[i], [](MacroAssembler& assm) { __ nlzc_h(w2, w0); }); - run_msa_2r(&tc_w[i], [](MacroAssembler& assm) { __ nlzc_w(w2, w0); }); - run_msa_2r(&tc_d[i], [](MacroAssembler& assm) { __ nlzc_d(w2, w0); }); + run_msa_2r(&tc_b[i], [](MacroAssembler& assm) { __ nlzc_b(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + run_msa_2r(&tc_h[i], [](MacroAssembler& assm) { __ nlzc_h(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + run_msa_2r(&tc_w[i], [](MacroAssembler& assm) { __ nlzc_w(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + run_msa_2r(&tc_d[i], [](MacroAssembler& assm) { __ nlzc_d(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); } } @@ -7749,10 +7849,885 @@ TEST(MSA_nloc) { {0xFFFFFFFF1CC7074F, 0xF8ABACB5354CD9AB, 0x20, 0x5}}; for (size_t i = 0; i < sizeof(tc_b) / sizeof(TestCaseMsa2R); ++i) { - run_msa_2r(&tc_b[i], [](MacroAssembler& assm) { __ nloc_b(w2, w0); }); - run_msa_2r(&tc_h[i], [](MacroAssembler& assm) { __ nloc_h(w2, w0); }); - run_msa_2r(&tc_w[i], [](MacroAssembler& assm) { __ nloc_w(w2, w0); }); - run_msa_2r(&tc_d[i], [](MacroAssembler& assm) { __ nloc_d(w2, w0); }); + run_msa_2r(&tc_b[i], [](MacroAssembler& assm) { __ nloc_b(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + run_msa_2r(&tc_h[i], [](MacroAssembler& assm) { __ nloc_h(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + run_msa_2r(&tc_w[i], [](MacroAssembler& assm) { __ nloc_w(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + run_msa_2r(&tc_d[i], [](MacroAssembler& assm) { __ nloc_d(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + } +} + +struct TestCaseMsa2RF_F_U { + float ws1; + float ws2; + float ws3; + float ws4; + uint32_t exp_res_1; + uint32_t exp_res_2; + uint32_t exp_res_3; + uint32_t exp_res_4; +}; + +struct TestCaseMsa2RF_D_U { + double ws1; + double ws2; + uint64_t exp_res_1; + uint64_t exp_res_2; +}; + +TEST(MSA_fclass) { + if ((kArchVariant != kMips64r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + +#define BIT(n) (0x1 << n) +#define SNAN BIT(0) +#define QNAN BIT(1) +#define NEG_INFINITY BIT((2)) +#define NEG_NORMAL BIT(3) +#define NEG_SUBNORMAL BIT(4) +#define NEG_ZERO BIT(5) +#define POS_INFINITY BIT(6) +#define POS_NORMAL BIT(7) +#define POS_SUBNORMAL BIT(8) +#define POS_ZERO BIT(9) + + const float inf_float = std::numeric_limits<float>::infinity(); + const double inf_double = std::numeric_limits<double>::infinity(); + + const struct TestCaseMsa2RF_F_U tc_s[] = { + {1.f, -0.00001, 208e10f, -34.8e-30f, POS_NORMAL, NEG_NORMAL, POS_NORMAL, + NEG_NORMAL}, + {inf_float, -inf_float, 0, -0.f, POS_INFINITY, NEG_INFINITY, POS_ZERO, + NEG_ZERO}, + {3.036e-40f, -6.392e-43f, 1.41e-45f, -1.17e-38f, POS_SUBNORMAL, + NEG_SUBNORMAL, POS_SUBNORMAL, NEG_SUBNORMAL}}; + + const struct TestCaseMsa2RF_D_U tc_d[] = { + {1., -0.00000001, POS_NORMAL, NEG_NORMAL}, + {208e10, -34.8e-300, POS_NORMAL, NEG_NORMAL}, + {inf_double, -inf_double, POS_INFINITY, NEG_INFINITY}, + {0, -0., POS_ZERO, NEG_ZERO}, + {1.036e-308, -6.392e-309, POS_SUBNORMAL, NEG_SUBNORMAL}, + {1.41e-323, -3.17e208, POS_SUBNORMAL, NEG_NORMAL}}; + + for (size_t i = 0; i < sizeof(tc_s) / sizeof(TestCaseMsa2RF_F_U); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_s[i]), + [](MacroAssembler& assm) { __ fclass_w(w2, w0); }, + load_uint32_elements_of_vector, store_uint32_elements_of_vector); + } + for (size_t i = 0; i < sizeof(tc_d) / sizeof(TestCaseMsa2RF_D_U); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [](MacroAssembler& assm) { __ fclass_d(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + } + +#undef BIT +#undef SNAN +#undef QNAN +#undef NEG_INFINITY +#undef NEG_NORMAL +#undef NEG_SUBNORMAL +#undef NEG_ZERO +#undef POS_INFINITY +#undef POS_NORMAL +#undef POS_SUBNORMAL +#undef POS_ZERO +} + +struct TestCaseMsa2RF_F_I { + float ws1; + float ws2; + float ws3; + float ws4; + int32_t exp_res_1; + int32_t exp_res_2; + int32_t exp_res_3; + int32_t exp_res_4; +}; + +struct TestCaseMsa2RF_D_I { + double ws1; + double ws2; + int64_t exp_res_1; + int64_t exp_res_2; +}; + +TEST(MSA_ftrunc_s) { + if ((kArchVariant != kMips64r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + + const float inf_float = std::numeric_limits<float>::infinity(); + const float qNaN_float = std::numeric_limits<float>::quiet_NaN(); + const double inf_double = std::numeric_limits<double>::infinity(); + const double qNaN_double = std::numeric_limits<double>::quiet_NaN(); + const int32_t max_int32 = std::numeric_limits<int32_t>::max(); + const int32_t min_int32 = std::numeric_limits<int32_t>::min(); + const int64_t max_int64 = std::numeric_limits<int64_t>::max(); + const int64_t min_int64 = std::numeric_limits<int64_t>::min(); + + const struct TestCaseMsa2RF_F_I tc_s[] = { + {inf_float, 2.345f, -324.9235f, 30004.51f, max_int32, 2, -324, 30004}, + {-inf_float, -0.983f, 0.0832f, static_cast<float>(max_int32) * 3.f, + min_int32, 0, 0, max_int32}, + {-23.125f, qNaN_float, 2 * static_cast<float>(min_int32), -0.f, -23, 0, + min_int32, 0}}; + + const struct TestCaseMsa2RF_D_I tc_d[] = { + {inf_double, 2.345, max_int64, 2}, + {-324.9235, 246569139.51, -324, 246569139}, + {-inf_double, -0.983, min_int64, 0}, + {0.0832, 6 * static_cast<double>(max_int64), 0, max_int64}, + {-21453889872.94, qNaN_double, -21453889872, 0}, + {2 * static_cast<double>(min_int64), -0., min_int64, 0}}; + + for (size_t i = 0; i < sizeof(tc_s) / sizeof(TestCaseMsa2RF_F_I); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_s[i]), + [](MacroAssembler& assm) { __ ftrunc_s_w(w2, w0); }, + load_uint32_elements_of_vector, store_uint32_elements_of_vector); + } + for (size_t i = 0; i < sizeof(tc_d) / sizeof(TestCaseMsa2RF_D_I); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [](MacroAssembler& assm) { __ ftrunc_s_d(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + } +} + +TEST(MSA_ftrunc_u) { + if ((kArchVariant != kMips64r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + + const float inf_float = std::numeric_limits<float>::infinity(); + const float qNaN_float = std::numeric_limits<float>::quiet_NaN(); + const double inf_double = std::numeric_limits<double>::infinity(); + const double qNaN_double = std::numeric_limits<double>::quiet_NaN(); + const uint32_t max_uint32 = std::numeric_limits<uint32_t>::max(); + const uint64_t max_uint64 = std::numeric_limits<uint64_t>::max(); + + const struct TestCaseMsa2RF_F_U tc_s[] = { + {inf_float, 2.345f, -324.9235f, 30004.51f, max_uint32, 2, 0, 30004}, + {-inf_float, 0.983f, 0.0832f, static_cast<float>(max_uint32) * 3., 0, 0, + 0, max_uint32}, + {23.125f, qNaN_float, -0.982, -0.f, 23, 0, 0, 0}}; + + const struct TestCaseMsa2RF_D_U tc_d[] = { + {inf_double, 2.345, max_uint64, 2}, + {-324.9235, 246569139.51, 0, 246569139}, + {-inf_double, -0.983, 0, 0}, + {0.0832, 6 * static_cast<double>(max_uint64), 0, max_uint64}, + {21453889872.94, qNaN_double, 21453889872, 0}, + {0.9889, -0., 0, 0}}; + + for (size_t i = 0; i < sizeof(tc_s) / sizeof(TestCaseMsa2RF_F_U); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_s[i]), + [](MacroAssembler& assm) { __ ftrunc_u_w(w2, w0); }, + load_uint32_elements_of_vector, store_uint32_elements_of_vector); + } + for (size_t i = 0; i < sizeof(tc_d) / sizeof(TestCaseMsa2RF_D_U); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [](MacroAssembler& assm) { __ ftrunc_u_d(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + } +} + +struct TestCaseMsa2RF_F_F { + float ws1; + float ws2; + float ws3; + float ws4; + float exp_res_1; + float exp_res_2; + float exp_res_3; + float exp_res_4; +}; + +struct TestCaseMsa2RF_D_D { + double ws1; + double ws2; + double exp_res_1; + double exp_res_2; +}; + +TEST(MSA_fsqrt) { + if ((kArchVariant != kMips64r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + + const float inf_float = std::numeric_limits<float>::infinity(); + const double inf_double = std::numeric_limits<double>::infinity(); + + const struct TestCaseMsa2RF_F_F tc_s[] = { + {81.f, 576.f, inf_float, -0.f, 9.f, 24.f, inf_float, -0.f}}; + + const struct TestCaseMsa2RF_D_D tc_d[] = {{81., inf_double, 9., inf_double}, + {331776., -0., 576, -0.}}; + + for (size_t i = 0; i < sizeof(tc_s) / sizeof(TestCaseMsa2RF_F_F); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_s[i]), + [](MacroAssembler& assm) { __ fsqrt_w(w2, w0); }, + load_uint32_elements_of_vector, store_uint32_elements_of_vector); + } + for (size_t i = 0; i < sizeof(tc_d) / sizeof(TestCaseMsa2RF_D_D); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [](MacroAssembler& assm) { __ fsqrt_d(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + } +} + +TEST(MSA_frsqrt) { + if ((kArchVariant != kMips64r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + + const float inf_float = std::numeric_limits<float>::infinity(); + const double inf_double = std::numeric_limits<double>::infinity(); + + const struct TestCaseMsa2RF_F_F tc_s[] = { + {81.f, 576.f, inf_float, -0.f, 1.f / 9.f, 1.f / 24.f, 0.f, -inf_float}, + {0.f, 1.f / 576.f, 1.f / 81.f, 1.f / 4.f, inf_float, 24.f, 9.f, 2.f}}; + + const struct TestCaseMsa2RF_D_D tc_d[] = { + {81., inf_double, 1. / 9., 0.}, + {331776., -0., 1. / 576., -inf_double}, + {0., 1. / 81, inf_double, 9.}}; + + for (size_t i = 0; i < sizeof(tc_s) / sizeof(TestCaseMsa2RF_F_F); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_s[i]), + [](MacroAssembler& assm) { __ frsqrt_w(w2, w0); }, + load_uint32_elements_of_vector, store_uint32_elements_of_vector); + } + for (size_t i = 0; i < sizeof(tc_d) / sizeof(TestCaseMsa2RF_D_D); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [](MacroAssembler& assm) { __ frsqrt_d(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + } +} + +TEST(MSA_frcp) { + if ((kArchVariant != kMips64r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + + const float inf_float = std::numeric_limits<float>::infinity(); + const double inf_double = std::numeric_limits<double>::infinity(); + + const struct TestCaseMsa2RF_F_F tc_s[] = { + {12.f, 576.f, inf_float, -0.f, 1.f / 12.f, 1.f / 576.f, 0.f, -inf_float}, + {0.f, 1.f / 576.f, -inf_float, 1.f / 400.f, inf_float, 576.f, -0.f, + 400.f}}; + + const struct TestCaseMsa2RF_D_D tc_d[] = { + {81., inf_double, 1. / 81., 0.}, + {331777., -0., 1. / 331777., -inf_double}, + {0., 1. / 80, inf_double, 80.}, + {1. / 40000., -inf_double, 40000., -0.}}; + + for (size_t i = 0; i < sizeof(tc_s) / sizeof(TestCaseMsa2RF_F_F); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_s[i]), + [](MacroAssembler& assm) { __ frcp_w(w2, w0); }, + load_uint32_elements_of_vector, store_uint32_elements_of_vector); + } + for (size_t i = 0; i < sizeof(tc_d) / sizeof(TestCaseMsa2RF_D_D); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [](MacroAssembler& assm) { __ frcp_d(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + } +} + +void test_frint_s(size_t data_size, TestCaseMsa2RF_F_F tc_d[], + int rounding_mode) { + for (size_t i = 0; i < data_size / sizeof(TestCaseMsa2RF_F_F); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [&rounding_mode](MacroAssembler& assm) { + MSAControlRegister msareg = {kMSACSRRegister}; + __ li(t0, static_cast<uint32_t>(rounding_mode)); + __ cfcmsa(t1, msareg); + __ ctcmsa(msareg, t0); + __ frint_w(w2, w0); + __ ctcmsa(msareg, t1); + }, + load_uint32_elements_of_vector, store_uint32_elements_of_vector); + } +} + +void test_frint_d(size_t data_size, TestCaseMsa2RF_D_D tc_d[], + int rounding_mode) { + for (size_t i = 0; i < data_size / sizeof(TestCaseMsa2RF_D_D); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [&rounding_mode](MacroAssembler& assm) { + MSAControlRegister msareg = {kMSACSRRegister}; + __ li(t0, static_cast<uint32_t>(rounding_mode)); + __ cfcmsa(t1, msareg); + __ ctcmsa(msareg, t0); + __ frint_d(w2, w0); + __ ctcmsa(msareg, t1); + }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + } +} + +TEST(MSA_frint) { + if ((kArchVariant != kMips64r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + + struct TestCaseMsa2RF_F_F tc_s1[] = { + {0.f, 4.51f, 1.49f, -12.51f, 0.f, 5.f, 1.f, -13.f}, + {-1.32f, -23.38f, 2.8f, -32.6f, -1.f, -23.f, 3.f, -33.f}}; + + struct TestCaseMsa2RF_D_D tc_d1[] = {{0., 4.51, 0., 5.}, + {1.49, -12.51, 1., -13.}, + {-1.32, -23.38, -1., -23.}, + {2.8, -32.6, 3., -33.}}; + + test_frint_s(sizeof(tc_s1), tc_s1, kRoundToNearest); + test_frint_d(sizeof(tc_d1), tc_d1, kRoundToNearest); + + struct TestCaseMsa2RF_F_F tc_s2[] = { + {0.f, 4.5f, 1.49f, -12.51f, 0.f, 4.f, 1.f, -12.f}, + {-1.f, -23.38f, 2.8f, -32.6f, -1.f, -23.f, 2.f, -32.f}}; + + struct TestCaseMsa2RF_D_D tc_d2[] = {{0., 4.5, 0., 4.}, + {1.49, -12.51, 1., -12.}, + {-1., -23.38, -1., -23.}, + {2.8, -32.6, 2., -32.}}; + + test_frint_s(sizeof(tc_s2), tc_s2, kRoundToZero); + test_frint_d(sizeof(tc_d2), tc_d2, kRoundToZero); + + struct TestCaseMsa2RF_F_F tc_s3[] = { + {0.f, 4.5f, 1.49f, -12.51f, 0.f, 5.f, 2.f, -12.f}, + {-1.f, -23.38f, 2.8f, -32.6f, -1.f, -23.f, 3.f, -32.f}}; + + struct TestCaseMsa2RF_D_D tc_d3[] = {{0., 4.5, 0., 5.}, + {1.49, -12.51, 2., -12.}, + {-1., -23.38, -1., -23.}, + {2.8, -32.6, 3., -32.}}; + + test_frint_s(sizeof(tc_s3), tc_s3, kRoundToPlusInf); + test_frint_d(sizeof(tc_d3), tc_d3, kRoundToPlusInf); + + struct TestCaseMsa2RF_F_F tc_s4[] = { + {0.f, 4.5f, 1.49f, -12.51f, 0.f, 4.f, 1.f, -13.f}, + {-1.f, -23.38f, 2.8f, -32.6f, -1.f, -24.f, 2.f, -33.f}}; + + struct TestCaseMsa2RF_D_D tc_d4[] = {{0., 4.5, 0., 4.}, + {1.49, -12.51, 1., -13.}, + {-1., -23.38, -1., -24.}, + {2.8, -32.6, 2., -33.}}; + + test_frint_s(sizeof(tc_s4), tc_s4, kRoundToMinusInf); + test_frint_d(sizeof(tc_d4), tc_d4, kRoundToMinusInf); +} + +TEST(MSA_flog2) { + if ((kArchVariant != kMips64r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + + const float inf_float = std::numeric_limits<float>::infinity(); + const double inf_double = std::numeric_limits<double>::infinity(); + + struct TestCaseMsa2RF_F_F tc_s[] = { + {std::ldexp(0.58f, -48), std::ldexp(0.5f, 110), std::ldexp(1.11f, -130), + inf_float, -49.f, 109.f, -130.f, inf_float}, + {0.f, -0.f, std::ldexp(0.89f, -12), std::ldexp(0.32f, 126), -inf_float, + -inf_float, -13.f, 124.f}}; + + struct TestCaseMsa2RF_D_D tc_d[] = { + {std::ldexp(0.58, -48), std::ldexp(0.5, 110), -49., 109.}, + {std::ldexp(1.11, -1050), inf_double, -1050., inf_double}, + {0., -0., -inf_double, -inf_double}, + {std::ldexp(0.32, 1021), std::ldexp(1.23, -123), 1019., -123.}}; + + for (size_t i = 0; i < sizeof(tc_s) / sizeof(TestCaseMsa2RF_F_F); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_s[i]), + [](MacroAssembler& assm) { __ flog2_w(w2, w0); }, + load_uint32_elements_of_vector, store_uint32_elements_of_vector); + } + + for (size_t i = 0; i < sizeof(tc_d) / sizeof(TestCaseMsa2RF_D_D); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [](MacroAssembler& assm) { __ flog2_d(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + } +} + +void test_ftint_s_s(size_t data_size, TestCaseMsa2RF_F_I tc_d[], + int rounding_mode) { + for (size_t i = 0; i < data_size / sizeof(TestCaseMsa2RF_F_I); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [&rounding_mode](MacroAssembler& assm) { + MSAControlRegister msareg = {kMSACSRRegister}; + __ li(t0, static_cast<uint32_t>(rounding_mode)); + __ cfcmsa(t1, msareg); + __ ctcmsa(msareg, t0); + __ ftint_s_w(w2, w0); + __ ctcmsa(msareg, t1); + }, + load_uint32_elements_of_vector, store_uint32_elements_of_vector); + } +} + +void test_ftint_s_d(size_t data_size, TestCaseMsa2RF_D_I tc_d[], + int rounding_mode) { + for (size_t i = 0; i < data_size / sizeof(TestCaseMsa2RF_D_I); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [&rounding_mode](MacroAssembler& assm) { + MSAControlRegister msareg = {kMSACSRRegister}; + __ li(t0, static_cast<uint32_t>(rounding_mode)); + __ cfcmsa(t1, msareg); + __ ctcmsa(msareg, t0); + __ ftint_s_d(w2, w0); + __ ctcmsa(msareg, t1); + }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + } +} + +TEST(MSA_ftint_s) { + if ((kArchVariant != kMips64r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + + const float inf_float = std::numeric_limits<float>::infinity(); + const double inf_double = std::numeric_limits<double>::infinity(); + const int32_t int32_max = std::numeric_limits<int32_t>::max(); + const int32_t int32_min = std::numeric_limits<int32_t>::min(); + const int64_t int64_max = std::numeric_limits<int64_t>::max(); + const int64_t int64_min = std::numeric_limits<int64_t>::min(); + + struct TestCaseMsa2RF_F_I tc_s1[] = { + {0.f, 4.51f, 1.49f, -12.51f, 0, 5, 1, -13}, + {-0.32f, -23.38f, 2.8f, -32.6f, 0, -23, 3, -33}, + {inf_float, -inf_float, 3.f * int32_min, 4.f * int32_max, int32_max, + int32_min, int32_min, int32_max}}; + + struct TestCaseMsa2RF_D_I tc_d1[] = { + {0., 4.51, 0, 5}, + {1.49, -12.51, 1, -13}, + {-0.32, -23.38, 0, -23}, + {2.8, -32.6, 3, -33}, + {inf_double, -inf_double, int64_max, int64_min}, + {33.23 * int64_min, 4000. * int64_max, int64_min, int64_max}}; + + test_ftint_s_s(sizeof(tc_s1), tc_s1, kRoundToNearest); + test_ftint_s_d(sizeof(tc_d1), tc_d1, kRoundToNearest); + + struct TestCaseMsa2RF_F_I tc_s2[] = { + {0.f, 4.5f, 1.49f, -12.51f, 0, 4, 1, -12}, + {-0.f, -23.38f, 2.8f, -32.6f, -0, -23, 2, -32}, + {inf_float, -inf_float, 3.f * int32_min, 4.f * int32_max, int32_max, + int32_min, int32_min, int32_max}}; + + struct TestCaseMsa2RF_D_I tc_d2[] = { + {0., 4.5, 0, 4}, + {1.49, -12.51, 1, -12}, + {-0., -23.38, -0, -23}, + {2.8, -32.6, 2, -32}, + {inf_double, -inf_double, int64_max, int64_min}, + {33.23 * int64_min, 4000. * int64_max, int64_min, int64_max}}; + + test_ftint_s_s(sizeof(tc_s2), tc_s2, kRoundToZero); + test_ftint_s_d(sizeof(tc_d2), tc_d2, kRoundToZero); + + struct TestCaseMsa2RF_F_I tc_s3[] = { + {0.f, 4.5f, 1.49f, -12.51f, 0, 5, 2, -12}, + {-0.f, -23.38f, 2.8f, -32.6f, -0, -23, 3, -32}, + {inf_float, -inf_float, 3.f * int32_min, 4.f * int32_max, int32_max, + int32_min, int32_min, int32_max}}; + + struct TestCaseMsa2RF_D_I tc_d3[] = { + {0., 4.5, 0, 5}, + {1.49, -12.51, 2, -12}, + {-0., -23.38, -0, -23}, + {2.8, -32.6, 3, -32}, + {inf_double, -inf_double, int64_max, int64_min}, + {33.23 * int64_min, 4000. * int64_max, int64_min, int64_max}}; + + test_ftint_s_s(sizeof(tc_s3), tc_s3, kRoundToPlusInf); + test_ftint_s_d(sizeof(tc_d3), tc_d3, kRoundToPlusInf); + + struct TestCaseMsa2RF_F_I tc_s4[] = { + {0.f, 4.5f, 1.49f, -12.51f, 0, 4, 1, -13}, + {-0.f, -23.38f, 2.8f, -32.6f, -0, -24, 2, -33}, + {inf_float, -inf_float, 3.f * int32_min, 4.f * int32_max, int32_max, + int32_min, int32_min, int32_max}}; + + struct TestCaseMsa2RF_D_I tc_d4[] = { + {0., 4.5, 0, 4}, + {1.49, -12.51, 1, -13}, + {-0., -23.38, -0, -24}, + {2.8, -32.6, 2, -33}, + {inf_double, -inf_double, int64_max, int64_min}, + {33.23 * int64_min, 4000. * int64_max, int64_min, int64_max}}; + + test_ftint_s_s(sizeof(tc_s4), tc_s4, kRoundToMinusInf); + test_ftint_s_d(sizeof(tc_d4), tc_d4, kRoundToMinusInf); +} + +void test_ftint_u_s(size_t data_size, TestCaseMsa2RF_F_U tc_d[], + int rounding_mode) { + for (size_t i = 0; i < data_size / sizeof(TestCaseMsa2RF_F_U); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [&rounding_mode](MacroAssembler& assm) { + MSAControlRegister msareg = {kMSACSRRegister}; + __ li(t0, static_cast<uint32_t>(rounding_mode)); + __ cfcmsa(t1, msareg); + __ ctcmsa(msareg, t0); + __ ftint_u_w(w2, w0); + __ ctcmsa(msareg, t1); + }, + load_uint32_elements_of_vector, store_uint32_elements_of_vector); + } +} + +void test_ftint_u_d(size_t data_size, TestCaseMsa2RF_D_U tc_d[], + int rounding_mode) { + for (size_t i = 0; i < data_size / sizeof(TestCaseMsa2RF_D_U); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [&rounding_mode](MacroAssembler& assm) { + MSAControlRegister msareg = {kMSACSRRegister}; + __ li(t0, static_cast<uint32_t>(rounding_mode)); + __ cfcmsa(t1, msareg); + __ ctcmsa(msareg, t0); + __ ftint_u_d(w2, w0); + __ ctcmsa(msareg, t1); + }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + } +} + +TEST(MSA_ftint_u) { + if ((kArchVariant != kMips64r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + + const float inf_float = std::numeric_limits<float>::infinity(); + const double inf_double = std::numeric_limits<double>::infinity(); + const uint32_t uint32_max = std::numeric_limits<uint32_t>::max(); + const uint64_t uint64_max = std::numeric_limits<uint64_t>::max(); + + struct TestCaseMsa2RF_F_U tc_s1[] = { + {0.f, 4.51f, 1.49f, -12.51f, 0, 5, 1, 0}, + {-0.32f, 23.38f, 2.8f, 32.6f, 0, 23, 3, 33}, + {inf_float, -inf_float, 0, 4.f * uint32_max, uint32_max, 0, 0, + uint32_max}}; + + struct TestCaseMsa2RF_D_U tc_d1[] = { + {0., 4.51, 0, 5}, + {1.49, -12.51, 1, 0}, + {-0.32, 23.38, 0, 23}, + {2.8, 32.6, 3, 33}, + {inf_double, -inf_double, uint64_max, 0}, + {-0., 4000. * uint64_max, 0, uint64_max}}; + + test_ftint_u_s(sizeof(tc_s1), tc_s1, kRoundToNearest); + test_ftint_u_d(sizeof(tc_d1), tc_d1, kRoundToNearest); + + struct TestCaseMsa2RF_F_U tc_s2[] = { + {0.f, 4.5f, 1.49f, -12.51f, 0, 4, 1, 0}, + {-0.f, 23.38f, 2.8f, 32.6f, 0, 23, 2, 32}, + {inf_float, -inf_float, 0., 4.f * uint32_max, uint32_max, 0, 0, + uint32_max}}; + + struct TestCaseMsa2RF_D_U tc_d2[] = { + {0., 4.5, 0, 4}, + {1.49, -12.51, 1, 0}, + {-0., 23.38, 0, 23}, + {2.8, 32.6, 2, 32}, + {inf_double, -inf_double, uint64_max, 0}, + {-0.2345, 4000. * uint64_max, 0, uint64_max}}; + + test_ftint_u_s(sizeof(tc_s2), tc_s2, kRoundToZero); + test_ftint_u_d(sizeof(tc_d2), tc_d2, kRoundToZero); + + struct TestCaseMsa2RF_F_U tc_s3[] = { + {0.f, 4.5f, 1.49f, -12.51f, 0, 5, 2, 0}, + {-0.f, 23.38f, 2.8f, 32.6f, 0, 24, 3, 33}, + {inf_float, -inf_float, 0, 4.f * uint32_max, uint32_max, 0, 0, + uint32_max}}; + + struct TestCaseMsa2RF_D_U tc_d3[] = { + {0., 4.5, 0, 5}, + {1.49, -12.51, 2, 0}, + {-0., 23.38, -0, 24}, + {2.8, 32.6, 3, 33}, + {inf_double, -inf_double, uint64_max, 0}, + {-0.5252, 4000. * uint64_max, 0, uint64_max}}; + + test_ftint_u_s(sizeof(tc_s3), tc_s3, kRoundToPlusInf); + test_ftint_u_d(sizeof(tc_d3), tc_d3, kRoundToPlusInf); + + struct TestCaseMsa2RF_F_U tc_s4[] = { + {0.f, 4.5f, 1.49f, -12.51f, 0, 4, 1, 0}, + {-0.f, 23.38f, 2.8f, 32.6f, 0, 23, 2, 32}, + {inf_float, -inf_float, 0, 4.f * uint32_max, uint32_max, 0, 0, + uint32_max}}; + + struct TestCaseMsa2RF_D_U tc_d4[] = { + {0., 4.5, 0, 4}, + {1.49, -12.51, 1, 0}, + {-0., 23.38, -0, 23}, + {2.8, 32.6, 2, 32}, + {inf_double, -inf_double, uint64_max, 0}, + {-0.098797, 4000. * uint64_max, 0, uint64_max}}; + + test_ftint_u_s(sizeof(tc_s4), tc_s4, kRoundToMinusInf); + test_ftint_u_d(sizeof(tc_d4), tc_d4, kRoundToMinusInf); +} + +struct TestCaseMsa2RF_U_F { + uint32_t ws1; + uint32_t ws2; + uint32_t ws3; + uint32_t ws4; + float exp_res_1; + float exp_res_2; + float exp_res_3; + float exp_res_4; +}; + +struct TestCaseMsa2RF_U_D { + uint64_t ws1; + uint64_t ws2; + double exp_res_1; + double exp_res_2; +}; + +TEST(MSA_ffint_u) { + if ((kArchVariant != kMips64r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + + struct TestCaseMsa2RF_U_F tc_s[] = { + {0, 345, 234, 1000, 0.f, 345.f, 234.f, 1000.f}}; + + struct TestCaseMsa2RF_U_D tc_d[] = {{0, 345, 0., 345.}, + {234, 1000, 234., 1000.}}; + + for (size_t i = 0; i < sizeof(tc_s) / sizeof(TestCaseMsa2RF_U_F); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_s[i]), + [](MacroAssembler& assm) { __ ffint_u_w(w2, w0); }, + load_uint32_elements_of_vector, store_uint32_elements_of_vector); + } + for (size_t i = 0; i < sizeof(tc_d) / sizeof(TestCaseMsa2RF_U_D); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [](MacroAssembler& assm) { __ ffint_u_d(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + } +} + +struct TestCaseMsa2RF_I_F { + int32_t ws1; + int32_t ws2; + int32_t ws3; + int32_t ws4; + float exp_res_1; + float exp_res_2; + float exp_res_3; + float exp_res_4; +}; + +struct TestCaseMsa2RF_I_D { + int64_t ws1; + int64_t ws2; + double exp_res_1; + double exp_res_2; +}; + +TEST(MSA_ffint_s) { + if ((kArchVariant != kMips64r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + + struct TestCaseMsa2RF_I_F tc_s[] = { + {0, 345, -234, 1000, 0.f, 345.f, -234.f, 1000.f}}; + + struct TestCaseMsa2RF_I_D tc_d[] = {{0, 345, 0., 345.}, + {-234, 1000, -234., 1000.}}; + + for (size_t i = 0; i < sizeof(tc_s) / sizeof(TestCaseMsa2RF_I_F); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_s[i]), + [](MacroAssembler& assm) { __ ffint_s_w(w2, w0); }, + load_uint32_elements_of_vector, store_uint32_elements_of_vector); + } + for (size_t i = 0; i < sizeof(tc_d) / sizeof(TestCaseMsa2RF_I_D); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [](MacroAssembler& assm) { __ ffint_s_d(w2, w0); }, + load_uint64_elements_of_vector, store_uint64_elements_of_vector); + } +} + +struct TestCaseMsa2RF_U16_F { + uint16_t ws1; + uint16_t ws2; + uint16_t ws3; + uint16_t ws4; + uint16_t ws5; + uint16_t ws6; + uint16_t ws7; + uint16_t ws8; + float exp_res_1; + float exp_res_2; + float exp_res_3; + float exp_res_4; +}; + +struct TestCaseMsa2RF_F_D { + float ws1; + float ws2; + float ws3; + float ws4; + double exp_res_1; + double exp_res_2; +}; + +TEST(MSA_fexupl) { + if ((kArchVariant != kMips64r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + + const float inf_float = std::numeric_limits<float>::infinity(); + const double inf_double = std::numeric_limits<double>::infinity(); + + struct TestCaseMsa2RF_U16_F tc_s[] = { + {1, 2, 0x7c00, 0x0c00, 0, 0x7c00, 0xfc00, 0x8000, 0.f, inf_float, + -inf_float, -0.f}, + {0xfc00, 0xffff, 0x00ff, 0x8000, 0x81fe, 0x8000, 0x0345, 0xaaaa, + -3.0398368835e-5f, -0.f, 4.9889088e-5f, -5.2062988281e-2f}, + {3, 4, 0x5555, 6, 0x2aaa, 0x8700, 0x7777, 0x6a8b, 5.2062988281e-2f, + -1.06811523458e-4f, 3.0576e4f, 3.35e3f}}; + + struct TestCaseMsa2RF_F_D tc_d[] = { + {0.f, 123.456f, inf_float, -0.f, inf_double, -0.}, + {-inf_float, -3.f, 0.f, -inf_float, 0., -inf_double}, + {2.3f, 3., 1.37747639043129518071e-41f, -3.22084585277826e35f, + 1.37747639043129518071e-41, -3.22084585277826e35}}; + + for (size_t i = 0; i < sizeof(tc_s) / sizeof(TestCaseMsa2RF_U16_F); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_s[i]), + [](MacroAssembler& assm) { __ fexupl_w(w2, w0); }, + load_uint16_elements_of_vector, store_uint32_elements_of_vector); + } + for (size_t i = 0; i < sizeof(tc_d) / sizeof(TestCaseMsa2RF_F_D); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [](MacroAssembler& assm) { __ fexupl_d(w2, w0); }, + load_uint32_elements_of_vector, store_uint64_elements_of_vector); + } +} + +TEST(MSA_fexupr) { + if ((kArchVariant != kMips64r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + + const float inf_float = std::numeric_limits<float>::infinity(); + const double inf_double = std::numeric_limits<double>::infinity(); + + struct TestCaseMsa2RF_U16_F tc_s[] = { + {0, 0x7c00, 0xfc00, 0x8000, 1, 2, 0x7c00, 0x0c00, 0.f, inf_float, + -inf_float, -0.f}, + {0x81fe, 0x8000, 0x0345, 0xaaaa, 0xfc00, 0xffff, 0x00ff, 0x8000, + -3.0398368835e-5f, -0.f, 4.9889088e-5f, -5.2062988281e-2f}, + {0x2aaa, 0x8700, 0x7777, 0x6a8b, 3, 4, 0x5555, 6, 5.2062988281e-2f, + -1.06811523458e-4f, 3.0576e4f, 3.35e3f}}; + + struct TestCaseMsa2RF_F_D tc_d[] = { + {inf_float, -0.f, 0.f, 123.456f, inf_double, -0.}, + {0.f, -inf_float, -inf_float, -3.f, 0., -inf_double}, + {1.37747639043129518071e-41f, -3.22084585277826e35f, 2.3f, 3., + 1.37747639043129518071e-41, -3.22084585277826e35}}; + + for (size_t i = 0; i < sizeof(tc_s) / sizeof(TestCaseMsa2RF_U16_F); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_s[i]), + [](MacroAssembler& assm) { __ fexupr_w(w2, w0); }, + load_uint16_elements_of_vector, store_uint32_elements_of_vector); + } + for (size_t i = 0; i < sizeof(tc_d) / sizeof(TestCaseMsa2RF_F_D); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [](MacroAssembler& assm) { __ fexupr_d(w2, w0); }, + load_uint32_elements_of_vector, store_uint64_elements_of_vector); + } +} + +struct TestCaseMsa2RF_U32_D { + uint32_t ws1; + uint32_t ws2; + uint32_t ws3; + uint32_t ws4; + double exp_res_1; + double exp_res_2; +}; + +TEST(MSA_ffql) { + if ((kArchVariant != kMips64r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + + struct TestCaseMsa2RF_U16_F tc_s[] = {{0, 3, 0xffff, 0x8000, 0x8000, 0xe000, + 0x0FF0, 0, -1.f, -0.25f, + 0.12451171875f, 0.f}}; + + struct TestCaseMsa2RF_U32_D tc_d[] = { + {0, 45, 0x80000000, 0xe0000000, -1., -0.25}, + {0x28379, 0xaaaa5555, 0x024903d3, 0, 17.853239085525274277e-3, 0.}}; + + for (size_t i = 0; i < sizeof(tc_s) / sizeof(TestCaseMsa2RF_U16_F); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_s[i]), + [](MacroAssembler& assm) { __ ffql_w(w2, w0); }, + load_uint16_elements_of_vector, store_uint32_elements_of_vector); + } + for (size_t i = 0; i < sizeof(tc_d) / sizeof(TestCaseMsa2RF_U32_D); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [](MacroAssembler& assm) { __ ffql_d(w2, w0); }, + load_uint32_elements_of_vector, store_uint64_elements_of_vector); + } +} + +TEST(MSA_ffqr) { + if ((kArchVariant != kMips64r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) + return; + + CcTest::InitializeVM(); + + struct TestCaseMsa2RF_U16_F tc_s[] = {{0x8000, 0xe000, 0x0FF0, 0, 0, 3, + 0xffff, 0x8000, -1.f, -0.25f, + 0.12451171875f, 0.f}}; + + struct TestCaseMsa2RF_U32_D tc_d[] = { + {0x80000000, 0xe0000000, 0, 45, -1., -0.25}, + {0x024903d3, 0, 0x28379, 0xaaaa5555, 17.853239085525274277e-3, 0.}}; + + for (size_t i = 0; i < sizeof(tc_s) / sizeof(TestCaseMsa2RF_U16_F); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_s[i]), + [](MacroAssembler& assm) { __ ffqr_w(w2, w0); }, + load_uint16_elements_of_vector, store_uint32_elements_of_vector); + } + for (size_t i = 0; i < sizeof(tc_d) / sizeof(TestCaseMsa2RF_U32_D); ++i) { + run_msa_2r(reinterpret_cast<const TestCaseMsa2R*>(&tc_d[i]), + [](MacroAssembler& assm) { __ ffqr_d(w2, w0); }, + load_uint32_elements_of_vector, store_uint64_elements_of_vector); } } @@ -7776,35 +8751,21 @@ void run_msa_vector(struct TestCaseMsaVector* input, CpuFeatureScope fscope(&assm, MIPS_SIMD); msa_reg_t res; -#define LOAD_W_REG(lo, hi, w_reg) \ - __ li(t0, lo); \ - __ li(t1, hi); \ - __ insert_d(w_reg, 0, t0); \ - __ insert_d(w_reg, 1, t1) - - LOAD_W_REG(input->ws_lo, input->ws_hi, w0); - LOAD_W_REG(input->wt_lo, input->wt_hi, w2); - LOAD_W_REG(input->wd_lo, input->wd_hi, w4); -#undef LOAD_W_REG + load_uint64_elements_of_vector(assm, &(input->ws_lo), w0, t0, t1); + load_uint64_elements_of_vector(assm, &(input->wt_lo), w2, t0, t1); + load_uint64_elements_of_vector(assm, &(input->wd_lo), w4, t0, t1); GenerateVectorInstructionFunc(assm); - __ copy_u_w(t2, w4, 0); - __ sw(t2, MemOperand(a0, 0)); - __ copy_u_w(t2, w4, 1); - __ sw(t2, MemOperand(a0, 4)); - __ copy_u_w(t2, w4, 2); - __ sw(t2, MemOperand(a0, 8)); - __ copy_u_w(t2, w4, 3); - __ sw(t2, MemOperand(a0, 12)); + store_uint64_elements_of_vector(assm, w4, a0); __ jr(ra); __ nop(); CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -7879,34 +8840,20 @@ void run_msa_bit(struct TestCaseMsaBit* input, InstFunc GenerateInstructionFunc, CpuFeatureScope fscope(&assm, MIPS_SIMD); msa_reg_t res; -#define LOAD_W_REG(lo, hi, w_reg) \ - __ li(t0, lo); \ - __ li(t1, hi); \ - __ insert_d(w_reg, 0, t0); \ - __ insert_d(w_reg, 1, t1) - - LOAD_W_REG(input->ws_lo, input->ws_hi, w0); - LOAD_W_REG(input->wd_lo, input->wd_hi, w2); -#undef LOAD_W_REG + load_uint64_elements_of_vector(assm, &(input->ws_lo), w0, t0, t1); + load_uint64_elements_of_vector(assm, &(input->wd_lo), w2, t0, t1); GenerateInstructionFunc(assm, input->m); - __ copy_u_w(t2, w2, 0); - __ sw(t2, MemOperand(a0, 0)); - __ copy_u_w(t2, w2, 1); - __ sw(t2, MemOperand(a0, 4)); - __ copy_u_w(t2, w2, 2); - __ sw(t2, MemOperand(a0, 8)); - __ copy_u_w(t2, w2, 3); - __ sw(t2, MemOperand(a0, 12)); + store_uint64_elements_of_vector(assm, w2, a0); __ jr(ra); __ nop(); CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -8371,22 +9318,15 @@ void run_msa_i10(int32_t input, InstFunc GenerateVectorInstructionFunc, GenerateVectorInstructionFunc(assm, input); - __ copy_u_w(t2, w0, 0); - __ sw(t2, MemOperand(a0, 0)); - __ copy_u_w(t2, w0, 1); - __ sw(t2, MemOperand(a0, 4)); - __ copy_u_w(t2, w0, 2); - __ sw(t2, MemOperand(a0, 8)); - __ copy_u_w(t2, w0, 3); - __ sw(t2, MemOperand(a0, 12)); + store_uint64_elements_of_vector(assm, w0, a0); __ jr(ra); __ nop(); CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -8463,8 +9403,8 @@ void run_msa_mi10(InstFunc GenerateVectorInstructionFunc) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -8509,4 +9449,782 @@ TEST(MSA_load_store_vector) { #undef LDI_DF } +struct TestCaseMsa3R { + uint64_t ws_lo; + uint64_t ws_hi; + uint64_t wt_lo; + uint64_t wt_hi; + uint64_t wd_lo; + uint64_t wd_hi; +}; + +static const uint64_t Unpredictable = 0x312014017725ll; + +template <typename InstFunc, typename OperFunc> +void run_msa_3r(struct TestCaseMsa3R* input, InstFunc GenerateI5InstructionFunc, + OperFunc GenerateOperationFunc) { + Isolate* isolate = CcTest::i_isolate(); + HandleScope scope(isolate); + + MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); + CpuFeatureScope fscope(&assm, MIPS_SIMD); + msa_reg_t res; + uint64_t expected; + + load_uint64_elements_of_vector(assm, &(input->wt_lo), w0, t0, t1); + load_uint64_elements_of_vector(assm, &(input->ws_lo), w1, t0, t1); + load_uint64_elements_of_vector(assm, &(input->wd_lo), w2, t0, t1); + + GenerateI5InstructionFunc(assm); + + store_uint64_elements_of_vector(assm, w2, a0); + + __ jr(ra); + __ nop(); + + CodeDesc desc; + assm.GetCode(isolate, &desc); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); +#ifdef OBJECT_PRINT + code->Print(std::cout); +#endif + F3 f = FUNCTION_CAST<F3>(code->entry()); + + (CALL_GENERATED_CODE(isolate, f, &res, 0, 0, 0, 0)); + + expected = GenerateOperationFunc(input->ws_lo, input->wt_lo, input->wd_lo); + if (expected != Unpredictable) { + CHECK_EQ(expected, res.d[0]); + } + + expected = GenerateOperationFunc(input->ws_hi, input->wt_hi, input->wd_hi); + if (expected != Unpredictable) { + CHECK_EQ(expected, res.d[1]); + } +} + +TEST(MSA_3R_instructions) { + if (kArchVariant == kMips64r6 || !CpuFeatures::IsSupported(MIPS_SIMD)) return; + + CcTest::InitializeVM(); + + struct TestCaseMsa3R tc[] = { + {0x1169751bb9a7d9c3, 0xf7a594aec8ef8a9c, 0x1169751bb9a7d9c3, + 0xf7a594aec8ef8a9c, 0x1169751bb9a7d9c3, 0xf7a594aec8ef8a9c}, + {0x2b665362c4e812df, 0x3a0d80d68b3f8bc8, 0x2b665362c4e812df, + 0x3a0d80d68b3f8bc8, 0x2b665362c4e812df, 0x3a0d80d68b3f8bc8}, + {0x1169751bb9a7d9c3, 0xf7a594aec8ef8a9c, 0x1169751bb9a7d9c3, + 0xf7a594aec8ef8a9c, 0x1169751bb9a7d9c3, 0xf7a594aec8ef8a9c}, + {0x2b665362c4e812df, 0x3a0d80d68b3f8bc8, 0x2b665362c4e812df, + 0x3a0d80d68b3f8bc8, 0x2b665362c4e812df, 0x3a0d80d68b3f8bc8}, + {0xffab807f807fffcd, 0x7f23ff80ff567f80, 0xffab807f807fffcd, + 0x7f23ff80ff567f80, 0xffab807f807fffcd, 0x7f23ff80ff567f80}, + {0x80ffefff7f12807f, 0x807f80ff7fdeff78, 0x80ffefff7f12807f, + 0x807f80ff7fdeff78, 0x80ffefff7f12807f, 0x807f80ff7fdeff78}, + {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, + 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}, + {0x0000000000000000, 0xffffffffffffffff, 0xffffffffffffffff, + 0x0000000000000000, 0x0000000000000000, 0xffffffffffffffff}, + {0xffff0000ffff0000, 0xffff0000ffff0000, 0xffff0000ffff0000, + 0xffff0000ffff0000, 0xffff0000ffff0000, 0xffff0000ffff0000}, + {0xff00ff00ff00ff00, 0xff00ff00ff00ff00, 0xff00ff00ff00ff00, + 0xff00ff00ff00ff00, 0xff00ff00ff00ff00, 0xff00ff00ff00ff00}, + {0xf0f0f0f0f0f0f0f0, 0xf0f0f0f0f0f0f0f0, 0xf0f0f0f0f0f0f0f0, + 0xf0f0f0f0f0f0f0f0, 0xf0f0f0f0f0f0f0f0, 0xf0f0f0f0f0f0f0f0}, + {0xff0000ffff0000ff, 0xff0000ffff0000ff, 0xff0000ffff0000ff, + 0xff0000ffff0000ff, 0xff0000ffff0000ff, 0xff0000ffff0000ff}, + {0xffff00000000ffff, 0xffff00000000ffff, 0xffff00000000ffff, + 0xffff00000000ffff, 0xffff00000000ffff, 0xffff00000000ffff}}; + +#define SLL_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T src_op = static_cast<T>((ws >> shift) & mask); \ + T shift_op = static_cast<T>((wt >> shift) & mask) % size_in_bits; \ + res |= (static_cast<uint64_t>(src_op << shift_op) & mask) << shift; \ + } \ + return res + +#define SRA_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T src_op = static_cast<T>((ws >> shift) & mask); \ + int shift_op = ((wt >> shift) & mask) % size_in_bits; \ + res |= \ + (static_cast<uint64_t>(ArithmeticShiftRight(src_op, shift_op) & mask)) \ + << shift; \ + } \ + return res + +#define SRL_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T src_op = static_cast<T>((ws >> shift) & mask); \ + T shift_op = static_cast<T>(((wt >> shift) & mask) % size_in_bits); \ + res |= (static_cast<uint64_t>(src_op >> shift_op) & mask) << shift; \ + } \ + return res + +#define BCRL_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T src_op = static_cast<T>((ws >> shift) & mask); \ + T shift_op = static_cast<T>(((wt >> shift) & mask) % size_in_bits); \ + T r = (static_cast<T>(~(1ull << shift_op)) & src_op) & mask; \ + res |= static_cast<uint64_t>(r) << shift; \ + } \ + return res + +#define BSET_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T src_op = static_cast<T>((ws >> shift) & mask); \ + T shift_op = static_cast<T>(((wt >> shift) & mask) % size_in_bits); \ + T r = (static_cast<T>(1ull << shift_op) | src_op) & mask; \ + res |= static_cast<uint64_t>(r) << shift; \ + } \ + return res + +#define BNEG_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T src_op = static_cast<T>((ws >> shift) & mask); \ + T shift_op = static_cast<T>(((wt >> shift) & mask) % size_in_bits); \ + T r = (static_cast<T>(1ull << shift_op) ^ src_op) & mask; \ + res |= static_cast<uint64_t>(r) << shift; \ + } \ + return res + +#define BINSL_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wd_op = static_cast<T>((wd >> shift) & mask); \ + int shift_op = static_cast<int>(((wt >> shift) & mask) % size_in_bits); \ + int bits = shift_op + 1; \ + T r; \ + if (bits == size_in_bits) { \ + r = static_cast<T>(ws_op); \ + } else { \ + uint64_t mask2 = ((1ull << bits) - 1) << (size_in_bits - bits); \ + r = static_cast<T>((static_cast<T>(mask2) & ws_op) | \ + (static_cast<T>(~mask2) & wd_op)); \ + } \ + res |= static_cast<uint64_t>(r) << shift; \ + } \ + return res + +#define BINSR_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wd_op = static_cast<T>((wd >> shift) & mask); \ + int shift_op = static_cast<int>(((wt >> shift) & mask) % size_in_bits); \ + int bits = shift_op + 1; \ + T r; \ + if (bits == size_in_bits) { \ + r = static_cast<T>(ws_op); \ + } else { \ + uint64_t mask2 = (1ull << bits) - 1; \ + r = static_cast<T>((static_cast<T>(mask2) & ws_op) | \ + (static_cast<T>(~mask2) & wd_op)); \ + } \ + res |= static_cast<uint64_t>(r) << shift; \ + } \ + return res + +#define ADDV_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + res |= (static_cast<uint64_t>(ws_op + wt_op) & mask) << shift; \ + } \ + return res + +#define SUBV_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + res |= (static_cast<uint64_t>(ws_op - wt_op) & mask) << shift; \ + } \ + return res + +#define MAX_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + res |= (static_cast<uint64_t>(Max<T>(ws_op, wt_op)) & mask) << shift; \ + } \ + return res + +#define MIN_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + res |= (static_cast<uint64_t>(Min<T>(ws_op, wt_op)) & mask) << shift; \ + } \ + return res + +#define MAXA_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + res |= (static_cast<uint64_t>(Nabs(ws_op) < Nabs(wt_op) ? ws_op : wt_op) & \ + mask) \ + << shift; \ + } \ + return res + +#define MINA_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + res |= (static_cast<uint64_t>(Nabs(ws_op) > Nabs(wt_op) ? ws_op : wt_op) & \ + mask) \ + << shift; \ + } \ + return res + +#define CEQ_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + res |= \ + (static_cast<uint64_t>(!Compare(ws_op, wt_op) ? -1ull : 0ull) & mask) \ + << shift; \ + } \ + return res + +#define CLT_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + res |= \ + (static_cast<uint64_t>((Compare(ws_op, wt_op) == -1) ? -1ull : 0ull) & \ + mask) \ + << shift; \ + } \ + return res + +#define CLE_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + res |= \ + (static_cast<uint64_t>((Compare(ws_op, wt_op) != 1) ? -1ull : 0ull) & \ + mask) \ + << shift; \ + } \ + return res + +#define ADD_A_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + res |= (static_cast<uint64_t>(Abs(ws_op) + Abs(wt_op)) & mask) << shift; \ + } \ + return res + +#define ADDS_A_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = Nabs(static_cast<T>((ws >> shift) & mask)); \ + T wt_op = Nabs(static_cast<T>((wt >> shift) & mask)); \ + T r; \ + if (ws_op < -std::numeric_limits<T>::max() - wt_op) { \ + r = std::numeric_limits<T>::max(); \ + } else { \ + r = -(ws_op + wt_op); \ + } \ + res |= (static_cast<uint64_t>(r) & mask) << shift; \ + } \ + return res + +#define ADDS_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + res |= (static_cast<uint64_t>(SaturateAdd(ws_op, wt_op)) & mask) << shift; \ + } \ + return res + +#define AVE_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + res |= (static_cast<uint64_t>(((wt_op & ws_op) + ((ws_op ^ wt_op) >> 1)) & \ + mask)) \ + << shift; \ + } \ + return res + +#define AVER_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + res |= (static_cast<uint64_t>(((wt_op | ws_op) - ((ws_op ^ wt_op) >> 1)) & \ + mask)) \ + << shift; \ + } \ + return res + +#define SUBS_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + res |= (static_cast<uint64_t>(SaturateSub(ws_op, wt_op)) & mask) << shift; \ + } \ + return res + +#define SUBSUS_U_DF(T, lanes, mask) \ + typedef typename std::make_unsigned<T>::type uT; \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + uT ws_op = static_cast<uT>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + T r; \ + if (wt_op > 0) { \ + uT wtu = static_cast<uT>(wt_op); \ + if (wtu > ws_op) { \ + r = 0; \ + } else { \ + r = static_cast<T>(ws_op - wtu); \ + } \ + } else { \ + if (ws_op > std::numeric_limits<uT>::max() + wt_op) { \ + r = static_cast<T>(std::numeric_limits<uT>::max()); \ + } else { \ + r = static_cast<T>(ws_op - wt_op); \ + } \ + } \ + res |= (static_cast<uint64_t>(r) & mask) << shift; \ + } \ + return res + +#define SUBSUU_S_DF(T, lanes, mask) \ + typedef typename std::make_unsigned<T>::type uT; \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + uT ws_op = static_cast<uT>((ws >> shift) & mask); \ + uT wt_op = static_cast<uT>((wt >> shift) & mask); \ + uT wdu; \ + T r; \ + if (ws_op > wt_op) { \ + wdu = ws_op - wt_op; \ + if (wdu > std::numeric_limits<T>::max()) { \ + r = std::numeric_limits<T>::max(); \ + } else { \ + r = static_cast<T>(wdu); \ + } \ + } else { \ + wdu = wt_op - ws_op; \ + CHECK(-std::numeric_limits<T>::max() == \ + std::numeric_limits<T>::min() + 1); \ + if (wdu <= std::numeric_limits<T>::max()) { \ + r = -static_cast<T>(wdu); \ + } else { \ + r = std::numeric_limits<T>::min(); \ + } \ + } \ + res |= (static_cast<uint64_t>(r) & mask) << shift; \ + } \ + return res + +#define ASUB_S_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + res |= (static_cast<uint64_t>(Abs(ws_op - wt_op)) & mask) << shift; \ + } \ + return res + +#define ASUB_U_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + res |= (static_cast<uint64_t>(ws_op > wt_op ? ws_op - wt_op \ + : wt_op - ws_op) & \ + mask) \ + << shift; \ + } \ + return res + +#define MULV_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + res |= (static_cast<uint64_t>(ws_op * wt_op) & mask) << shift; \ + } \ + return res + +#define MADDV_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + T wd_op = static_cast<T>((wd >> shift) & mask); \ + res |= (static_cast<uint64_t>(wd_op + ws_op * wt_op) & mask) << shift; \ + } \ + return res + +#define MSUBV_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + T wd_op = static_cast<T>((wd >> shift) & mask); \ + res |= (static_cast<uint64_t>(wd_op - ws_op * wt_op) & mask) << shift; \ + } \ + return res + +#define DIV_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + if (wt_op == 0) { \ + res = Unpredictable; \ + break; \ + } \ + res |= (static_cast<uint64_t>(ws_op / wt_op) & mask) << shift; \ + } \ + return res + +#define MOD_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T ws_op = static_cast<T>((ws >> shift) & mask); \ + T wt_op = static_cast<T>((wt >> shift) & mask); \ + if (wt_op == 0) { \ + res = Unpredictable; \ + break; \ + } \ + res |= (static_cast<uint64_t>(wt_op != 0 ? ws_op % wt_op : 0) & mask) \ + << shift; \ + } \ + return res + +#define SRAR_DF(T, lanes, mask) \ + uint64_t res = 0; \ + int size_in_bits = kMSARegSize / lanes; \ + for (int i = 0; i < lanes / 2; ++i) { \ + uint64_t shift = size_in_bits * i; \ + T src_op = static_cast<T>((ws >> shift) & mask); \ + int shift_op = ((wt >> shift) & mask) % size_in_bits; \ + uint32_t bit = shift_op == 0 ? 0 : src_op >> (shift_op - 1) & 1; \ + res |= \ + (static_cast<uint64_t>(ArithmeticShiftRight(src_op, shift_op) + bit) & \ + mask) \ + << shift; \ + } \ + return res + +#define TEST_CASE(V) \ + V(sll_b, SLL_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(sll_h, SLL_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(sll_w, SLL_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(sll_d, SLL_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(sra_b, SRA_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(sra_h, SRA_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(sra_w, SRA_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(sra_d, SRA_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(srl_b, SRL_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(srl_h, SRL_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(srl_w, SRL_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(srl_d, SRL_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(bclr_b, BCRL_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(bclr_h, BCRL_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(bclr_w, BCRL_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(bclr_d, BCRL_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(bset_b, BSET_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(bset_h, BSET_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(bset_w, BSET_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(bset_d, BSET_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(bneg_b, BNEG_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(bneg_h, BNEG_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(bneg_w, BNEG_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(bneg_d, BNEG_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(binsl_b, BINSL_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(binsl_h, BINSL_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(binsl_w, BINSL_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(binsl_d, BINSL_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(binsr_b, BINSR_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(binsr_h, BINSR_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(binsr_w, BINSR_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(binsr_d, BINSR_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(addv_b, ADDV_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(addv_h, ADDV_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(addv_w, ADDV_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(addv_d, ADDV_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(subv_b, SUBV_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(subv_h, SUBV_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(subv_w, SUBV_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(subv_d, SUBV_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(max_s_b, MAX_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(max_s_h, MAX_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(max_s_w, MAX_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(max_s_d, MAX_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(max_u_b, MAX_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(max_u_h, MAX_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(max_u_w, MAX_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(max_u_d, MAX_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(min_s_b, MIN_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(min_s_h, MIN_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(min_s_w, MIN_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(min_s_d, MIN_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(min_u_b, MIN_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(min_u_h, MIN_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(min_u_w, MIN_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(min_u_d, MIN_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(max_a_b, MAXA_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(max_a_h, MAXA_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(max_a_w, MAXA_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(max_a_d, MAXA_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(min_a_b, MINA_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(min_a_h, MINA_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(min_a_w, MINA_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(min_a_d, MINA_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(ceq_b, CEQ_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(ceq_h, CEQ_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(ceq_w, CEQ_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(ceq_d, CEQ_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(clt_s_b, CLT_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(clt_s_h, CLT_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(clt_s_w, CLT_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(clt_s_d, CLT_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(clt_u_b, CLT_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(clt_u_h, CLT_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(clt_u_w, CLT_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(clt_u_d, CLT_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(cle_s_b, CLE_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(cle_s_h, CLE_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(cle_s_w, CLE_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(cle_s_d, CLE_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(cle_u_b, CLE_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(cle_u_h, CLE_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(cle_u_w, CLE_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(cle_u_d, CLE_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(add_a_b, ADD_A_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(add_a_h, ADD_A_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(add_a_w, ADD_A_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(add_a_d, ADD_A_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(adds_a_b, ADDS_A_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(adds_a_h, ADDS_A_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(adds_a_w, ADDS_A_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(adds_a_d, ADDS_A_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(adds_s_b, ADDS_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(adds_s_h, ADDS_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(adds_s_w, ADDS_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(adds_s_d, ADDS_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(adds_u_b, ADDS_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(adds_u_h, ADDS_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(adds_u_w, ADDS_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(adds_u_d, ADDS_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(ave_s_b, AVE_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(ave_s_h, AVE_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(ave_s_w, AVE_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(ave_s_d, AVE_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(ave_u_b, AVE_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(ave_u_h, AVE_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(ave_u_w, AVE_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(ave_u_d, AVE_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(aver_s_b, AVER_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(aver_s_h, AVER_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(aver_s_w, AVER_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(aver_s_d, AVER_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(aver_u_b, AVER_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(aver_u_h, AVER_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(aver_u_w, AVER_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(aver_u_d, AVER_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(subs_s_b, SUBS_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(subs_s_h, SUBS_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(subs_s_w, SUBS_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(subs_s_d, SUBS_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(subs_u_b, SUBS_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(subs_u_h, SUBS_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(subs_u_w, SUBS_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(subs_u_d, SUBS_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(subsus_u_b, SUBSUS_U_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(subsus_u_h, SUBSUS_U_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(subsus_u_w, SUBSUS_U_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(subsus_u_d, SUBSUS_U_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(subsuu_s_b, SUBSUU_S_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(subsuu_s_h, SUBSUU_S_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(subsuu_s_w, SUBSUU_S_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(subsuu_s_d, SUBSUU_S_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(asub_s_b, ASUB_S_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(asub_s_h, ASUB_S_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(asub_s_w, ASUB_S_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(asub_s_d, ASUB_S_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(asub_u_b, ASUB_U_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(asub_u_h, ASUB_U_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(asub_u_w, ASUB_U_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(asub_u_d, ASUB_U_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(mulv_b, MULV_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(mulv_h, MULV_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(mulv_w, MULV_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(mulv_d, MULV_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(maddv_b, MADDV_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(maddv_h, MADDV_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(maddv_w, MADDV_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(maddv_d, MADDV_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(msubv_b, MSUBV_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(msubv_h, MSUBV_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(msubv_w, MSUBV_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(msubv_d, MSUBV_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(div_s_b, DIV_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(div_s_h, DIV_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(div_s_w, DIV_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(div_s_d, DIV_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(div_u_b, DIV_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(div_u_h, DIV_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(div_u_w, DIV_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(div_u_d, DIV_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(mod_s_b, MOD_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(mod_s_h, MOD_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(mod_s_w, MOD_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(mod_s_d, MOD_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(mod_u_b, MOD_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(mod_u_h, MOD_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(mod_u_w, MOD_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(mod_u_d, MOD_DF, uint64_t, kMSALanesDword, UINT64_MAX) \ + V(srar_b, SRAR_DF, int8_t, kMSALanesByte, UINT8_MAX) \ + V(srar_h, SRAR_DF, int16_t, kMSALanesHalf, UINT16_MAX) \ + V(srar_w, SRAR_DF, int32_t, kMSALanesWord, UINT32_MAX) \ + V(srar_d, SRAR_DF, int64_t, kMSALanesDword, UINT64_MAX) \ + V(srlr_b, SRAR_DF, uint8_t, kMSALanesByte, UINT8_MAX) \ + V(srlr_h, SRAR_DF, uint16_t, kMSALanesHalf, UINT16_MAX) \ + V(srlr_w, SRAR_DF, uint32_t, kMSALanesWord, UINT32_MAX) \ + V(srlr_d, SRAR_DF, uint64_t, kMSALanesDword, UINT64_MAX) + +#define RUN_TEST(instr, verify, type, lanes, mask) \ + run_msa_3r(&tc[i], [](MacroAssembler& assm) { __ instr(w2, w1, w0); }, \ + [](uint64_t ws, uint64_t wt, uint64_t wd) { \ + verify(type, lanes, mask); \ + }); + + for (size_t i = 0; i < arraysize(tc); ++i) { + TEST_CASE(RUN_TEST) + } + +#undef RUN_TEST +#undef SLL_DF +#undef SRL_DF +#undef BCRL_DF +#undef BSET_DF +#undef BNEG_DF +#undef BINSL_DF +#undef BINSR_DF +#undef ADDV_DF +#undef SUBV_DF +#undef MAX_DF +#undef MIN_DF +#undef MAXA_DF +#undef MINA_DF +#undef CEQ_DF +#undef CLT_DF +#undef CLE_DF +#undef ADD_A_DF +#undef ADDS_A_DF +#undef ADDS_DF +#undef AVE_DF +#undef AVER_DF +#undef SUBS_DF +#undef SUBSUS_U_DF +#undef SUBSUU_S_DF +#undef ASUB_S_DF +#undef ASUB_U_DF +#undef MULV_DF +#undef MADDV_DF +#undef MSUBV_DF +#undef DIV_DF +#undef MOD_DF +#undef SRAR_DF +} + #undef __ + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-assembler-ppc.cc b/deps/v8/test/cctest/test-assembler-ppc.cc index 06bbb8966a..9a11523605 100644 --- a/deps/v8/test/cctest/test-assembler-ppc.cc +++ b/deps/v8/test/cctest/test-assembler-ppc.cc @@ -33,8 +33,8 @@ #include "src/ppc/simulator-ppc.h" #include "test/cctest/cctest.h" -using namespace v8::internal; - +namespace v8 { +namespace internal { // Define these function prototypes to match JSEntryFunction in execution.cc. typedef Object* (*F1)(int x, int p1, int p2, int p3, int p4); @@ -60,8 +60,8 @@ TEST(0) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG code->Print(); #endif @@ -99,8 +99,8 @@ TEST(1) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG code->Print(); #endif @@ -150,8 +150,8 @@ TEST(2) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG code->Print(); #endif @@ -223,8 +223,8 @@ TEST(3) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG code->Print(); #endif @@ -338,7 +338,7 @@ TEST(4) { assm.GetCode(isolate, &desc); Object* code = isolate->heap()->CreateCode( desc, - Code::ComputeFlags(Code::STUB), + Code::STUB, Handle<Code>())->ToObjectChecked(); CHECK(code->IsCode()); #ifdef DEBUG @@ -399,7 +399,7 @@ TEST(5) { assm.GetCode(isolate, &desc); Object* code = isolate->heap()->CreateCode( desc, - Code::ComputeFlags(Code::STUB), + Code::STUB, Handle<Code>())->ToObjectChecked(); CHECK(code->IsCode()); #ifdef DEBUG @@ -435,7 +435,7 @@ TEST(6) { assm.GetCode(isolate, &desc); Object* code = isolate->heap()->CreateCode( desc, - Code::ComputeFlags(Code::STUB), + Code::STUB, Handle<Code>())->ToObjectChecked(); CHECK(code->IsCode()); #ifdef DEBUG @@ -511,7 +511,7 @@ static void TestRoundingMode(VCVTTypes types, assm.GetCode(isolate, &desc); Object* code = isolate->heap()->CreateCode( desc, - Code::ComputeFlags(Code::STUB), + Code::STUB, Handle<Code>())->ToObjectChecked(); CHECK(code->IsCode()); #ifdef DEBUG @@ -699,7 +699,7 @@ TEST(8) { assm.GetCode(isolate, &desc); Object* code = isolate->heap()->CreateCode( desc, - Code::ComputeFlags(Code::STUB), + Code::STUB, Handle<Code>())->ToObjectChecked(); CHECK(code->IsCode()); #ifdef DEBUG @@ -815,7 +815,7 @@ TEST(9) { assm.GetCode(isolate, &desc); Object* code = isolate->heap()->CreateCode( desc, - Code::ComputeFlags(Code::STUB), + Code::STUB, Handle<Code>())->ToObjectChecked(); CHECK(code->IsCode()); #ifdef DEBUG @@ -927,7 +927,7 @@ TEST(10) { assm.GetCode(isolate, &desc); Object* code = isolate->heap()->CreateCode( desc, - Code::ComputeFlags(Code::STUB), + Code::STUB, Handle<Code>())->ToObjectChecked(); CHECK(code->IsCode()); #ifdef DEBUG @@ -1025,7 +1025,7 @@ TEST(11) { assm.GetCode(isolate, &desc); Object* code = isolate->heap()->CreateCode( desc, - Code::ComputeFlags(Code::STUB), + Code::STUB, Handle<Code>())->ToObjectChecked(); CHECK(code->IsCode()); #ifdef DEBUG @@ -1058,3 +1058,6 @@ TEST(12) { #endif #undef __ + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-assembler-s390.cc b/deps/v8/test/cctest/test-assembler-s390.cc index 5cc6856483..da2727402e 100644 --- a/deps/v8/test/cctest/test-assembler-s390.cc +++ b/deps/v8/test/cctest/test-assembler-s390.cc @@ -34,7 +34,8 @@ #include "src/s390/simulator-s390.h" #include "test/cctest/cctest.h" -using namespace v8::internal; +namespace v8 { +namespace internal { // Define these function prototypes to match JSEntryFunction in execution.cc. typedef Object* (*F1)(int x, int p1, int p2, int p3, int p4); @@ -60,8 +61,8 @@ TEST(0) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG code->Print(); #endif @@ -100,8 +101,8 @@ TEST(1) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG code->Print(); #endif @@ -152,8 +153,8 @@ TEST(2) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG code->Print(); #endif @@ -208,8 +209,8 @@ TEST(3) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG code->Print(); #endif @@ -250,7 +251,7 @@ TEST(4) { CodeDesc desc; assm.GetCode(isolate, &desc); Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + desc, Code::STUB, Handle<Code>()); #ifdef DEBUG code->Print(); #endif @@ -278,7 +279,7 @@ TEST(5) { CodeDesc desc; assm.GetCode(isolate, &desc); Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + desc, Code::STUB, Handle<Code>()); #ifdef DEBUG code->Print(); #endif @@ -312,7 +313,7 @@ TEST(6) { CodeDesc desc; assm.GetCode(isolate, &desc); Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + desc, Code::STUB, Handle<Code>()); #ifdef DEBUG code->Print(); #endif @@ -344,7 +345,7 @@ TEST(7) { CodeDesc desc; assm.GetCode(isolate, &desc); Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + desc, Code::STUB, Handle<Code>()); #ifdef DEBUG code->Print(); #endif @@ -375,7 +376,7 @@ TEST(8) { CodeDesc desc; assm.GetCode(isolate, &desc); Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + desc, Code::STUB, Handle<Code>()); #ifdef DEBUG code->Print(); #endif @@ -402,7 +403,7 @@ TEST(9) { CodeDesc desc; assm.GetCode(isolate, &desc); Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + desc, Code::STUB, Handle<Code>()); #ifdef DEBUG code->Print(); #endif @@ -486,8 +487,8 @@ TEST(10) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG code->Print(); #endif @@ -499,3 +500,6 @@ TEST(10) { } #undef __ + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-assembler-x64.cc b/deps/v8/test/cctest/test-assembler-x64.cc index f57a1c113c..8e7af93b2e 100644 --- a/deps/v8/test/cctest/test-assembler-x64.cc +++ b/deps/v8/test/cctest/test-assembler-x64.cc @@ -186,7 +186,7 @@ TEST(Regression684407) { Assembler assm(CcTest::i_isolate(), buffer, static_cast<int>(actual_size)); Address before = assm.pc(); __ cmpl(Operand(arg1, 0), - Immediate(0, RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); + Immediate(0, RelocInfo::WASM_FUNCTION_TABLE_SIZE_REFERENCE)); Address after = assm.pc(); size_t instruction_size = static_cast<size_t>(after - before); // Check that the immediate is not encoded as uint8. @@ -789,8 +789,8 @@ TEST(AssemblerMultiByteNop) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F0 f = FUNCTION_CAST<F0>(code->entry()); int res = f(); @@ -845,8 +845,8 @@ void DoSSE2(const v8::FunctionCallbackInfo<v8::Value>& args) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F0 f = FUNCTION_CAST<F0>(code->entry()); int res = f(); @@ -908,8 +908,8 @@ TEST(AssemblerX64Extractps) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT OFStream os(stdout); code->Print(os); @@ -946,10 +946,8 @@ TEST(AssemblerX64SSE) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, - Code::ComputeFlags(Code::STUB), - Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT OFStream os(stdout); code->Print(os); @@ -1174,8 +1172,8 @@ TEST(AssemblerX64FMA_sd) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT OFStream os(stdout); code->Print(os); @@ -1400,8 +1398,8 @@ TEST(AssemblerX64FMA_ss) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT OFStream os(stdout); code->Print(os); @@ -1475,8 +1473,8 @@ TEST(AssemblerX64SSE_ss) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT OFStream os(stdout); code->Print(os); @@ -1560,8 +1558,8 @@ TEST(AssemblerX64AVX_ss) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT OFStream os(stdout); code->Print(os); @@ -1799,8 +1797,8 @@ TEST(AssemblerX64AVX_sd) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT OFStream os(stdout); code->Print(os); @@ -1991,8 +1989,8 @@ TEST(AssemblerX64BMI1) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT OFStream os(stdout); code->Print(os); @@ -2051,8 +2049,8 @@ TEST(AssemblerX64LZCNT) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT OFStream os(stdout); code->Print(os); @@ -2111,8 +2109,8 @@ TEST(AssemblerX64POPCNT) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT OFStream os(stdout); code->Print(os); @@ -2374,8 +2372,8 @@ TEST(AssemblerX64BMI2) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT OFStream os(stdout); code->Print(os); @@ -2419,8 +2417,8 @@ TEST(AssemblerX64JumpTables1) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -2468,8 +2466,8 @@ TEST(AssemblerX64JumpTables2) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -2527,8 +2525,8 @@ TEST(AssemblerX64vmovups) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT OFStream os(stdout); code->Print(os); diff --git a/deps/v8/test/cctest/test-atomicops.cc b/deps/v8/test/cctest/test-atomicops.cc index 07445cb2d1..add819f771 100644 --- a/deps/v8/test/cctest/test-atomicops.cc +++ b/deps/v8/test/cctest/test-atomicops.cc @@ -30,9 +30,8 @@ #include "src/base/atomicops.h" #include "test/cctest/cctest.h" -using namespace v8::base; -using namespace v8::internal; - +namespace v8 { +namespace base { #define CHECK_EQU(v1, v2) \ CHECK_EQ(static_cast<int64_t>(v1), static_cast<int64_t>(v2)) @@ -287,3 +286,6 @@ TEST(Load) { TestLoad<Atomic32>(); TestLoad<AtomicWord>(); } + +} // namespace base +} // namespace v8 diff --git a/deps/v8/test/cctest/test-bignum-dtoa.cc b/deps/v8/test/cctest/test-bignum-dtoa.cc index df84dcbf9b..42562958e6 100644 --- a/deps/v8/test/cctest/test-bignum-dtoa.cc +++ b/deps/v8/test/cctest/test-bignum-dtoa.cc @@ -40,6 +40,7 @@ namespace v8 { namespace internal { +namespace test_bignum_dtoa { // Removes trailing '0' digits. // Can return the empty string if all digits are 0. @@ -314,5 +315,6 @@ TEST(BignumDtoaGayPrecision) { } } +} // namespace test_bignum_dtoa } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/test-bignum.cc b/deps/v8/test/cctest/test-bignum.cc index 8cd74eeb30..d9721b06e1 100644 --- a/deps/v8/test/cctest/test-bignum.cc +++ b/deps/v8/test/cctest/test-bignum.cc @@ -35,6 +35,7 @@ namespace v8 { namespace internal { +namespace test_bignum { static const int kBufferSize = 1024; @@ -1541,5 +1542,6 @@ TEST(AssignPowerUInt16) { buffer)); } +} // namespace test_bignum } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/test-code-cache.cc b/deps/v8/test/cctest/test-code-cache.cc deleted file mode 100644 index 51052bd0c6..0000000000 --- a/deps/v8/test/cctest/test-code-cache.cc +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2016 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/v8.h" - -#include "src/factory.h" -#include "src/isolate.h" -#include "src/objects.h" -// FIXME(mstarzinger, marja): This is weird, but required because of the missing -// (disallowed) include: src/factory.h -> src/objects-inl.h -#include "src/objects-inl.h" -// FIXME(mstarzinger, marja): This is weird, but required because of the missing -// (disallowed) include: src/feedback-vector.h -> -// src/feedback-vector-inl.h -#include "src/feedback-vector-inl.h" -#include "test/cctest/cctest.h" - -namespace v8 { -namespace internal { - -namespace { - -static Handle<Code> GetDummyCode(Isolate* isolate) { - CodeDesc desc = {nullptr, // buffer - 0, // buffer_size - 0, // instr_size - 0, // reloc_size - 0, // constant_pool_size - nullptr, // unwinding_info - 0, // unwinding_info_size - nullptr}; // origin - Code::Flags flags = Code::ComputeFlags(Code::LOAD_IC, kNoExtraICState); - Handle<Code> self_ref; - return isolate->factory()->NewCode(desc, flags, self_ref); -} - -} // namespace - -TEST(CodeCache) { - CcTest::InitializeVM(); - Isolate* isolate = CcTest::i_isolate(); - Factory* factory = isolate->factory(); - HandleScope handle_scope(isolate); - - Handle<Map> map = - factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize, PACKED_ELEMENTS); - - // This number should be large enough to cause the code cache to use its - // hash table storage format. - static const int kEntries = 150; - - // Prepare name/code pairs. - std::vector<Handle<Name>> names; - std::vector<Handle<Code>> codes; - names.reserve(kEntries); - codes.reserve(kEntries); - for (int i = 0; i < kEntries; i++) { - names.push_back(isolate->factory()->NewSymbol()); - codes.push_back(GetDummyCode(isolate)); - } - Handle<Name> bad_name = isolate->factory()->NewSymbol(); - Code::Flags flags = Code::ComputeFlags(Code::LOAD_IC, kNoExtraICState); - - // Cache name/code pairs. - for (int i = 0; i < kEntries; i++) { - Handle<Name> name = names.at(i); - Handle<Code> code = codes.at(i); - Map::UpdateCodeCache(map, name, code); - CHECK_EQ(*code, map->LookupInCodeCache(*name, code->flags())); - } - CHECK_NULL(map->LookupInCodeCache(*bad_name, flags)); - - // Check that lookup works not only right after storing. - for (int i = 0; i < kEntries; i++) { - Handle<Name> name = names.at(i); - Handle<Code> code = codes.at(i); - CHECK_EQ(*code, map->LookupInCodeCache(*name, code->flags())); - } -} - -} // namespace internal -} // namespace v8 diff --git a/deps/v8/test/cctest/test-code-layout.cc b/deps/v8/test/cctest/test-code-layout.cc index e4ee251465..caeeaf3283 100644 --- a/deps/v8/test/cctest/test-code-layout.cc +++ b/deps/v8/test/cctest/test-code-layout.cc @@ -4,14 +4,7 @@ #include "src/factory.h" #include "src/isolate.h" -#include "src/objects.h" -// FIXME(mstarzinger, marja): This is weird, but required because of the missing -// (disallowed) include: src/factory.h -> src/objects-inl.h #include "src/objects-inl.h" -// FIXME(mstarzinger, marja): This is weird, but required because of the missing -// (disallowed) include: src/feedback-vector.h -> -// src/feedback-vector-inl.h -#include "src/feedback-vector-inl.h" #include "test/cctest/cctest.h" namespace v8 { @@ -39,7 +32,7 @@ TEST(CodeLayoutWithoutUnwindingInfo) { code_desc.unwinding_info_size = 0; Handle<Code> code = CcTest::i_isolate()->factory()->NewCode( - code_desc, 0, Handle<Object>::null()); + code_desc, Code::STUB, Handle<Object>::null()); CHECK(!code->has_unwinding_info()); CHECK_EQ(code->instruction_size(), buffer_size); @@ -76,7 +69,7 @@ TEST(CodeLayoutWithUnwindingInfo) { code_desc.unwinding_info_size = unwinding_info_size; Handle<Code> code = CcTest::i_isolate()->factory()->NewCode( - code_desc, 0, Handle<Object>::null()); + code_desc, Code::STUB, Handle<Object>::null()); CHECK(code->has_unwinding_info()); CHECK_EQ(code->instruction_size(), buffer_size); diff --git a/deps/v8/test/cctest/test-code-stub-assembler.cc b/deps/v8/test/cctest/test-code-stub-assembler.cc index e34b232244..1c48225a14 100644 --- a/deps/v8/test/cctest/test-code-stub-assembler.cc +++ b/deps/v8/test/cctest/test-code-stub-assembler.cc @@ -7,6 +7,8 @@ #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" +#include "src/char-predicates.h" #include "src/code-factory.h" #include "src/code-stub-assembler.h" #include "src/compiler/node.h" @@ -78,7 +80,8 @@ TEST(CallCFunction3WithCallerSavedRegisters) { Node* const result = m.CallCFunction3WithCallerSavedRegisters( type_intptr, type_intptr, type_intptr, type_intptr, fun_constant, - m.IntPtrConstant(0), m.IntPtrConstant(1), m.IntPtrConstant(2)); + m.IntPtrConstant(0), m.IntPtrConstant(1), m.IntPtrConstant(2), + kSaveFPRegs); m.Return(m.SmiTag(result)); } @@ -2263,7 +2266,6 @@ TEST(AllocateFunctionWithMapAndContext) { CHECK_EQ(isolate->heap()->the_hole_value(), fun->prototype_or_initial_map()); CHECK_EQ(*isolate->promise_resolve_shared_fun(), fun->shared()); CHECK_EQ(isolate->promise_resolve_shared_fun()->code(), fun->code()); - CHECK_EQ(isolate->heap()->undefined_value(), fun->next_function_link()); } TEST(CreatePromiseGetCapabilitiesExecutorContext) { @@ -2276,14 +2278,14 @@ TEST(CreatePromiseGetCapabilitiesExecutorContext) { Node* const context = m.Parameter(kNumParams + 2); Node* const native_context = m.LoadNativeContext(context); - Node* const map = m.LoadRoot(Heap::kJSPromiseCapabilityMapRootIndex); - Node* const capability = m.AllocateJSObjectFromMap(map); + Node* const map = m.LoadRoot(Heap::kPromiseCapabilityMapRootIndex); + Node* const capability = m.AllocateStruct(map); m.StoreObjectFieldNoWriteBarrier( - capability, JSPromiseCapability::kPromiseOffset, m.UndefinedConstant()); + capability, PromiseCapability::kPromiseOffset, m.UndefinedConstant()); m.StoreObjectFieldNoWriteBarrier( - capability, JSPromiseCapability::kResolveOffset, m.UndefinedConstant()); - m.StoreObjectFieldNoWriteBarrier( - capability, JSPromiseCapability::kRejectOffset, m.UndefinedConstant()); + capability, PromiseCapability::kResolveOffset, m.UndefinedConstant()); + m.StoreObjectFieldNoWriteBarrier(capability, PromiseCapability::kRejectOffset, + m.UndefinedConstant()); Node* const executor_context = m.CreatePromiseGetCapabilitiesExecutorContext(capability, native_context); m.Return(executor_context); @@ -2299,7 +2301,7 @@ TEST(CreatePromiseGetCapabilitiesExecutorContext) { CHECK_EQ(isolate->heap()->the_hole_value(), context_js->extension()); CHECK_EQ(*isolate->native_context(), context_js->native_context()); CHECK(context_js->get(PromiseBuiltinsAssembler::kCapabilitySlot) - ->IsJSPromiseCapability()); + ->IsPromiseCapability()); } TEST(NewPromiseCapability) { @@ -2323,9 +2325,9 @@ TEST(NewPromiseCapability) { Handle<Object> result_obj = ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); - CHECK(result_obj->IsJSPromiseCapability()); - Handle<JSPromiseCapability> result = - Handle<JSPromiseCapability>::cast(result_obj); + CHECK(result_obj->IsPromiseCapability()); + Handle<PromiseCapability> result = + Handle<PromiseCapability>::cast(result_obj); CHECK(result->promise()->IsJSPromise()); CHECK(result->resolve()->IsJSFunction()); @@ -2376,9 +2378,9 @@ TEST(NewPromiseCapability) { Handle<Object> result_obj = ft.Call(isolate->factory()->undefined_value(), constructor_fn) .ToHandleChecked(); - CHECK(result_obj->IsJSPromiseCapability()); - Handle<JSPromiseCapability> result = - Handle<JSPromiseCapability>::cast(result_obj); + CHECK(result_obj->IsPromiseCapability()); + Handle<PromiseCapability> result = + Handle<PromiseCapability>::cast(result_obj); CHECK(result->promise()->IsJSObject()); Handle<JSObject> promise(JSObject::cast(result->promise())); @@ -2606,6 +2608,246 @@ TEST(LoadJSArrayElementsMap) { } } +TEST(AllocateStruct) { + Isolate* isolate(CcTest::InitIsolateOnce()); + + const int kNumParams = 3; + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeStubAssembler m(asm_tester.state()); + + { + Node* map = m.Parameter(0); + Node* result = m.AllocateStruct(map); + + m.Return(result); + } + + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); + + Handle<Map> maps[] = { + handle(isolate->heap()->promise_capability_map(), isolate), + handle(isolate->heap()->tuple2_map(), isolate), + }; + + { + for (size_t i = 0; i < 2; i++) { + Handle<Map> map = maps[i]; + Handle<Struct> result = + Handle<Struct>::cast(ft.Call(map).ToHandleChecked()); + CHECK_EQ(result->map(), *map); +#ifdef VERIFY_HEAP + isolate->heap()->Verify(); +#endif + } + } +} + +TEST(GotoIfNotWhiteSpaceOrLineTerminator) { + Isolate* isolate(CcTest::InitIsolateOnce()); + + const int kNumParams = 1; + CodeAssemblerTester asm_tester(isolate, kNumParams); + StringTrimAssembler m(asm_tester.state()); + + { // Returns true if whitespace, false otherwise. + Label if_not_whitespace(&m); + + m.GotoIfNotWhiteSpaceOrLineTerminator(m.SmiToWord32(m.Parameter(0)), + &if_not_whitespace); + m.Return(m.TrueConstant()); + + m.BIND(&if_not_whitespace); + m.Return(m.FalseConstant()); + } + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); + + Handle<Object> true_value = ft.true_value(); + Handle<Object> false_value = ft.false_value(); + + for (uc16 c = 0; c < 0xFFFF; c++) { + Handle<Object> expected_value = + WhiteSpaceOrLineTerminator::Is(c) ? true_value : false_value; + ft.CheckCall(expected_value, handle(Smi::FromInt(c), isolate)); + } +} + +TEST(BranchIfNumericRelationalComparison) { + Isolate* isolate(CcTest::InitIsolateOnce()); + Factory* f = isolate->factory(); + const int kNumParams = 2; + CodeAssemblerTester asm_tester(isolate, kNumParams); + { + CodeStubAssembler m(asm_tester.state()); + Label return_true(&m), return_false(&m); + m.BranchIfNumericRelationalComparison( + CodeStubAssembler::kGreaterThanOrEqual, m.Parameter(0), m.Parameter(1), + &return_true, &return_false); + m.BIND(&return_true); + m.Return(m.BooleanConstant(true)); + m.BIND(&return_false); + m.Return(m.BooleanConstant(false)); + } + + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); + + ft.CheckTrue(f->NewNumber(0), f->NewNumber(0)); + ft.CheckTrue(f->NewNumber(1), f->NewNumber(0)); + ft.CheckTrue(f->NewNumber(1), f->NewNumber(1)); + ft.CheckFalse(f->NewNumber(0), f->NewNumber(1)); + ft.CheckFalse(f->NewNumber(-1), f->NewNumber(0)); + ft.CheckTrue(f->NewNumber(-1), f->NewNumber(-1)); + + ft.CheckTrue(f->NewNumber(-1), f->NewNumber(-1.5)); + ft.CheckFalse(f->NewNumber(-1.5), f->NewNumber(-1)); + ft.CheckTrue(f->NewNumber(-1.5), f->NewNumber(-1.5)); +} + +TEST(IsNumberArrayIndex) { + Isolate* isolate(CcTest::InitIsolateOnce()); + const int kNumParams = 1; + CodeAssemblerTester asm_tester(isolate, kNumParams); + { + CodeStubAssembler m(asm_tester.state()); + m.Return(m.SmiFromWord32(m.IsNumberArrayIndex(m.Parameter(0)))); + } + + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); + + double indices[] = {Smi::kMinValue, + -11, + -1, + 0, + 1, + 2, + Smi::kMaxValue, + -11.0, + -11.1, + -2.0, + -1.0, + -0.0, + 0.0, + 0.00001, + 0.1, + 1, + 2, + Smi::kMinValue - 1.0, + Smi::kMinValue + 1.0, + Smi::kMinValue + 1.2, + kMaxInt + 1.2, + kMaxInt - 10.0, + kMaxInt - 1.0, + kMaxInt, + kMaxInt + 1.0, + kMaxInt + 10.0}; + + for (size_t i = 0; i < arraysize(indices); i++) { + Handle<Object> index = isolate->factory()->NewNumber(indices[i]); + uint32_t array_index; + CHECK_EQ(index->ToArrayIndex(&array_index), + (ft.CallChecked<Smi>(index)->value() == 1)); + } +} + +TEST(NumberMinMax) { + Isolate* isolate(CcTest::InitIsolateOnce()); + const int kNumParams = 2; + CodeAssemblerTester asm_tester_min(isolate, kNumParams); + { + CodeStubAssembler m(asm_tester_min.state()); + m.Return(m.NumberMin(m.Parameter(0), m.Parameter(1))); + } + FunctionTester ft_min(asm_tester_min.GenerateCode(), kNumParams); + + CodeAssemblerTester asm_tester_max(isolate, kNumParams); + { + CodeStubAssembler m(asm_tester_max.state()); + m.Return(m.NumberMax(m.Parameter(0), m.Parameter(1))); + } + FunctionTester ft_max(asm_tester_max.GenerateCode(), kNumParams); + + // Test smi values. + Handle<Smi> smi_1(Smi::FromInt(1), isolate); + Handle<Smi> smi_2(Smi::FromInt(2), isolate); + Handle<Smi> smi_5(Smi::FromInt(5), isolate); + CHECK_EQ(ft_min.CallChecked<Smi>(smi_1, smi_2)->value(), 1); + CHECK_EQ(ft_min.CallChecked<Smi>(smi_2, smi_1)->value(), 1); + CHECK_EQ(ft_max.CallChecked<Smi>(smi_1, smi_2)->value(), 2); + CHECK_EQ(ft_max.CallChecked<Smi>(smi_2, smi_1)->value(), 2); + + // Test double values. + Handle<Object> double_a = isolate->factory()->NewNumber(2.5); + Handle<Object> double_b = isolate->factory()->NewNumber(3.5); + Handle<Object> nan = + isolate->factory()->NewNumber(std::numeric_limits<double>::quiet_NaN()); + Handle<Object> infinity = isolate->factory()->NewNumber(V8_INFINITY); + + CHECK_EQ(ft_min.CallChecked<HeapNumber>(double_a, double_b)->value(), 2.5); + CHECK_EQ(ft_min.CallChecked<HeapNumber>(double_b, double_a)->value(), 2.5); + CHECK_EQ(ft_min.CallChecked<HeapNumber>(infinity, double_a)->value(), 2.5); + CHECK_EQ(ft_min.CallChecked<HeapNumber>(double_a, infinity)->value(), 2.5); + CHECK(std::isnan(ft_min.CallChecked<HeapNumber>(nan, double_a)->value())); + CHECK(std::isnan(ft_min.CallChecked<HeapNumber>(double_a, nan)->value())); + + CHECK_EQ(ft_max.CallChecked<HeapNumber>(double_a, double_b)->value(), 3.5); + CHECK_EQ(ft_max.CallChecked<HeapNumber>(double_b, double_a)->value(), 3.5); + CHECK_EQ(ft_max.CallChecked<HeapNumber>(infinity, double_a)->value(), + V8_INFINITY); + CHECK_EQ(ft_max.CallChecked<HeapNumber>(double_a, infinity)->value(), + V8_INFINITY); + CHECK(std::isnan(ft_max.CallChecked<HeapNumber>(nan, double_a)->value())); + CHECK(std::isnan(ft_max.CallChecked<HeapNumber>(double_a, nan)->value())); + + // Mixed smi/double values. + CHECK_EQ(ft_max.CallChecked<HeapNumber>(smi_1, double_b)->value(), 3.5); + CHECK_EQ(ft_max.CallChecked<HeapNumber>(double_b, smi_1)->value(), 3.5); + CHECK_EQ(ft_min.CallChecked<HeapNumber>(smi_5, double_b)->value(), 3.5); + CHECK_EQ(ft_min.CallChecked<HeapNumber>(double_b, smi_5)->value(), 3.5); +} + +TEST(NumberAddSub) { + Isolate* isolate(CcTest::InitIsolateOnce()); + const int kNumParams = 2; + CodeAssemblerTester asm_tester_add(isolate, kNumParams); + { + CodeStubAssembler m(asm_tester_add.state()); + m.Return(m.NumberAdd(m.Parameter(0), m.Parameter(1))); + } + FunctionTester ft_add(asm_tester_add.GenerateCode(), kNumParams); + + CodeAssemblerTester asm_tester_sub(isolate, kNumParams); + { + CodeStubAssembler m(asm_tester_sub.state()); + m.Return(m.NumberSub(m.Parameter(0), m.Parameter(1))); + } + FunctionTester ft_sub(asm_tester_sub.GenerateCode(), kNumParams); + + // Test smi values. + Handle<Smi> smi_1(Smi::FromInt(1), isolate); + Handle<Smi> smi_2(Smi::FromInt(2), isolate); + CHECK_EQ(ft_add.CallChecked<Smi>(smi_1, smi_2)->value(), 3); + CHECK_EQ(ft_sub.CallChecked<Smi>(smi_2, smi_1)->value(), 1); + + // Test double values. + Handle<Object> double_a = isolate->factory()->NewNumber(2.5); + Handle<Object> double_b = isolate->factory()->NewNumber(3.0); + CHECK_EQ(ft_add.CallChecked<HeapNumber>(double_a, double_b)->value(), 5.5); + CHECK_EQ(ft_sub.CallChecked<HeapNumber>(double_a, double_b)->value(), -.5); + + // Test overflow. + Handle<Smi> smi_max(Smi::FromInt(Smi::kMaxValue), isolate); + Handle<Smi> smi_min(Smi::FromInt(Smi::kMinValue), isolate); + CHECK_EQ(ft_add.CallChecked<HeapNumber>(smi_max, smi_1)->value(), + static_cast<double>(Smi::kMaxValue) + 1); + CHECK_EQ(ft_sub.CallChecked<HeapNumber>(smi_min, smi_1)->value(), + static_cast<double>(Smi::kMinValue) - 1); + + // Test mixed smi/double values. + CHECK_EQ(ft_add.CallChecked<HeapNumber>(smi_1, double_a)->value(), 3.5); + CHECK_EQ(ft_add.CallChecked<HeapNumber>(double_a, smi_1)->value(), 3.5); + CHECK_EQ(ft_sub.CallChecked<HeapNumber>(smi_1, double_a)->value(), -1.5); + CHECK_EQ(ft_sub.CallChecked<HeapNumber>(double_a, smi_1)->value(), 1.5); +} + } // 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 1a34e7d4ab..cb80382901 100644 --- a/deps/v8/test/cctest/test-code-stubs-arm.cc +++ b/deps/v8/test/cctest/test-code-stubs-arm.cc @@ -38,7 +38,8 @@ #include "test/cctest/cctest.h" #include "test/cctest/test-code-stubs.h" -using namespace v8::internal; +namespace v8 { +namespace internal { #define __ masm. @@ -71,7 +72,7 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate, // Push the double argument. __ sub(sp, sp, Operand(kDoubleSize)); __ vstr(d0, sp, 0); - if (!source_reg.is(sp)) { + if (source_reg != sp) { __ mov(source_reg, sp); } @@ -81,7 +82,7 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate, for (; reg_num < Register::kNumRegisters; ++reg_num) { if (RegisterConfiguration::Default()->IsAllocatableGeneralCode(reg_num)) { Register reg = Register::from_code(reg_num); - if (!reg.is(destination_reg)) { + if (reg != destination_reg) { __ push(reg); source_reg_offset += kPointerSize; } @@ -96,7 +97,7 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate, if (inline_fastpath) { __ vldr(d0, MemOperand(source_reg)); __ TryInlineTruncateDoubleToI(destination_reg, d0, &done); - if (destination_reg.is(source_reg) && !source_reg.is(sp)) { + if (destination_reg == source_reg && source_reg != sp) { // Restore clobbered source_reg. __ add(source_reg, sp, Operand(source_reg_offset)); } @@ -110,7 +111,7 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate, for (--reg_num; reg_num >= 0; --reg_num) { if (RegisterConfiguration::Default()->IsAllocatableGeneralCode(reg_num)) { Register reg = Register::from_code(reg_num); - if (!reg.is(destination_reg)) { + if (reg != destination_reg) { __ ldr(ip, MemOperand(sp, 0)); __ cmp(reg, ip); __ Assert(eq, kRegisterWasClobbered); @@ -121,8 +122,7 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate, __ add(sp, sp, Operand(kDoubleSize)); - if (!destination_reg.is(r0)) - __ mov(r0, destination_reg); + if (destination_reg != r0) __ mov(r0, destination_reg); // Restore callee save registers. __ Pop(lr); @@ -188,3 +188,6 @@ TEST(ConvertDToI) { } } } + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-code-stubs-arm64.cc b/deps/v8/test/cctest/test-code-stubs-arm64.cc index 2b668cc277..64435703c9 100644 --- a/deps/v8/test/cctest/test-code-stubs-arm64.cc +++ b/deps/v8/test/cctest/test-code-stubs-arm64.cc @@ -38,7 +38,8 @@ #include "test/cctest/cctest.h" #include "test/cctest/test-code-stubs.h" -using namespace v8::internal; +namespace v8 { +namespace internal { #define __ masm. @@ -193,3 +194,6 @@ TEST(ConvertDToI) { } } } + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-code-stubs-ia32.cc b/deps/v8/test/cctest/test-code-stubs-ia32.cc index 66ddf46f2a..3ddf7323ad 100644 --- a/deps/v8/test/cctest/test-code-stubs-ia32.cc +++ b/deps/v8/test/cctest/test-code-stubs-ia32.cc @@ -35,10 +35,12 @@ #include "src/code-stubs.h" #include "src/factory.h" #include "src/macro-assembler.h" +#include "src/objects-inl.h" #include "test/cctest/cctest.h" #include "test/cctest/test-code-stubs.h" -using namespace v8::internal; +namespace v8 { +namespace internal { #define __ assm. @@ -53,8 +55,7 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate, HandleScope handles(isolate); MacroAssembler assm(isolate, buffer, static_cast<int>(actual_size), v8::internal::CodeObjectRequired::kYes); - int offset = - source_reg.is(esp) ? 0 : (HeapNumber::kValueOffset - kSmiTagSize); + int offset = source_reg == esp ? 0 : (HeapNumber::kValueOffset - kSmiTagSize); DoubleToIStub stub(isolate, source_reg, destination_reg, offset, true); byte* start = stub.GetCode()->instruction_start(); @@ -64,7 +65,7 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate, __ push(esi); __ push(edi); - if (!source_reg.is(esp)) { + if (source_reg != esp) { __ lea(source_reg, MemOperand(esp, 6 * kPointerSize - offset)); } @@ -74,7 +75,7 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate, for (; reg_num < Register::kNumRegisters; ++reg_num) { if (RegisterConfiguration::Default()->IsAllocatableGeneralCode(reg_num)) { Register reg = Register::from_code(reg_num); - if (!reg.is(esp) && !reg.is(ebp) && !reg.is(destination_reg)) { + if (reg != esp && reg != ebp && reg != destination_reg) { __ push(reg); param_offset += kPointerSize; } @@ -94,7 +95,7 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate, for (--reg_num; reg_num >= 0; --reg_num) { if (RegisterConfiguration::Default()->IsAllocatableGeneralCode(reg_num)) { Register reg = Register::from_code(reg_num); - if (!reg.is(esp) && !reg.is(ebp) && !reg.is(destination_reg)) { + if (reg != esp && reg != ebp && reg != destination_reg) { __ cmp(reg, MemOperand(esp, 0)); __ Assert(equal, kRegisterWasClobbered); __ add(esp, Immediate(kPointerSize)); @@ -151,3 +152,6 @@ TEST(ConvertDToI) { } } } + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-code-stubs-mips.cc b/deps/v8/test/cctest/test-code-stubs-mips.cc index 78f70cf601..39aa88bea2 100644 --- a/deps/v8/test/cctest/test-code-stubs-mips.cc +++ b/deps/v8/test/cctest/test-code-stubs-mips.cc @@ -34,12 +34,14 @@ #include "src/factory.h" #include "src/macro-assembler.h" #include "src/mips/constants-mips.h" +#include "src/objects-inl.h" #include "src/register-configuration.h" #include "src/simulator.h" #include "test/cctest/cctest.h" #include "test/cctest/test-code-stubs.h" -using namespace v8::internal; +namespace v8 { +namespace internal { #define __ masm. @@ -84,7 +86,7 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate, for (; reg_num < Register::kNumRegisters; ++reg_num) { if (RegisterConfiguration::Default()->IsAllocatableGeneralCode(reg_num)) { Register reg = Register::from_code(reg_num); - if (!reg.is(destination_reg)) { + if (reg != destination_reg) { __ push(reg); source_reg_offset += kPointerSize; } @@ -99,7 +101,7 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate, if (inline_fastpath) { __ Ldc1(f12, MemOperand(source_reg)); __ TryInlineTruncateDoubleToI(destination_reg, f12, &done); - if (destination_reg.is(source_reg) && !source_reg.is(sp)) { + if (destination_reg == source_reg && source_reg != sp) { // Restore clobbered source_reg. __ Addu(source_reg, sp, Operand(source_reg_offset)); } @@ -113,7 +115,7 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate, for (--reg_num; reg_num >= 2; --reg_num) { if (RegisterConfiguration::Default()->IsAllocatableGeneralCode(reg_num)) { Register reg = Register::from_code(reg_num); - if (!reg.is(destination_reg)) { + if (reg != destination_reg) { __ lw(at, MemOperand(sp, 0)); __ Assert(eq, kRegisterWasClobbered, reg, Operand(at)); __ Addu(sp, sp, Operand(kPointerSize)); @@ -201,3 +203,6 @@ TEST(ConvertDToI) { } } } + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-code-stubs-mips64.cc b/deps/v8/test/cctest/test-code-stubs-mips64.cc index 6048678029..ee6388e316 100644 --- a/deps/v8/test/cctest/test-code-stubs-mips64.cc +++ b/deps/v8/test/cctest/test-code-stubs-mips64.cc @@ -34,12 +34,14 @@ #include "src/factory.h" #include "src/macro-assembler.h" #include "src/mips64/constants-mips64.h" +#include "src/objects-inl.h" #include "src/register-configuration.h" #include "src/simulator.h" #include "test/cctest/cctest.h" #include "test/cctest/test-code-stubs.h" -using namespace v8::internal; +namespace v8 { +namespace internal { #define __ masm. @@ -84,7 +86,7 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate, const RegisterConfiguration* config = RegisterConfiguration::Default(); for (; reg_num < config->num_allocatable_general_registers(); ++reg_num) { Register reg = Register::from_code(reg_num); - if (!reg.is(destination_reg)) { + if (reg != destination_reg) { __ push(reg); source_reg_offset += kPointerSize; } @@ -98,7 +100,7 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate, if (inline_fastpath) { __ Ldc1(f12, MemOperand(source_reg)); __ TryInlineTruncateDoubleToI(destination_reg, f12, &done); - if (destination_reg.is(source_reg) && !source_reg.is(sp)) { + if (destination_reg == source_reg && source_reg != sp) { // Restore clobbered source_reg. __ Daddu(source_reg, sp, Operand(source_reg_offset)); } @@ -111,7 +113,7 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate, // Make sure no registers have been unexpectedly clobbered for (--reg_num; reg_num >= 2; --reg_num) { Register reg = Register::from_code(reg_num); - if (!reg.is(destination_reg)) { + if (reg != destination_reg) { __ Ld(at, MemOperand(sp, 0)); __ Assert(eq, kRegisterWasClobbered, reg, Operand(at)); __ Daddu(sp, sp, Operand(kPointerSize)); @@ -199,3 +201,6 @@ TEST(ConvertDToI) { } } } + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-code-stubs-x64.cc b/deps/v8/test/cctest/test-code-stubs-x64.cc index a58cb6949a..bd29e7ab5c 100644 --- a/deps/v8/test/cctest/test-code-stubs-x64.cc +++ b/deps/v8/test/cctest/test-code-stubs-x64.cc @@ -38,8 +38,9 @@ #include "test/cctest/cctest.h" #include "test/cctest/test-code-stubs.h" -using namespace v8::internal; - +namespace v8 { +namespace internal { +namespace test_code_stubs_x64 { #define __ assm. @@ -54,8 +55,7 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate, HandleScope handles(isolate); MacroAssembler assm(isolate, buffer, static_cast<int>(actual_size), v8::internal::CodeObjectRequired::kYes); - int offset = - source_reg.is(rsp) ? 0 : (HeapNumber::kValueOffset - kSmiTagSize); + int offset = source_reg == rsp ? 0 : (HeapNumber::kValueOffset - kSmiTagSize); DoubleToIStub stub(isolate, source_reg, destination_reg, offset, true); byte* start = stub.GetCode()->instruction_start(); @@ -66,7 +66,7 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate, __ pushq(rdi); const RegisterConfiguration* config = RegisterConfiguration::Default(); - if (!source_reg.is(rsp)) { + if (source_reg != rsp) { // The argument we pass to the stub is not a heap number, but instead // stack-allocated and offset-wise made to look like a heap number for // the stub. We create that "heap number" after pushing all allocatable @@ -82,7 +82,7 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate, for (; reg_num < config->num_allocatable_general_registers(); ++reg_num) { Register reg = Register::from_code(config->GetAllocatableGeneralCode(reg_num)); - if (!reg.is(rsp) && !reg.is(rbp) && !reg.is(destination_reg)) { + if (reg != rsp && reg != rbp && reg != destination_reg) { __ pushq(reg); } } @@ -100,7 +100,7 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate, for (--reg_num; reg_num >= 0; --reg_num) { Register reg = Register::from_code(config->GetAllocatableGeneralCode(reg_num)); - if (!reg.is(rsp) && !reg.is(rbp) && !reg.is(destination_reg)) { + if (reg != rsp && reg != rbp && reg != destination_reg) { __ cmpq(reg, MemOperand(rsp, 0)); __ Assert(equal, kRegisterWasClobbered); __ addq(rsp, Immediate(kPointerSize)); @@ -156,3 +156,7 @@ TEST(ConvertDToI) { } } } + +} // namespace test_code_stubs_x64 +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-code-stubs.cc b/deps/v8/test/cctest/test-code-stubs.cc index 0a8b24e4d3..27f411c56c 100644 --- a/deps/v8/test/cctest/test-code-stubs.cc +++ b/deps/v8/test/cctest/test-code-stubs.cc @@ -40,8 +40,8 @@ #include "test/cctest/cctest.h" #include "test/cctest/test-code-stubs.h" -using namespace v8::internal; - +namespace v8 { +namespace internal { int STDCALL ConvertDToICVersion(double d) { #if defined(V8_TARGET_BIG_ENDIAN) @@ -199,3 +199,6 @@ TEST(CodeStubMajorKeys) { } CODE_STUB_LIST(CHECK_STUB); } + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-code-stubs.h b/deps/v8/test/cctest/test-code-stubs.h index 0cfa0ec7c8..54182d0c45 100644 --- a/deps/v8/test/cctest/test-code-stubs.h +++ b/deps/v8/test/cctest/test-code-stubs.h @@ -28,6 +28,9 @@ #ifndef V8_TEST_CODE_STUBS_H_ #define V8_TEST_CODE_STUBS_H_ +namespace v8 { +namespace internal { + #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87 #if __GNUC__ #define STDCALL __attribute__((stdcall)) @@ -50,4 +53,7 @@ void RunAllTruncationTests(ConvertDToIFunc func); void RunAllTruncationTests(ConvertDToICallWrapper callWrapper, ConvertDToIFunc func); +} // namespace internal +} // namespace v8 + #endif diff --git a/deps/v8/test/cctest/test-compiler.cc b/deps/v8/test/cctest/test-compiler.cc index 8667aaf458..8a50ff0f57 100644 --- a/deps/v8/test/cctest/test-compiler.cc +++ b/deps/v8/test/cctest/test-compiler.cc @@ -63,11 +63,13 @@ static Handle<JSFunction> Compile(const char* source) { Isolate* isolate = CcTest::i_isolate(); Handle<String> source_code = isolate->factory()->NewStringFromUtf8( CStrVector(source)).ToHandleChecked(); - Handle<SharedFunctionInfo> shared = Compiler::GetSharedFunctionInfoForScript( - source_code, Handle<String>(), 0, 0, v8::ScriptOriginOptions(), - Handle<Object>(), Handle<Context>(isolate->native_context()), NULL, NULL, - v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE, - Handle<FixedArray>()); + Handle<SharedFunctionInfo> shared = + Compiler::GetSharedFunctionInfoForScript( + source_code, MaybeHandle<String>(), 0, 0, v8::ScriptOriginOptions(), + MaybeHandle<Object>(), Handle<Context>(isolate->native_context()), + NULL, NULL, v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE, + MaybeHandle<FixedArray>()) + .ToHandleChecked(); return isolate->factory()->NewFunctionFromSharedFunctionInfo( shared, isolate->native_context()); } @@ -632,63 +634,6 @@ TEST(CompileFunctionInContextHarmonyFunctionToString) { #undef CHECK_NOT_CAUGHT } -#ifdef ENABLE_DISASSEMBLER -static Handle<JSFunction> GetJSFunction(v8::Local<v8::Object> obj, - const char* property_name) { - v8::Local<v8::Function> fun = v8::Local<v8::Function>::Cast( - obj->Get(CcTest::isolate()->GetCurrentContext(), v8_str(property_name)) - .ToLocalChecked()); - return Handle<JSFunction>::cast(v8::Utils::OpenHandle(*fun)); -} - - -static void CheckCodeForUnsafeLiteral(Handle<JSFunction> f) { - // Create a disassembler with default name lookup. - disasm::NameConverter name_converter; - disasm::Disassembler d(name_converter); - - if (f->code()->kind() == Code::FUNCTION) { - Address pc = f->code()->instruction_start(); - int decode_size = - Min(f->code()->instruction_size(), - static_cast<int>(f->code()->back_edge_table_offset())); - if (FLAG_enable_embedded_constant_pool) { - decode_size = Min(decode_size, f->code()->constant_pool_offset()); - } - Address end = pc + decode_size; - - v8::internal::EmbeddedVector<char, 128> decode_buffer; - v8::internal::EmbeddedVector<char, 128> smi_hex_buffer; - Smi* smi = Smi::FromInt(12345678); - SNPrintF(smi_hex_buffer, "0x%" V8PRIxPTR, reinterpret_cast<intptr_t>(smi)); - while (pc < end) { - int num_const = d.ConstantPoolSizeAt(pc); - if (num_const >= 0) { - pc += (num_const + 1) * kPointerSize; - } else { - pc += d.InstructionDecode(decode_buffer, pc); - CHECK(strstr(decode_buffer.start(), smi_hex_buffer.start()) == NULL); - } - } - } -} - - -TEST(SplitConstantsInFullCompiler) { - LocalContext context; - v8::HandleScope scope(CcTest::isolate()); - - CompileRun("function f() { a = 12345678 }; f();"); - CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); - CompileRun("function f(x) { a = 12345678 + x}; f(1);"); - CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); - CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); - CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); - CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); - CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); -} -#endif - TEST(InvocationCount) { FLAG_allow_natives_syntax = true; FLAG_always_opt = false; diff --git a/deps/v8/test/cctest/test-conversions.cc b/deps/v8/test/cctest/test-conversions.cc index db080d2215..dc6e9fcb9d 100644 --- a/deps/v8/test/cctest/test-conversions.cc +++ b/deps/v8/test/cctest/test-conversions.cc @@ -29,16 +29,9 @@ #include "src/base/platform/platform.h" #include "src/conversions.h" -#include "src/factory.h" +#include "src/factory-inl.h" #include "src/isolate.h" -// FIXME(mstarzinger, marja): This is weird, but required because of the missing -// (disallowed) include: src/factory.h -> src/objects-inl.h -#include "src/objects-inl.h" #include "src/objects.h" -// FIXME(mstarzinger, marja): This is weird, but required because of the missing -// (disallowed) include: src/feedback-vector.h -> -// src/feedback-vector-inl.h -#include "src/feedback-vector-inl.h" #include "src/unicode-cache.h" #include "src/v8.h" #include "test/cctest/cctest.h" diff --git a/deps/v8/test/cctest/test-cpu-profiler.cc b/deps/v8/test/cctest/test-cpu-profiler.cc index 689305f30e..0a297d9f0c 100644 --- a/deps/v8/test/cctest/test-cpu-profiler.cc +++ b/deps/v8/test/cctest/test-cpu-profiler.cc @@ -44,17 +44,9 @@ #include "include/libplatform/v8-tracing.h" #include "src/tracing/trace-event.h" -using i::CodeEntry; -using i::CpuProfile; -using i::CpuProfiler; -using i::CpuProfilesCollection; -using i::Heap; -using i::ProfileGenerator; -using i::ProfileNode; -using i::ProfilerEventsProcessor; -using i::ProfilerListener; -using i::ScopedVector; -using i::Vector; +namespace v8 { +namespace internal { +namespace test_cpu_profiler { // Helper methods static v8::Local<v8::Function> GetFunction(v8::Local<v8::Context> env, @@ -786,11 +778,12 @@ class TestApiCallbacks { private: void Wait() { if (is_warming_up_) return; - double start = v8::base::OS::TimeCurrentMillis(); + v8::Platform* platform = v8::internal::V8::GetCurrentPlatform(); + double start = platform->CurrentClockTimeMillis(); double duration = 0; while (duration < min_duration_ms_) { v8::base::OS::Sleep(v8::base::TimeDelta::FromMilliseconds(1)); - duration = v8::base::OS::TimeCurrentMillis() - start; + duration = platform->CurrentClockTimeMillis() - start; } } @@ -2191,3 +2184,59 @@ TEST(TracingCpuProfiler) { i::V8::SetPlatformForTesting(old_platform); } + +TEST(Issue763073) { + class AllowNativesSyntax { + public: + AllowNativesSyntax() + : allow_natives_syntax_(i::FLAG_allow_natives_syntax), + trace_deopt_(i::FLAG_trace_deopt) { + i::FLAG_allow_natives_syntax = true; + i::FLAG_trace_deopt = true; + } + + ~AllowNativesSyntax() { + i::FLAG_allow_natives_syntax = allow_natives_syntax_; + i::FLAG_trace_deopt = trace_deopt_; + } + + private: + bool allow_natives_syntax_; + bool trace_deopt_; + }; + + AllowNativesSyntax allow_natives_syntax_scope; + LocalContext env; + v8::HandleScope scope(env->GetIsolate()); + + CompileRun( + "function f() { return function g(x) { }; }" + // Create first closure, optimize it, and deoptimize it. + "var g = f();" + "g(1);" + "%OptimizeFunctionOnNextCall(g);" + "g(1);" + "%DeoptimizeFunction(g);" + // Create second closure, and optimize it. This will create another + // optimized code object and put in the (shared) type feedback vector. + "var h = f();" + "h(1);" + "%OptimizeFunctionOnNextCall(h);" + "h(1);"); + + // Start profiling. + v8::CpuProfiler* cpu_profiler = v8::CpuProfiler::New(env->GetIsolate()); + v8::Local<v8::String> profile_name = v8_str("test"); + + // Here we test that the heap iteration upon profiling start is not + // confused by having a deoptimized code object for a closure while + // having a different optimized code object in the type feedback vector. + cpu_profiler->StartProfiling(profile_name); + v8::CpuProfile* p = cpu_profiler->StopProfiling(profile_name); + p->Delete(); + cpu_profiler->Dispose(); +} + +} // namespace test_cpu_profiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-debug.cc b/deps/v8/test/cctest/test-debug.cc index 8c3818e8e9..794bc9c841 100644 --- a/deps/v8/test/cctest/test-debug.cc +++ b/deps/v8/test/cctest/test-debug.cc @@ -6518,22 +6518,115 @@ TEST(DebugCoverage) { CHECK_EQ(2, function_data.Count()); } +namespace { +v8::debug::Coverage::ScriptData GetScriptDataAndDeleteCoverage( + v8::Isolate* isolate) { + v8::debug::Coverage coverage = v8::debug::Coverage::CollectPrecise(isolate); + CHECK_EQ(1u, coverage.ScriptCount()); + return coverage.GetScriptData(0); +} +} // namespace + +TEST(DebugCoverageWithCoverageOutOfScope) { + i::FLAG_always_opt = false; + LocalContext env; + v8::Isolate* isolate = env->GetIsolate(); + v8::HandleScope scope(isolate); + v8::debug::Coverage::SelectMode(isolate, v8::debug::Coverage::kPreciseCount); + v8::Local<v8::String> source = v8_str( + "function f() {\n" + "}\n" + "f();\n" + "f();"); + CompileRun(source); + v8::debug::Coverage::ScriptData script_data = + GetScriptDataAndDeleteCoverage(isolate); + v8::Local<v8::debug::Script> script = script_data.GetScript(); + CHECK(script->Source() + .ToLocalChecked() + ->Equals(env.local(), source) + .FromMaybe(false)); + + CHECK_EQ(2u, script_data.FunctionCount()); + v8::debug::Coverage::FunctionData function_data = + script_data.GetFunctionData(0); + + CHECK_EQ(0, function_data.StartOffset()); + CHECK_EQ(26, function_data.EndOffset()); + + v8::debug::Location start = + script->GetSourceLocation(function_data.StartOffset()); + v8::debug::Location end = + script->GetSourceLocation(function_data.EndOffset()); + CHECK_EQ(0, start.GetLineNumber()); + CHECK_EQ(0, start.GetColumnNumber()); + CHECK_EQ(3, end.GetLineNumber()); + CHECK_EQ(4, end.GetColumnNumber()); + CHECK_EQ(1, function_data.Count()); + + function_data = script_data.GetFunctionData(1); + start = script->GetSourceLocation(function_data.StartOffset()); + end = script->GetSourceLocation(function_data.EndOffset()); + + CHECK_EQ(0, function_data.StartOffset()); + CHECK_EQ(16, function_data.EndOffset()); + + CHECK_EQ(0, start.GetLineNumber()); + CHECK_EQ(0, start.GetColumnNumber()); + CHECK_EQ(1, end.GetLineNumber()); + CHECK_EQ(1, end.GetColumnNumber()); + CHECK_EQ(2, function_data.Count()); +} + +namespace { +v8::debug::Coverage::FunctionData GetFunctionDataAndDeleteCoverage( + v8::Isolate* isolate) { + v8::debug::Coverage coverage = v8::debug::Coverage::CollectPrecise(isolate); + CHECK_EQ(1u, coverage.ScriptCount()); + + v8::debug::Coverage::ScriptData script_data = coverage.GetScriptData(0); + + CHECK_EQ(2u, script_data.FunctionCount()); + v8::debug::Coverage::FunctionData function_data = + script_data.GetFunctionData(0); + CHECK_EQ(1, function_data.Count()); + CHECK_EQ(0, function_data.StartOffset()); + CHECK_EQ(26, function_data.EndOffset()); + return function_data; +} +} // namespace + +TEST(DebugCoverageWithScriptDataOutOfScope) { + i::FLAG_always_opt = false; + LocalContext env; + v8::Isolate* isolate = env->GetIsolate(); + v8::HandleScope scope(isolate); + v8::debug::Coverage::SelectMode(isolate, v8::debug::Coverage::kPreciseCount); + v8::Local<v8::String> source = v8_str( + "function f() {\n" + "}\n" + "f();\n" + "f();"); + CompileRun(source); + + v8::debug::Coverage::FunctionData function_data = + GetFunctionDataAndDeleteCoverage(isolate); + CHECK_EQ(1, function_data.Count()); + CHECK_EQ(0, function_data.StartOffset()); + CHECK_EQ(26, function_data.EndOffset()); +} + TEST(BuiltinsExceptionPrediction) { v8::Isolate* isolate = CcTest::isolate(); v8::HandleScope handle_scope(isolate); v8::Context::New(isolate); - // TODO(gsathya): Fix catch prediction for the following. - std::set<int> whitelist( - {i::Builtins::kPromiseThenFinally, i::Builtins::kPromiseCatchFinally}); - i::Builtins* builtins = CcTest::i_isolate()->builtins(); bool fail = false; for (int i = 0; i < i::Builtins::builtin_count; i++) { - Code* builtin = builtins->builtin(static_cast<i::Builtins::Name>(i)); + Code* builtin = builtins->builtin(i); if (builtin->kind() != Code::BUILTIN) continue; - if (whitelist.find(i) != whitelist.end()) continue; auto prediction = builtin->GetBuiltinCatchPrediction(); USE(prediction); @@ -6574,19 +6667,19 @@ TEST(DebugEvaluateNoSideEffect) { LocalContext env; i::Isolate* isolate = CcTest::i_isolate(); i::HandleScope scope(isolate); - i::List<i::Handle<i::JSFunction>> list; + std::vector<i::Handle<i::JSFunction>> all_functions; { i::HeapIterator iterator(isolate->heap()); while (i::HeapObject* obj = iterator.next()) { if (!obj->IsJSFunction()) continue; i::JSFunction* fun = i::JSFunction::cast(obj); - list.Add(i::Handle<i::JSFunction>(fun)); + all_functions.emplace_back(fun); } } // Perform side effect check on all built-in functions. The side effect check // itself contains additional sanity checks. - for (i::Handle<i::JSFunction> fun : list) { + for (i::Handle<i::JSFunction> fun : all_functions) { bool failed = false; { i::NoSideEffectScope scope(isolate, true); diff --git a/deps/v8/test/cctest/test-disasm-arm.cc b/deps/v8/test/cctest/test-disasm-arm.cc index d73e1ac139..c8c9daa0e2 100644 --- a/deps/v8/test/cctest/test-disasm-arm.cc +++ b/deps/v8/test/cctest/test-disasm-arm.cc @@ -40,7 +40,8 @@ #include "src/v8.h" #include "test/cctest/cctest.h" -using namespace v8::internal; +namespace v8 { +namespace internal { template <typename... S> bool DisassembleAndCompare(byte* begin, S... expected_strings) { @@ -1577,3 +1578,6 @@ TEST(LoadStoreExclusive) { VERIFY_RUN(); } + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-disasm-arm64.cc b/deps/v8/test/cctest/test-disasm-arm64.cc index 313c18d338..efebac208c 100644 --- a/deps/v8/test/cctest/test-disasm-arm64.cc +++ b/deps/v8/test/cctest/test-disasm-arm64.cc @@ -42,7 +42,8 @@ #include "src/arm64/macro-assembler-arm64.h" #include "src/arm64/utils-arm64.h" -using namespace v8::internal; +namespace v8 { +namespace internal { #define TEST_(name) TEST(DISASM_##name) @@ -4958,3 +4959,6 @@ TEST(neon_shift_immediate) { CLEANUP(); } + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-disasm-ia32.cc b/deps/v8/test/cctest/test-disasm-ia32.cc index eae020023d..84940c51b7 100644 --- a/deps/v8/test/cctest/test-disasm-ia32.cc +++ b/deps/v8/test/cctest/test-disasm-ia32.cc @@ -37,8 +37,8 @@ #include "src/macro-assembler.h" #include "test/cctest/cctest.h" -using namespace v8::internal; - +namespace v8 { +namespace internal { #define __ assm. @@ -846,8 +846,8 @@ TEST(DisasmIa320) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); USE(code); #ifdef OBJECT_PRINT OFStream os(stdout); @@ -859,3 +859,6 @@ TEST(DisasmIa320) { } #undef __ + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-disasm-mips.cc b/deps/v8/test/cctest/test-disasm-mips.cc index f525d44985..04f007fcb3 100644 --- a/deps/v8/test/cctest/test-disasm-mips.cc +++ b/deps/v8/test/cctest/test-disasm-mips.cc @@ -37,7 +37,8 @@ #include "src/macro-assembler.h" #include "test/cctest/cctest.h" -using namespace v8::internal; +namespace v8 { +namespace internal { bool prev_instr_compact_branch = false; @@ -1814,3 +1815,6 @@ TEST(MSA_BIT) { } VERIFY_RUN(); } + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-disasm-mips64.cc b/deps/v8/test/cctest/test-disasm-mips64.cc index 9ccf630c35..0405a82e5d 100644 --- a/deps/v8/test/cctest/test-disasm-mips64.cc +++ b/deps/v8/test/cctest/test-disasm-mips64.cc @@ -37,7 +37,8 @@ #include "src/macro-assembler.h" #include "test/cctest/cctest.h" -using namespace v8::internal; +namespace v8 { +namespace internal { bool prev_instr_compact_branch = false; @@ -2017,3 +2018,6 @@ TEST(MSA_BIT) { } VERIFY_RUN(); } + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-disasm-ppc.cc b/deps/v8/test/cctest/test-disasm-ppc.cc index 8abba45643..9650fee7a6 100644 --- a/deps/v8/test/cctest/test-disasm-ppc.cc +++ b/deps/v8/test/cctest/test-disasm-ppc.cc @@ -37,8 +37,8 @@ #include "src/macro-assembler.h" #include "test/cctest/cctest.h" -using namespace v8::internal; - +namespace v8 { +namespace internal { bool DisassembleAndCompare(byte* pc, const char* compare_string) { disasm::NameConverter converter; @@ -153,3 +153,6 @@ TEST(DisasmPPC) { VERIFY_RUN(); } + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-disasm-s390.cc b/deps/v8/test/cctest/test-disasm-s390.cc index 5ff343cf13..e4f8c55307 100644 --- a/deps/v8/test/cctest/test-disasm-s390.cc +++ b/deps/v8/test/cctest/test-disasm-s390.cc @@ -37,7 +37,8 @@ #include "src/macro-assembler.h" #include "test/cctest/cctest.h" -using namespace v8::internal; +namespace v8 { +namespace internal { bool DisassembleAndCompare(byte* pc, const char* compare_string) { disasm::NameConverter converter; @@ -296,3 +297,6 @@ TEST(SixBytes) { VERIFY_RUN(); } + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-disasm-x64.cc b/deps/v8/test/cctest/test-disasm-x64.cc index 1a4e577ad2..0c7ebbc1a7 100644 --- a/deps/v8/test/cctest/test-disasm-x64.cc +++ b/deps/v8/test/cctest/test-disasm-x64.cc @@ -946,8 +946,8 @@ TEST(DisasmX64) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); USE(code); #ifdef OBJECT_PRINT OFStream os(stdout); diff --git a/deps/v8/test/cctest/test-dtoa.cc b/deps/v8/test/cctest/test-dtoa.cc index ff917b0815..8f156d9f2a 100644 --- a/deps/v8/test/cctest/test-dtoa.cc +++ b/deps/v8/test/cctest/test-dtoa.cc @@ -40,6 +40,7 @@ namespace v8 { namespace internal { +namespace test_dtoa { // Removes trailing '0' digits. static void TrimRepresentation(Vector<char> representation) { @@ -329,5 +330,6 @@ TEST(DtoaGayPrecision) { } } +} // namespace test_dtoa } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/test-elements-kind.cc b/deps/v8/test/cctest/test-elements-kind.cc index e23d889072..b1d86e6367 100644 --- a/deps/v8/test/cctest/test-elements-kind.cc +++ b/deps/v8/test/cctest/test-elements-kind.cc @@ -18,6 +18,7 @@ namespace v8 { namespace internal { +namespace test_elements_kind { // // Helper functions. @@ -479,5 +480,6 @@ TEST(JSArrayAddingElementsGeneralizingiFastDoubleElements) { CHECK_EQ(array->map(), *previous_map); } +} // namespace test_elements_kind } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/test-fast-dtoa.cc b/deps/v8/test/cctest/test-fast-dtoa.cc index ad9b7aaff5..c063d6348b 100644 --- a/deps/v8/test/cctest/test-fast-dtoa.cc +++ b/deps/v8/test/cctest/test-fast-dtoa.cc @@ -39,6 +39,7 @@ namespace v8 { namespace internal { +namespace test_fast_dtoa { static const int kBufferSize = 100; @@ -293,5 +294,6 @@ TEST(FastDtoaGayPrecision) { CHECK_GT(succeeded_15*1.0/total_15, 0.9999); } +} // namespace test_fast_dtoa } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/test-feedback-vector.cc b/deps/v8/test/cctest/test-feedback-vector.cc index 47b0d81649..119ca4c150 100644 --- a/deps/v8/test/cctest/test-feedback-vector.cc +++ b/deps/v8/test/cctest/test-feedback-vector.cc @@ -43,7 +43,7 @@ TEST(VectorStructure) { { FeedbackVectorSpec one_slot(&zone); - one_slot.AddGeneralSlot(); + one_slot.AddForInSlot(); vector = NewFeedbackVector(isolate, &one_slot); FeedbackVectorHelper helper(vector); CHECK_EQ(1, helper.slot_count()); @@ -60,7 +60,7 @@ TEST(VectorStructure) { { FeedbackVectorSpec spec(&zone); for (int i = 0; i < 3; i++) { - spec.AddGeneralSlot(); + spec.AddForInSlot(); } for (int i = 0; i < 5; i++) { spec.AddCallICSlot(); @@ -87,9 +87,9 @@ TEST(VectorStructure) { { FeedbackVectorSpec spec(&zone); - spec.AddGeneralSlot(); + spec.AddForInSlot(); spec.AddCreateClosureSlot(); - spec.AddGeneralSlot(); + spec.AddForInSlot(); vector = NewFeedbackVector(isolate, &spec); FeedbackVectorHelper helper(vector); CHECK_EQ(1, @@ -113,7 +113,7 @@ TEST(VectorICMetadata) { for (int i = 0; i < 40; i++) { switch (i % 4) { case 0: - spec.AddGeneralSlot(); + spec.AddForInSlot(); break; case 1: spec.AddCallICSlot(); @@ -140,7 +140,7 @@ TEST(VectorICMetadata) { FeedbackSlotKind kind = vector->GetKind(helper.slot(i)); switch (i % 4) { case 0: - CHECK_EQ(FeedbackSlotKind::kGeneral, kind); + CHECK_EQ(FeedbackSlotKind::kForIn, kind); break; case 1: CHECK_EQ(FeedbackSlotKind::kCall, kind); @@ -156,43 +156,6 @@ TEST(VectorICMetadata) { } -TEST(VectorSlotClearing) { - LocalContext context; - v8::HandleScope scope(context->GetIsolate()); - Isolate* isolate = CcTest::i_isolate(); - Factory* factory = isolate->factory(); - Zone zone(isolate->allocator(), ZONE_NAME); - - CompileRun("function f() {};"); - Handle<JSFunction> f = GetFunction("f"); - - // We only test clearing of a FeedbackSlotKind::kGeneral slots because all - // the other slot kinds require a host function for clearing. - FeedbackVectorSpec spec(&zone); - for (int i = 0; i < 5; i++) { - spec.AddGeneralSlot(); - } - Handle<FeedbackVector> vector = NewFeedbackVector(isolate, &spec); - FeedbackVectorHelper helper(vector); - - // Fill with information - vector->Set(helper.slot(0), Smi::FromInt(1)); - Handle<WeakCell> cell = factory->NewWeakCell(factory->fixed_array_map()); - vector->Set(helper.slot(1), *cell); - Handle<AllocationSite> site = factory->NewAllocationSite(); - vector->Set(helper.slot(2), *site); - - vector->ClearSlots(*f); - - // The feedback vector slots are cleared. AllocationSites are still granted - // an exemption from clearing, as are smis. - CHECK_EQ(Smi::FromInt(1), vector->Get(helper.slot(0))); - CHECK_EQ(*FeedbackVector::UninitializedSentinel(isolate), - vector->Get(helper.slot(1))); - CHECK(vector->Get(helper.slot(2))->IsAllocationSite()); -} - - TEST(VectorCallICStates) { if (i::FLAG_always_opt) return; CcTest::InitializeVM(); diff --git a/deps/v8/test/cctest/test-field-type-tracking.cc b/deps/v8/test/cctest/test-field-type-tracking.cc index 3310c5c1d1..89845e9bf5 100644 --- a/deps/v8/test/cctest/test-field-type-tracking.cc +++ b/deps/v8/test/cctest/test-field-type-tracking.cc @@ -24,6 +24,7 @@ namespace v8 { namespace internal { +namespace test_field_type_tracking { // TODO(ishell): fix this once TransitionToPrototype stops generalizing // all field representations (similar to crbug/448711 where elements kind @@ -109,6 +110,20 @@ class Expectations { CHECK(index < MAX_PROPERTIES); kinds_[index] = kind; locations_[index] = location; + if (kind == kData && location == kField && + IsTransitionableFastElementsKind(elements_kind_) && + Map::IsInplaceGeneralizableField(constness, representation, + FieldType::cast(*value))) { + // Maps with transitionable elements kinds must have non in-place + // generalizable fields. + if (FLAG_track_constant_fields && FLAG_modify_map_inplace && + constness == kConst) { + constness = kMutable; + } + if (representation.IsHeapObject() && !FieldType::cast(*value)->IsAny()) { + value = FieldType::Any(isolate_); + } + } constnesses_[index] = constness; attributes_[index] = attributes; representations_[index] = representation; @@ -317,27 +332,14 @@ class Expectations { Handle<Map> AddDataField(Handle<Map> map, PropertyAttributes attributes, PropertyConstness constness, Representation representation, - Handle<FieldType> heap_type) { + Handle<FieldType> field_type) { CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); int property_index = number_of_properties_++; - PropertyConstness expected_constness = constness; - Representation expected_representation = representation; - Handle<FieldType> expected_heap_type = heap_type; - if (IsTransitionableFastElementsKind(map->elements_kind())) { - // Maps with transitionable elements kinds must have non in-place - // generalizable fields. - if (FLAG_track_constant_fields && FLAG_modify_map_inplace) { - expected_constness = kMutable; - } - if (representation.IsHeapObject() && heap_type->IsClass()) { - expected_heap_type = FieldType::Any(isolate_); - } - } - SetDataField(property_index, attributes, expected_constness, - expected_representation, expected_heap_type); + SetDataField(property_index, attributes, constness, representation, + field_type); Handle<String> name = MakeName("prop", property_index); - return Map::CopyWithField(map, name, heap_type, attributes, constness, + return Map::CopyWithField(map, name, field_type, attributes, constness, representation, INSERT_TRANSITION) .ToHandleChecked(); } @@ -1715,6 +1717,7 @@ static void TestReconfigureElementsKind_GeneralizeField( // Create a map, add required properties to it and initialize expectations. Handle<Map> initial_map = Map::Create(isolate, 0); + initial_map->set_instance_type(JS_ARRAY_TYPE); initial_map->set_elements_kind(PACKED_SMI_ELEMENTS); Handle<Map> map = initial_map; @@ -1808,6 +1811,7 @@ static void TestReconfigureElementsKind_GeneralizeFieldTrivial( // Create a map, add required properties to it and initialize expectations. Handle<Map> initial_map = Map::Create(isolate, 0); + initial_map->set_instance_type(JS_ARRAY_TYPE); initial_map->set_elements_kind(PACKED_SMI_ELEMENTS); Handle<Map> map = initial_map; @@ -1990,7 +1994,6 @@ TEST(ReconfigureElementsKind_GeneralizeHeapObjFieldToHeapObj) { {kConst, Representation::HeapObject(), current_type}, {kConst, Representation::HeapObject(), new_type}, {kConst, Representation::HeapObject(), expected_type}); - if (FLAG_modify_map_inplace) { // kConst to kMutable migration does not create a new map, therefore // trivial generalization. @@ -2742,5 +2745,6 @@ TEST(HoleyMutableHeapNumber) { CHECK_EQ(kHoleNanInt64, HeapNumber::cast(*obj)->value_as_bits()); } +} // namespace test_field_type_tracking } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/test-fuzz-arm64.cc b/deps/v8/test/cctest/test-fuzz-arm64.cc index bdf143c055..059eda46fd 100644 --- a/deps/v8/test/cctest/test-fuzz-arm64.cc +++ b/deps/v8/test/cctest/test-fuzz-arm64.cc @@ -29,7 +29,8 @@ #include "src/arm64/decoder-arm64-inl.h" #include "src/arm64/disasm-arm64.h" -using namespace v8::internal; +namespace v8 { +namespace internal { TEST(FUZZ_decoder) { // Feed noise into the decoder to check that it doesn't crash. @@ -69,3 +70,6 @@ TEST(FUZZ_disasm) { decoder.Decode(buffer); } } + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-global-handles.cc b/deps/v8/test/cctest/test-global-handles.cc index 4550618de6..d3e229530f 100644 --- a/deps/v8/test/cctest/test-global-handles.cc +++ b/deps/v8/test/cctest/test-global-handles.cc @@ -185,5 +185,42 @@ TEST(PhatomHandlesWithoutCallbacks) { CHECK_EQ(0u, isolate->NumberOfPhantomHandleResetsSinceLastCall()); } +namespace { + +void ResurrectingFinalizer( + const v8::WeakCallbackInfo<v8::Global<v8::Object>>& data) { + data.GetParameter()->ClearWeak(); +} + +} // namespace + +TEST(Regress772299) { + CcTest::InitializeVM(); + v8::Isolate* isolate = CcTest::isolate(); + + v8::Global<v8::Object> g1, g2; + { + v8::HandleScope scope(isolate); + v8::Local<v8::Object> o1 = + v8::Local<v8::Object>::New(isolate, v8::Object::New(isolate)); + v8::Local<v8::Object> o2 = + v8::Local<v8::Object>::New(isolate, v8::Object::New(isolate)); + o1->Set(isolate->GetCurrentContext(), v8_str("link"), o2).FromJust(); + g1.Reset(isolate, o1); + g2.Reset(isolate, o2); + // g1 will be finalized but resurrected. + g1.SetWeak(&g1, ResurrectingFinalizer, v8::WeakCallbackType::kFinalizer); + // g2 will be a phantom handle that should not be reset as g1 transitively + // keeps it alive. + g2.SetWeak(); + } + + CcTest::CollectAllAvailableGarbage(); + // Both, g1 and g2, should stay alive as the finalizer resurrects the root + // object that transitively keeps the other one alive. + CHECK(!g1.IsEmpty()); + CHECK(!g2.IsEmpty()); +} + } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/test-hashmap.cc b/deps/v8/test/cctest/test-hashmap.cc index b1adc7b005..163bc09f19 100644 --- a/deps/v8/test/cctest/test-hashmap.cc +++ b/deps/v8/test/cctest/test-hashmap.cc @@ -32,12 +32,12 @@ #include "src/base/hashmap.h" -using namespace v8::internal; - +namespace v8 { +namespace internal { +namespace test_hashmap { typedef uint32_t (*IntKeyHash)(uint32_t key); - class IntSet { public: explicit IntSet(IntKeyHash hash) : hash_(hash) {} @@ -173,3 +173,7 @@ TEST(HashSet) { TestSet(Hash, 100); TestSet(CollisionHash, 50); } + +} // namespace test_hashmap +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-heap-profiler.cc b/deps/v8/test/cctest/test-heap-profiler.cc index ebc78a5ed4..b089fa8521 100644 --- a/deps/v8/test/cctest/test-heap-profiler.cc +++ b/deps/v8/test/cctest/test-heap-profiler.cc @@ -2433,14 +2433,14 @@ static AllocationTraceNode* FindNode( AllocationTraceNode* node = tracker->trace_tree()->root(); for (int i = 0; node != NULL && i < names.length(); i++) { const char* name = names[i]; - Vector<AllocationTraceNode*> children = node->children(); + const std::vector<AllocationTraceNode*>& children = node->children(); node = NULL; - for (int j = 0; j < children.length(); j++) { - unsigned index = children[j]->function_info_index(); + for (AllocationTraceNode* child : children) { + unsigned index = child->function_info_index(); AllocationTracker::FunctionInfo* info = tracker->function_info_list()[index]; if (info && strcmp(info->name, name) == 0) { - node = children[j]; + node = child; break; } } @@ -3063,3 +3063,77 @@ TEST(SamplingHeapProfilerLeftTrimming) { heap_profiler->StopSamplingHeapProfiler(); } + +TEST(SamplingHeapProfilerPretenuredInlineAllocations) { + i::FLAG_allow_natives_syntax = true; + i::FLAG_expose_gc = true; + + CcTest::InitializeVM(); + if (!CcTest::i_isolate()->use_optimizer() || i::FLAG_always_opt) return; + if (i::FLAG_gc_global || i::FLAG_stress_compaction || + i::FLAG_stress_incremental_marking) { + return; + } + + v8::HandleScope scope(v8::Isolate::GetCurrent()); + LocalContext env; + v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); + + // Suppress randomness to avoid flakiness in tests. + v8::internal::FLAG_sampling_heap_profiler_suppress_randomness = true; + + // Grow new space unitl maximum capacity reached. + while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) { + CcTest::heap()->new_space()->Grow(); + } + + i::ScopedVector<char> source(1024); + i::SNPrintF(source, + "var number_elements = %d;" + "var elements = new Array(number_elements);" + "function f() {" + " for (var i = 0; i < number_elements; i++) {" + " elements[i] = [{}, {}, {}];" + " }" + " return elements[number_elements - 1];" + "};" + "f(); gc();" + "f(); f();" + "%%OptimizeFunctionOnNextCall(f);" + "f();" + "f;", + i::AllocationSite::kPretenureMinimumCreated + 1); + + v8::Local<v8::Function> f = + v8::Local<v8::Function>::Cast(CompileRun(source.start())); + + // Make sure the function is producing pre-tenured objects. + auto res = f->Call(env.local(), env->Global(), 0, NULL).ToLocalChecked(); + i::Handle<i::JSObject> o = i::Handle<i::JSObject>::cast( + v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res))); + CHECK(CcTest::heap()->InOldSpace(o->elements())); + CHECK(CcTest::heap()->InOldSpace(*o)); + + // Call the function and profile it. + heap_profiler->StartSamplingHeapProfiler(64); + for (int i = 0; i < 100; ++i) { + f->Call(env.local(), env->Global(), 0, NULL).ToLocalChecked(); + } + + std::unique_ptr<v8::AllocationProfile> profile( + heap_profiler->GetAllocationProfile()); + CHECK(profile); + heap_profiler->StopSamplingHeapProfiler(); + + const char* names[] = {"f"}; + auto node_f = FindAllocationProfileNode(env->GetIsolate(), *profile, + ArrayVector(names)); + CHECK(node_f); + + int count = 0; + for (auto allocation : node_f->allocations) { + count += allocation.count; + } + + CHECK_GE(count, 9000); +} diff --git a/deps/v8/test/cctest/test-identity-map.cc b/deps/v8/test/cctest/test-identity-map.cc index f7d1c313e2..8a0d99d1dc 100644 --- a/deps/v8/test/cctest/test-identity-map.cc +++ b/deps/v8/test/cctest/test-identity-map.cc @@ -4,19 +4,11 @@ #include <set> -#include "src/factory.h" +#include "src/factory-inl.h" #include "src/identity-map.h" #include "src/isolate.h" #include "src/objects.h" #include "src/zone/zone.h" -// FIXME(mstarzinger, marja): This is weird, but required because of the missing -// (disallowed) include: src/factory.h -> src/objects-inl.h -#include "src/objects-inl.h" -// FIXME(mstarzinger, marja): This is weird, but required because of the missing -// (disallowed) include: src/feedback-vector.h -> -// src/feedback-vector-inl.h -#include "src/feedback-vector-inl.h" -#include "src/v8.h" #include "test/cctest/cctest.h" namespace v8 { @@ -773,6 +765,7 @@ TEST(CanonicalHandleScope) { } TEST(GCShortCutting) { + ManualGCScope manual_gc_scope; IdentityMapTester t; Isolate* isolate = CcTest::i_isolate(); Factory* factory = isolate->factory(); diff --git a/deps/v8/test/cctest/test-inobject-slack-tracking.cc b/deps/v8/test/cctest/test-inobject-slack-tracking.cc index e8b20a7702..9586d72456 100644 --- a/deps/v8/test/cctest/test-inobject-slack-tracking.cc +++ b/deps/v8/test/cctest/test-inobject-slack-tracking.cc @@ -13,8 +13,9 @@ #include "test/cctest/cctest.h" -using namespace v8::base; -using namespace v8::internal; +namespace v8 { +namespace internal { +namespace test_inobject_slack_tracking { static const int kMaxInobjectProperties = JSObject::kMaxInObjectProperties; @@ -62,15 +63,13 @@ Handle<T> GetLexical(const std::string& name) { return GetLexical<T>(name.c_str()); } - template <typename T> -static inline Handle<T> Run(v8::Local<v8::Script> script) { +static inline Handle<T> RunI(v8::Local<v8::Script> script) { return OpenHandle<T>(Run(script)); } - template <typename T> -static inline Handle<T> CompileRun(const char* script) { +static inline Handle<T> CompileRunI(const char* script) { return OpenHandle<T>(CompileRun(script)); } @@ -135,7 +134,7 @@ TEST(JSObjectBasic) { v8::Local<v8::Script> new_A_script = v8_compile("new A();"); - Handle<JSObject> obj = Run<JSObject>(new_A_script); + Handle<JSObject> obj = RunI<JSObject>(new_A_script); CHECK(func->has_initial_map()); Handle<Map> initial_map(func->initial_map()); @@ -155,7 +154,7 @@ TEST(JSObjectBasic) { // Create several objects to complete the tracking. for (int i = 1; i < Map::kGenerousAllocationCount; i++) { CHECK(initial_map->IsInobjectSlackTrackingInProgress()); - Handle<JSObject> tmp = Run<JSObject>(new_A_script); + Handle<JSObject> tmp = RunI<JSObject>(new_A_script); CHECK_EQ(initial_map->IsInobjectSlackTrackingInProgress(), IsObjectShrinkable(*tmp)); } @@ -194,9 +193,9 @@ TEST(JSObjectComplex) { // Zero instances were created so far. CHECK(!func->has_initial_map()); - Handle<JSObject> obj1 = CompileRun<JSObject>("new A(1);"); - Handle<JSObject> obj3 = CompileRun<JSObject>("new A(3);"); - Handle<JSObject> obj5 = CompileRun<JSObject>("new A(5);"); + Handle<JSObject> obj1 = CompileRunI<JSObject>("new A(1);"); + Handle<JSObject> obj3 = CompileRunI<JSObject>("new A(3);"); + Handle<JSObject> obj5 = CompileRunI<JSObject>("new A(5);"); CHECK(func->has_initial_map()); Handle<Map> initial_map(func->initial_map()); @@ -237,9 +236,9 @@ TEST(JSObjectComplex) { CHECK_EQ(0, obj5->map()->unused_property_fields()); // Since slack tracking is complete, the new objects should not be shrinkable. - obj1 = CompileRun<JSObject>("new A(1);"); - obj3 = CompileRun<JSObject>("new A(3);"); - obj5 = CompileRun<JSObject>("new A(5);"); + obj1 = CompileRunI<JSObject>("new A(1);"); + obj3 = CompileRunI<JSObject>("new A(3);"); + obj5 = CompileRunI<JSObject>("new A(5);"); CHECK(!IsObjectShrinkable(*obj1)); CHECK(!IsObjectShrinkable(*obj3)); @@ -281,7 +280,7 @@ TEST(JSGeneratorObjectBasic) { v8::Local<v8::Script> new_A_script = v8_compile("CreateGenerator();"); - Handle<JSObject> obj = Run<JSObject>(new_A_script); + Handle<JSObject> obj = RunI<JSObject>(new_A_script); CHECK(func->has_initial_map()); Handle<Map> initial_map(func->initial_map()); @@ -301,7 +300,7 @@ TEST(JSGeneratorObjectBasic) { // Create several objects to complete the tracking. for (int i = 1; i < Map::kGenerousAllocationCount; i++) { CHECK(initial_map->IsInobjectSlackTrackingInProgress()); - Handle<JSObject> tmp = Run<JSObject>(new_A_script); + Handle<JSObject> tmp = RunI<JSObject>(new_A_script); CHECK_EQ(initial_map->IsInobjectSlackTrackingInProgress(), IsObjectShrinkable(*tmp)); } @@ -357,7 +356,7 @@ TEST(SubclassBasicNoBaseClassInstances) { v8::Local<v8::Script> new_B_script = v8_compile("new B();"); - Handle<JSObject> obj = Run<JSObject>(new_B_script); + Handle<JSObject> obj = RunI<JSObject>(new_B_script); CHECK(a_func->has_initial_map()); Handle<Map> a_initial_map(a_func->initial_map()); @@ -388,7 +387,7 @@ TEST(SubclassBasicNoBaseClassInstances) { // Create several subclass instances to complete the tracking. for (int i = 1; i < Map::kGenerousAllocationCount; i++) { CHECK(b_initial_map->IsInobjectSlackTrackingInProgress()); - Handle<JSObject> tmp = Run<JSObject>(new_B_script); + Handle<JSObject> tmp = RunI<JSObject>(new_B_script); CHECK_EQ(b_initial_map->IsInobjectSlackTrackingInProgress(), IsObjectShrinkable(*tmp)); } @@ -451,8 +450,8 @@ TEST(SubclassBasic) { v8::Local<v8::Script> new_A_script = v8_compile("new A();"); v8::Local<v8::Script> new_B_script = v8_compile("new B();"); - Handle<JSObject> a_obj = Run<JSObject>(new_A_script); - Handle<JSObject> b_obj = Run<JSObject>(new_B_script); + Handle<JSObject> a_obj = RunI<JSObject>(new_A_script); + Handle<JSObject> b_obj = RunI<JSObject>(new_B_script); CHECK(a_func->has_initial_map()); Handle<Map> a_initial_map(a_func->initial_map()); @@ -473,7 +472,7 @@ TEST(SubclassBasic) { // Create several base class instances to complete the tracking. for (int i = 1; i < Map::kGenerousAllocationCount; i++) { CHECK(a_initial_map->IsInobjectSlackTrackingInProgress()); - Handle<JSObject> tmp = Run<JSObject>(new_A_script); + Handle<JSObject> tmp = RunI<JSObject>(new_A_script); CHECK_EQ(a_initial_map->IsInobjectSlackTrackingInProgress(), IsObjectShrinkable(*tmp)); } @@ -496,7 +495,7 @@ TEST(SubclassBasic) { // Create several subclass instances to complete the tracking. for (int i = 1; i < Map::kGenerousAllocationCount; i++) { CHECK(b_initial_map->IsInobjectSlackTrackingInProgress()); - Handle<JSObject> tmp = Run<JSObject>(new_B_script); + Handle<JSObject> tmp = RunI<JSObject>(new_B_script); CHECK_EQ(b_initial_map->IsInobjectSlackTrackingInProgress(), IsObjectShrinkable(*tmp)); } @@ -575,7 +574,7 @@ static void TestClassHierarchy(const std::vector<int>& hierarchy_desc, int n) { Handle<JSFunction> func = GetLexical<JSFunction>(class_name); - Handle<JSObject> obj = Run<JSObject>(new_script); + Handle<JSObject> obj = RunI<JSObject>(new_script); CHECK(func->has_initial_map()); Handle<Map> initial_map(func->initial_map()); @@ -594,7 +593,7 @@ static void TestClassHierarchy(const std::vector<int>& hierarchy_desc, int n) { // Create several instances to complete the tracking. for (int i = 1; i < Map::kGenerousAllocationCount; i++) { CHECK(initial_map->IsInobjectSlackTrackingInProgress()); - Handle<JSObject> tmp = Run<JSObject>(new_script); + Handle<JSObject> tmp = RunI<JSObject>(new_script); CHECK_EQ(initial_map->IsInobjectSlackTrackingInProgress(), IsObjectShrinkable(*tmp)); CHECK_EQ(Map::kSlackTrackingCounterStart - i - 1, @@ -675,7 +674,7 @@ TEST(InobjectPropetiesCountOverflowInSubclass) { Handle<JSFunction> func = GetLexical<JSFunction>(class_name); - Handle<JSObject> obj = Run<JSObject>(new_script); + Handle<JSObject> obj = RunI<JSObject>(new_script); CHECK(func->has_initial_map()); Handle<Map> initial_map(func->initial_map()); @@ -692,7 +691,7 @@ TEST(InobjectPropetiesCountOverflowInSubclass) { // Create several instances to complete the tracking. for (int i = 1; i < Map::kGenerousAllocationCount; i++) { CHECK(initial_map->IsInobjectSlackTrackingInProgress()); - Handle<JSObject> tmp = Run<JSObject>(new_script); + Handle<JSObject> tmp = RunI<JSObject>(new_script); CHECK(!IsObjectShrinkable(*tmp)); } CHECK(!initial_map->IsInobjectSlackTrackingInProgress()); @@ -859,7 +858,7 @@ TEST(SlowModeSubclass) { Handle<JSFunction> func = GetLexical<JSFunction>(class_name); - Handle<JSObject> obj = Run<JSObject>(new_script); + Handle<JSObject> obj = RunI<JSObject>(new_script); CHECK(func->has_initial_map()); Handle<Map> initial_map(func->initial_map()); @@ -876,7 +875,7 @@ TEST(SlowModeSubclass) { // Create several instances to complete the tracking. for (int i = 1; i < Map::kGenerousAllocationCount; i++) { CHECK(initial_map->IsInobjectSlackTrackingInProgress()); - Handle<JSObject> tmp = Run<JSObject>(new_script); + Handle<JSObject> tmp = RunI<JSObject>(new_script); CHECK(!IsObjectShrinkable(*tmp)); } CHECK(!initial_map->IsInobjectSlackTrackingInProgress()); @@ -925,7 +924,7 @@ static void TestSubclassBuiltin(const char* subclass_name, new_script = v8_compile(os.str().c_str()); } - Run<JSObject>(new_script); + RunI<JSObject>(new_script); CHECK(func->has_initial_map()); Handle<Map> initial_map(func->initial_map()); @@ -939,7 +938,7 @@ static void TestSubclassBuiltin(const char* subclass_name, // Create two instances in order to ensure that |obj|.o is a data field // in case of Function subclassing. - Handle<JSObject> obj = Run<JSObject>(new_script); + Handle<JSObject> obj = RunI<JSObject>(new_script); // Two instances of a subclass created. CHECK_EQ(Map::kSlackTrackingCounterStart - 2, @@ -956,7 +955,7 @@ static void TestSubclassBuiltin(const char* subclass_name, // Create several subclass instances to complete the tracking. for (int i = 2; i < Map::kGenerousAllocationCount; i++) { CHECK(initial_map->IsInobjectSlackTrackingInProgress()); - Handle<JSObject> tmp = Run<JSObject>(new_script); + Handle<JSObject> tmp = RunI<JSObject>(new_script); CHECK_EQ(initial_map->IsInobjectSlackTrackingInProgress(), IsObjectShrinkable(*tmp)); } @@ -1203,3 +1202,7 @@ TEST(SubclassPromiseBuiltinNoInlineNew) { FLAG_inline_new = false; TestSubclassPromiseBuiltin(); } + +} // namespace test_inobject_slack_tracking +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-javascript-arm64.cc b/deps/v8/test/cctest/test-javascript-arm64.cc index d23b63e0a9..3b1f1a1d12 100644 --- a/deps/v8/test/cctest/test-javascript-arm64.cc +++ b/deps/v8/test/cctest/test-javascript-arm64.cc @@ -39,40 +39,23 @@ #include "src/utils.h" #include "test/cctest/cctest.h" -using ::v8::Context; -using ::v8::Extension; -using ::v8::Function; -using ::v8::FunctionTemplate; -using ::v8::HandleScope; -using ::v8::Local; -using ::v8::Message; -using ::v8::MessageCallback; -using ::v8::Object; -using ::v8::ObjectTemplate; -using ::v8::Persistent; -using ::v8::Script; -using ::v8::StackTrace; -using ::v8::String; -using ::v8::TryCatch; -using ::v8::Undefined; -using ::v8::V8; -using ::v8::Value; - -static void ExpectBoolean(Local<Context> context, bool expected, +namespace v8 { +namespace internal { +namespace test_javascript_arm64 { + +static void ExpectBoolean(Local<v8::Context> context, bool expected, Local<Value> result) { CHECK(result->IsBoolean()); CHECK_EQ(expected, result->BooleanValue(context).FromJust()); } - -static void ExpectInt32(Local<Context> context, int32_t expected, +static void ExpectInt32(Local<v8::Context> context, int32_t expected, Local<Value> result) { CHECK(result->IsInt32()); CHECK_EQ(expected, result->Int32Value(context).FromJust()); } - -static void ExpectNumber(Local<Context> context, double expected, +static void ExpectNumber(Local<v8::Context> context, double expected, Local<Value> result) { CHECK(result->IsNumber()); CHECK_EQ(expected, result->NumberValue(context).FromJust()); @@ -125,7 +108,7 @@ TEST(binary_op) { ExpectInt32(env.local(), 0x2468, result); } -static void if_comparison_testcontext_helper(Local<Context> context, +static void if_comparison_testcontext_helper(Local<v8::Context> context, char const* op, char const* lhs, char const* rhs, int expect) { char buffer[256]; @@ -139,7 +122,7 @@ static void if_comparison_testcontext_helper(Local<Context> context, ExpectInt32(context, expect, result); } -static void if_comparison_effectcontext_helper(Local<Context> context, +static void if_comparison_effectcontext_helper(Local<v8::Context> context, char const* op, char const* lhs, char const* rhs, int expect) { char buffer[256]; @@ -154,7 +137,7 @@ static void if_comparison_effectcontext_helper(Local<Context> context, ExpectInt32(context, expect, result); } -static void if_comparison_helper(Local<Context> context, char const* op, +static void if_comparison_helper(Local<v8::Context> context, char const* op, int expect_when_lt, int expect_when_eq, int expect_when_gt) { // TODO(all): Non-SMI tests. @@ -259,3 +242,7 @@ TEST(unary_not) { result = CompileRun("var a = 1; if ( !a ) { 1; } else { 0; }"); ExpectInt32(env.local(), 0, result); } + +} // namespace test_javascript_arm64 +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-js-arm64-variables.cc b/deps/v8/test/cctest/test-js-arm64-variables.cc index dbcf8f94ac..442407a79e 100644 --- a/deps/v8/test/cctest/test-js-arm64-variables.cc +++ b/deps/v8/test/cctest/test-js-arm64-variables.cc @@ -41,26 +41,11 @@ #include "src/utils.h" #include "test/cctest/cctest.h" -using ::v8::Context; -using ::v8::Extension; -using ::v8::Function; -using ::v8::FunctionTemplate; -using ::v8::HandleScope; -using ::v8::Local; -using ::v8::Message; -using ::v8::MessageCallback; -using ::v8::Object; -using ::v8::ObjectTemplate; -using ::v8::Persistent; -using ::v8::Script; -using ::v8::StackTrace; -using ::v8::String; -using ::v8::TryCatch; -using ::v8::Undefined; -using ::v8::V8; -using ::v8::Value; - -static void ExpectInt32(Local<Context> context, int32_t expected, +namespace v8 { +namespace internal { +namespace test_js_arm64_variables { + +static void ExpectInt32(Local<v8::Context> context, int32_t expected, Local<Value> result) { CHECK(result->IsInt32()); CHECK_EQ(expected, result->Int32Value(context).FromJust()); @@ -140,3 +125,7 @@ TEST(lookup_slots) { "f5(5);"); ExpectInt32(env.local(), 5, result); } + +} // namespace test_js_arm64_variables +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-list.cc b/deps/v8/test/cctest/test-list.cc deleted file mode 100644 index c943d10e26..0000000000 --- a/deps/v8/test/cctest/test-list.cc +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright 2011 the V8 project authors. All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials provided -// with the distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (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 <stdlib.h> -#include <string.h> -#include "src/list-inl.h" -#include "src/list.h" -#include "src/v8.h" -#include "test/cctest/cctest.h" - -namespace v8 { -namespace internal { - -// Use a testing allocator that clears memory before deletion. -class ZeroingAllocationPolicy { - public: - void* New(size_t size) { - // Stash the size in the first word to use for Delete. - size_t true_size = size + sizeof(size_t); - size_t* result = reinterpret_cast<size_t*>(malloc(true_size)); - if (result == NULL) return result; - *result = true_size; - return result + 1; - } - - static void Delete(void* ptr) { - size_t* true_ptr = reinterpret_cast<size_t*>(ptr) - 1; - memset(true_ptr, 0, *true_ptr); - free(true_ptr); - } -}; - - -// Check that we can add (a reference to) an element of the list -// itself. -TEST(ListAdd) { - // Add elements to the list to grow it to its capacity. - List<int, ZeroingAllocationPolicy> list(4); - list.Add(1); - list.Add(2); - list.Add(3); - list.Add(4); - - // Add an existing element, the backing store should have to grow. - list.Add(list[0]); - CHECK_EQ(1, list[4]); -} - - -// Test that we can add all elements from a list to another list. -TEST(ListAddAll) { - List<int, ZeroingAllocationPolicy> list(4); - list.Add(0); - list.Add(1); - list.Add(2); - - CHECK_EQ(3, list.length()); - for (int i = 0; i < 3; i++) { - CHECK_EQ(i, list[i]); - } - - List<int, ZeroingAllocationPolicy> other_list(4); - - // Add no elements to list since other_list is empty. - list.AddAll(other_list); - CHECK_EQ(3, list.length()); - for (int i = 0; i < 3; i++) { - CHECK_EQ(i, list[i]); - } - - // Add three elements to other_list. - other_list.Add(0); - other_list.Add(1); - other_list.Add(2); - - // Copy the three elements from other_list to list. - list.AddAll(other_list); - CHECK_EQ(6, list.length()); - for (int i = 0; i < 6; i++) { - CHECK_EQ(i % 3, list[i]); - } -} - - -TEST(RemoveLast) { - List<int> list(4); - CHECK_EQ(0, list.length()); - list.Add(1); - CHECK_EQ(1, list.length()); - CHECK_EQ(1, list.last()); - list.RemoveLast(); - CHECK_EQ(0, list.length()); - list.Add(2); - list.Add(3); - CHECK_EQ(2, list.length()); - CHECK_EQ(3, list.last()); - list.RemoveLast(); - CHECK_EQ(1, list.length()); - CHECK_EQ(2, list.last()); - list.RemoveLast(); - CHECK_EQ(0, list.length()); - - const int kElements = 100; - for (int i = 0; i < kElements; i++) list.Add(i); - for (int j = kElements - 1; j >= 0; j--) { - CHECK_EQ(j + 1, list.length()); - CHECK_EQ(j, list.last()); - list.RemoveLast(); - CHECK_EQ(j, list.length()); - } -} - - -TEST(Allocate) { - List<int> list(4); - list.Add(1); - CHECK_EQ(1, list.length()); - list.Allocate(100); - CHECK_EQ(100, list.length()); - CHECK_LE(100, list.capacity()); - list[99] = 123; - CHECK_EQ(123, list[99]); -} - - -TEST(Clear) { - List<int> list(4); - CHECK_EQ(0, list.length()); - for (int i = 0; i < 4; ++i) list.Add(i); - CHECK_EQ(4, list.length()); - list.Clear(); - CHECK_EQ(0, list.length()); -} - - -TEST(DeleteEmpty) { - { - List<int>* list = new List<int>(0); - delete list; - } - { - List<int> list(0); - } -} - -} // namespace internal -} // namespace v8 diff --git a/deps/v8/test/cctest/test-lockers.cc b/deps/v8/test/cctest/test-lockers.cc index a310bfd684..ebfbe88de2 100644 --- a/deps/v8/test/cctest/test-lockers.cc +++ b/deps/v8/test/cctest/test-lockers.cc @@ -41,19 +41,247 @@ #include "src/utils.h" #include "test/cctest/cctest.h" -using ::v8::Context; -using ::v8::Extension; -using ::v8::Function; -using ::v8::HandleScope; -using ::v8::Local; -using ::v8::Object; -using ::v8::ObjectTemplate; -using ::v8::Persistent; -using ::v8::Script; -using ::v8::String; -using ::v8::Value; -using ::v8::V8; +namespace { +class DeoptimizeCodeThread : public v8::base::Thread { + public: + DeoptimizeCodeThread(v8::Isolate* isolate, v8::Local<v8::Context> context, + const char* trigger) + : Thread(Options("DeoptimizeCodeThread")), + isolate_(isolate), + context_(isolate, context), + source_(trigger) {} + + void Run() { + v8::Locker locker(isolate_); + isolate_->Enter(); + v8::HandleScope handle_scope(isolate_); + v8::Local<v8::Context> context = + v8::Local<v8::Context>::New(isolate_, context_); + v8::Context::Scope context_scope(context); + CHECK_EQ(isolate_, v8::Isolate::GetCurrent()); + // This code triggers deoptimization of some function that will be + // used in a different thread. + CompileRun(source_); + isolate_->Exit(); + } + + private: + v8::Isolate* isolate_; + v8::Persistent<v8::Context> context_; + // The code that triggers the deoptimization. + const char* source_; +}; + +void UnlockForDeoptimization(const v8::FunctionCallbackInfo<v8::Value>& args) { + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + // Gets the pointer to the thread that will trigger the deoptimization of the + // code. + DeoptimizeCodeThread* deoptimizer = + reinterpret_cast<DeoptimizeCodeThread*>(isolate->GetData(0)); + { + // Exits and unlocks the isolate. + isolate->Exit(); + v8::Unlocker unlocker(isolate); + // Starts the deoptimizing thread. + deoptimizer->Start(); + // Waits for deoptimization to finish. + deoptimizer->Join(); + } + // The deoptimizing thread has finished its work, and the isolate + // will now be used by the current thread. + isolate->Enter(); +} + +void UnlockForDeoptimizationIfReady( + const v8::FunctionCallbackInfo<v8::Value>& args) { + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + bool* ready_to_deoptimize = reinterpret_cast<bool*>(isolate->GetData(1)); + if (*ready_to_deoptimize) { + // The test should enter here only once, so put the flag back to false. + *ready_to_deoptimize = false; + // Gets the pointer to the thread that will trigger the deoptimization of + // the code. + DeoptimizeCodeThread* deoptimizer = + reinterpret_cast<DeoptimizeCodeThread*>(isolate->GetData(0)); + { + // Exits and unlocks the thread. + isolate->Exit(); + v8::Unlocker unlocker(isolate); + // Starts the thread that deoptimizes the function. + deoptimizer->Start(); + // Waits for the deoptimizing thread to finish. + deoptimizer->Join(); + } + // The deoptimizing thread has finished its work, and the isolate + // will now be used by the current thread. + isolate->Enter(); + } +} +} // namespace + +namespace v8 { +namespace internal { +namespace test_lockers { + +TEST(LazyDeoptimizationMultithread) { + i::FLAG_allow_natives_syntax = true; + v8::Isolate::CreateParams create_params; + create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); + v8::Isolate* isolate = v8::Isolate::New(create_params); + { + v8::Locker locker(isolate); + v8::Isolate::Scope isolate_scope(isolate); + v8::HandleScope scope(isolate); + v8::Local<v8::Context> context = v8::Context::New(isolate); + const char* trigger_deopt = "obj = { y: 0, x: 1 };"; + + // We use the isolate to pass arguments to the UnlockForDeoptimization + // function. Namely, we pass a pointer to the deoptimizing thread. + DeoptimizeCodeThread deoptimize_thread(isolate, context, trigger_deopt); + isolate->SetData(0, &deoptimize_thread); + v8::Context::Scope context_scope(context); + + // Create the function templace for C++ code that is invoked from + // JavaScript code. + Local<v8::FunctionTemplate> fun_templ = + v8::FunctionTemplate::New(isolate, UnlockForDeoptimization); + Local<Function> fun = fun_templ->GetFunction(context).ToLocalChecked(); + CHECK(context->Global() + ->Set(context, v8_str("unlock_for_deoptimization"), fun) + .FromJust()); + + // Optimizes a function f, which will be deoptimized in another + // thread. + CompileRun( + "var b = false; var obj = { x: 1 };" + "function f() { g(); return obj.x; }" + "function g() { if (b) { unlock_for_deoptimization(); } }" + "%NeverOptimizeFunction(g);" + "f(); f(); %OptimizeFunctionOnNextCall(f);" + "f();"); + + // Trigger the unlocking. + Local<Value> v = CompileRun("b = true; f();"); + + // Once the isolate has been unlocked, the thread will wait for the + // other thread to finish its task. Once this happens, this thread + // continues with its execution, that is, with the execution of the + // function g, which then returns to f. The function f should have + // also been deoptimized. If the replacement did not happen on this + // thread's stack, then the test will fail here. + CHECK(v->IsNumber()); + CHECK_EQ(1, static_cast<int>(v->NumberValue(context).FromJust())); + } + isolate->Dispose(); +} + +TEST(LazyDeoptimizationMultithreadWithNatives) { + i::FLAG_allow_natives_syntax = true; + v8::Isolate::CreateParams create_params; + create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); + v8::Isolate* isolate = v8::Isolate::New(create_params); + { + v8::Locker locker(isolate); + v8::Isolate::Scope isolate_scope(isolate); + v8::HandleScope scope(isolate); + v8::Local<v8::Context> context = v8::Context::New(isolate); + const char* trigger_deopt = "%DeoptimizeFunction(f);"; + + // We use the isolate to pass arguments to the UnlockForDeoptimization + // function. Namely, we pass a pointer to the deoptimizing thread. + DeoptimizeCodeThread deoptimize_thread(isolate, context, trigger_deopt); + isolate->SetData(0, &deoptimize_thread); + bool ready_to_deopt = false; + isolate->SetData(1, &ready_to_deopt); + v8::Context::Scope context_scope(context); + + // Create the function templace for C++ code that is invoked from + // JavaScript code. + Local<v8::FunctionTemplate> fun_templ = + v8::FunctionTemplate::New(isolate, UnlockForDeoptimizationIfReady); + Local<Function> fun = fun_templ->GetFunction(context).ToLocalChecked(); + CHECK(context->Global() + ->Set(context, v8_str("unlock_for_deoptimization"), fun) + .FromJust()); + + // Optimizes a function f, which will be deoptimized in another + // thread. + CompileRun( + "var obj = { x: 1 };" + "function f() { g(); return obj.x;}" + "function g() { " + " unlock_for_deoptimization(); }" + "%NeverOptimizeFunction(g);" + "f(); f(); %OptimizeFunctionOnNextCall(f);"); + + // Trigger the unlocking. + ready_to_deopt = true; + isolate->SetData(1, &ready_to_deopt); + Local<Value> v = CompileRun("f();"); + + // Once the isolate has been unlocked, the thread will wait for the + // other thread to finish its task. Once this happens, this thread + // continues with its execution, that is, with the execution of the + // function g, which then returns to f. The function f should have + // also been deoptimized. Otherwise, the test will fail here. + CHECK(v->IsNumber()); + CHECK_EQ(1, static_cast<int>(v->NumberValue(context).FromJust())); + } + isolate->Dispose(); +} + +TEST(EagerDeoptimizationMultithread) { + i::FLAG_allow_natives_syntax = true; + v8::Isolate::CreateParams create_params; + create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); + v8::Isolate* isolate = v8::Isolate::New(create_params); + { + v8::Locker locker(isolate); + v8::Isolate::Scope isolate_scope(isolate); + v8::HandleScope scope(isolate); + v8::Local<v8::Context> context = v8::Context::New(isolate); + const char* trigger_deopt = "f({y: 0, x: 1});"; + + // We use the isolate to pass arguments to the UnlockForDeoptimization + // function. Namely, we pass a pointer to the deoptimizing thread. + DeoptimizeCodeThread deoptimize_thread(isolate, context, trigger_deopt); + isolate->SetData(0, &deoptimize_thread); + bool ready_to_deopt = false; + isolate->SetData(1, &ready_to_deopt); + v8::Context::Scope context_scope(context); + + // Create the function templace for C++ code that is invoked from + // JavaScript code. + Local<v8::FunctionTemplate> fun_templ = + v8::FunctionTemplate::New(isolate, UnlockForDeoptimizationIfReady); + Local<Function> fun = fun_templ->GetFunction(context).ToLocalChecked(); + CHECK(context->Global() + ->Set(context, v8_str("unlock_for_deoptimization"), fun) + .FromJust()); + + // Optimizes a function f, which will be deoptimized by another thread. + CompileRun( + "function f(obj) { unlock_for_deoptimization(); return obj.x; }" + "f({x: 1}); f({x: 1});" + "%OptimizeFunctionOnNextCall(f);" + "f({x: 1});"); + + // Trigger the unlocking. + ready_to_deopt = true; + isolate->SetData(1, &ready_to_deopt); + Local<Value> v = CompileRun("f({x: 1});"); + + // Once the isolate has been unlocked, the thread will wait for the + // other thread to finish its task. Once this happens, this thread + // continues with its execution, that is, with the execution of the + // function g, which then returns to f. The function f should have + // also been deoptimized. Otherwise, the test will fail here. + CHECK(v->IsNumber()); + CHECK_EQ(1, static_cast<int>(v->NumberValue(context).FromJust())); + } + isolate->Dispose(); +} // Migrating an isolate class KangarooThread : public v8::base::Thread { @@ -92,7 +320,7 @@ class KangarooThread : public v8::base::Thread { private: v8::Isolate* isolate_; - Persistent<v8::Context> context_; + v8::Persistent<v8::Context> context_; }; @@ -332,7 +560,7 @@ class LockIsolateAndCalculateFibSharedContextThread : public JoinableThread { virtual void Run() { v8::Locker lock(isolate_); v8::Isolate::Scope isolate_scope(isolate_); - HandleScope handle_scope(isolate_); + v8::HandleScope handle_scope(isolate_); v8::Local<v8::Context> context = v8::Local<v8::Context>::New(isolate_, context_); v8::Context::Scope context_scope(context); @@ -340,7 +568,7 @@ class LockIsolateAndCalculateFibSharedContextThread : public JoinableThread { } private: v8::Isolate* isolate_; - Persistent<v8::Context> context_; + v8::Persistent<v8::Context> context_; }; class LockerUnlockerThread : public JoinableThread { @@ -661,12 +889,12 @@ TEST(Regress1433) { v8::Locker lock(isolate); v8::Isolate::Scope isolate_scope(isolate); v8::HandleScope handle_scope(isolate); - v8::Local<Context> context = v8::Context::New(isolate); + v8::Local<v8::Context> context = v8::Context::New(isolate); v8::Context::Scope context_scope(context); - v8::Local<String> source = v8_str("1+1"); - v8::Local<Script> script = + v8::Local<v8::String> source = v8_str("1+1"); + v8::Local<v8::Script> script = v8::Script::Compile(context, source).ToLocalChecked(); - v8::Local<Value> result = script->Run(context).ToLocalChecked(); + v8::Local<v8::Value> result = script->Run(context).ToLocalChecked(); v8::String::Utf8Value utf8(isolate, result); } isolate->Dispose(); @@ -744,3 +972,7 @@ TEST(ExtensionsRegistration) { } StartJoinAndDeleteThreads(threads); } + +} // namespace test_lockers +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-macro-assembler-arm.cc b/deps/v8/test/cctest/test-macro-assembler-arm.cc index 2bbcb7a566..97579674c0 100644 --- a/deps/v8/test/cctest/test-macro-assembler-arm.cc +++ b/deps/v8/test/cctest/test-macro-assembler-arm.cc @@ -34,7 +34,9 @@ #include "src/v8.h" #include "test/cctest/cctest.h" -using namespace v8::internal; +namespace v8 { +namespace internal { +namespace test_macro_assembler_arm { typedef void* (*F)(int x, int y, int p2, int p3, int p4); @@ -125,8 +127,8 @@ TEST(LoadAndStoreWithRepresentation) { CodeDesc desc; masm->GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); // Call the function from C++. F5 f = FUNCTION_CAST<F5>(code->entry()); @@ -235,8 +237,8 @@ TEST(ExtractLane) { CodeDesc desc; masm->GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG OFStream os(stdout); code->Print(os); @@ -370,8 +372,8 @@ TEST(ReplaceLane) { CodeDesc desc; masm->GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG OFStream os(stdout); code->Print(os); @@ -404,3 +406,7 @@ TEST(ReplaceLane) { } #undef __ + +} // namespace test_macro_assembler_arm +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-macro-assembler-mips.cc b/deps/v8/test/cctest/test-macro-assembler-mips.cc index c00b8e65a1..f1a0b2a1a6 100644 --- a/deps/v8/test/cctest/test-macro-assembler-mips.cc +++ b/deps/v8/test/cctest/test-macro-assembler-mips.cc @@ -28,17 +28,18 @@ #include <stdlib.h> #include <iostream> // NOLINT(readability/streams) +#include "src/api.h" #include "src/base/utils/random-number-generator.h" #include "src/macro-assembler.h" #include "src/mips/macro-assembler-mips.h" #include "src/mips/simulator-mips.h" +#include "src/objects-inl.h" #include "src/v8.h" #include "test/cctest/cctest.h" +namespace v8 { +namespace internal { -using namespace v8::internal; - -typedef void* (*F)(int x, int y, int p2, int p3, int p4); typedef Object* (*F1)(int x, int p1, int p2, int p3, int p4); typedef Object* (*F3)(void* p, int p1, int p2, int p3, int p4); typedef Object* (*F4)(void* p0, void* p1, int p2, int p3, int p4); @@ -93,9 +94,9 @@ TEST(BYTESWAP) { CodeDesc desc; masm->GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); - ::F3 f = FUNCTION_CAST<::F3>(code->entry()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); + F3 f = FUNCTION_CAST<F3>(code->entry()); t.r1 = 0x781A15C3; t.r2 = 0x2CDE; t.r3 = 0x9F; @@ -202,8 +203,8 @@ TEST(jump_tables4) { CodeDesc desc; masm->GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -269,8 +270,8 @@ TEST(jump_tables5) { CodeDesc desc; masm->GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -360,8 +361,8 @@ TEST(jump_tables6) { CodeDesc desc; masm->GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -387,8 +388,8 @@ static uint32_t run_lsa(uint32_t rt, uint32_t rs, int8_t sa) { CodeDesc desc; assembler.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F1 f = FUNCTION_CAST<F1>(code->entry()); @@ -517,8 +518,8 @@ RET_TYPE run_Cvt(IN_TYPE x, Func GenerateConvertInstructionFunc) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F_CVT f = FUNCTION_CAST<F_CVT>(code->entry()); @@ -622,8 +623,8 @@ static bool runOverflow(IN_TYPE valLeft, IN_TYPE valRight, CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F_CVT f = FUNCTION_CAST<F_CVT>(code->entry()); @@ -1051,9 +1052,9 @@ TEST(min_max_nan) { CodeDesc desc; masm->GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); - ::F3 f = FUNCTION_CAST<::F3>(code->entry()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); + F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 0; i < kTableLength; i++) { test.a = inputsa[i]; test.b = inputsb[i]; @@ -1087,8 +1088,8 @@ bool run_Unaligned(char* memory_buffer, int32_t in_offset, int32_t out_offset, CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F_CVT f = FUNCTION_CAST<F_CVT>(code->entry()); @@ -1335,8 +1336,8 @@ bool run_Sltu(uint32_t rs, uint32_t rd, Func GenerateSltuInstructionFunc) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F_CVT f = FUNCTION_CAST<F_CVT>(code->entry()); int32_t res = reinterpret_cast<int32_t>( @@ -1366,7 +1367,7 @@ TEST(Sltu) { } template <typename T, typename Inputs, typename Results> -static ::F4 GenerateMacroFloat32MinMax(MacroAssembler* masm) { +static F4 GenerateMacroFloat32MinMax(MacroAssembler* masm) { T a = T::from_code(4); // f4 T b = T::from_code(6); // f6 T c = T::from_code(8); // f8 @@ -1430,13 +1431,13 @@ static ::F4 GenerateMacroFloat32MinMax(MacroAssembler* masm) { CodeDesc desc; masm->GetCode(masm->isolate(), &desc); - Handle<Code> code = masm->isolate()->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + masm->isolate()->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG OFStream os(stdout); code->Print(os); #endif - return FUNCTION_CAST<::F4>(code->entry()); + return FUNCTION_CAST<F4>(code->entry()); } TEST(macro_float_minmax_f32) { @@ -1465,7 +1466,7 @@ TEST(macro_float_minmax_f32) { float max_aba_; }; - ::F4 f = GenerateMacroFloat32MinMax<FPURegister, Inputs, Results>(masm); + F4 f = GenerateMacroFloat32MinMax<FPURegister, Inputs, Results>(masm); Object* dummy = nullptr; USE(dummy); @@ -1509,7 +1510,7 @@ TEST(macro_float_minmax_f32) { } template <typename T, typename Inputs, typename Results> -static ::F4 GenerateMacroFloat64MinMax(MacroAssembler* masm) { +static F4 GenerateMacroFloat64MinMax(MacroAssembler* masm) { T a = T::from_code(4); // f4 T b = T::from_code(6); // f6 T c = T::from_code(8); // f8 @@ -1573,13 +1574,13 @@ static ::F4 GenerateMacroFloat64MinMax(MacroAssembler* masm) { CodeDesc desc; masm->GetCode(masm->isolate(), &desc); - Handle<Code> code = masm->isolate()->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + masm->isolate()->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG OFStream os(stdout); code->Print(os); #endif - return FUNCTION_CAST<::F4>(code->entry()); + return FUNCTION_CAST<F4>(code->entry()); } TEST(macro_float_minmax_f64) { @@ -1608,7 +1609,7 @@ TEST(macro_float_minmax_f64) { double max_aba_; }; - ::F4 f = GenerateMacroFloat64MinMax<DoubleRegister, Inputs, Results>(masm); + F4 f = GenerateMacroFloat64MinMax<DoubleRegister, Inputs, Results>(masm); Object* dummy = nullptr; USE(dummy); @@ -1652,3 +1653,6 @@ TEST(macro_float_minmax_f64) { } #undef __ + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-macro-assembler-mips64.cc b/deps/v8/test/cctest/test-macro-assembler-mips64.cc index 9432584c4d..58e5b32dd6 100644 --- a/deps/v8/test/cctest/test-macro-assembler-mips64.cc +++ b/deps/v8/test/cctest/test-macro-assembler-mips64.cc @@ -35,11 +35,12 @@ #include "src/macro-assembler.h" #include "src/mips64/macro-assembler-mips64.h" #include "src/mips64/simulator-mips64.h" +#include "src/objects-inl.h" +namespace v8 { +namespace internal { -using namespace v8::internal; - -typedef void* (*F)(int64_t x, int64_t y, int p2, int p3, int p4); +typedef void* (*FV)(int64_t x, int64_t y, int p2, int p3, int p4); typedef Object* (*F1)(int x, int p1, int p2, int p3, int p4); typedef Object* (*F3)(void* p, int p1, int p2, int p3, int p4); typedef Object* (*F4)(void* p0, void* p1, int p2, int p3, int p4); @@ -108,9 +109,9 @@ TEST(BYTESWAP) { CodeDesc desc; masm->GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); - ::F3 f = FUNCTION_CAST<::F3>(code->entry()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); + F3 f = FUNCTION_CAST<F3>(code->entry()); t.r1 = 0x5612FFCD9D327ACC; t.r2 = 0x781A15C3; t.r3 = 0xFCDE; @@ -160,10 +161,10 @@ TEST(LoadConstants) { CodeDesc desc; masm->GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); - ::F f = FUNCTION_CAST< ::F>(code->entry()); + FV f = FUNCTION_CAST<FV>(code->entry()); (void)CALL_GENERATED_CODE(isolate, f, reinterpret_cast<int64_t>(result), 0, 0, 0, 0); // Check results. @@ -205,10 +206,10 @@ TEST(LoadAddress) { CodeDesc desc; masm->GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); - ::F f = FUNCTION_CAST< ::F>(code->entry()); + FV f = FUNCTION_CAST<FV>(code->entry()); (void)CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0); // Check results. } @@ -263,8 +264,8 @@ TEST(jump_tables4) { CodeDesc desc; masm->GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -337,8 +338,8 @@ TEST(jump_tables5) { CodeDesc desc; masm->GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -429,8 +430,8 @@ TEST(jump_tables6) { CodeDesc desc; masm->GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef OBJECT_PRINT code->Print(std::cout); #endif @@ -456,8 +457,8 @@ static uint64_t run_lsa(uint32_t rt, uint32_t rs, int8_t sa) { CodeDesc desc; assembler.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F1 f = FUNCTION_CAST<F1>(code->entry()); @@ -538,10 +539,10 @@ static uint64_t run_dlsa(uint64_t rt, uint64_t rs, int8_t sa) { CodeDesc desc; assembler.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); - ::F f = FUNCTION_CAST<::F>(code->entry()); + FV f = FUNCTION_CAST<FV>(code->entry()); uint64_t res = reinterpret_cast<uint64_t>( CALL_GENERATED_CODE(isolate, f, rt, rs, 0, 0, 0)); @@ -690,8 +691,8 @@ RET_TYPE run_Cvt(IN_TYPE x, Func GenerateConvertInstructionFunc) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F_CVT f = FUNCTION_CAST<F_CVT>(code->entry()); @@ -853,8 +854,8 @@ static bool runOverflow(IN_TYPE valLeft, IN_TYPE valRight, CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F_CVT f = FUNCTION_CAST<F_CVT>(code->entry()); @@ -1209,9 +1210,9 @@ TEST(min_max_nan) { CodeDesc desc; masm->GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); - ::F3 f = FUNCTION_CAST<::F3>(code->entry()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); + F3 f = FUNCTION_CAST<F3>(code->entry()); for (int i = 0; i < kTableLength; i++) { test.a = inputsa[i]; test.b = inputsb[i]; @@ -1245,8 +1246,8 @@ bool run_Unaligned(char* memory_buffer, int32_t in_offset, int32_t out_offset, CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F_CVT f = FUNCTION_CAST<F_CVT>(code->entry()); @@ -1610,8 +1611,8 @@ bool run_Sltu(uint64_t rs, uint64_t rd, Func GenerateSltuInstructionFunc) { CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F_CVT f = FUNCTION_CAST<F_CVT>(code->entry()); int64_t res = reinterpret_cast<int64_t>( @@ -1641,7 +1642,7 @@ TEST(Sltu) { } template <typename T, typename Inputs, typename Results> -static ::F4 GenerateMacroFloat32MinMax(MacroAssembler* masm) { +static F4 GenerateMacroFloat32MinMax(MacroAssembler* masm) { T a = T::from_code(4); // f4 T b = T::from_code(6); // f6 T c = T::from_code(8); // f8 @@ -1705,13 +1706,13 @@ static ::F4 GenerateMacroFloat32MinMax(MacroAssembler* masm) { CodeDesc desc; masm->GetCode(masm->isolate(), &desc); - Handle<Code> code = masm->isolate()->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + masm->isolate()->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG OFStream os(stdout); code->Print(os); #endif - return FUNCTION_CAST<::F4>(code->entry()); + return FUNCTION_CAST<F4>(code->entry()); } TEST(macro_float_minmax_f32) { @@ -1740,7 +1741,7 @@ TEST(macro_float_minmax_f32) { float max_aba_; }; - ::F4 f = GenerateMacroFloat32MinMax<FPURegister, Inputs, Results>(masm); + F4 f = GenerateMacroFloat32MinMax<FPURegister, Inputs, Results>(masm); Object* dummy = nullptr; USE(dummy); @@ -1784,7 +1785,7 @@ TEST(macro_float_minmax_f32) { } template <typename T, typename Inputs, typename Results> -static ::F4 GenerateMacroFloat64MinMax(MacroAssembler* masm) { +static F4 GenerateMacroFloat64MinMax(MacroAssembler* masm) { T a = T::from_code(4); // f4 T b = T::from_code(6); // f6 T c = T::from_code(8); // f8 @@ -1848,13 +1849,13 @@ static ::F4 GenerateMacroFloat64MinMax(MacroAssembler* masm) { CodeDesc desc; masm->GetCode(masm->isolate(), &desc); - Handle<Code> code = masm->isolate()->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + masm->isolate()->factory()->NewCode(desc, Code::STUB, Handle<Code>()); #ifdef DEBUG OFStream os(stdout); code->Print(os); #endif - return FUNCTION_CAST<::F4>(code->entry()); + return FUNCTION_CAST<F4>(code->entry()); } TEST(macro_float_minmax_f64) { @@ -1883,7 +1884,7 @@ TEST(macro_float_minmax_f64) { double max_aba_; }; - ::F4 f = GenerateMacroFloat64MinMax<DoubleRegister, Inputs, Results>(masm); + F4 f = GenerateMacroFloat64MinMax<DoubleRegister, Inputs, Results>(masm); Object* dummy = nullptr; USE(dummy); @@ -1927,3 +1928,6 @@ TEST(macro_float_minmax_f64) { } #undef __ + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-macro-assembler-x64.cc b/deps/v8/test/cctest/test-macro-assembler-x64.cc index 08839193cb..6da2ee492f 100644 --- a/deps/v8/test/cctest/test-macro-assembler-x64.cc +++ b/deps/v8/test/cctest/test-macro-assembler-x64.cc @@ -35,71 +35,9 @@ #include "src/objects-inl.h" #include "test/cctest/cctest.h" -namespace i = v8::internal; -using i::Address; -using i::Assembler; -using i::CodeDesc; -using i::Condition; -using i::FUNCTION_CAST; -using i::HandleScope; -using i::Immediate; -using i::Isolate; -using i::Label; -using i::MacroAssembler; -using i::Operand; -using i::RelocInfo; -using i::Representation; -using i::Smi; -using i::SmiIndex; -using i::byte; -using i::carry; -using i::greater; -using i::greater_equal; -using i::kIntSize; -using i::kFloatSize; -using i::kDoubleSize; -using i::kPointerSize; -using i::kSimd128Size; -using i::kSmiTagMask; -using i::kSmiValueSize; -using i::less_equal; -using i::negative; -using i::not_carry; -using i::not_equal; -using i::equal; -using i::not_zero; -using i::positive; -using i::r11; -using i::r13; -using i::r14; -using i::r15; -using i::r8; -using i::r9; -using i::rax; -using i::rbp; -using i::rbx; -using i::rcx; -using i::rdi; -using i::rdx; -using i::rsi; -using i::rsp; -using i::xmm0; -using i::xmm1; -using i::xmm2; -using i::xmm3; -using i::xmm4; -using i::xmm5; -using i::xmm6; -using i::xmm7; -using i::xmm8; -using i::xmm9; -using i::xmm10; -using i::xmm11; -using i::xmm12; -using i::xmm13; -using i::xmm14; -using i::xmm15; -using i::times_pointer_size; +namespace v8 { +namespace internal { +namespace test_macro_assembler_x64 { // Test the x64 assembler by compiling some simple functions into // a buffer and executing them. These tests do not initialize the @@ -117,15 +55,11 @@ typedef int (*F0)(); static void EntryCode(MacroAssembler* masm) { // Smi constant register is callee save. - __ pushq(i::kRootRegister); + __ pushq(kRootRegister); __ InitializeRootRegister(); } - -static void ExitCode(MacroAssembler* masm) { - __ popq(i::kRootRegister); -} - +static void ExitCode(MacroAssembler* masm) { __ popq(kRootRegister); } TEST(Smi) { // Check that C++ Smi operations work as expected. @@ -461,39 +395,6 @@ TEST(SmiCheck) { cond = masm->CheckSmi(rcx); __ j(cond, &exit); - // CheckBothSmi - - __ incq(rax); - __ movq(rcx, Immediate(Smi::kMaxValue)); - __ Integer32ToSmi(rcx, rcx); - __ movq(rdx, Immediate(Smi::kMinValue)); - __ Integer32ToSmi(rdx, rdx); - cond = masm->CheckBothSmi(rcx, rdx); - __ j(NegateCondition(cond), &exit); - - __ incq(rax); - __ xorq(rcx, Immediate(kSmiTagMask)); - cond = masm->CheckBothSmi(rcx, rdx); - __ j(cond, &exit); - - __ incq(rax); - __ xorq(rdx, Immediate(kSmiTagMask)); - cond = masm->CheckBothSmi(rcx, rdx); - __ j(cond, &exit); - - __ incq(rax); - __ xorq(rcx, Immediate(kSmiTagMask)); - cond = masm->CheckBothSmi(rcx, rdx); - __ j(cond, &exit); - - __ incq(rax); - cond = masm->CheckBothSmi(rcx, rcx); - __ j(NegateCondition(cond), &exit); - - __ incq(rax); - cond = masm->CheckBothSmi(rdx, rdx); - __ j(cond, &exit); - // Success __ xorq(rax, rax); @@ -545,9 +446,9 @@ static void SmiAddTest(MacroAssembler* masm, __ movl(rcx, Immediate(first)); __ Integer32ToSmi(rcx, rcx); - i::SmiOperationConstraints constraints = - i::SmiOperationConstraint::kPreserveSourceRegister | - i::SmiOperationConstraint::kBailoutOnOverflow; + SmiOperationConstraints constraints = + SmiOperationConstraint::kPreserveSourceRegister | + SmiOperationConstraint::kBailoutOnOverflow; __ incq(rax); __ SmiAddConstant(r9, rcx, Smi::FromInt(second), constraints, exit); __ cmpq(r9, r8); @@ -561,8 +462,8 @@ static void SmiAddTest(MacroAssembler* masm, __ movl(rcx, Immediate(first)); __ Integer32ToSmi(rcx, rcx); - constraints = i::SmiOperationConstraint::kPreserveSourceRegister | - i::SmiOperationConstraint::kBailoutOnNoOverflow; + constraints = SmiOperationConstraint::kPreserveSourceRegister | + SmiOperationConstraint::kBailoutOnNoOverflow; Label done; __ incq(rax); __ SmiAddConstant(rcx, rcx, Smi::FromInt(second), constraints, &done); @@ -607,9 +508,9 @@ static void SmiAddOverflowTest(MacroAssembler* masm, __ j(not_equal, exit); } - i::SmiOperationConstraints constraints = - i::SmiOperationConstraint::kPreserveSourceRegister | - i::SmiOperationConstraint::kBailoutOnOverflow; + SmiOperationConstraints constraints = + SmiOperationConstraint::kPreserveSourceRegister | + SmiOperationConstraint::kBailoutOnOverflow; __ movq(rcx, r11); { Label overflow_ok; @@ -669,7 +570,7 @@ static void SmiAddOverflowTest(MacroAssembler* masm, __ j(not_equal, exit); } - constraints = i::SmiOperationConstraint::kBailoutOnOverflow; + constraints = SmiOperationConstraint::kBailoutOnOverflow; { Label overflow_ok; __ incq(rax); @@ -760,9 +661,9 @@ static void SmiSubTest(MacroAssembler* masm, __ cmpq(rcx, r8); __ j(not_equal, exit); - i::SmiOperationConstraints constraints = - i::SmiOperationConstraint::kPreserveSourceRegister | - i::SmiOperationConstraint::kBailoutOnOverflow; + SmiOperationConstraints constraints = + SmiOperationConstraint::kPreserveSourceRegister | + SmiOperationConstraint::kBailoutOnOverflow; __ Move(rcx, Smi::FromInt(first)); __ incq(rax); // Test 4. __ SmiSubConstant(rcx, rcx, Smi::FromInt(second), constraints, exit); @@ -775,8 +676,8 @@ static void SmiSubTest(MacroAssembler* masm, __ cmpq(r9, r8); __ j(not_equal, exit); - constraints = i::SmiOperationConstraint::kPreserveSourceRegister | - i::SmiOperationConstraint::kBailoutOnNoOverflow; + constraints = SmiOperationConstraint::kPreserveSourceRegister | + SmiOperationConstraint::kBailoutOnNoOverflow; __ Move(rcx, Smi::FromInt(first)); Label done; __ incq(rax); // Test 6. @@ -822,9 +723,9 @@ static void SmiSubOverflowTest(MacroAssembler* masm, __ j(not_equal, exit); } - i::SmiOperationConstraints constraints = - i::SmiOperationConstraint::kPreserveSourceRegister | - i::SmiOperationConstraint::kBailoutOnOverflow; + SmiOperationConstraints constraints = + SmiOperationConstraint::kPreserveSourceRegister | + SmiOperationConstraint::kBailoutOnOverflow; __ movq(rcx, r11); { @@ -885,7 +786,7 @@ static void SmiSubOverflowTest(MacroAssembler* masm, __ j(not_equal, exit); } - constraints = i::SmiOperationConstraint::kBailoutOnOverflow; + constraints = SmiOperationConstraint::kBailoutOnOverflow; __ movq(rcx, r11); { Label overflow_ok; @@ -951,7 +852,7 @@ void TestSmiIndex(MacroAssembler* masm, Label* exit, int id, int x) { for (int i = 0; i < 8; i++) { __ Move(rcx, Smi::FromInt(x)); SmiIndex index = masm->SmiToIndex(rdx, rcx, i); - CHECK(index.reg.is(rcx) || index.reg.is(rdx)); + CHECK(index.reg == rcx || index.reg == rdx); __ shlq(index.reg, Immediate(index.scale)); __ Set(r8, static_cast<intptr_t>(x) << i); __ cmpq(index.reg, r8); @@ -959,7 +860,7 @@ void TestSmiIndex(MacroAssembler* masm, Label* exit, int id, int x) { __ incq(rax); __ Move(rcx, Smi::FromInt(x)); index = masm->SmiToIndex(rcx, rcx, i); - CHECK(index.reg.is(rcx)); + CHECK(index.reg == rcx); __ shlq(rcx, Immediate(index.scale)); __ Set(r8, static_cast<intptr_t>(x) << i); __ cmpq(rcx, r8); @@ -1001,75 +902,6 @@ TEST(SmiIndex) { CHECK_EQ(0, result); } -void TestSelectNonSmi(MacroAssembler* masm, Label* exit, int id, int x, int y) { - __ movl(rax, Immediate(id)); - __ Move(rcx, Smi::FromInt(x)); - __ Move(rdx, Smi::FromInt(y)); - __ xorq(rdx, Immediate(kSmiTagMask)); - __ SelectNonSmi(r9, rcx, rdx, exit); - - __ incq(rax); - __ cmpq(r9, rdx); - __ j(not_equal, exit); - - __ incq(rax); - __ Move(rcx, Smi::FromInt(x)); - __ Move(rdx, Smi::FromInt(y)); - __ xorq(rcx, Immediate(kSmiTagMask)); - __ SelectNonSmi(r9, rcx, rdx, exit); - - __ incq(rax); - __ cmpq(r9, rcx); - __ j(not_equal, exit); - - __ incq(rax); - Label fail_ok; - __ Move(rcx, Smi::FromInt(x)); - __ Move(rdx, Smi::FromInt(y)); - __ xorq(rcx, Immediate(kSmiTagMask)); - __ xorq(rdx, Immediate(kSmiTagMask)); - __ SelectNonSmi(r9, rcx, rdx, &fail_ok); - __ jmp(exit); - __ bind(&fail_ok); -} - -TEST(SmiSelectNonSmi) { - // Allocate an executable page of memory. - size_t actual_size; - byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( - Assembler::kMinimalBufferSize * 2, &actual_size, true)); - CHECK(buffer); - Isolate* isolate = CcTest::i_isolate(); - HandleScope handles(isolate); - MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size), - v8::internal::CodeObjectRequired::kYes); - - MacroAssembler* masm = &assembler; - EntryCode(masm); - Label exit; - - TestSelectNonSmi(masm, &exit, 0x10, 0, 0); - TestSelectNonSmi(masm, &exit, 0x20, 0, 1); - TestSelectNonSmi(masm, &exit, 0x30, 1, 0); - TestSelectNonSmi(masm, &exit, 0x40, 0, -1); - TestSelectNonSmi(masm, &exit, 0x50, -1, 0); - TestSelectNonSmi(masm, &exit, 0x60, -1, -1); - TestSelectNonSmi(masm, &exit, 0x70, 1, 1); - TestSelectNonSmi(masm, &exit, 0x80, Smi::kMinValue, Smi::kMaxValue); - TestSelectNonSmi(masm, &exit, 0x90, Smi::kMinValue, Smi::kMinValue); - - __ xorq(rax, rax); // Success. - __ bind(&exit); - ExitCode(masm); - __ ret(0); - - CodeDesc desc; - masm->GetCode(isolate, &desc); - // Call the function from C++. - int result = FUNCTION_CAST<F0>(buffer)(); - CHECK_EQ(0, result); -} - void TestPositiveSmiPowerUp(MacroAssembler* masm, Label* exit, int id, int x) { CHECK(x >= 0); int powers[] = { 0, 1, 2, 3, 8, 16, 24, 31 }; @@ -1791,3 +1623,7 @@ TEST(SIMDMacros) { } #undef __ + +} // namespace test_macro_assembler_x64 +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-managed.cc b/deps/v8/test/cctest/test-managed.cc index bfba366663..11eb7bad9a 100644 --- a/deps/v8/test/cctest/test-managed.cc +++ b/deps/v8/test/cctest/test-managed.cc @@ -38,7 +38,7 @@ TEST(ManagedCollect) { isolate->RegisterForReleaseAtTeardown(&finalizer); { HandleScope scope(isolate); - auto handle = Managed<DeleteRecorder>::New(isolate, d1); + auto handle = Managed<DeleteRecorder>::From(isolate, d1); USE(handle); } @@ -65,7 +65,7 @@ TEST(DisposeCollect) { DeleteRecorder* d2 = new DeleteRecorder(&deleted2); { HandleScope scope(i_isolate); - auto handle = Managed<DeleteRecorder>::New(i_isolate, d1); + auto handle = Managed<DeleteRecorder>::From(i_isolate, d1); USE(handle); } Isolate::ManagedObjectFinalizer finalizer(d2, DeleteRecorder::Deleter); diff --git a/deps/v8/test/cctest/test-mementos.cc b/deps/v8/test/cctest/test-mementos.cc index d60dc23c8c..d5a9a9c4cd 100644 --- a/deps/v8/test/cctest/test-mementos.cc +++ b/deps/v8/test/cctest/test-mementos.cc @@ -28,13 +28,7 @@ #include "src/factory.h" #include "src/heap/heap.h" #include "src/isolate.h" -// FIXME(mstarzinger, marja): This is weird, but required because of the missing -// (disallowed) include: src/factory.h -> src/objects-inl.h #include "src/objects-inl.h" -// FIXME(mstarzinger, marja): This is weird, but required because of the missing -// (disallowed) include: src/feedback-vector.h -> -// src/feedback-vector-inl.h -#include "src/feedback-vector-inl.h" #include "test/cctest/cctest.h" namespace v8 { diff --git a/deps/v8/test/cctest/test-object.cc b/deps/v8/test/cctest/test-object.cc index 0efc67e9e6..088803ec36 100644 --- a/deps/v8/test/cctest/test-object.cc +++ b/deps/v8/test/cctest/test-object.cc @@ -2,6 +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/factory.h" #include "src/handles-inl.h" #include "src/handles.h" @@ -60,8 +61,8 @@ TEST(NoSideEffectsToString) { CheckObject(isolate, factory->null_value(), "null"); CheckObject(isolate, factory->error_to_string(), "[object Error]"); - CheckObject(isolate, factory->stack_trace_symbol(), - "Symbol(stack_trace_symbol)"); + CheckObject(isolate, factory->unscopables_symbol(), + "Symbol(Symbol.unscopables)"); CheckObject(isolate, factory->NewError(isolate->error_function(), factory->empty_string()), "Error"); @@ -73,5 +74,179 @@ TEST(NoSideEffectsToString) { "#<Object>"); } +TEST(EnumCache) { + LocalContext env; + v8::Isolate* isolate = env->GetIsolate(); + i::Factory* factory = CcTest::i_isolate()->factory(); + v8::HandleScope scope(isolate); + + // Create a nice transition tree: + // (a) --> (b) --> (c) shared DescriptorArray 1 + // | + // +---> (cc) shared DescriptorArray 2 + CompileRun( + "function O(a) { this.a = 1 };" + + "a = new O();" + + "b = new O();" + "b.b = 2;" + + "c = new O();" + "c.b = 2;" + "c.c = 3;" + + "cc = new O();" + "cc.b = 2;" + "cc.cc = 4;"); + + Handle<JSObject> a = Handle<JSObject>::cast(v8::Utils::OpenHandle( + *env->Global()->Get(env.local(), v8_str("a")).ToLocalChecked())); + Handle<JSObject> b = Handle<JSObject>::cast(v8::Utils::OpenHandle( + *env->Global()->Get(env.local(), v8_str("b")).ToLocalChecked())); + Handle<JSObject> c = Handle<JSObject>::cast(v8::Utils::OpenHandle( + *env->Global()->Get(env.local(), v8_str("c")).ToLocalChecked())); + Handle<JSObject> cc = Handle<JSObject>::cast(v8::Utils::OpenHandle( + *env->Global()->Get(env.local(), v8_str("cc")).ToLocalChecked())); + + // Check the transition tree. + CHECK_EQ(a->map()->instance_descriptors(), b->map()->instance_descriptors()); + CHECK_EQ(b->map()->instance_descriptors(), c->map()->instance_descriptors()); + CHECK_NE(c->map()->instance_descriptors(), cc->map()->instance_descriptors()); + CHECK_NE(b->map()->instance_descriptors(), cc->map()->instance_descriptors()); + + // Check that the EnumLength is unset. + CHECK_EQ(a->map()->EnumLength(), kInvalidEnumCacheSentinel); + CHECK_EQ(b->map()->EnumLength(), kInvalidEnumCacheSentinel); + CHECK_EQ(c->map()->EnumLength(), kInvalidEnumCacheSentinel); + CHECK_EQ(cc->map()->EnumLength(), kInvalidEnumCacheSentinel); + + // Check that the EnumCache is empty. + CHECK_EQ(a->map()->instance_descriptors()->GetEnumCache(), + *factory->empty_enum_cache()); + CHECK_EQ(b->map()->instance_descriptors()->GetEnumCache(), + *factory->empty_enum_cache()); + CHECK_EQ(c->map()->instance_descriptors()->GetEnumCache(), + *factory->empty_enum_cache()); + CHECK_EQ(cc->map()->instance_descriptors()->GetEnumCache(), + *factory->empty_enum_cache()); + + // The EnumCache is shared on the DescriptorArray, creating it on {cc} has no + // effect on the other maps. + CompileRun("var s = 0; for (let key in cc) { s += cc[key] };"); + { + CHECK_EQ(a->map()->EnumLength(), kInvalidEnumCacheSentinel); + CHECK_EQ(b->map()->EnumLength(), kInvalidEnumCacheSentinel); + CHECK_EQ(c->map()->EnumLength(), kInvalidEnumCacheSentinel); + CHECK_EQ(cc->map()->EnumLength(), 3); + + CHECK_EQ(a->map()->instance_descriptors()->GetEnumCache(), + *factory->empty_enum_cache()); + CHECK_EQ(b->map()->instance_descriptors()->GetEnumCache(), + *factory->empty_enum_cache()); + CHECK_EQ(c->map()->instance_descriptors()->GetEnumCache(), + *factory->empty_enum_cache()); + + EnumCache* enum_cache = cc->map()->instance_descriptors()->GetEnumCache(); + CHECK_NE(enum_cache, *factory->empty_enum_cache()); + CHECK_EQ(enum_cache->keys()->length(), 3); + CHECK_EQ(enum_cache->indices()->length(), 3); + } + + // Initializing the EnumCache for the the topmost map {a} will not create the + // cache for the other maps. + CompileRun("var s = 0; for (let key in a) { s += a[key] };"); + { + CHECK_EQ(a->map()->EnumLength(), 1); + CHECK_EQ(b->map()->EnumLength(), kInvalidEnumCacheSentinel); + CHECK_EQ(c->map()->EnumLength(), kInvalidEnumCacheSentinel); + CHECK_EQ(cc->map()->EnumLength(), 3); + + // The enum cache is shared on the descriptor array of maps {a}, {b} and + // {c} only. + EnumCache* enum_cache = a->map()->instance_descriptors()->GetEnumCache(); + CHECK_NE(enum_cache, *factory->empty_enum_cache()); + CHECK_NE(cc->map()->instance_descriptors()->GetEnumCache(), + *factory->empty_enum_cache()); + CHECK_NE(cc->map()->instance_descriptors()->GetEnumCache(), enum_cache); + CHECK_EQ(a->map()->instance_descriptors()->GetEnumCache(), enum_cache); + CHECK_EQ(b->map()->instance_descriptors()->GetEnumCache(), enum_cache); + CHECK_EQ(c->map()->instance_descriptors()->GetEnumCache(), enum_cache); + + CHECK_EQ(enum_cache->keys()->length(), 1); + CHECK_EQ(enum_cache->indices()->length(), 1); + } + + // Creating the EnumCache for {c} will create a new EnumCache on the shared + // DescriptorArray. + Handle<EnumCache> previous_enum_cache( + a->map()->instance_descriptors()->GetEnumCache()); + Handle<FixedArray> previous_keys(previous_enum_cache->keys()); + Handle<FixedArray> previous_indices(previous_enum_cache->indices()); + CompileRun("var s = 0; for (let key in c) { s += c[key] };"); + { + CHECK_EQ(a->map()->EnumLength(), 1); + CHECK_EQ(b->map()->EnumLength(), kInvalidEnumCacheSentinel); + CHECK_EQ(c->map()->EnumLength(), 3); + CHECK_EQ(cc->map()->EnumLength(), 3); + + EnumCache* enum_cache = c->map()->instance_descriptors()->GetEnumCache(); + CHECK_NE(enum_cache, *factory->empty_enum_cache()); + // The keys and indices caches are updated. + CHECK_EQ(enum_cache, *previous_enum_cache); + CHECK_NE(enum_cache->keys(), *previous_keys); + CHECK_NE(enum_cache->indices(), *previous_indices); + CHECK_EQ(previous_keys->length(), 1); + CHECK_EQ(previous_indices->length(), 1); + CHECK_EQ(enum_cache->keys()->length(), 3); + CHECK_EQ(enum_cache->indices()->length(), 3); + + // The enum cache is shared on the descriptor array of maps {a}, {b} and + // {c} only. + CHECK_NE(cc->map()->instance_descriptors()->GetEnumCache(), + *factory->empty_enum_cache()); + CHECK_NE(cc->map()->instance_descriptors()->GetEnumCache(), enum_cache); + CHECK_NE(cc->map()->instance_descriptors()->GetEnumCache(), + *previous_enum_cache); + CHECK_EQ(a->map()->instance_descriptors()->GetEnumCache(), enum_cache); + CHECK_EQ(b->map()->instance_descriptors()->GetEnumCache(), enum_cache); + CHECK_EQ(c->map()->instance_descriptors()->GetEnumCache(), enum_cache); + } + + // {b} can reuse the existing EnumCache, hence we only need to set the correct + // EnumLength on the map without modifying the cache itself. + previous_enum_cache = + handle(a->map()->instance_descriptors()->GetEnumCache()); + previous_keys = handle(previous_enum_cache->keys()); + previous_indices = handle(previous_enum_cache->indices()); + CompileRun("var s = 0; for (let key in b) { s += b[key] };"); + { + CHECK_EQ(a->map()->EnumLength(), 1); + CHECK_EQ(b->map()->EnumLength(), 2); + CHECK_EQ(c->map()->EnumLength(), 3); + CHECK_EQ(cc->map()->EnumLength(), 3); + + EnumCache* enum_cache = c->map()->instance_descriptors()->GetEnumCache(); + CHECK_NE(enum_cache, *factory->empty_enum_cache()); + // The keys and indices caches are not updated. + CHECK_EQ(enum_cache, *previous_enum_cache); + CHECK_EQ(enum_cache->keys(), *previous_keys); + CHECK_EQ(enum_cache->indices(), *previous_indices); + CHECK_EQ(enum_cache->keys()->length(), 3); + CHECK_EQ(enum_cache->indices()->length(), 3); + + // The enum cache is shared on the descriptor array of maps {a}, {b} and + // {c} only. + CHECK_NE(cc->map()->instance_descriptors()->GetEnumCache(), + *factory->empty_enum_cache()); + CHECK_NE(cc->map()->instance_descriptors()->GetEnumCache(), enum_cache); + CHECK_NE(cc->map()->instance_descriptors()->GetEnumCache(), + *previous_enum_cache); + CHECK_EQ(a->map()->instance_descriptors()->GetEnumCache(), enum_cache); + CHECK_EQ(b->map()->instance_descriptors()->GetEnumCache(), enum_cache); + CHECK_EQ(c->map()->instance_descriptors()->GetEnumCache(), enum_cache); + } +} + } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/test-orderedhashtable.cc b/deps/v8/test/cctest/test-orderedhashtable.cc index 6e6fe5348a..d4809f4562 100644 --- a/deps/v8/test/cctest/test-orderedhashtable.cc +++ b/deps/v8/test/cctest/test-orderedhashtable.cc @@ -9,6 +9,7 @@ namespace v8 { namespace internal { +namespace test_orderedhashtable { static Isolate* GetIsolateFrom(LocalContext* context) { return reinterpret_cast<Isolate*>((*context)->GetIsolate()); @@ -896,5 +897,6 @@ TEST(OrderedHashSetDuplicateHashCodeDeletion) { CHECK(!OrderedHashSet::HasKey(isolate, *set, *key2)); } +} // namespace test_orderedhashtable } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/test-parsing.cc b/deps/v8/test/cctest/test-parsing.cc index 8c7d168778..e604040ffd 100644 --- a/deps/v8/test/cctest/test-parsing.cc +++ b/deps/v8/test/cctest/test-parsing.cc @@ -33,6 +33,7 @@ #include "src/v8.h" +#include "src/api.h" #include "src/ast/ast-numbering.h" #include "src/ast/ast-value-factory.h" #include "src/ast/ast.h" @@ -56,6 +57,21 @@ #include "test/cctest/scope-test-helper.h" #include "test/cctest/unicode-helpers.h" +namespace v8 { +namespace internal { +namespace test_parsing { + +namespace { + +int* global_use_counts = NULL; + +void MockUseCounterCallback(v8::Isolate* isolate, + v8::Isolate::UseCounterFeature feature) { + ++global_use_counts[feature]; +} + +} // namespace + TEST(ScanKeywords) { struct KeywordToken { const char* keyword; @@ -77,7 +93,7 @@ TEST(ScanKeywords) { CHECK(static_cast<int>(sizeof(buffer)) >= length); { auto stream = i::ScannerStream::ForTesting(keyword, length); - i::Scanner scanner(&unicode_cache); + i::Scanner scanner(&unicode_cache, global_use_counts); scanner.Initialize(stream.get(), false); CHECK_EQ(key_token.token, scanner.Next()); CHECK_EQ(i::Token::EOS, scanner.Next()); @@ -85,7 +101,7 @@ TEST(ScanKeywords) { // Removing characters will make keyword matching fail. { auto stream = i::ScannerStream::ForTesting(keyword, length - 1); - i::Scanner scanner(&unicode_cache); + i::Scanner scanner(&unicode_cache, global_use_counts); scanner.Initialize(stream.get(), false); CHECK_EQ(i::Token::IDENTIFIER, scanner.Next()); CHECK_EQ(i::Token::EOS, scanner.Next()); @@ -96,7 +112,7 @@ 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); + i::Scanner scanner(&unicode_cache, global_use_counts); scanner.Initialize(stream.get(), false); CHECK_EQ(i::Token::IDENTIFIER, scanner.Next()); CHECK_EQ(i::Token::EOS, scanner.Next()); @@ -106,7 +122,7 @@ TEST(ScanKeywords) { i::MemMove(buffer, keyword, length); buffer[length - 1] = '_'; auto stream = i::ScannerStream::ForTesting(buffer, length); - i::Scanner scanner(&unicode_cache); + i::Scanner scanner(&unicode_cache, global_use_counts); scanner.Initialize(stream.get(), false); CHECK_EQ(i::Token::IDENTIFIER, scanner.Next()); CHECK_EQ(i::Token::EOS, scanner.Next()); @@ -172,7 +188,7 @@ TEST(ScanHTMLEndComments) { for (int i = 0; tests[i]; i++) { const char* source = tests[i]; auto stream = i::ScannerStream::ForTesting(source); - i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); + i::Scanner scanner(CcTest::i_isolate()->unicode_cache(), global_use_counts); scanner.Initialize(stream.get(), false); i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); i::AstValueFactory ast_value_factory( @@ -191,7 +207,7 @@ 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(CcTest::i_isolate()->unicode_cache()); + i::Scanner scanner(CcTest::i_isolate()->unicode_cache(), global_use_counts); scanner.Initialize(stream.get(), false); i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); i::AstValueFactory ast_value_factory( @@ -216,7 +232,7 @@ TEST(ScanHtmlComments) { // Disallow HTML comments. { auto stream = i::ScannerStream::ForTesting(src); - i::Scanner scanner(&unicode_cache); + i::Scanner scanner(&unicode_cache, global_use_counts); scanner.Initialize(stream.get(), true); CHECK_EQ(i::Token::IDENTIFIER, scanner.Next()); CHECK_EQ(i::Token::ILLEGAL, scanner.Next()); @@ -225,7 +241,7 @@ TEST(ScanHtmlComments) { // Skip HTML comments: { auto stream = i::ScannerStream::ForTesting(src); - i::Scanner scanner(&unicode_cache); + i::Scanner scanner(&unicode_cache, global_use_counts); scanner.Initialize(stream.get(), false); CHECK_EQ(i::Token::IDENTIFIER, scanner.Next()); CHECK_EQ(i::Token::EOS, scanner.Next()); @@ -384,7 +400,7 @@ TEST(StandAlonePreParser) { uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); for (int i = 0; programs[i]; i++) { auto stream = i::ScannerStream::ForTesting(programs[i]); - i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); + i::Scanner scanner(CcTest::i_isolate()->unicode_cache(), global_use_counts); scanner.Initialize(stream.get(), false); i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); @@ -420,7 +436,7 @@ 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()); + i::Scanner scanner(isolate->unicode_cache(), global_use_counts); scanner.Initialize(stream.get(), false); // Preparser defaults to disallowing natives syntax. @@ -490,7 +506,7 @@ 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()); + i::Scanner scanner(CcTest::i_isolate()->unicode_cache(), global_use_counts); scanner.Initialize(stream.get(), false); i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); i::AstValueFactory ast_value_factory( @@ -565,7 +581,7 @@ 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()); + i::Scanner scanner(isolate->unicode_cache(), global_use_counts); scanner.Initialize(stream.get(), false); i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); @@ -585,7 +601,7 @@ 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()); + i::Scanner scanner(CcTest::i_isolate()->unicode_cache(), global_use_counts); scanner.Initialize(stream, false); int i = 0; @@ -663,7 +679,7 @@ 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()); + i::Scanner scanner(CcTest::i_isolate()->unicode_cache(), global_use_counts); scanner.Initialize(stream.get(), false); i::Token::Value start = scanner.peek(); @@ -853,8 +869,14 @@ TEST(ScopeUsesArgumentsSuperThis) { !scope->AsDeclarationScope()->is_arrow_scope()) { CHECK_NOT_NULL(scope->AsDeclarationScope()->arguments()); } - CHECK_EQ((source_data[i].expected & SUPER_PROPERTY) != 0, - scope->AsDeclarationScope()->uses_super_property()); + if (IsClassConstructor(scope->AsDeclarationScope()->function_kind())) { + CHECK_EQ((source_data[i].expected & SUPER_PROPERTY) != 0 || + (source_data[i].expected & EVAL) != 0, + scope->AsDeclarationScope()->NeedsHomeObject()); + } else { + CHECK_EQ((source_data[i].expected & SUPER_PROPERTY) != 0, + scope->AsDeclarationScope()->NeedsHomeObject()); + } if ((source_data[i].expected & THIS) != 0) { // Currently the is_used() flag is conservative; all variables in a // script scope are marked as used. @@ -1275,6 +1297,7 @@ enum ParserFlag { kAllowHarmonyDynamicImport, kAllowHarmonyAsyncIteration, kAllowHarmonyTemplateEscapes, + kAllowHarmonyImportMeta, }; enum ParserSyncTestResult { @@ -1292,6 +1315,7 @@ void SetGlobalFlags(i::EnumSet<ParserFlag> flags) { i::FLAG_harmony_object_rest_spread = flags.Contains(kAllowHarmonyObjectRestSpread); i::FLAG_harmony_dynamic_import = flags.Contains(kAllowHarmonyDynamicImport); + i::FLAG_harmony_import_meta = flags.Contains(kAllowHarmonyImportMeta); i::FLAG_harmony_async_iteration = flags.Contains(kAllowHarmonyAsyncIteration); i::FLAG_harmony_template_escapes = flags.Contains(kAllowHarmonyTemplateEscapes); @@ -1309,6 +1333,8 @@ void SetParserFlags(i::PreParser* parser, i::EnumSet<ParserFlag> flags) { flags.Contains(kAllowHarmonyObjectRestSpread)); parser->set_allow_harmony_dynamic_import( flags.Contains(kAllowHarmonyDynamicImport)); + parser->set_allow_harmony_import_meta( + flags.Contains(kAllowHarmonyImportMeta)); parser->set_allow_harmony_async_iteration( flags.Contains(kAllowHarmonyAsyncIteration)); parser->set_allow_harmony_template_escapes( @@ -1328,7 +1354,7 @@ void TestParserSyncWithFlags(i::Handle<i::String> source, // Preparse the data. i::PendingCompilationErrorHandler pending_error_handler; if (test_preparser) { - i::Scanner scanner(isolate->unicode_cache()); + i::Scanner scanner(isolate->unicode_cache(), global_use_counts); std::unique_ptr<i::Utf16CharacterStream> stream( i::ScannerStream::For(source)); i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); @@ -3958,16 +3984,6 @@ TEST(AsmModuleFlag) { CHECK(s->IsAsmModule() && s->AsDeclarationScope()->asm_module()); } -namespace { - -int* global_use_counts = NULL; - -void MockUseCounterCallback(v8::Isolate* isolate, - v8::Isolate::UseCounterFeature feature) { - ++global_use_counts[feature]; -} - -} // namespace TEST(UseAsmUseCount) { i::Isolate* isolate = CcTest::i_isolate(); @@ -4027,6 +4043,34 @@ TEST(BothModesUseCount) { CHECK_LT(0, use_counts[v8::Isolate::kStrictMode]); } +TEST(LineOrParagraphSeparatorAsLineTerminator) { + // Tests that both preparsing and parsing accept U+2028 LINE SEPARATOR and + // U+2029 PARAGRAPH SEPARATOR as LineTerminator symbols. + const char* context_data[][2] = {{"", ""}, {nullptr, nullptr}}; + const char* statement_data[] = {"\x31\xE2\x80\xA8\x32", // "1<U+2028>2" + "\x31\xE2\x80\xA9\x32", // "1<U+2029>2" + nullptr}; + + RunParserSyncTest(context_data, statement_data, kError); +} + +TEST(LineOrParagraphSeparatorAsLineTerminatorUseCount) { + i::Isolate* isolate = CcTest::i_isolate(); + i::HandleScope scope(isolate); + LocalContext env; + int use_counts[v8::Isolate::kUseCounterFeatureCount] = {}; + global_use_counts = use_counts; + CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback); + CompileRun(""); + CHECK_EQ(0, use_counts[v8::Isolate::UseCounterFeature:: + kLineOrParagraphSeparatorAsLineTerminator]); + CompileRun("// Foo\xE2\x80\xA8"); // "// Foo<U+2028>" + CHECK_LT(0, use_counts[v8::Isolate::UseCounterFeature:: + kLineOrParagraphSeparatorAsLineTerminator]); + CompileRun("// Foo\xE2\x80\xA9"); // "// Foo<U+2029>" + CHECK_LT(1, use_counts[v8::Isolate::UseCounterFeature:: + kLineOrParagraphSeparatorAsLineTerminator]); +} TEST(ErrorsArrowFormalParameters) { const char* context_data[][2] = { @@ -7873,6 +7917,9 @@ TEST(DestructuringAssignmentNegativeTests) { "{ new.target }", "{ x: new.target }", "{ x: new.target = 1 }", + "{ import.meta }", + "{ x: import.meta }", + "{ x: import.meta = 1 }", "[x--]", "[--x = 1]", "[x()]", @@ -7880,6 +7927,8 @@ TEST(DestructuringAssignmentNegativeTests) { "[this = 1]", "[new.target]", "[new.target = 1]", + "[import.meta]", + "[import.meta = 1]", "[super]", "[super = 1]", "[function f() {}]", @@ -8280,6 +8329,106 @@ TEST(NewTarget) { RunParserSyncTest(bad_context_data, data, kError); } +TEST(ImportMetaSuccess) { + // clang-format off + const char* context_data[][2] = { + {"", ""}, + {"'use strict';", ""}, + {"function f() {", "}"}, + {"'use strict'; function f() {", "}"}, + {"var f = function() {", "}"}, + {"'use strict'; var f = function() {", "}"}, + {"({m: function() {", "}})"}, + {"'use strict'; ({m: function() {", "}})"}, + {"({m() {", "}})"}, + {"'use strict'; ({m() {", "}})"}, + {"({get x() {", "}})"}, + {"'use strict'; ({get x() {", "}})"}, + {"({set x(_) {", "}})"}, + {"'use strict'; ({set x(_) {", "}})"}, + {"class C {m() {", "}}"}, + {"class C {get x() {", "}}"}, + {"class C {set x(_) {", "}}"}, + {NULL} + }; + + const char* data[] = { + "import.meta", + "() => { import.meta }", + "() => import.meta", + "if (1) { import.meta }", + "if (1) {} else { import.meta }", + "while (0) { import.meta }", + "do { import.meta } while (0)", + "import.meta.url", + "import.meta[0]", + "import.meta.couldBeMutable = true", + "import.meta()", + "new import.meta.MagicClass", + "new import.meta", + "t = [...import.meta]", + "f = {...import.meta}", + "delete import.meta", + NULL + }; + + // clang-format on + + // Making sure the same *wouldn't* parse without the flags + RunModuleParserSyncTest(context_data, data, kError, NULL, 0, NULL, 0, NULL, 0, + true, true); + + static const ParserFlag flags[] = { + kAllowHarmonyImportMeta, kAllowHarmonyDynamicImport, + kAllowHarmonyObjectRestSpread, + }; + // 2.1.1 Static Semantics: Early Errors + // ImportMeta + // * It is an early Syntax Error if Module is not the syntactic goal symbol. + RunParserSyncTest(context_data, data, kError, NULL, 0, flags, + arraysize(flags)); + // Making sure the same wouldn't parse without the flags either + RunParserSyncTest(context_data, data, kError); + + RunModuleParserSyncTest(context_data, data, kSuccess, NULL, 0, flags, + arraysize(flags)); +} + +TEST(ImportMetaFailure) { + // clang-format off + const char* context_data[][2] = { + {"var ", ""}, + {"let ", ""}, + {"const ", ""}, + {"var [", "] = [1]"}, + {"([", "] = [1])"}, + {"({", "} = {1})"}, + {"var {", " = 1} = 1"}, + {"for (var ", " of [1]) {}"}, + {NULL} + }; + + const char* data[] = { + "import.meta", + NULL + }; + + // clang-format on + + static const ParserFlag flags[] = { + kAllowHarmonyImportMeta, kAllowHarmonyDynamicImport, + kAllowHarmonyObjectRestSpread, + }; + + RunParserSyncTest(context_data, data, kError, NULL, 0, flags, + arraysize(flags)); + RunModuleParserSyncTest(context_data, data, kError, NULL, 0, flags, + arraysize(flags)); + + RunModuleParserSyncTest(context_data, data, kError, NULL, 0, NULL, 0, NULL, 0, + true, true); + RunParserSyncTest(context_data, data, kError); +} TEST(ConstSloppy) { // clang-format off @@ -10404,3 +10553,7 @@ TEST(LexicalLoopVariable) { }); } } + +} // namespace test_parsing +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-platform-linux.cc b/deps/v8/test/cctest/test-platform-linux.cc index c358227397..d41222e2a5 100644 --- a/deps/v8/test/cctest/test-platform-linux.cc +++ b/deps/v8/test/cctest/test-platform-linux.cc @@ -25,32 +25,28 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // -// Tests of the TokenLock class from lock.h - -#include <pthread.h> -#include <stdlib.h> -#include <unistd.h> // for usleep() - -#include "src/v8.h" #include "src/base/platform/platform.h" #include "test/cctest/cctest.h" +using OS = v8::base::OS; + namespace v8 { namespace internal { -TEST(VirtualMemory) { - v8::base::VirtualMemory* vm = - new v8::base::VirtualMemory(1 * MB, v8::base::OS::GetRandomMmapAddr()); - CHECK(vm->IsReserved()); - void* block_addr = vm->address(); +TEST(OSReserveMemory) { + size_t mem_size = 0; + void* mem_addr = OS::ReserveAlignedRegion(1 * MB, OS::AllocateAlignment(), + GetRandomMmapAddr(), &mem_size); + CHECK_NE(0, mem_size); + CHECK_NOT_NULL(mem_addr); size_t block_size = 4 * KB; - CHECK(vm->Commit(block_addr, block_size, false)); + CHECK(OS::CommitRegion(mem_addr, block_size, false)); // Check whether we can write to memory. - int* addr = static_cast<int*>(block_addr); - addr[KB-1] = 2; - CHECK(vm->Uncommit(block_addr, block_size)); - delete vm; + int* addr = static_cast<int*>(mem_addr); + addr[KB - 1] = 2; + CHECK(OS::UncommitRegion(mem_addr, block_size)); + OS::ReleaseRegion(mem_addr, mem_size); } } // namespace internal diff --git a/deps/v8/test/cctest/test-platform-win32.cc b/deps/v8/test/cctest/test-platform-win32.cc index 484b187e21..d41222e2a5 100644 --- a/deps/v8/test/cctest/test-platform-win32.cc +++ b/deps/v8/test/cctest/test-platform-win32.cc @@ -25,29 +25,29 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // -// Tests of the TokenLock class from lock.h - -#include <stdlib.h> - -#include "src/v8.h" #include "src/base/platform/platform.h" -#include "src/base/win32-headers.h" #include "test/cctest/cctest.h" -using namespace ::v8::internal; +using OS = v8::base::OS; +namespace v8 { +namespace internal { -TEST(VirtualMemory) { - v8::base::VirtualMemory* vm = - new v8::base::VirtualMemory(1 * MB, v8::base::OS::GetRandomMmapAddr()); - CHECK(vm->IsReserved()); - void* block_addr = vm->address(); +TEST(OSReserveMemory) { + size_t mem_size = 0; + void* mem_addr = OS::ReserveAlignedRegion(1 * MB, OS::AllocateAlignment(), + GetRandomMmapAddr(), &mem_size); + CHECK_NE(0, mem_size); + CHECK_NOT_NULL(mem_addr); size_t block_size = 4 * KB; - CHECK(vm->Commit(block_addr, block_size, false)); + CHECK(OS::CommitRegion(mem_addr, block_size, false)); // Check whether we can write to memory. - int* addr = static_cast<int*>(block_addr); - addr[KB-1] = 2; - CHECK(vm->Uncommit(block_addr, block_size)); - delete vm; + int* addr = static_cast<int*>(mem_addr); + addr[KB - 1] = 2; + CHECK(OS::UncommitRegion(mem_addr, block_size)); + OS::ReleaseRegion(mem_addr, mem_size); } + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-profile-generator.cc b/deps/v8/test/cctest/test-profile-generator.cc index 67d2893024..6a16cca906 100644 --- a/deps/v8/test/cctest/test-profile-generator.cc +++ b/deps/v8/test/cctest/test-profile-generator.cc @@ -36,17 +36,9 @@ #include "test/cctest/cctest.h" #include "test/cctest/profiler-extension.h" -using i::CodeEntry; -using i::CodeMap; -using i::CpuProfile; -using i::CpuProfiler; -using i::CpuProfilesCollection; -using i::ProfileNode; -using i::ProfileTree; -using i::ProfileGenerator; -using i::TickSample; -using i::Vector; - +namespace v8 { +namespace internal { +namespace test_profile_generator { TEST(ProfileNodeFindOrAddChild) { CcTest::InitializeVM(); @@ -733,3 +725,7 @@ TEST(BailoutReason) { CHECK(const_cast<v8::CpuProfileNode*>(current)); CHECK(!strcmp("Optimization disabled for test", current->GetBailoutReason())); } + +} // namespace test_profile_generator +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-regexp.cc b/deps/v8/test/cctest/test-regexp.cc index 0da513d4af..5d28a577ff 100644 --- a/deps/v8/test/cctest/test-regexp.cc +++ b/deps/v8/test/cctest/test-regexp.cc @@ -32,6 +32,7 @@ #include "include/v8.h" #include "src/v8.h" +#include "src/api.h" #include "src/ast/ast.h" #include "src/char-predicates-inl.h" #include "src/objects-inl.h" @@ -42,6 +43,8 @@ #include "src/regexp/regexp-parser.h" #include "src/splay-tree-inl.h" #include "src/string-stream.h" +#include "src/unicode-inl.h" + #ifdef V8_INTERPRETED_REGEXP #include "src/regexp/interpreter-irregexp.h" #else // V8_INTERPRETED_REGEXP @@ -91,6 +94,7 @@ namespace v8 { namespace internal { +namespace test_regexp { static bool CheckParse(const char* input) { v8::HandleScope scope(CcTest::isolate()); @@ -2033,5 +2037,6 @@ TEST(UncachedExternalString) { ExpectString("external.substring(1).match(re)[1]", "z"); } +} // namespace test_regexp } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/test-run-wasm-relocation-arm.cc b/deps/v8/test/cctest/test-run-wasm-relocation-arm.cc index accbf88e51..fe01199f5f 100644 --- a/deps/v8/test/cctest/test-run-wasm-relocation-arm.cc +++ b/deps/v8/test/cctest/test-run-wasm-relocation-arm.cc @@ -15,15 +15,15 @@ #include "test/cctest/compiler/c-signature.h" #include "test/cctest/compiler/call-tester.h" -using namespace v8::base; -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace wasm { #define __ assm. static int32_t DummyStaticFunction(Object* result) { return 1; } -TEST(WasmRelocationArmMemoryReference) { +TEST(WasmRelocationArmContextReference) { Isolate* isolate = CcTest::i_isolate(); HandleScope scope(isolate); v8::internal::byte buffer[4096]; @@ -32,16 +32,16 @@ TEST(WasmRelocationArmMemoryReference) { Assembler assm(isolate, buffer, sizeof buffer); - __ mov(r0, Operand(imm, RelocInfo::WASM_MEMORY_REFERENCE)); + __ mov(r0, Operand(imm, RelocInfo::WASM_CONTEXT_REFERENCE)); __ mov(pc, Operand(lr)); CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); - CSignature0<int32_t> csig; - CodeRunner<int32_t> runnable(isolate, code, &csig); + compiler::CSignature0<int32_t> csig; + compiler::CodeRunner<int32_t> runnable(isolate, code, &csig); int32_t ret_value = runnable.Call(); CHECK_EQ(ret_value, imm); @@ -53,12 +53,12 @@ TEST(WasmRelocationArmMemoryReference) { int offset = 1234; // Relocating references by offset - int mode_mask = (1 << RelocInfo::WASM_MEMORY_REFERENCE); + int mode_mask = (1 << RelocInfo::WASM_CONTEXT_REFERENCE); for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { - DCHECK(RelocInfo::IsWasmMemoryReference(it.rinfo()->rmode())); - it.rinfo()->update_wasm_memory_reference( - isolate, it.rinfo()->wasm_memory_reference(), - it.rinfo()->wasm_memory_reference() + offset, SKIP_ICACHE_FLUSH); + DCHECK(RelocInfo::IsWasmContextReference(it.rinfo()->rmode())); + it.rinfo()->set_wasm_context_reference( + isolate, it.rinfo()->wasm_context_reference() + offset, + SKIP_ICACHE_FLUSH); } // Call into relocated code object @@ -71,56 +71,8 @@ TEST(WasmRelocationArmMemoryReference) { #endif } -TEST(WasmRelocationArmMemorySizeReference) { - CcTest::InitializeVM(); - Isolate* isolate = CcTest::i_isolate(); - HandleScope scope(isolate); - v8::internal::byte buffer[4096]; - DummyStaticFunction(NULL); - int32_t size = 512; - Label fail; - - Assembler assm(isolate, buffer, sizeof buffer); - - __ mov(r0, Operand(size, RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); - __ cmp(r0, Operand(size, RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); - __ b(ne, &fail); - __ mov(pc, Operand(lr)); - __ bind(&fail); - __ mov(r0, Operand(0xdeadbeef)); - __ mov(pc, Operand(lr)); - - CodeDesc desc; - assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); - - CSignature0<int32_t> csig; - CodeRunner<int32_t> runnable(isolate, code, &csig); - int32_t ret_value = runnable.Call(); - CHECK_NE(ret_value, bit_cast<int32_t>(0xdeadbeef)); - -#ifdef DEBUG - OFStream os(stdout); - code->Print(os); - ::printf("f() = %d\n\n", ret_value); -#endif - size_t diff = 512; - - int mode_mask = (1 << RelocInfo::WASM_MEMORY_SIZE_REFERENCE); - for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { - DCHECK(RelocInfo::IsWasmMemorySizeReference(it.rinfo()->rmode())); - it.rinfo()->update_wasm_memory_size( - isolate, it.rinfo()->wasm_memory_size_reference(), - it.rinfo()->wasm_memory_size_reference() + diff, SKIP_ICACHE_FLUSH); - } - - ret_value = runnable.Call(); - CHECK_NE(ret_value, bit_cast<int32_t>(0xdeadbeef)); - -#ifdef DEBUG - code->Print(os); - ::printf("f() = %d\n\n", ret_value); -#endif -} #undef __ + +} // namespace wasm +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-run-wasm-relocation-arm64.cc b/deps/v8/test/cctest/test-run-wasm-relocation-arm64.cc index 71a069cd11..7448250ed6 100644 --- a/deps/v8/test/cctest/test-run-wasm-relocation-arm64.cc +++ b/deps/v8/test/cctest/test-run-wasm-relocation-arm64.cc @@ -19,15 +19,15 @@ #include "test/cctest/compiler/c-signature.h" #include "test/cctest/compiler/call-tester.h" -using namespace v8::base; -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace wasm { #define __ masm. static int64_t DummyStaticFunction(Object* result) { return 1; } -TEST(WasmRelocationArm64MemoryReference) { +TEST(WasmRelocationArm64ContextReference) { Isolate* isolate = CcTest::i_isolate(); HandleScope scope(isolate); v8::internal::byte buffer[4096]; @@ -37,16 +37,16 @@ TEST(WasmRelocationArm64MemoryReference) { MacroAssembler masm(isolate, buffer, sizeof buffer, v8::internal::CodeObjectRequired::kYes); - __ Mov(x0, Immediate(imm, RelocInfo::WASM_MEMORY_REFERENCE)); + __ Mov(x0, Immediate(imm, RelocInfo::WASM_CONTEXT_REFERENCE)); __ Ret(); CodeDesc desc; masm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); - CSignature0<int64_t> csig; - CodeRunner<int64_t> runnable(isolate, code, &csig); + compiler::CSignature0<int64_t> csig; + compiler::CodeRunner<int64_t> runnable(isolate, code, &csig); int64_t ret_value = runnable.Call(); CHECK_EQ(ret_value, imm); @@ -58,12 +58,12 @@ TEST(WasmRelocationArm64MemoryReference) { int offset = 1234; // Relocating reference by offset - int mode_mask = (1 << RelocInfo::WASM_MEMORY_REFERENCE); + int mode_mask = (1 << RelocInfo::WASM_CONTEXT_REFERENCE); for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { - DCHECK(RelocInfo::IsWasmMemoryReference(it.rinfo()->rmode())); - it.rinfo()->update_wasm_memory_reference( - isolate, it.rinfo()->wasm_memory_reference(), - it.rinfo()->wasm_memory_reference() + offset, SKIP_ICACHE_FLUSH); + DCHECK(RelocInfo::IsWasmContextReference(it.rinfo()->rmode())); + it.rinfo()->set_wasm_context_reference( + isolate, it.rinfo()->wasm_context_reference() + offset, + SKIP_ICACHE_FLUSH); } // Call into relocated code object @@ -76,58 +76,8 @@ TEST(WasmRelocationArm64MemoryReference) { #endif } -TEST(WasmRelocationArm64MemorySizeReference) { - CcTest::InitializeVM(); - Isolate* isolate = CcTest::i_isolate(); - HandleScope scope(isolate); - v8::internal::byte buffer[4096]; - DummyStaticFunction(NULL); - Immediate size = Immediate(512, RelocInfo::WASM_MEMORY_SIZE_REFERENCE); - Label fail; - - MacroAssembler masm(isolate, buffer, sizeof buffer, - v8::internal::CodeObjectRequired::kYes); - - __ Mov(x0, size); - __ Cmp(x0, size); - __ B(ne, &fail); - __ Ret(); - __ Bind(&fail); - __ Mov(x0, Immediate(0xdeadbeef)); - __ Ret(); - - CodeDesc desc; - masm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); - - CSignature0<int64_t> csig; - CodeRunner<int64_t> runnable(isolate, code, &csig); - int64_t ret_value = runnable.Call(); - CHECK_NE(ret_value, 0xdeadbeef); - -#ifdef DEBUG - OFStream os(stdout); - code->Print(os); - ::printf("f() = %" PRIx64 "\n\n", ret_value); -#endif - int32_t diff = 512; - - int mode_mask = (1 << RelocInfo::WASM_MEMORY_SIZE_REFERENCE); - for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { - DCHECK(RelocInfo::IsWasmMemorySizeReference(it.rinfo()->rmode())); - it.rinfo()->update_wasm_memory_size( - isolate, it.rinfo()->wasm_memory_size_reference(), - it.rinfo()->wasm_memory_size_reference() + diff, SKIP_ICACHE_FLUSH); - } - - ret_value = runnable.Call(); - CHECK_NE(ret_value, 0xdeadbeef); - -#ifdef DEBUG - code->Print(os); - ::printf("f() = %" PRIx64 "\n\n", ret_value); -#endif -} - #undef __ + +} // namespace wasm +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-run-wasm-relocation-ia32.cc b/deps/v8/test/cctest/test-run-wasm-relocation-ia32.cc index a78efa8fca..a59dbfec8a 100644 --- a/deps/v8/test/cctest/test-run-wasm-relocation-ia32.cc +++ b/deps/v8/test/cctest/test-run-wasm-relocation-ia32.cc @@ -12,18 +12,21 @@ #include "src/frame-constants.h" #include "src/ic/ic.h" #include "src/macro-assembler.h" +#include "src/objects-inl.h" +#include "src/ostreams.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/c-signature.h" #include "test/cctest/compiler/call-tester.h" -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace wasm { #define __ assm. static int32_t DummyStaticFunction(Object* result) { return 1; } -TEST(WasmRelocationIa32MemoryReference) { +TEST(WasmRelocationIa32ContextReference) { Isolate* isolate = CcTest::i_isolate(); Zone zone(isolate->allocator(), ZONE_NAME); HandleScope scope(isolate); @@ -33,18 +36,18 @@ TEST(WasmRelocationIa32MemoryReference) { int32_t imm = 1234567; __ mov(eax, Immediate(reinterpret_cast<Address>(imm), - RelocInfo::WASM_MEMORY_REFERENCE)); + RelocInfo::WASM_CONTEXT_REFERENCE)); __ nop(); __ ret(0); - CSignature0<int32_t> csig; + compiler::CSignature0<int32_t> csig; CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); USE(code); - CodeRunner<int32_t> runnable(isolate, code, &csig); + compiler::CodeRunner<int32_t> runnable(isolate, code, &csig); int32_t ret_value = runnable.Call(); CHECK_EQ(ret_value, imm); @@ -59,12 +62,12 @@ TEST(WasmRelocationIa32MemoryReference) { int offset = 1234; // Relocating references by offset - int mode_mask = (1 << RelocInfo::WASM_MEMORY_REFERENCE); + int mode_mask = (1 << RelocInfo::WASM_CONTEXT_REFERENCE); for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { - DCHECK(RelocInfo::IsWasmMemoryReference(it.rinfo()->rmode())); - it.rinfo()->update_wasm_memory_reference( - isolate, it.rinfo()->wasm_memory_reference(), - it.rinfo()->wasm_memory_reference() + offset, SKIP_ICACHE_FLUSH); + DCHECK(RelocInfo::IsWasmContextReference(it.rinfo()->rmode())); + it.rinfo()->set_wasm_context_reference( + isolate, it.rinfo()->wasm_context_reference() + offset, + SKIP_ICACHE_FLUSH); } // Check if immediate is updated correctly @@ -79,64 +82,8 @@ TEST(WasmRelocationIa32MemoryReference) { #endif } -TEST(WasmRelocationIa32MemorySizeReference) { - CcTest::InitializeVM(); - Isolate* isolate = CcTest::i_isolate(); - Zone zone(isolate->allocator(), ZONE_NAME); - HandleScope scope(isolate); - v8::internal::byte buffer[4096]; - Assembler assm(isolate, buffer, sizeof buffer); - DummyStaticFunction(NULL); - int32_t size = 80; - Label fail; - - __ mov(eax, Immediate(reinterpret_cast<Address>(size), - RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); - __ cmp(eax, Immediate(reinterpret_cast<Address>(size), - RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); - __ j(not_equal, &fail); - __ ret(0); - __ bind(&fail); - __ mov(eax, 0xdeadbeef); - __ ret(0); - - CSignature0<int32_t> csig; - CodeDesc desc; - assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); - USE(code); - - CodeRunner<int32_t> runnable(isolate, code, &csig); - int32_t ret_value = runnable.Call(); - CHECK_NE(ret_value, bit_cast<int32_t>(0xdeadbeef)); - -#ifdef OBJECT_PRINT - OFStream os(stdout); - code->Print(os); - byte* begin = code->instruction_start(); - byte* end = begin + code->instruction_size(); - disasm::Disassembler::Disassemble(stdout, begin, end); -#endif - - size_t offset = 10; - - int mode_mask = (1 << RelocInfo::WASM_MEMORY_SIZE_REFERENCE); - for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { - DCHECK(RelocInfo::IsWasmMemorySizeReference(it.rinfo()->rmode())); - it.rinfo()->update_wasm_memory_size( - isolate, it.rinfo()->wasm_memory_size_reference(), - it.rinfo()->wasm_memory_size_reference() + offset, SKIP_ICACHE_FLUSH); - } - - ret_value = runnable.Call(); - CHECK_NE(ret_value, bit_cast<int32_t>(0xdeadbeef)); - -#ifdef OBJECT_PRINT - code->Print(os); - begin = code->instruction_start(); - end = begin + code->instruction_size(); - disasm::Disassembler::Disassemble(stdout, begin, end); -#endif -} #undef __ + +} // namespace wasm +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-run-wasm-relocation-x64.cc b/deps/v8/test/cctest/test-run-wasm-relocation-x64.cc index fd52a80097..b886c6fde2 100644 --- a/deps/v8/test/cctest/test-run-wasm-relocation-x64.cc +++ b/deps/v8/test/cctest/test-run-wasm-relocation-x64.cc @@ -25,7 +25,7 @@ namespace compiler { static int32_t DummyStaticFunction(Object* result) { return 1; } -TEST(WasmRelocationX64MemoryReference) { +TEST(WasmRelocationX64ContextReference) { Isolate* isolate = CcTest::i_isolate(); HandleScope scope(isolate); v8::internal::byte buffer[4096]; @@ -33,14 +33,14 @@ TEST(WasmRelocationX64MemoryReference) { DummyStaticFunction(NULL); int64_t imm = 1234567; - __ movq(rax, imm, RelocInfo::WASM_MEMORY_REFERENCE); + __ movq(rax, imm, RelocInfo::WASM_CONTEXT_REFERENCE); __ nop(); __ ret(0); CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); USE(code); CSignature0<int64_t> csig; @@ -58,12 +58,12 @@ TEST(WasmRelocationX64MemoryReference) { int offset = 1234; // Relocating references by offset - int mode_mask = (1 << RelocInfo::WASM_MEMORY_REFERENCE); + int mode_mask = (1 << RelocInfo::WASM_CONTEXT_REFERENCE); for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { - DCHECK(RelocInfo::IsWasmMemoryReference(it.rinfo()->rmode())); - it.rinfo()->update_wasm_memory_reference( - isolate, it.rinfo()->wasm_memory_reference(), - it.rinfo()->wasm_memory_reference() + offset, SKIP_ICACHE_FLUSH); + DCHECK(RelocInfo::IsWasmContextReference(it.rinfo()->rmode())); + it.rinfo()->set_wasm_context_reference( + isolate, it.rinfo()->wasm_context_reference() + offset, + SKIP_ICACHE_FLUSH); } // Check if immediate is updated correctly @@ -78,62 +78,6 @@ TEST(WasmRelocationX64MemoryReference) { #endif } -TEST(WasmRelocationX64WasmMemorySizeReference) { - CcTest::InitializeVM(); - Isolate* isolate = CcTest::i_isolate(); - HandleScope scope(isolate); - v8::internal::byte buffer[4096]; - Assembler assm(isolate, buffer, sizeof buffer); - DummyStaticFunction(NULL); - int32_t size = 512; - Label fail; - - __ movl(rax, Immediate(size, RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); - __ cmpl(rax, Immediate(size, RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); - __ j(not_equal, &fail); - __ ret(0); - __ bind(&fail); - __ movl(rax, Immediate(0xdeadbeef)); - __ ret(0); - - CodeDesc desc; - assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); - USE(code); - - CSignature0<int64_t> csig; - CodeRunner<int64_t> runnable(isolate, code, &csig); - int64_t ret_value = runnable.Call(); - CHECK_NE(ret_value, bit_cast<uint32_t>(0xdeadbeef)); - -#ifdef OBJECT_PRINT - OFStream os(stdout); - code->Print(os); - byte* begin = code->instruction_start(); - byte* end = begin + code->instruction_size(); - disasm::Disassembler::Disassemble(stdout, begin, end); -#endif - int32_t diff = 512; - - int mode_mask = (1 << RelocInfo::WASM_MEMORY_SIZE_REFERENCE); - for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { - DCHECK(RelocInfo::IsWasmMemorySizeReference(it.rinfo()->rmode())); - it.rinfo()->update_wasm_memory_size( - isolate, it.rinfo()->wasm_memory_size_reference(), - it.rinfo()->wasm_memory_size_reference() + diff, SKIP_ICACHE_FLUSH); - } - - ret_value = runnable.Call(); - CHECK_NE(ret_value, bit_cast<uint32_t>(0xdeadbeef)); - -#ifdef OBJECT_PRINT - code->Print(os); - begin = code->instruction_start(); - end = begin + code->instruction_size(); - disasm::Disassembler::Disassemble(stdout, begin, end); -#endif -} #undef __ } // namespace compiler diff --git a/deps/v8/test/cctest/test-serialize.cc b/deps/v8/test/cctest/test-serialize.cc index 481c168154..6cd9110856 100644 --- a/deps/v8/test/cctest/test-serialize.cc +++ b/deps/v8/test/cctest/test-serialize.cc @@ -41,6 +41,8 @@ #include "src/macro-assembler-inl.h" #include "src/objects-inl.h" #include "src/runtime/runtime.h" +#include "src/snapshot/builtin-deserializer.h" +#include "src/snapshot/builtin-serializer.h" #include "src/snapshot/code-serializer.h" #include "src/snapshot/natives.h" #include "src/snapshot/partial-deserializer.h" @@ -52,7 +54,15 @@ #include "test/cctest/heap/heap-utils.h" #include "test/cctest/setup-isolate-for-tests.h" -using namespace v8::internal; +namespace v8 { +namespace internal { + +void DisableLazyDeserialization() { + // UNINITIALIZED tests do not set up the isolate sufficiently for lazy + // deserialization to work. + // TODO(jgruber): Fix this. It may just be enough to set the snapshot_blob. + FLAG_lazy_deserialization = false; +} void DisableAlwaysOpt() { // Isolates prepared for serialization do not optimize. The only exception is @@ -66,7 +76,7 @@ class TestIsolate : public Isolate { public: static v8::Isolate* NewInitialized(bool enable_serializer) { i::Isolate* isolate = new TestIsolate(enable_serializer); - isolate->setup_delegate_ = new SetupIsolateDelegateForTests(); + isolate->setup_delegate_ = new SetupIsolateDelegateForTests(true); v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); v8::Isolate::Scope isolate_scope(v8_isolate); isolate->Init(NULL); @@ -77,14 +87,16 @@ class TestIsolate : public Isolate { // the production Isolate class has one or the other behavior baked in. static v8::Isolate* New(const v8::Isolate::CreateParams& params) { i::Isolate* isolate = new TestIsolate(false); - isolate->setup_delegate_ = new SetupIsolateDelegateForTests(); + bool create_heap_objects = params.snapshot_blob == nullptr; + isolate->setup_delegate_ = + new SetupIsolateDelegateForTests(create_heap_objects); return v8::IsolateNewImpl(isolate, params); } explicit TestIsolate(bool enable_serializer) : Isolate(enable_serializer) { set_array_buffer_allocator(CcTest::array_buffer_allocator()); } - void CreateSetupDelegateForTests() { - setup_delegate_ = new SetupIsolateDelegateForTests(); + void SetDeserializeFromSnapshot() { + setup_delegate_ = new SetupIsolateDelegateForTests(false); } }; @@ -95,7 +107,19 @@ static Vector<const byte> WritePayload(const Vector<const byte>& payload) { return Vector<const byte>(const_cast<const byte*>(blob), length); } -static Vector<const byte> Serialize(v8::Isolate* isolate) { +// A convenience struct to simplify management of the two blobs required to +// deserialize an isolate. +struct StartupBlobs { + Vector<const byte> startup; + Vector<const byte> builtin; + + void Dispose() { + startup.Dispose(); + builtin.Dispose(); + } +}; + +static StartupBlobs Serialize(v8::Isolate* isolate) { // We have to create one context. One reason for this is so that the builtins // can be loaded from v8natives.js and their addresses can be processed. This // will clear the pending fixups array, which would otherwise contain GC roots @@ -112,9 +136,15 @@ static Vector<const byte> Serialize(v8::Isolate* isolate) { StartupSerializer ser(internal_isolate, v8::SnapshotCreator::FunctionCodeHandling::kClear); ser.SerializeStrongReferences(); + + i::BuiltinSerializer builtin_serializer(internal_isolate, &ser); + builtin_serializer.SerializeBuiltins(); + ser.SerializeWeakReferencesAndDeferred(); - SnapshotData snapshot_data(&ser); - return WritePayload(snapshot_data.RawData()); + SnapshotData startup_snapshot(&ser); + BuiltinSnapshotData builtin_snapshot(&builtin_serializer); + return {WritePayload(startup_snapshot.RawData()), + WritePayload(builtin_snapshot.RawData())}; } @@ -134,22 +164,23 @@ Vector<const uint8_t> ConstructSource(Vector<const uint8_t> head, source_length); } -v8::Isolate* InitializeFromBlob(Vector<const byte> blob) { +v8::Isolate* InitializeFromBlob(StartupBlobs& blobs) { v8::Isolate* v8_isolate = NULL; { - SnapshotData snapshot_data(blob); - StartupDeserializer deserializer(&snapshot_data); + SnapshotData startup_snapshot(blobs.startup); + BuiltinSnapshotData builtin_snapshot(blobs.builtin); + StartupDeserializer deserializer(&startup_snapshot, &builtin_snapshot); TestIsolate* isolate = new TestIsolate(false); v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); v8::Isolate::Scope isolate_scope(v8_isolate); - isolate->CreateSetupDelegateForTests(); + isolate->SetDeserializeFromSnapshot(); isolate->Init(&deserializer); } return v8_isolate; } -static v8::Isolate* Deserialize(Vector<const byte> blob) { - v8::Isolate* isolate = InitializeFromBlob(blob); +static v8::Isolate* Deserialize(StartupBlobs& blobs) { + v8::Isolate* isolate = InitializeFromBlob(blobs); CHECK(isolate); return isolate; } @@ -168,11 +199,13 @@ static void SanityCheck(v8::Isolate* v8_isolate) { } UNINITIALIZED_TEST(StartupSerializerOnce) { + DisableLazyDeserialization(); DisableAlwaysOpt(); v8::Isolate* isolate = TestIsolate::NewInitialized(true); - Vector<const byte> blob = Serialize(isolate); - isolate = Deserialize(blob); - blob.Dispose(); + StartupBlobs blobs = Serialize(isolate); + isolate->Dispose(); + isolate = Deserialize(blobs); + blobs.Dispose(); { v8::HandleScope handle_scope(isolate); v8::Isolate::Scope isolate_scope(isolate); @@ -234,13 +267,15 @@ UNINITIALIZED_TEST(StartupSerializerRootMapDependencies) { } UNINITIALIZED_TEST(StartupSerializerTwice) { + DisableLazyDeserialization(); DisableAlwaysOpt(); v8::Isolate* isolate = TestIsolate::NewInitialized(true); - Vector<const byte> blob1 = Serialize(isolate); - Vector<const byte> blob2 = Serialize(isolate); - blob1.Dispose(); - isolate = Deserialize(blob2); - blob2.Dispose(); + StartupBlobs blobs1 = Serialize(isolate); + StartupBlobs blobs2 = Serialize(isolate); + isolate->Dispose(); + blobs1.Dispose(); + isolate = Deserialize(blobs2); + blobs2.Dispose(); { v8::Isolate::Scope isolate_scope(isolate); v8::HandleScope handle_scope(isolate); @@ -254,11 +289,13 @@ UNINITIALIZED_TEST(StartupSerializerTwice) { } UNINITIALIZED_TEST(StartupSerializerOnceRunScript) { + DisableLazyDeserialization(); DisableAlwaysOpt(); v8::Isolate* isolate = TestIsolate::NewInitialized(true); - Vector<const byte> blob = Serialize(isolate); - isolate = Deserialize(blob); - blob.Dispose(); + StartupBlobs blobs = Serialize(isolate); + isolate->Dispose(); + isolate = Deserialize(blobs); + blobs.Dispose(); { v8::Isolate::Scope isolate_scope(isolate); v8::HandleScope handle_scope(isolate); @@ -278,13 +315,15 @@ UNINITIALIZED_TEST(StartupSerializerOnceRunScript) { } UNINITIALIZED_TEST(StartupSerializerTwiceRunScript) { + DisableLazyDeserialization(); DisableAlwaysOpt(); v8::Isolate* isolate = TestIsolate::NewInitialized(true); - Vector<const byte> blob1 = Serialize(isolate); - Vector<const byte> blob2 = Serialize(isolate); - blob1.Dispose(); - isolate = Deserialize(blob2); - blob2.Dispose(); + StartupBlobs blobs1 = Serialize(isolate); + StartupBlobs blobs2 = Serialize(isolate); + isolate->Dispose(); + blobs1.Dispose(); + isolate = Deserialize(blobs2); + blobs2.Dispose(); { v8::Isolate::Scope isolate_scope(isolate); v8::HandleScope handle_scope(isolate); @@ -303,6 +342,7 @@ UNINITIALIZED_TEST(StartupSerializerTwiceRunScript) { } static void PartiallySerializeContext(Vector<const byte>* startup_blob_out, + Vector<const byte>* builtin_blob_out, Vector<const byte>* partial_blob_out) { v8::Isolate* v8_isolate = TestIsolate::NewInitialized(true); Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); @@ -343,26 +383,35 @@ static void PartiallySerializeContext(Vector<const byte>* startup_blob_out, PartialSerializer partial_serializer(isolate, &startup_serializer, v8::SerializeInternalFieldsCallback()); partial_serializer.Serialize(&raw_context, false); + + i::BuiltinSerializer builtin_serializer(isolate, &startup_serializer); + builtin_serializer.SerializeBuiltins(); + startup_serializer.SerializeWeakReferencesAndDeferred(); SnapshotData startup_snapshot(&startup_serializer); + BuiltinSnapshotData builtin_snapshot(&builtin_serializer); SnapshotData partial_snapshot(&partial_serializer); *partial_blob_out = WritePayload(partial_snapshot.RawData()); + *builtin_blob_out = WritePayload(builtin_snapshot.RawData()); *startup_blob_out = WritePayload(startup_snapshot.RawData()); } v8_isolate->Dispose(); } UNINITIALIZED_TEST(PartialSerializerContext) { + DisableLazyDeserialization(); DisableAlwaysOpt(); Vector<const byte> startup_blob; + Vector<const byte> builtin_blob; Vector<const byte> partial_blob; - PartiallySerializeContext(&startup_blob, &partial_blob); + PartiallySerializeContext(&startup_blob, &builtin_blob, &partial_blob); - v8::Isolate* v8_isolate = InitializeFromBlob(startup_blob); + StartupBlobs blobs = {startup_blob, builtin_blob}; + v8::Isolate* v8_isolate = InitializeFromBlob(blobs); CHECK(v8_isolate); - startup_blob.Dispose(); + blobs.Dispose(); { v8::Isolate::Scope isolate_scope(v8_isolate); @@ -398,7 +447,7 @@ UNINITIALIZED_TEST(PartialSerializerContext) { } static void PartiallySerializeCustomContext( - Vector<const byte>* startup_blob_out, + Vector<const byte>* startup_blob_out, Vector<const byte>* builtin_blob_out, Vector<const byte>* partial_blob_out) { v8::Isolate* v8_isolate = TestIsolate::NewInitialized(true); Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); @@ -459,26 +508,35 @@ static void PartiallySerializeCustomContext( PartialSerializer partial_serializer(isolate, &startup_serializer, v8::SerializeInternalFieldsCallback()); partial_serializer.Serialize(&raw_context, false); + + i::BuiltinSerializer builtin_serializer(isolate, &startup_serializer); + builtin_serializer.SerializeBuiltins(); + startup_serializer.SerializeWeakReferencesAndDeferred(); SnapshotData startup_snapshot(&startup_serializer); + BuiltinSnapshotData builtin_snapshot(&builtin_serializer); SnapshotData partial_snapshot(&partial_serializer); *partial_blob_out = WritePayload(partial_snapshot.RawData()); + *builtin_blob_out = WritePayload(builtin_snapshot.RawData()); *startup_blob_out = WritePayload(startup_snapshot.RawData()); } v8_isolate->Dispose(); } UNINITIALIZED_TEST(PartialSerializerCustomContext) { + DisableLazyDeserialization(); DisableAlwaysOpt(); Vector<const byte> startup_blob; + Vector<const byte> builtin_blob; Vector<const byte> partial_blob; - PartiallySerializeCustomContext(&startup_blob, &partial_blob); + PartiallySerializeCustomContext(&startup_blob, &builtin_blob, &partial_blob); - v8::Isolate* v8_isolate = InitializeFromBlob(startup_blob); + StartupBlobs blobs = {startup_blob, builtin_blob}; + v8::Isolate* v8_isolate = InitializeFromBlob(blobs); CHECK(v8_isolate); - startup_blob.Dispose(); + blobs.Dispose(); { v8::Isolate::Scope isolate_scope(v8_isolate); @@ -732,6 +790,7 @@ TEST(CustomSnapshotDataBlobNeuteredArrayBuffer) { Int32Expectations expectations = {std::make_tuple("x.buffer.byteLength", 0), std::make_tuple("x.length", 0)}; + DisableLazyDeserialization(); DisableAlwaysOpt(); i::FLAG_allow_natives_syntax = true; v8::StartupData blob; @@ -1021,6 +1080,7 @@ bool IsCompiled(const char* name) { } TEST(SnapshotDataBlobWithWarmup) { + DisableLazyDeserialization(); DisableAlwaysOpt(); const char* warmup = "Math.abs(1); Math.random = 1;"; @@ -1050,6 +1110,7 @@ TEST(SnapshotDataBlobWithWarmup) { } TEST(CustomSnapshotDataBlobWithWarmup) { + DisableLazyDeserialization(); DisableAlwaysOpt(); const char* source = "function f() { return Math.abs(1); }\n" @@ -1143,13 +1204,13 @@ static Handle<SharedFunctionInfo> CompileScript( Isolate* isolate, Handle<String> source, Handle<String> name, ScriptData** cached_data, v8::ScriptCompiler::CompileOptions options) { return Compiler::GetSharedFunctionInfoForScript( - source, name, 0, 0, v8::ScriptOriginOptions(), Handle<Object>(), - Handle<Context>(isolate->native_context()), NULL, cached_data, options, - NOT_NATIVES_CODE, Handle<FixedArray>()); + source, name, 0, 0, v8::ScriptOriginOptions(), Handle<Object>(), + Handle<Context>(isolate->native_context()), NULL, cached_data, + options, NOT_NATIVES_CODE, Handle<FixedArray>()) + .ToHandleChecked(); } TEST(CodeSerializerOnePlusOne) { - FLAG_serialize_toplevel = true; LocalContext context; Isolate* isolate = CcTest::i_isolate(); isolate->compilation_cache()->Disable(); // Disable same-isolate code cache. @@ -1199,7 +1260,6 @@ TEST(CodeSerializerOnePlusOne) { } TEST(CodeSerializerPromotedToCompilationCache) { - FLAG_serialize_toplevel = true; LocalContext context; Isolate* isolate = CcTest::i_isolate(); @@ -1229,7 +1289,6 @@ TEST(CodeSerializerPromotedToCompilationCache) { } TEST(CodeSerializerInternalizedString) { - FLAG_serialize_toplevel = true; LocalContext context; Isolate* isolate = CcTest::i_isolate(); isolate->compilation_cache()->Disable(); // Disable same-isolate code cache. @@ -1288,7 +1347,6 @@ TEST(CodeSerializerInternalizedString) { } TEST(CodeSerializerLargeCodeObject) { - FLAG_serialize_toplevel = true; LocalContext context; Isolate* isolate = CcTest::i_isolate(); isolate->compilation_cache()->Disable(); // Disable same-isolate code cache. @@ -1341,7 +1399,6 @@ TEST(CodeSerializerLargeCodeObject) { TEST(CodeSerializerLargeCodeObjectWithIncrementalMarking) { if (FLAG_never_compact) return; ManualGCScope manual_gc_scope; - FLAG_serialize_toplevel = true; FLAG_always_opt = false; const char* filter_flag = "--turbo-filter=NOTHING"; FlagList::SetFlagsFromString(filter_flag, StrLength(filter_flag)); @@ -1418,7 +1475,6 @@ TEST(CodeSerializerLargeCodeObjectWithIncrementalMarking) { source.Dispose(); } TEST(CodeSerializerLargeStrings) { - FLAG_serialize_toplevel = true; LocalContext context; Isolate* isolate = CcTest::i_isolate(); Factory* f = isolate->factory(); @@ -1475,7 +1531,6 @@ TEST(CodeSerializerLargeStrings) { } TEST(CodeSerializerThreeBigStrings) { - FLAG_serialize_toplevel = true; LocalContext context; Isolate* isolate = CcTest::i_isolate(); Factory* f = isolate->factory(); @@ -1585,7 +1640,6 @@ class SerializerTwoByteResource : public v8::String::ExternalStringResource { }; TEST(CodeSerializerExternalString) { - FLAG_serialize_toplevel = true; LocalContext context; Isolate* isolate = CcTest::i_isolate(); isolate->compilation_cache()->Disable(); // Disable same-isolate code cache. @@ -1647,7 +1701,6 @@ TEST(CodeSerializerExternalString) { } TEST(CodeSerializerLargeExternalString) { - FLAG_serialize_toplevel = true; LocalContext context; Isolate* isolate = CcTest::i_isolate(); isolate->compilation_cache()->Disable(); // Disable same-isolate code cache. @@ -1705,7 +1758,6 @@ TEST(CodeSerializerLargeExternalString) { } TEST(CodeSerializerExternalScriptName) { - FLAG_serialize_toplevel = true; LocalContext context; Isolate* isolate = CcTest::i_isolate(); isolate->compilation_cache()->Disable(); // Disable same-isolate code cache. @@ -1764,8 +1816,8 @@ static void SerializerCodeEventListener(const v8::JitCodeEvent* event) { } } - -v8::ScriptCompiler::CachedData* ProduceCache(const char* source) { +v8::ScriptCompiler::CachedData* ProduceCache(const char* source, + bool eager = false) { v8::ScriptCompiler::CachedData* cache; v8::Isolate::CreateParams create_params; create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); @@ -1779,9 +1831,11 @@ v8::ScriptCompiler::CachedData* ProduceCache(const char* source) { v8::Local<v8::String> source_str = v8_str(source); v8::ScriptOrigin origin(v8_str("test")); v8::ScriptCompiler::Source source(source_str, origin); + v8::ScriptCompiler::CompileOptions options = + eager ? v8::ScriptCompiler::kProduceFullCodeCache + : v8::ScriptCompiler::kProduceCodeCache; v8::Local<v8::UnboundScript> script = - v8::ScriptCompiler::CompileUnboundScript( - isolate1, &source, v8::ScriptCompiler::kProduceCodeCache) + v8::ScriptCompiler::CompileUnboundScript(isolate1, &source, options) .ToLocalChecked(); const v8::ScriptCompiler::CachedData* data = source.GetCachedData(); CHECK(data); @@ -1803,9 +1857,16 @@ v8::ScriptCompiler::CachedData* ProduceCache(const char* source) { return cache; } -TEST(CodeSerializerIsolates) { - FLAG_serialize_toplevel = true; +void CheckDeserializedFlag(v8::Local<v8::UnboundScript> script) { + i::Handle<i::SharedFunctionInfo> sfi = v8::Utils::OpenHandle(*script); + i::Handle<i::Script> i_script(Script::cast(sfi->script())); + i::SharedFunctionInfo::ScriptIterator iterator(i_script); + while (SharedFunctionInfo* next = iterator.Next()) { + CHECK_EQ(next->is_compiled(), next->deserialized()); + } +} +TEST(CodeSerializerIsolates) { const char* source = "function f() { return 'abc'; }; f() + 'def'"; v8::ScriptCompiler::CachedData* cache = ProduceCache(source); @@ -1832,6 +1893,7 @@ TEST(CodeSerializerIsolates) { .ToLocalChecked(); } CHECK(!cache->rejected); + CheckDeserializedFlag(script); v8::Local<v8::Value> result = script->BindToCurrentContext() ->Run(isolate2->GetCurrentContext()) .ToLocalChecked(); @@ -1844,9 +1906,53 @@ TEST(CodeSerializerIsolates) { isolate2->Dispose(); } -TEST(CodeSerializerFlagChange) { - FLAG_serialize_toplevel = true; +TEST(CodeSerializerIsolatesEager) { + const char* source = + "function f() {" + " return function g() {" + " return 'abc';" + " }" + "}" + "f()() + 'def'"; + v8::ScriptCompiler::CachedData* cache = ProduceCache(source, true); + + v8::Isolate::CreateParams create_params; + create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); + v8::Isolate* isolate2 = v8::Isolate::New(create_params); + isolate2->SetJitCodeEventHandler(v8::kJitCodeEventDefault, + SerializerCodeEventListener); + toplevel_test_code_event_found = false; + { + v8::Isolate::Scope iscope(isolate2); + v8::HandleScope scope(isolate2); + v8::Local<v8::Context> context = v8::Context::New(isolate2); + v8::Context::Scope context_scope(context); + + v8::Local<v8::String> source_str = v8_str(source); + v8::ScriptOrigin origin(v8_str("test")); + v8::ScriptCompiler::Source source(source_str, origin, cache); + v8::Local<v8::UnboundScript> script; + { + DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2)); + script = v8::ScriptCompiler::CompileUnboundScript( + isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache) + .ToLocalChecked(); + } + CHECK(!cache->rejected); + CheckDeserializedFlag(script); + v8::Local<v8::Value> result = script->BindToCurrentContext() + ->Run(isolate2->GetCurrentContext()) + .ToLocalChecked(); + CHECK(result->ToString(isolate2->GetCurrentContext()) + .ToLocalChecked() + ->Equals(isolate2->GetCurrentContext(), v8_str("abcdef")) + .FromJust()); + } + CHECK(toplevel_test_code_event_found); + isolate2->Dispose(); +} +TEST(CodeSerializerFlagChange) { const char* source = "function f() { return 'abc'; }; f() + 'def'"; v8::ScriptCompiler::CachedData* cache = ProduceCache(source); @@ -1874,8 +1980,6 @@ TEST(CodeSerializerFlagChange) { } TEST(CodeSerializerBitFlip) { - FLAG_serialize_toplevel = true; - const char* source = "function f() { return 'abc'; }; f() + 'def'"; v8::ScriptCompiler::CachedData* cache = ProduceCache(source); @@ -1903,8 +2007,6 @@ TEST(CodeSerializerBitFlip) { } TEST(CodeSerializerWithHarmonyScoping) { - FLAG_serialize_toplevel = true; - const char* source1 = "'use strict'; let x = 'X'"; const char* source2 = "'use strict'; let y = 'Y'"; const char* source3 = "'use strict'; x + y"; @@ -1969,6 +2071,7 @@ TEST(CodeSerializerWithHarmonyScoping) { isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache) .ToLocalChecked(); } + CheckDeserializedFlag(script); v8::Local<v8::Value> result = script->BindToCurrentContext() ->Run(isolate2->GetCurrentContext()) .ToLocalChecked(); @@ -1991,11 +2094,13 @@ TEST(Regress503552) { Handle<String> source = isolate->factory()->NewStringFromAsciiChecked( "function f() {} function g() {}"); ScriptData* script_data = NULL; - Handle<SharedFunctionInfo> shared = Compiler::GetSharedFunctionInfoForScript( - source, Handle<String>(), 0, 0, v8::ScriptOriginOptions(), - Handle<Object>(), Handle<Context>(isolate->native_context()), NULL, - &script_data, v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE, - Handle<FixedArray>()); + Handle<SharedFunctionInfo> shared = + Compiler::GetSharedFunctionInfoForScript( + source, MaybeHandle<String>(), 0, 0, v8::ScriptOriginOptions(), + MaybeHandle<Object>(), Handle<Context>(isolate->native_context()), + NULL, &script_data, v8::ScriptCompiler::kProduceCodeCache, + NOT_NATIVES_CODE, MaybeHandle<FixedArray>()) + .ToHandleChecked(); delete script_data; heap::SimulateIncrementalMarking(isolate->heap()); @@ -2004,60 +2109,6 @@ TEST(Regress503552) { delete script_data; } -TEST(CodeSerializerEmbeddedObject) { - FLAG_serialize_toplevel = true; - LocalContext context; - Isolate* isolate = CcTest::i_isolate(); - isolate->compilation_cache()->Disable(); // Disable same-isolate code cache. - v8::HandleScope scope(CcTest::isolate()); - - size_t actual_size; - byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( - Assembler::kMinimalBufferSize, &actual_size, true)); - CHECK(buffer); - HandleScope handles(isolate); - - MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size), - v8::internal::CodeObjectRequired::kYes); - assembler.enable_serializer(); - Handle<HeapNumber> number = isolate->factory()->NewHeapNumber(0.3); - CHECK(isolate->heap()->InNewSpace(*number)); - Handle<Code> code; - { - MacroAssembler* masm = &assembler; - masm->Push(number); - CodeDesc desc; - masm->GetCode(isolate, &desc); - code = isolate->factory()->NewCode(desc, Code::ComputeFlags(Code::FUNCTION), - masm->CodeObject()); - code->set_has_reloc_info_for_serialization(true); - } - RelocIterator rit1(*code, RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT)); - CHECK_EQ(*number, rit1.rinfo()->target_object()); - - Handle<String> source = isolate->factory()->empty_string(); - Handle<SharedFunctionInfo> sfi = - isolate->factory()->NewSharedFunctionInfo(source, code, false); - ScriptData* script_data = CodeSerializer::Serialize(isolate, sfi, source); - - Handle<SharedFunctionInfo> copy = - CodeSerializer::Deserialize(isolate, script_data, source) - .ToHandleChecked(); - RelocIterator rit2(copy->code(), - RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT)); - CHECK(rit2.rinfo()->target_object()->IsHeapNumber()); - CHECK_EQ(0.3, HeapNumber::cast(rit2.rinfo()->target_object())->value()); - - CcTest::CollectAllAvailableGarbage(); - - RelocIterator rit3(copy->code(), - RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT)); - CHECK(rit3.rinfo()->target_object()->IsHeapNumber()); - CHECK_EQ(0.3, HeapNumber::cast(rit3.rinfo()->target_object())->value()); - - delete script_data; -} - TEST(SnapshotCreatorMultipleContexts) { DisableAlwaysOpt(); v8::StartupData blob; @@ -2718,3 +2769,27 @@ TEST(SerializationMemoryStats) { v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); delete[] blob.data; } + +TEST(BuiltinsHaveBuiltinIdForLazyDeserialization) { + CcTest::InitializeVM(); + Isolate* isolate = CcTest::i_isolate(); + i::HandleScope scope(isolate); + + CHECK(Builtins::IsLazy(Builtins::kRegExpPrototypeExec)); + CHECK_EQ(Builtins::kRegExpPrototypeExec, + isolate->regexp_exec_function() + ->shared() + ->lazy_deserialization_builtin_id()); + CHECK(Builtins::IsLazy(Builtins::kAsyncIteratorValueUnwrap)); + CHECK_EQ(Builtins::kAsyncIteratorValueUnwrap, + isolate->async_iterator_value_unwrap_shared_fun() + ->lazy_deserialization_builtin_id()); + + CHECK(!Builtins::IsLazy(Builtins::kIllegal)); + CHECK(!isolate->opaque_reference_function() + ->shared() + ->HasLazyDeserializationBuiltinId()); +} + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-simulator-arm.cc b/deps/v8/test/cctest/test-simulator-arm.cc index 6350e177d8..eabc43df31 100644 --- a/deps/v8/test/cctest/test-simulator-arm.cc +++ b/deps/v8/test/cctest/test-simulator-arm.cc @@ -29,19 +29,20 @@ #include "test/cctest/cctest.h" #include "src/arm/simulator-arm.h" +#include "src/assembler-inl.h" #include "src/disassembler.h" #include "src/factory.h" #include "src/macro-assembler.h" +namespace v8 { +namespace internal { + #if defined(USE_SIMULATOR) #ifndef V8_TARGET_LITTLE_ENDIAN #error Expected ARM to be little-endian #endif -using namespace v8::base; -using namespace v8::internal; - // Define these function prototypes to match JSEntryFunction in execution.cc. typedef Object* (*F1)(int x, int p1, int p2, int p3, int p4); typedef Object* (*F3)(void* p0, int p1, int p2, int p3, int p4); @@ -195,8 +196,8 @@ static void TestInvalidateExclusiveAccess( CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); TestData t = initial_data; @@ -263,8 +264,8 @@ static int ExecuteMemoryAccess(Isolate* isolate, TestData* test_data, CodeDesc desc; assm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); F3 f = FUNCTION_CAST<F3>(code->entry()); return reinterpret_cast<int>( @@ -278,30 +279,33 @@ class MemoryAccessThread : public v8::base::Thread { test_data_(NULL), is_finished_(false), has_request_(false), - did_request_(false) {} + did_request_(false), + isolate_(nullptr) {} virtual void Run() { v8::Isolate::CreateParams create_params; create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); - v8::Isolate* isolate = v8::Isolate::New(create_params); - Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate); - v8::Isolate::Scope scope(isolate); - - v8::base::LockGuard<v8::base::Mutex> lock_guard(&mutex_); - while (!is_finished_) { - while (!(has_request_ || is_finished_)) { - has_request_cv_.Wait(&mutex_); - } + isolate_ = v8::Isolate::New(create_params); + Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate_); + { + v8::Isolate::Scope scope(isolate_); + v8::base::LockGuard<v8::base::Mutex> lock_guard(&mutex_); + while (!is_finished_) { + while (!(has_request_ || is_finished_)) { + has_request_cv_.Wait(&mutex_); + } + + if (is_finished_) { + break; + } - if (is_finished_) { - break; + ExecuteMemoryAccess(i_isolate, test_data_, access_); + has_request_ = false; + did_request_ = true; + did_request_cv_.NotifyOne(); } - - ExecuteMemoryAccess(i_isolate, test_data_, access_); - has_request_ = false; - did_request_ = true; - did_request_cv_.NotifyOne(); } + isolate_->Dispose(); } void NextAndWait(TestData* test_data, MemoryAccess access) { @@ -332,6 +336,7 @@ class MemoryAccessThread : public v8::base::Thread { v8::base::Mutex mutex_; v8::base::ConditionVariable has_request_cv_; v8::base::ConditionVariable did_request_cv_; + v8::Isolate* isolate_; }; TEST(simulator_invalidate_exclusive_access_threaded) { @@ -385,3 +390,6 @@ TEST(simulator_invalidate_exclusive_access_threaded) { #undef __ #endif // USE_SIMULATOR + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-simulator-arm64.cc b/deps/v8/test/cctest/test-simulator-arm64.cc index 137e2066d0..9ba216a643 100644 --- a/deps/v8/test/cctest/test-simulator-arm64.cc +++ b/deps/v8/test/cctest/test-simulator-arm64.cc @@ -33,15 +33,15 @@ #include "src/macro-assembler-inl.h" #include "src/objects-inl.h" +namespace v8 { +namespace internal { + #if defined(USE_SIMULATOR) #ifndef V8_TARGET_LITTLE_ENDIAN #error Expected ARM to be little-endian #endif -using namespace v8::base; -using namespace v8::internal; - #define __ masm. struct MemoryAccess { @@ -189,8 +189,8 @@ static void TestInvalidateExclusiveAccess( CodeDesc desc; masm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); TestData t = initial_data; Simulator::CallArgument args[] = { Simulator::CallArgument(reinterpret_cast<uintptr_t>(&t)), @@ -259,8 +259,8 @@ static int ExecuteMemoryAccess(Isolate* isolate, TestData* test_data, CodeDesc desc; masm.GetCode(isolate, &desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + Handle<Code> code = + isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>()); Simulator::CallArgument args[] = { Simulator::CallArgument(reinterpret_cast<uintptr_t>(test_data)), Simulator::CallArgument::End()}; @@ -275,30 +275,33 @@ class MemoryAccessThread : public v8::base::Thread { test_data_(NULL), is_finished_(false), has_request_(false), - did_request_(false) {} + did_request_(false), + isolate_(nullptr) {} virtual void Run() { v8::Isolate::CreateParams create_params; create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); - v8::Isolate* isolate = v8::Isolate::New(create_params); - Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate); - v8::Isolate::Scope scope(isolate); - - v8::base::LockGuard<v8::base::Mutex> lock_guard(&mutex_); - while (!is_finished_) { - while (!(has_request_ || is_finished_)) { - has_request_cv_.Wait(&mutex_); - } + isolate_ = v8::Isolate::New(create_params); + Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate_); + { + v8::Isolate::Scope scope(isolate_); + v8::base::LockGuard<v8::base::Mutex> lock_guard(&mutex_); + while (!is_finished_) { + while (!(has_request_ || is_finished_)) { + has_request_cv_.Wait(&mutex_); + } + + if (is_finished_) { + break; + } - if (is_finished_) { - break; + ExecuteMemoryAccess(i_isolate, test_data_, access_); + has_request_ = false; + did_request_ = true; + did_request_cv_.NotifyOne(); } - - ExecuteMemoryAccess(i_isolate, test_data_, access_); - has_request_ = false; - did_request_ = true; - did_request_cv_.NotifyOne(); } + isolate_->Dispose(); } void NextAndWait(TestData* test_data, MemoryAccess access) { @@ -329,6 +332,7 @@ class MemoryAccessThread : public v8::base::Thread { v8::base::Mutex mutex_; v8::base::ConditionVariable has_request_cv_; v8::base::ConditionVariable did_request_cv_; + v8::Isolate* isolate_; }; TEST(simulator_invalidate_exclusive_access_threaded) { @@ -382,3 +386,6 @@ TEST(simulator_invalidate_exclusive_access_threaded) { #undef __ #endif // USE_SIMULATOR + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-strings.cc b/deps/v8/test/cctest/test-strings.cc index e35f516947..ec6b659406 100644 --- a/deps/v8/test/cctest/test-strings.cc +++ b/deps/v8/test/cctest/test-strings.cc @@ -97,6 +97,7 @@ class MyRandomNumberGenerator { namespace v8 { namespace internal { +namespace test_strings { static const int DEEP_DEPTH = 8 * 1024; static const int SUPER_DEEP_DEPTH = 80 * 1024; @@ -1154,7 +1155,6 @@ TEST(CachedHashOverflow) { TEST(SliceFromCons) { - FLAG_string_slices = true; CcTest::InitializeVM(); Factory* factory = CcTest::i_isolate()->factory(); v8::HandleScope scope(CcTest::isolate()); @@ -1221,7 +1221,6 @@ TEST(InternalizeExternal) { } TEST(SliceFromExternal) { - FLAG_string_slices = true; CcTest::InitializeVM(); Factory* factory = CcTest::i_isolate()->factory(); v8::HandleScope scope(CcTest::isolate()); @@ -1242,7 +1241,6 @@ TEST(SliceFromExternal) { TEST(TrivialSlice) { // This tests whether a slice that contains the entire parent string // actually creates a new string (it should not). - FLAG_string_slices = true; CcTest::InitializeVM(); Factory* factory = CcTest::i_isolate()->factory(); v8::HandleScope scope(CcTest::isolate()); @@ -1272,7 +1270,6 @@ TEST(TrivialSlice) { TEST(SliceFromSlice) { // This tests whether a slice that contains the entire parent string // actually creates a new string (it should not). - FLAG_string_slices = true; CcTest::InitializeVM(); v8::HandleScope scope(CcTest::isolate()); v8::Local<v8::Value> result; @@ -1505,27 +1502,28 @@ static void CheckCanonicalEquivalence(uint16_t c, uint16_t test) { TEST(Latin1IgnoreCase) { - using namespace unibrow; - for (uint16_t c = Latin1::kMaxChar + 1; c != 0; c++) { - uint16_t lower = ConvertLatin1<ToLowercase, false>(c); - uint16_t upper = ConvertLatin1<ToUppercase, false>(c); - uint16_t test = Latin1::ConvertNonLatin1ToLatin1(c); + for (uint16_t c = unibrow::Latin1::kMaxChar + 1; c != 0; c++) { + uint16_t lower = ConvertLatin1<unibrow::ToLowercase, false>(c); + uint16_t upper = ConvertLatin1<unibrow::ToUppercase, false>(c); + uint16_t test = unibrow::Latin1::ConvertNonLatin1ToLatin1(c); // Filter out all character whose upper is not their lower or vice versa. if (lower == 0 && upper == 0) { CheckCanonicalEquivalence(c, test); continue; } - if (lower > Latin1::kMaxChar && upper > Latin1::kMaxChar) { + if (lower > unibrow::Latin1::kMaxChar && + upper > unibrow::Latin1::kMaxChar) { CheckCanonicalEquivalence(c, test); continue; } if (lower == 0 && upper != 0) { - lower = ConvertLatin1<ToLowercase, false>(upper); + lower = ConvertLatin1<unibrow::ToLowercase, false>(upper); } if (upper == 0 && lower != c) { - upper = ConvertLatin1<ToUppercase, false>(lower); + upper = ConvertLatin1<unibrow::ToUppercase, false>(lower); } - if (lower > Latin1::kMaxChar && upper > Latin1::kMaxChar) { + if (lower > unibrow::Latin1::kMaxChar && + upper > unibrow::Latin1::kMaxChar) { CheckCanonicalEquivalence(c, test); continue; } @@ -1668,5 +1666,6 @@ TEST(ExternalStringIndexOf) { .FromJust()); } +} // namespace test_strings } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/test-strtod.cc b/deps/v8/test/cctest/test-strtod.cc index 622886c941..2a9bf99723 100644 --- a/deps/v8/test/cctest/test-strtod.cc +++ b/deps/v8/test/cctest/test-strtod.cc @@ -38,6 +38,7 @@ namespace v8 { namespace internal { +namespace test_strtod { static Vector<const char> StringToVector(const char* str) { return Vector<const char>(str, StrLength(str)); @@ -480,5 +481,6 @@ TEST(RandomStrtod) { } } +} // namespace test_strtod } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/test-symbols.cc b/deps/v8/test/cctest/test-symbols.cc index be37c20717..750ab3c06f 100644 --- a/deps/v8/test/cctest/test-symbols.cc +++ b/deps/v8/test/cctest/test-symbols.cc @@ -33,15 +33,8 @@ #include "src/factory.h" #include "src/isolate.h" #include "src/objects.h" +#include "src/objects/name-inl.h" #include "src/ostreams.h" -// FIXME(mstarzinger, marja): This is weird, but required because of the missing -// (disallowed) include: src/factory.h -> src/objects-inl.h -#include "src/objects-inl.h" -// FIXME(mstarzinger, marja): This is weird, but required because of the missing -// (disallowed) include: src/feedback-vector.h -> -// src/feedback-vector-inl.h -#include "src/feedback-vector-inl.h" -#include "src/v8.h" #include "test/cctest/cctest.h" namespace v8 { diff --git a/deps/v8/test/cctest/test-thread-termination.cc b/deps/v8/test/cctest/test-thread-termination.cc index d288eb7242..0c6c0b6a0a 100644 --- a/deps/v8/test/cctest/test-thread-termination.cc +++ b/deps/v8/test/cctest/test-thread-termination.cc @@ -595,3 +595,29 @@ TEST(TerminateAndTryCall) { CHECK_EQ(4, result.FromJust()); CHECK(!isolate->IsExecutionTerminating()); } + +class ConsoleImpl : public v8::debug::ConsoleDelegate { + private: + void Log(const v8::debug::ConsoleCallArguments& args, + const v8::debug::ConsoleContext&) override { + CompileRun("1 + 1"); + } +}; + +TEST(TerminateConsole) { + i::FLAG_allow_natives_syntax = true; + v8::Isolate* isolate = CcTest::isolate(); + ConsoleImpl console; + v8::debug::SetConsoleDelegate(isolate, &console); + v8::HandleScope scope(isolate); + v8::Local<v8::ObjectTemplate> global = CreateGlobalTemplate( + isolate, TerminateCurrentThread, DoLoopCancelTerminate); + v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global); + v8::Context::Scope context_scope(context); + CHECK(!isolate->IsExecutionTerminating()); + v8::TryCatch try_catch(isolate); + CHECK(!isolate->IsExecutionTerminating()); + CHECK(CompileRun("terminate(); console.log(); fail();").IsEmpty()); + CHECK(try_catch.HasCaught()); + CHECK(!isolate->IsExecutionTerminating()); +} diff --git a/deps/v8/test/cctest/test-transitions.cc b/deps/v8/test/cctest/test-transitions.cc index 2abab39b26..0c49094ce4 100644 --- a/deps/v8/test/cctest/test-transitions.cc +++ b/deps/v8/test/cctest/test-transitions.cc @@ -12,8 +12,6 @@ #include "src/factory.h" #include "src/field-type.h" #include "src/global-handles.h" -// FIXME(mstarzinger, marja): This is weird, but required because of the missing -// (disallowed) include: src/field-type.h -> src/objects-inl.h #include "src/objects-inl.h" #include "src/transitions.h" #include "test/cctest/cctest.h" diff --git a/deps/v8/test/cctest/test-types.cc b/deps/v8/test/cctest/test-types.cc index 46b7858194..782d4fd045 100644 --- a/deps/v8/test/cctest/test-types.cc +++ b/deps/v8/test/cctest/test-types.cc @@ -5,16 +5,10 @@ #include <vector> #include "src/compiler/types.h" -#include "src/factory.h" +#include "src/factory-inl.h" #include "src/heap/heap.h" #include "src/isolate.h" -// FIXME(mstarzinger, marja): This is weird, but required because of the missing -// (disallowed) include: src/factory.h -> src/objects-inl.h -#include "src/objects-inl.h" -// FIXME(mstarzinger, marja): This is weird, but required because of the missing -// (disallowed) include: src/feedback-vector.h -> -// src/feedback-vector-inl.h -#include "src/feedback-vector-inl.h" +#include "src/objects.h" #include "test/cctest/cctest.h" #include "test/cctest/types-fuzz.h" diff --git a/deps/v8/test/cctest/test-unboxed-doubles.cc b/deps/v8/test/cctest/test-unboxed-doubles.cc index 1aaa5bfa12..42b3e355ab 100644 --- a/deps/v8/test/cctest/test-unboxed-doubles.cc +++ b/deps/v8/test/cctest/test-unboxed-doubles.cc @@ -24,8 +24,9 @@ #include "test/cctest/cctest.h" #include "test/cctest/heap/heap-utils.h" -using namespace v8::base; -using namespace v8::internal; +namespace v8 { +namespace internal { +namespace test_unboxed_doubles { #if V8_DOUBLE_FIELDS_UNBOXING @@ -1597,3 +1598,7 @@ TEST(IncrementalWriteBarrierObjectShiftFieldsRight) { // Map::ReconfigureProperty() supports that. #endif + +} // namespace test_unboxed_doubles +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-usecounters.cc b/deps/v8/test/cctest/test-usecounters.cc index 7130137b55..c300361a51 100644 --- a/deps/v8/test/cctest/test-usecounters.cc +++ b/deps/v8/test/cctest/test-usecounters.cc @@ -6,7 +6,9 @@ #include "test/cctest/cctest.h" -namespace { +namespace v8 { +namespace internal { +namespace test_usecounters { int* global_use_counts = NULL; @@ -14,7 +16,6 @@ void MockUseCounterCallback(v8::Isolate* isolate, v8::Isolate::UseCounterFeature feature) { ++global_use_counts[feature]; } -} TEST(DefineGetterSetterThrowUseCount) { i::FLAG_harmony_strict_legacy_accessor_builtins = false; @@ -140,3 +141,7 @@ TEST(LabeledExpressionStatement) { "bat: do { } while (false);"); CHECK_EQ(2, use_counts[v8::Isolate::kLabeledExpressionStatement]); } + +} // namespace test_usecounters +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-utils-arm64.cc b/deps/v8/test/cctest/test-utils-arm64.cc index 6c2229b1a7..5abe0e46d3 100644 --- a/deps/v8/test/cctest/test-utils-arm64.cc +++ b/deps/v8/test/cctest/test-utils-arm64.cc @@ -29,6 +29,7 @@ #include "src/arm64/assembler-arm64-inl.h" #include "src/arm64/utils-arm64.h" +#include "src/base/template-utils.h" #include "src/macro-assembler-inl.h" #include "test/cctest/cctest.h" #include "test/cctest/test-utils-arm64.h" @@ -227,7 +228,6 @@ bool EqualRegisters(const RegisterDump* a, const RegisterDump* b) { return true; } - RegList PopulateRegisterArray(Register* w, Register* x, Register* r, int reg_size, int reg_count, RegList allowed) { RegList list = 0; diff --git a/deps/v8/test/cctest/test-utils-arm64.h b/deps/v8/test/cctest/test-utils-arm64.h index a8a0b0cbf9..f629a17646 100644 --- a/deps/v8/test/cctest/test-utils-arm64.h +++ b/deps/v8/test/cctest/test-utils-arm64.h @@ -212,6 +212,12 @@ bool EqualNzcv(uint32_t expected, uint32_t result); bool EqualRegisters(const RegisterDump* a, const RegisterDump* b); +// Create an array of type {RegType}, size {Size}, filled with {NoReg}. +template <typename RegType, size_t Size> +std::array<RegType, Size> CreateRegisterArray() { + return base::make_array<Size>([](size_t) { return RegType::no_reg(); }); +} + // Populate the w, x and r arrays with registers from the 'allowed' mask. The // r array will be populated with <reg_size>-sized registers, // diff --git a/deps/v8/test/cctest/test-version.cc b/deps/v8/test/cctest/test-version.cc index 78bc81a7e8..301fe58c50 100644 --- a/deps/v8/test/cctest/test-version.cc +++ b/deps/v8/test/cctest/test-version.cc @@ -70,28 +70,6 @@ static void CheckVersion(int major, int minor, int build, int patch, TEST(VersionString) { -#ifdef USE_SIMULATOR - CheckVersion(0, 0, 0, 0, false, "0.0.0 SIMULATOR", "libv8-0.0.0.so"); - CheckVersion(0, 0, 0, 0, true, - "0.0.0 (candidate) SIMULATOR", "libv8-0.0.0-candidate.so"); - CheckVersion(1, 0, 0, 0, false, "1.0.0 SIMULATOR", "libv8-1.0.0.so"); - CheckVersion(1, 0, 0, 0, true, - "1.0.0 (candidate) SIMULATOR", "libv8-1.0.0-candidate.so"); - CheckVersion(1, 0, 0, 1, false, "1.0.0.1 SIMULATOR", "libv8-1.0.0.1.so"); - CheckVersion(1, 0, 0, 1, true, - "1.0.0.1 (candidate) SIMULATOR", "libv8-1.0.0.1-candidate.so"); - CheckVersion(2, 5, 10, 7, false, "2.5.10.7 SIMULATOR", "libv8-2.5.10.7.so"); - CheckVersion(2, 5, 10, 7, true, - "2.5.10.7 (candidate) SIMULATOR", "libv8-2.5.10.7-candidate.so"); - CheckVersion(6, 0, 287, 0, "-emb.1", false, "6.0.287-emb.1 SIMULATOR", - "libv8-6.0.287-emb.1.so"); - CheckVersion(6, 0, 287, 0, "-emb.1", true, "6.0.287-emb.1 (candidate) SIMULATOR", - "libv8-6.0.287-emb.1-candidate.so"); - CheckVersion(6, 0, 287, 53, "-emb.1", false, "6.0.287.53-emb.1 SIMULATOR", - "libv8-6.0.287.53-emb.1.so"); - CheckVersion(6, 0, 287, 53, "-emb.1", true, "6.0.287.53-emb.1 (candidate) SIMULATOR", - "libv8-6.0.287.53-emb.1-candidate.so"); -#else CheckVersion(0, 0, 0, 0, "", false, "0.0.0", "libv8-0.0.0.so"); CheckVersion(0, 0, 0, 0, "", true, "0.0.0 (candidate)", "libv8-0.0.0-candidate.so"); @@ -112,7 +90,6 @@ TEST(VersionString) { "libv8-6.0.287.53-emb.1.so"); CheckVersion(6, 0, 287, 53, "-emb.1", true, "6.0.287.53-emb.1 (candidate)", "libv8-6.0.287.53-emb.1-candidate.so"); -#endif } } // namespace internal diff --git a/deps/v8/test/cctest/test-weakmaps.cc b/deps/v8/test/cctest/test-weakmaps.cc index 13a0c538d9..60f6498022 100644 --- a/deps/v8/test/cctest/test-weakmaps.cc +++ b/deps/v8/test/cctest/test-weakmaps.cc @@ -27,23 +27,16 @@ #include <utility> -#include "src/v8.h" - #include "src/factory.h" #include "src/global-handles.h" #include "src/isolate.h" -// FIXME(mstarzinger, marja): This is weird, but required because of the missing -// (disallowed) include: src/factory.h -> src/objects-inl.h #include "src/objects-inl.h" -// FIXME(mstarzinger, marja): This is weird, but required because of the missing -// (disallowed) include: src/feedback-vector.h -> -// src/feedback-vector-inl.h -#include "src/feedback-vector-inl.h" #include "test/cctest/cctest.h" #include "test/cctest/heap/heap-utils.h" namespace v8 { namespace internal { +namespace test_weakmaps { static Isolate* GetIsolateFrom(LocalContext* context) { return reinterpret_cast<Isolate*>((*context)->GetIsolate()); @@ -191,7 +184,7 @@ TEST(Regress2060a) { Handle<JSObject> object = factory->NewJSObject(function, TENURED); CHECK(!heap->InNewSpace(*object)); CHECK(!first_page->Contains(object->address())); - int32_t hash = object->GetOrCreateHash(isolate)->value(); + int32_t hash = key->GetOrCreateHash(isolate)->value(); JSWeakCollection::Set(weakmap, key, object, hash); } } @@ -263,5 +256,6 @@ TEST(Regress399527) { CcTest::CollectAllGarbage(); } +} // namespace test_weakmaps } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/test-weaksets.cc b/deps/v8/test/cctest/test-weaksets.cc index 9658ac3ed3..900515aadd 100644 --- a/deps/v8/test/cctest/test-weaksets.cc +++ b/deps/v8/test/cctest/test-weaksets.cc @@ -27,23 +27,16 @@ #include <utility> -#include "src/v8.h" - #include "src/factory.h" #include "src/global-handles.h" #include "src/isolate.h" -// FIXME(mstarzinger, marja): This is weird, but required because of the missing -// (disallowed) include: src/factory.h -> src/objects-inl.h #include "src/objects-inl.h" -// FIXME(mstarzinger, marja): This is weird, but required because of the missing -// (disallowed) include: src/feedback-vector.h -> -// src/feedback-vector-inl.h -#include "src/feedback-vector-inl.h" #include "test/cctest/cctest.h" #include "test/cctest/heap/heap-utils.h" namespace v8 { namespace internal { +namespace test_weaksets { static Isolate* GetIsolateFrom(LocalContext* context) { return reinterpret_cast<Isolate*>((*context)->GetIsolate()); @@ -244,5 +237,6 @@ TEST(WeakSet_Regress2060b) { CcTest::CollectAllGarbage(); } +} // namespace test_weaksets } // 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 2cd053767d..c7bb737299 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-64.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-64.cc @@ -16,6 +16,11 @@ #include "test/common/wasm/test-signatures.h" #include "test/common/wasm/wasm-macro-gen.h" +namespace v8 { +namespace internal { +namespace wasm { +namespace test_run_wasm_64 { + // If the target architecture is 64-bit, enable all tests. #if !V8_TARGET_ARCH_32_BIT || V8_TARGET_ARCH_X64 #define WASM_64 1 @@ -23,18 +28,6 @@ #define WASM_64 0 #endif -#define CHECK_TRAP32(x) \ - CHECK_EQ(0xdeadbeef, (bit_cast<uint32_t>(x)) & 0xFFFFFFFF) -#define CHECK_TRAP64(x) \ - CHECK_EQ(0xdeadbeefdeadbeef, (bit_cast<uint64_t>(x)) & 0xFFFFFFFFFFFFFFFF) -#define CHECK_TRAP(x) CHECK_TRAP32(x) - -#define asi64(x) static_cast<int64_t>(x) - -#define asu64(x) static_cast<uint64_t>(x) - -#define B2(a, b) kExprBlock, a, b, kExprEnd - // Can't bridge macro land with nested macros. #if V8_TARGET_ARCH_MIPS #define MIPS true @@ -95,6 +88,8 @@ FOREACH_I64_OPERATOR(DECLARE_CONST) #undef DECLARE_CONST +#undef FOREACH_I64_OPERATOR + #define REQUIRE(name) \ if (!WASM_64 && !kSupported_##name) return @@ -274,11 +269,11 @@ WASM_EXEC_TEST(I64DivS_Trap) { REQUIRE(I64DivS); WasmRunner<int64_t, int64_t, int64_t> r(execution_mode); BUILD(r, WASM_I64_DIVS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); - CHECK_EQ(0, r.Call(asi64(0), asi64(100))); - CHECK_TRAP64(r.Call(asi64(100), asi64(0))); - CHECK_TRAP64(r.Call(asi64(-1001), asi64(0))); - CHECK_TRAP64(r.Call(std::numeric_limits<int64_t>::min(), asi64(-1))); - CHECK_TRAP64(r.Call(std::numeric_limits<int64_t>::min(), asi64(0))); + CHECK_EQ(0, r.Call(int64_t{0}, int64_t{100})); + CHECK_TRAP64(r.Call(int64_t{100}, int64_t{0})); + CHECK_TRAP64(r.Call(int64_t{-1001}, int64_t{0})); + CHECK_TRAP64(r.Call(std::numeric_limits<int64_t>::min(), int64_t{-1})); + CHECK_TRAP64(r.Call(std::numeric_limits<int64_t>::min(), int64_t{0})); } WASM_EXEC_TEST(I64DivS_Byzero_Const) { @@ -315,10 +310,10 @@ WASM_EXEC_TEST(I64DivU_Trap) { REQUIRE(I64DivU); WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_mode); BUILD(r, WASM_I64_DIVU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); - CHECK_EQ(0, r.Call(asu64(0), asu64(100))); - CHECK_TRAP64(r.Call(asu64(100), asu64(0))); - CHECK_TRAP64(r.Call(asu64(1001), asu64(0))); - CHECK_TRAP64(r.Call(std::numeric_limits<uint64_t>::max(), asu64(0))); + CHECK_EQ(0, r.Call(uint64_t{0}, uint64_t{100})); + CHECK_TRAP64(r.Call(uint64_t{100}, uint64_t{0})); + CHECK_TRAP64(r.Call(uint64_t{1001}, uint64_t{0})); + CHECK_TRAP64(r.Call(std::numeric_limits<uint64_t>::max(), uint64_t{0})); } WASM_EXEC_TEST(I64DivU_Byzero_Const) { @@ -356,11 +351,11 @@ WASM_EXEC_TEST(I64RemS_Trap) { REQUIRE(I64RemS); WasmRunner<int64_t, int64_t, int64_t> r(execution_mode); BUILD(r, WASM_I64_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); - CHECK_EQ(33, r.Call(asi64(133), asi64(100))); - CHECK_EQ(0, r.Call(std::numeric_limits<int64_t>::min(), asi64(-1))); - CHECK_TRAP64(r.Call(asi64(100), asi64(0))); - CHECK_TRAP64(r.Call(asi64(-1001), asi64(0))); - CHECK_TRAP64(r.Call(std::numeric_limits<int64_t>::min(), asi64(0))); + 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})); + CHECK_TRAP64(r.Call(int64_t{100}, int64_t{0})); + CHECK_TRAP64(r.Call(int64_t{-1001}, int64_t{0})); + CHECK_TRAP64(r.Call(std::numeric_limits<int64_t>::min(), int64_t{0})); } WASM_EXEC_TEST(I64RemU) { @@ -382,10 +377,10 @@ WASM_EXEC_TEST(I64RemU_Trap) { REQUIRE(I64RemU); WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_mode); BUILD(r, WASM_I64_REMU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); - CHECK_EQ(17, r.Call(asu64(217), asu64(100))); - CHECK_TRAP64(r.Call(asu64(100), asu64(0))); - CHECK_TRAP64(r.Call(asu64(1001), asu64(0))); - CHECK_TRAP64(r.Call(std::numeric_limits<uint64_t>::max(), asu64(0))); + CHECK_EQ(17, r.Call(uint64_t{217}, uint64_t{100})); + CHECK_TRAP64(r.Call(uint64_t{100}, uint64_t{0})); + CHECK_TRAP64(r.Call(uint64_t{1001}, uint64_t{0})); + CHECK_TRAP64(r.Call(std::numeric_limits<uint64_t>::max(), uint64_t{0})); } WASM_EXEC_TEST(I64And) { @@ -998,6 +993,8 @@ WASM_EXEC_TEST(I64Binops) { TEST_I64_BINOP(I64Rol, 8728493013947314237, 0xe07af243ac4d219d, 15); } +#undef TEST_I64_BINOP + #define TEST_I64_CMP(name, expected, a, b) \ do { \ if (WASM_64 || kSupported_##name) \ @@ -1017,6 +1014,8 @@ WASM_EXEC_TEST(I64Compare) { TEST_I64_CMP(I64GeU, 0, 0x0886A0C58C7AA224, 0x5DDBE5A81FD7EE47); } +#undef TEST_I64_CMP + WASM_EXEC_TEST(I64Clz) { REQUIRE(I64Clz); struct { @@ -1476,7 +1475,7 @@ WASM_EXEC_TEST(I64Ror) { FOR_UINT64_INPUTS(i) { FOR_UINT64_INPUTS(j) { - int64_t expected = bits::RotateRight64(*i, *j & 0x3f); + int64_t expected = base::bits::RotateRight64(*i, *j & 0x3f); CHECK_EQ(expected, r.Call(*i, *j)); } } @@ -1489,7 +1488,7 @@ WASM_EXEC_TEST(I64Rol) { FOR_UINT64_INPUTS(i) { FOR_UINT64_INPUTS(j) { - int64_t expected = bits::RotateLeft64(*i, *j & 0x3f); + int64_t expected = base::bits::RotateLeft64(*i, *j & 0x3f); CHECK_EQ(expected, r.Call(*i, *j)); } } @@ -1519,7 +1518,7 @@ WASM_EXEC_TEST(StoreMem_offset_oob_i64) { CHECK_EQ(0, memcmp(&memory[0], &memory[8 + boundary], memsize)); for (uint32_t offset = boundary + 1; offset < boundary + 19; offset++) { - CHECK_TRAP(r.Call(offset)); // out of bounds. + CHECK_TRAP32(r.Call(offset)); // out of bounds. } } } @@ -1668,3 +1667,28 @@ WASM_EXEC_TEST(Regress5874) { r.Call(); } + +WASM_EXEC_TEST(Regression_6858) { + REQUIRE(I64DivS); + // WasmRunner with 5 params and returns, which is the maximum. + WasmRunner<int64_t, int64_t, int64_t, int64_t, int64_t> r(execution_mode); + BUILD(r, WASM_I64_DIVS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); + int64_t dividend = 15; + int64_t divisor = 0; + int64_t filler = 34; + CHECK_TRAP64(r.Call(dividend, divisor, filler, filler)); +} + +#undef WASM_64 +#undef MIPS +#undef REQUIRE +#undef ADD_CODE + +// clang-format gets confused about these closing parentheses (wants to change +// the first comment to "// namespace v8". Disable it. +// clang-format off +} // namespace test_run_wasm_64 +} // namespace wasm +} // namespace internal +} // namespace v8 +// clang-format on 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 75823cdfa2..9e15c46f8d 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-asmjs.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-asmjs.cc @@ -15,27 +15,9 @@ #include "test/common/wasm/test-signatures.h" #include "test/common/wasm/wasm-macro-gen.h" -using namespace v8::base; -using namespace v8::internal; -using namespace v8::internal::compiler; -using namespace v8::internal::wasm; - -// for even shorter tests. -#define B2(a, b) kExprBlock, a, b, kExprEnd -#define B1(a) kExprBlock, a, kExprEnd -#define RET(x) x, kExprReturn, 1 -#define RET_I8(x) kExprI8Const, x, kExprReturn, 1 - -namespace { -uint32_t GetMatchingRelocInfoCount(Handle<Code> code, RelocInfo::Mode rmode) { - int filter = 1 << rmode; - uint32_t ret = 0; - for (RelocIterator it(*code, filter); !it.done(); it.next()) { - ++ret; - } - return ret; -} -} +namespace v8 { +namespace internal { +namespace wasm { WASM_EXEC_TEST(Int32AsmjsDivS) { WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); @@ -213,88 +195,6 @@ WASM_EXEC_TEST(StoreMemI32_oob_asm) { } } -#define FOREACH_INT_CHECKED_LOAD_OP(TEST_BODY) \ - TEST_BODY(kExprI32AsmjsLoadMem8S) \ - TEST_BODY(kExprI32AsmjsLoadMem8U) \ - TEST_BODY(kExprI32AsmjsLoadMem16S) \ - TEST_BODY(kExprI32AsmjsLoadMem16U) \ - TEST_BODY(kExprI32AsmjsLoadMem) - -#define FOREACH_INT_CHECKED_STORE_OP(TEST_BODY) \ - TEST_BODY(kExprI32AsmjsStoreMem8) \ - TEST_BODY(kExprI32AsmjsStoreMem16) \ - TEST_BODY(kExprI32AsmjsStoreMem) - -#define INT_LOAD_TEST(OP_TYPE) \ - TEST(RunWasm_AsmCheckedRelocInfo##OP_TYPE) { \ - WasmRunner<int32_t, uint32_t> r(kExecuteCompiled); \ - r.builder().ChangeOriginToAsmjs(); \ - BUILD(r, WASM_UNOP(OP_TYPE, WASM_GET_LOCAL(0))); \ - CHECK_EQ(1, GetMatchingRelocInfoCount(r.builder().GetFunctionCode(0), \ - RelocInfo::WASM_MEMORY_REFERENCE)); \ - CHECK_NE( \ - 0, GetMatchingRelocInfoCount(r.builder().GetFunctionCode(0), \ - RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); \ - } - -FOREACH_INT_CHECKED_LOAD_OP(INT_LOAD_TEST) - -#define INT_STORE_TEST(OP_TYPE) \ - TEST(RunWasm_AsmCheckedRelocInfo##OP_TYPE) { \ - WasmRunner<int32_t, uint32_t, uint32_t> r(kExecuteCompiled); \ - r.builder().ChangeOriginToAsmjs(); \ - BUILD(r, WASM_BINOP(OP_TYPE, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); \ - CHECK_EQ(1, GetMatchingRelocInfoCount(r.builder().GetFunctionCode(0), \ - RelocInfo::WASM_MEMORY_REFERENCE)); \ - CHECK_NE( \ - 0, GetMatchingRelocInfoCount(r.builder().GetFunctionCode(0), \ - RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); \ - } - -FOREACH_INT_CHECKED_STORE_OP(INT_STORE_TEST) - -TEST(RunWasm_AsmCheckedLoadFloat32RelocInfo) { - WasmRunner<float, uint32_t> r(kExecuteCompiled); - r.builder().ChangeOriginToAsmjs(); - BUILD(r, WASM_UNOP(kExprF32AsmjsLoadMem, WASM_GET_LOCAL(0))); - - CHECK_EQ(1, GetMatchingRelocInfoCount(r.builder().GetFunctionCode(0), - RelocInfo::WASM_MEMORY_REFERENCE)); - CHECK_NE(0, GetMatchingRelocInfoCount(r.builder().GetFunctionCode(0), - RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); -} - -TEST(RunWasm_AsmCheckedStoreFloat32RelocInfo) { - WasmRunner<float, uint32_t, float> r(kExecuteCompiled); - r.builder().ChangeOriginToAsmjs(); - BUILD(r, WASM_BINOP(kExprF32AsmjsStoreMem, WASM_GET_LOCAL(0), - WASM_GET_LOCAL(1))); - - CHECK_EQ(1, GetMatchingRelocInfoCount(r.builder().GetFunctionCode(0), - RelocInfo::WASM_MEMORY_REFERENCE)); - CHECK_NE(0, GetMatchingRelocInfoCount(r.builder().GetFunctionCode(0), - RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); -} - -TEST(RunWasm_AsmCheckedLoadFloat64RelocInfo) { - WasmRunner<double, uint32_t> r(kExecuteCompiled); - r.builder().ChangeOriginToAsmjs(); - BUILD(r, WASM_UNOP(kExprF64AsmjsLoadMem, WASM_GET_LOCAL(0))); - - CHECK_EQ(1, GetMatchingRelocInfoCount(r.builder().GetFunctionCode(0), - RelocInfo::WASM_MEMORY_REFERENCE)); - CHECK_NE(0, GetMatchingRelocInfoCount(r.builder().GetFunctionCode(0), - RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); -} - -TEST(RunWasm_AsmCheckedStoreFloat64RelocInfo) { - WasmRunner<double, uint32_t, double> r(kExecuteCompiled); - r.builder().ChangeOriginToAsmjs(); - BUILD(r, WASM_BINOP(kExprF64AsmjsStoreMem, WASM_GET_LOCAL(0), - WASM_GET_LOCAL(1))); - - CHECK_EQ(1, GetMatchingRelocInfoCount(r.builder().GetFunctionCode(0), - RelocInfo::WASM_MEMORY_REFERENCE)); - CHECK_NE(0, GetMatchingRelocInfoCount(r.builder().GetFunctionCode(0), - RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); -} +} // namespace wasm +} // namespace internal +} // namespace v8 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 70b273aa48..cb291b8741 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-atomics.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-atomics.cc @@ -2,14 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "src/objects-inl.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/value-helper.h" #include "test/cctest/wasm/wasm-run-utils.h" #include "test/common/wasm/wasm-macro-gen.h" -#define WASM_ATOMICS_OP(op) kAtomicPrefix, static_cast<byte>(op) -#define WASM_ATOMICS_BINOP(op, x, y) x, y, WASM_ATOMICS_OP(op) -#define WASM_ATOMICS_TERNARY_OP(op, x, y, z) x, y, z, WASM_ATOMICS_OP(op) +namespace v8 { +namespace internal { +namespace wasm { typedef uint32_t (*Uint32BinOp)(uint32_t, uint32_t); typedef uint16_t (*Uint16BinOp)(uint16_t, uint16_t); @@ -55,8 +56,10 @@ void RunU32BinOp(WasmOpcode wasm_op, Uint32BinOp expected_op) { EXPERIMENTAL_FLAG_SCOPE(threads); WasmRunner<uint32_t, uint32_t> r(kExecuteCompiled); uint32_t* memory = r.builder().AddMemoryElems<uint32_t>(8); + r.builder().SetHasSharedMemory(); - BUILD(r, WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_1(0), WASM_GET_LOCAL(0))); + BUILD(r, WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_1(0), WASM_GET_LOCAL(0), + MachineRepresentation::kWord32)); FOR_UINT32_INPUTS(i) { uint32_t initial = *i; @@ -69,19 +72,21 @@ void RunU32BinOp(WasmOpcode wasm_op, Uint32BinOp expected_op) { } } -WASM_EXEC_TEST(I32Add) { RunU32BinOp(kExprI32AtomicAdd, Add); } -WASM_EXEC_TEST(I32Sub) { RunU32BinOp(kExprI32AtomicSub, Sub); } -WASM_EXEC_TEST(I32And) { RunU32BinOp(kExprI32AtomicAnd, And); } -WASM_EXEC_TEST(I32Or) { RunU32BinOp(kExprI32AtomicOr, Or); } -WASM_EXEC_TEST(I32Xor) { RunU32BinOp(kExprI32AtomicXor, Xor); } -WASM_EXEC_TEST(I32Exchange) { RunU32BinOp(kExprI32AtomicExchange, Exchange); } +TEST(I32AtomicAdd) { RunU32BinOp(kExprI32AtomicAdd, Add); } +TEST(I32AtomicSub) { RunU32BinOp(kExprI32AtomicSub, Sub); } +TEST(I32AtomicAnd) { RunU32BinOp(kExprI32AtomicAnd, And); } +TEST(I32AtomicOr) { RunU32BinOp(kExprI32AtomicOr, Or); } +TEST(I32AtomicXor) { RunU32BinOp(kExprI32AtomicXor, Xor); } +TEST(I32AtomicExchange) { RunU32BinOp(kExprI32AtomicExchange, Exchange); } void RunU16BinOp(WasmOpcode wasm_op, Uint16BinOp expected_op) { EXPERIMENTAL_FLAG_SCOPE(threads); WasmRunner<uint32_t, uint32_t> r(kExecuteCompiled); + r.builder().SetHasSharedMemory(); uint16_t* memory = r.builder().AddMemoryElems<uint16_t>(8); - BUILD(r, WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_1(0), WASM_GET_LOCAL(0))); + BUILD(r, WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_1(0), WASM_GET_LOCAL(0), + MachineRepresentation::kWord16)); FOR_UINT16_INPUTS(i) { uint16_t initial = *i; @@ -94,21 +99,21 @@ void RunU16BinOp(WasmOpcode wasm_op, Uint16BinOp expected_op) { } } -WASM_EXEC_TEST(I32Add16U) { RunU16BinOp(kExprI32AtomicAdd16U, Add); } -WASM_EXEC_TEST(I32Sub16U) { RunU16BinOp(kExprI32AtomicSub16U, Sub); } -WASM_EXEC_TEST(I32And16U) { RunU16BinOp(kExprI32AtomicAnd16U, And); } -WASM_EXEC_TEST(I32Or16U) { RunU16BinOp(kExprI32AtomicOr16U, Or); } -WASM_EXEC_TEST(I32Xor16U) { RunU16BinOp(kExprI32AtomicXor16U, Xor); } -WASM_EXEC_TEST(I32Exchange16U) { - RunU16BinOp(kExprI32AtomicExchange16U, Exchange); -} +TEST(I32AtomicAdd16U) { RunU16BinOp(kExprI32AtomicAdd16U, Add); } +TEST(I32AtomicSub16U) { RunU16BinOp(kExprI32AtomicSub16U, Sub); } +TEST(I32AtomicAnd16U) { RunU16BinOp(kExprI32AtomicAnd16U, And); } +TEST(I32AtomicOr16U) { RunU16BinOp(kExprI32AtomicOr16U, Or); } +TEST(I32AtomicXor16U) { RunU16BinOp(kExprI32AtomicXor16U, Xor); } +TEST(I32AtomicExchange16U) { RunU16BinOp(kExprI32AtomicExchange16U, Exchange); } void RunU8BinOp(WasmOpcode wasm_op, Uint8BinOp expected_op) { EXPERIMENTAL_FLAG_SCOPE(threads); WasmRunner<uint32_t, uint32_t> r(kExecuteCompiled); + r.builder().SetHasSharedMemory(); uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(8); - BUILD(r, WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_1(0), WASM_GET_LOCAL(0))); + BUILD(r, WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_1(0), WASM_GET_LOCAL(0), + MachineRepresentation::kWord8)); FOR_UINT8_INPUTS(i) { uint8_t initial = *i; @@ -121,22 +126,21 @@ void RunU8BinOp(WasmOpcode wasm_op, Uint8BinOp expected_op) { } } -WASM_EXEC_TEST(I32Add8U) { RunU8BinOp(kExprI32AtomicAdd8U, Add); } -WASM_EXEC_TEST(I32Sub8U) { RunU8BinOp(kExprI32AtomicSub8U, Sub); } -WASM_EXEC_TEST(I32And8U) { RunU8BinOp(kExprI32AtomicAnd8U, And); } -WASM_EXEC_TEST(I32Or8U) { RunU8BinOp(kExprI32AtomicOr8U, Or); } -WASM_EXEC_TEST(I32Xor8U) { RunU8BinOp(kExprI32AtomicXor8U, Xor); } -WASM_EXEC_TEST(I32Exchange8U) { - RunU8BinOp(kExprI32AtomicExchange8U, Exchange); -} +TEST(I32AtomicAdd8U) { RunU8BinOp(kExprI32AtomicAdd8U, Add); } +TEST(I32AtomicSub8U) { RunU8BinOp(kExprI32AtomicSub8U, Sub); } +TEST(I32AtomicAnd8U) { RunU8BinOp(kExprI32AtomicAnd8U, And); } +TEST(I32AtomicOr8U) { RunU8BinOp(kExprI32AtomicOr8U, Or); } +TEST(I32AtomicXor8U) { RunU8BinOp(kExprI32AtomicXor8U, Xor); } +TEST(I32AtomicExchange8U) { RunU8BinOp(kExprI32AtomicExchange8U, Exchange); } -WASM_EXEC_TEST(I32CompareExchange) { +TEST(I32AtomicCompareExchange) { EXPERIMENTAL_FLAG_SCOPE(threads); WasmRunner<uint32_t, uint32_t, uint32_t> r(kExecuteCompiled); + r.builder().SetHasSharedMemory(); uint32_t* memory = r.builder().AddMemoryElems<uint32_t>(8); - BUILD(r, - WASM_ATOMICS_TERNARY_OP(kExprI32AtomicCompareExchange, WASM_I32V_1(0), - WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); + BUILD(r, WASM_ATOMICS_TERNARY_OP( + kExprI32AtomicCompareExchange, WASM_I32V_1(0), WASM_GET_LOCAL(0), + WASM_GET_LOCAL(1), MachineRepresentation::kWord32)); FOR_UINT32_INPUTS(i) { uint32_t initial = *i; @@ -149,13 +153,15 @@ WASM_EXEC_TEST(I32CompareExchange) { } } -WASM_EXEC_TEST(I32CompareExchange16U) { +TEST(I32AtomicCompareExchange16U) { EXPERIMENTAL_FLAG_SCOPE(threads); WasmRunner<uint32_t, uint32_t, uint32_t> r(kExecuteCompiled); + r.builder().SetHasSharedMemory(); uint16_t* memory = r.builder().AddMemoryElems<uint16_t>(8); BUILD(r, WASM_ATOMICS_TERNARY_OP(kExprI32AtomicCompareExchange16U, WASM_I32V_1(0), WASM_GET_LOCAL(0), - WASM_GET_LOCAL(1))); + WASM_GET_LOCAL(1), + MachineRepresentation::kWord16)); FOR_UINT16_INPUTS(i) { uint16_t initial = *i; @@ -168,13 +174,15 @@ WASM_EXEC_TEST(I32CompareExchange16U) { } } -WASM_EXEC_TEST(I32CompareExchange8U) { +TEST(I32AtomicCompareExchange8U) { EXPERIMENTAL_FLAG_SCOPE(threads); WasmRunner<uint32_t, uint32_t, uint32_t> r(kExecuteCompiled); + r.builder().SetHasSharedMemory(); uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(8); BUILD(r, WASM_ATOMICS_TERNARY_OP(kExprI32AtomicCompareExchange8U, WASM_I32V_1(0), - WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); + WASM_GET_LOCAL(0), WASM_GET_LOCAL(1), + MachineRepresentation::kWord8)); FOR_UINT8_INPUTS(i) { uint8_t initial = *i; @@ -186,3 +194,110 @@ WASM_EXEC_TEST(I32CompareExchange8U) { } } } + +TEST(I32AtomicLoad) { + EXPERIMENTAL_FLAG_SCOPE(threads); + WasmRunner<uint32_t> r(kExecuteCompiled); + r.builder().SetHasSharedMemory(); + uint32_t* memory = r.builder().AddMemoryElems<uint32_t>(8); + BUILD(r, WASM_ATOMICS_LOAD_OP(kExprI32AtomicLoad, WASM_ZERO, + MachineRepresentation::kWord32)); + + FOR_UINT32_INPUTS(i) { + uint32_t expected = *i; + r.builder().WriteMemory(&memory[0], expected); + CHECK_EQ(expected, r.Call()); + } +} + +TEST(I32AtomicLoad16U) { + EXPERIMENTAL_FLAG_SCOPE(threads); + WasmRunner<uint32_t> r(kExecuteCompiled); + r.builder().SetHasSharedMemory(); + uint16_t* memory = r.builder().AddMemoryElems<uint16_t>(8); + BUILD(r, WASM_ATOMICS_LOAD_OP(kExprI32AtomicLoad16U, WASM_ZERO, + MachineRepresentation::kWord16)); + + FOR_UINT16_INPUTS(i) { + uint16_t expected = *i; + r.builder().WriteMemory(&memory[0], expected); + CHECK_EQ(expected, r.Call()); + } +} + +TEST(I32AtomicLoad8U) { + EXPERIMENTAL_FLAG_SCOPE(threads); + WasmRunner<uint32_t> r(kExecuteCompiled); + r.builder().SetHasSharedMemory(); + uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(8); + BUILD(r, WASM_ATOMICS_LOAD_OP(kExprI32AtomicLoad8U, WASM_ZERO, + MachineRepresentation::kWord8)); + + FOR_UINT8_INPUTS(i) { + uint8_t expected = *i; + r.builder().WriteMemory(&memory[0], expected); + CHECK_EQ(expected, r.Call()); + } +} + +TEST(I32AtomicStoreLoad) { + EXPERIMENTAL_FLAG_SCOPE(threads); + WasmRunner<uint32_t, uint32_t> r(kExecuteCompiled); + r.builder().SetHasSharedMemory(); + uint32_t* memory = r.builder().AddMemoryElems<uint32_t>(8); + + BUILD(r, + WASM_ATOMICS_STORE_OP(kExprI32AtomicStore, WASM_ZERO, WASM_GET_LOCAL(0), + MachineRepresentation::kWord32), + WASM_ATOMICS_LOAD_OP(kExprI32AtomicLoad, WASM_ZERO, + MachineRepresentation::kWord32)); + + FOR_UINT32_INPUTS(i) { + uint32_t expected = *i; + CHECK_EQ(expected, r.Call(*i)); + CHECK_EQ(expected, r.builder().ReadMemory(&memory[0])); + } +} + +TEST(I32AtomicStoreLoad16U) { + EXPERIMENTAL_FLAG_SCOPE(threads); + WasmRunner<uint32_t, uint32_t> r(kExecuteCompiled); + r.builder().SetHasSharedMemory(); + uint16_t* memory = r.builder().AddMemoryElems<uint16_t>(8); + + BUILD( + r, + WASM_ATOMICS_STORE_OP(kExprI32AtomicStore16U, WASM_ZERO, + WASM_GET_LOCAL(0), MachineRepresentation::kWord16), + WASM_ATOMICS_LOAD_OP(kExprI32AtomicLoad16U, WASM_ZERO, + MachineRepresentation::kWord16)); + + FOR_UINT16_INPUTS(i) { + uint16_t expected = *i; + CHECK_EQ(expected, r.Call(*i)); + CHECK_EQ(expected, r.builder().ReadMemory(&memory[0])); + } +} + +TEST(I32AtomicStoreLoad8U) { + EXPERIMENTAL_FLAG_SCOPE(threads); + WasmRunner<uint32_t, uint32_t> r(kExecuteCompiled); + r.builder().SetHasSharedMemory(); + uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(8); + + BUILD(r, + WASM_ATOMICS_STORE_OP(kExprI32AtomicStore8U, WASM_ZERO, + WASM_GET_LOCAL(0), MachineRepresentation::kWord8), + WASM_ATOMICS_LOAD_OP(kExprI32AtomicLoad8U, WASM_ZERO, + MachineRepresentation::kWord8)); + + FOR_UINT8_INPUTS(i) { + uint8_t expected = *i; + CHECK_EQ(expected, r.Call(*i)); + CHECK_EQ(*i, r.builder().ReadMemory(&memory[0])); + } +} + +} // namespace wasm +} // namespace internal +} // namespace v8 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 44a29b980d..10ba64c993 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-interpreter.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-interpreter.cc @@ -16,14 +16,10 @@ #include "test/common/wasm/test-signatures.h" #include "test/common/wasm/wasm-macro-gen.h" -using namespace v8::base; -using namespace v8::internal; -using namespace v8::internal::compiler; -using namespace v8::internal::wasm; - namespace v8 { namespace internal { namespace wasm { +namespace test_run_wasm_interpreter { TEST(Run_WasmInt8Const_i) { WasmRunner<int32_t> r(kExecuteInterpreted); @@ -428,6 +424,7 @@ TEST(InterpreterLoadWithoutMemory) { CHECK_TRAP32(r.Call(0)); } +} // namespace test_run_wasm_interpreter } // namespace wasm } // namespace internal } // namespace v8 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 8bbe59b8c2..e4bb9b0822 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-js.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-js.cc @@ -14,16 +14,9 @@ #include "test/common/wasm/test-signatures.h" #include "test/common/wasm/wasm-macro-gen.h" -using namespace v8::base; -using namespace v8::internal; -using namespace v8::internal::compiler; -using namespace v8::internal::wasm; - -#define BUILD(r, ...) \ - do { \ - byte code[] = {__VA_ARGS__}; \ - r.Build(code, code + arraysize(code)); \ - } while (false) +namespace v8 { +namespace internal { +namespace wasm { #define ADD_CODE(vec, ...) \ do { \ @@ -47,7 +40,7 @@ class PredictableInputValues { }; uint32_t AddJSSelector(TestingModuleBuilder* builder, FunctionSig* sig, - int which) { + int which, Handle<FixedArray> js_imports_table) { const int kMaxParams = 11; static const char* formals[kMaxParams] = {"", "a", @@ -68,7 +61,7 @@ uint32_t AddJSSelector(TestingModuleBuilder* builder, FunctionSig* sig, SNPrintF(source, "(function(%s) { return %c; })", formals[sig->parameter_count()], param); - return builder->AddJsFunction(sig, source.start()); + return builder->AddJsFunction(sig, source.start(), js_imports_table); } void EXPECT_CALL(double expected, Handle<JSFunction> jsfunc, @@ -84,7 +77,7 @@ void EXPECT_CALL(double expected, Handle<JSFunction> jsfunc, CHECK_EQ(expected, Smi::ToInt(*result)); } else { CHECK(result->IsHeapNumber()); - CheckFloatEq(expected, HeapNumber::cast(*result)->value()); + CHECK_FLOAT_EQ(expected, HeapNumber::cast(*result)->value()); } } @@ -97,8 +90,8 @@ void EXPECT_CALL(double expected, Handle<JSFunction> jsfunc, double a, } } // namespace -TEST(Run_Int32Sub_jswrapped) { - WasmRunner<int, int, int> r(kExecuteCompiled); +WASM_EXEC_TEST(Run_Int32Sub_jswrapped) { + WasmRunner<int, int, int> r(execution_mode); BUILD(r, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); Handle<JSFunction> jsfunc = r.builder().WrapCode(r.function()->func_index); @@ -106,8 +99,8 @@ TEST(Run_Int32Sub_jswrapped) { EXPECT_CALL(-8723487, jsfunc, -8000000, 723487); } -TEST(Run_Float32Div_jswrapped) { - WasmRunner<float, float, float> r(kExecuteCompiled); +WASM_EXEC_TEST(Run_Float32Div_jswrapped) { + WasmRunner<float, float, float> r(execution_mode); BUILD(r, WASM_F32_DIV(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); Handle<JSFunction> jsfunc = r.builder().WrapCode(r.function()->func_index); @@ -115,8 +108,8 @@ TEST(Run_Float32Div_jswrapped) { EXPECT_CALL(64, jsfunc, -16, -0.25); } -TEST(Run_Float64Add_jswrapped) { - WasmRunner<double, double, double> r(kExecuteCompiled); +WASM_EXEC_TEST(Run_Float64Add_jswrapped) { + WasmRunner<double, double, double> r(execution_mode); BUILD(r, WASM_F64_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); Handle<JSFunction> jsfunc = r.builder().WrapCode(r.function()->func_index); @@ -124,8 +117,8 @@ TEST(Run_Float64Add_jswrapped) { EXPECT_CALL(-5.5, jsfunc, -5.25, -0.25); } -TEST(Run_I32Popcount_jswrapped) { - WasmRunner<int, int> r(kExecuteCompiled); +WASM_EXEC_TEST(Run_I32Popcount_jswrapped) { + WasmRunner<int, int> r(execution_mode); BUILD(r, WASM_I32_POPCNT(WASM_GET_LOCAL(0))); Handle<JSFunction> jsfunc = r.builder().WrapCode(r.function()->func_index); @@ -134,11 +127,13 @@ TEST(Run_I32Popcount_jswrapped) { EXPECT_CALL(6, jsfunc, 0x3F, 0); } -TEST(Run_CallJS_Add_jswrapped) { - WasmRunner<int, int> r(kExecuteCompiled); +WASM_EXEC_TEST(Run_CallJS_Add_jswrapped) { + WasmRunner<int, int> r(execution_mode); TestSignatures sigs; - uint32_t js_index = - r.builder().AddJsFunction(sigs.i_i(), "(function(a) { return a + 99; })"); + Handle<FixedArray> js_imports_table = + r.main_isolate()->factory()->NewFixedArray(2 * 3 + 1, TENURED); + uint32_t js_index = r.builder().AddJsFunction( + sigs.i_i(), "(function(a) { return a + 99; })", js_imports_table); BUILD(r, WASM_CALL_FUNCTION(js_index, WASM_GET_LOCAL(0))); Handle<JSFunction> jsfunc = r.builder().WrapCode(r.function()->func_index); @@ -148,7 +143,7 @@ TEST(Run_CallJS_Add_jswrapped) { EXPECT_CALL(-666666801, jsfunc, -666666900, -1); } -void RunJSSelectTest(int which) { +void RunJSSelectTest(WasmExecutionMode mode, int which) { const int kMaxParams = 8; PredictableInputValues inputs(0x100); ValueType type = kWasmF64; @@ -158,8 +153,12 @@ void RunJSSelectTest(int which) { HandleScope scope(CcTest::InitIsolateOnce()); FunctionSig sig(1, num_params, types); - WasmRunner<void> r(kExecuteCompiled); - uint32_t js_index = AddJSSelector(&r.builder(), &sig, which); + WasmRunner<void> r(mode); + Handle<FixedArray> js_imports_table = + scope.isolate()->factory()->NewFixedArray(2 * 3 + 1, TENURED); + uint32_t js_index = + AddJSSelector(&r.builder(), &sig, which, js_imports_table); + WasmFunctionCompiler& t = r.NewFunction(&sig); { @@ -182,47 +181,47 @@ void RunJSSelectTest(int which) { } } -TEST(Run_JSSelect_0) { +WASM_EXEC_TEST(Run_JSSelect_0) { CcTest::InitializeVM(); - RunJSSelectTest(0); + RunJSSelectTest(execution_mode, 0); } -TEST(Run_JSSelect_1) { +WASM_EXEC_TEST(Run_JSSelect_1) { CcTest::InitializeVM(); - RunJSSelectTest(1); + RunJSSelectTest(execution_mode, 1); } -TEST(Run_JSSelect_2) { +WASM_EXEC_TEST(Run_JSSelect_2) { CcTest::InitializeVM(); - RunJSSelectTest(2); + RunJSSelectTest(execution_mode, 2); } -TEST(Run_JSSelect_3) { +WASM_EXEC_TEST(Run_JSSelect_3) { CcTest::InitializeVM(); - RunJSSelectTest(3); + RunJSSelectTest(execution_mode, 3); } -TEST(Run_JSSelect_4) { +WASM_EXEC_TEST(Run_JSSelect_4) { CcTest::InitializeVM(); - RunJSSelectTest(4); + RunJSSelectTest(execution_mode, 4); } -TEST(Run_JSSelect_5) { +WASM_EXEC_TEST(Run_JSSelect_5) { CcTest::InitializeVM(); - RunJSSelectTest(5); + RunJSSelectTest(execution_mode, 5); } -TEST(Run_JSSelect_6) { +WASM_EXEC_TEST(Run_JSSelect_6) { CcTest::InitializeVM(); - RunJSSelectTest(6); + RunJSSelectTest(execution_mode, 6); } -TEST(Run_JSSelect_7) { +WASM_EXEC_TEST(Run_JSSelect_7) { CcTest::InitializeVM(); - RunJSSelectTest(7); + RunJSSelectTest(execution_mode, 7); } -void RunWASMSelectTest(int which) { +void RunWASMSelectTest(WasmExecutionMode mode, int which) { PredictableInputValues inputs(0x200); Isolate* isolate = CcTest::InitIsolateOnce(); const int kMaxParams = 8; @@ -232,7 +231,7 @@ void RunWASMSelectTest(int which) { type, type, type, type}; FunctionSig sig(1, num_params, types); - WasmRunner<void> r(kExecuteCompiled); + WasmRunner<void> r(mode); WasmFunctionCompiler& t = r.NewFunction(&sig); BUILD(t, WASM_GET_LOCAL(which)); Handle<JSFunction> jsfunc = r.builder().WrapCode(t.function_index()); @@ -253,47 +252,48 @@ void RunWASMSelectTest(int which) { } } -TEST(Run_WASMSelect_0) { +WASM_EXEC_TEST(Run_WASMSelect_0) { CcTest::InitializeVM(); - RunWASMSelectTest(0); + RunWASMSelectTest(execution_mode, 0); } -TEST(Run_WASMSelect_1) { +WASM_EXEC_TEST(Run_WASMSelect_1) { CcTest::InitializeVM(); - RunWASMSelectTest(1); + RunWASMSelectTest(execution_mode, 1); } -TEST(Run_WASMSelect_2) { +WASM_EXEC_TEST(Run_WASMSelect_2) { CcTest::InitializeVM(); - RunWASMSelectTest(2); + RunWASMSelectTest(execution_mode, 2); } -TEST(Run_WASMSelect_3) { +WASM_EXEC_TEST(Run_WASMSelect_3) { CcTest::InitializeVM(); - RunWASMSelectTest(3); + RunWASMSelectTest(execution_mode, 3); } -TEST(Run_WASMSelect_4) { +WASM_EXEC_TEST(Run_WASMSelect_4) { CcTest::InitializeVM(); - RunWASMSelectTest(4); + RunWASMSelectTest(execution_mode, 4); } -TEST(Run_WASMSelect_5) { +WASM_EXEC_TEST(Run_WASMSelect_5) { CcTest::InitializeVM(); - RunWASMSelectTest(5); + RunWASMSelectTest(execution_mode, 5); } -TEST(Run_WASMSelect_6) { +WASM_EXEC_TEST(Run_WASMSelect_6) { CcTest::InitializeVM(); - RunWASMSelectTest(6); + RunWASMSelectTest(execution_mode, 6); } -TEST(Run_WASMSelect_7) { +WASM_EXEC_TEST(Run_WASMSelect_7) { CcTest::InitializeVM(); - RunWASMSelectTest(7); + RunWASMSelectTest(execution_mode, 7); } -void RunWASMSelectAlignTest(int num_args, int num_params) { +void RunWASMSelectAlignTest(WasmExecutionMode mode, int num_args, + int num_params) { PredictableInputValues inputs(0x300); Isolate* isolate = CcTest::InitIsolateOnce(); const int kMaxParams = 10; @@ -304,7 +304,7 @@ void RunWASMSelectAlignTest(int num_args, int num_params) { FunctionSig sig(1, num_params, types); for (int which = 0; which < num_params; which++) { - WasmRunner<void> r(kExecuteCompiled); + WasmRunner<void> r(mode); WasmFunctionCompiler& t = r.NewFunction(&sig); BUILD(t, WASM_GET_LOCAL(which)); Handle<JSFunction> jsfunc = r.builder().WrapCode(t.function_index()); @@ -326,68 +326,69 @@ void RunWASMSelectAlignTest(int num_args, int num_params) { } } -TEST(Run_WASMSelectAlign_0) { +WASM_EXEC_TEST(Run_WASMSelectAlign_0) { CcTest::InitializeVM(); - RunWASMSelectAlignTest(0, 1); - RunWASMSelectAlignTest(0, 2); + RunWASMSelectAlignTest(execution_mode, 0, 1); + RunWASMSelectAlignTest(execution_mode, 0, 2); } -TEST(Run_WASMSelectAlign_1) { +WASM_EXEC_TEST(Run_WASMSelectAlign_1) { CcTest::InitializeVM(); - RunWASMSelectAlignTest(1, 2); - RunWASMSelectAlignTest(1, 3); + RunWASMSelectAlignTest(execution_mode, 1, 2); + RunWASMSelectAlignTest(execution_mode, 1, 3); } -TEST(Run_WASMSelectAlign_2) { +WASM_EXEC_TEST(Run_WASMSelectAlign_2) { CcTest::InitializeVM(); - RunWASMSelectAlignTest(2, 3); - RunWASMSelectAlignTest(2, 4); + RunWASMSelectAlignTest(execution_mode, 2, 3); + RunWASMSelectAlignTest(execution_mode, 2, 4); } -TEST(Run_WASMSelectAlign_3) { +WASM_EXEC_TEST(Run_WASMSelectAlign_3) { CcTest::InitializeVM(); - RunWASMSelectAlignTest(3, 3); - RunWASMSelectAlignTest(3, 4); + RunWASMSelectAlignTest(execution_mode, 3, 3); + RunWASMSelectAlignTest(execution_mode, 3, 4); } -TEST(Run_WASMSelectAlign_4) { +WASM_EXEC_TEST(Run_WASMSelectAlign_4) { CcTest::InitializeVM(); - RunWASMSelectAlignTest(4, 3); - RunWASMSelectAlignTest(4, 4); + RunWASMSelectAlignTest(execution_mode, 4, 3); + RunWASMSelectAlignTest(execution_mode, 4, 4); } -TEST(Run_WASMSelectAlign_7) { +WASM_EXEC_TEST(Run_WASMSelectAlign_7) { CcTest::InitializeVM(); - RunWASMSelectAlignTest(7, 5); - RunWASMSelectAlignTest(7, 6); - RunWASMSelectAlignTest(7, 7); + RunWASMSelectAlignTest(execution_mode, 7, 5); + RunWASMSelectAlignTest(execution_mode, 7, 6); + RunWASMSelectAlignTest(execution_mode, 7, 7); } -TEST(Run_WASMSelectAlign_8) { +WASM_EXEC_TEST(Run_WASMSelectAlign_8) { CcTest::InitializeVM(); - RunWASMSelectAlignTest(8, 5); - RunWASMSelectAlignTest(8, 6); - RunWASMSelectAlignTest(8, 7); - RunWASMSelectAlignTest(8, 8); + RunWASMSelectAlignTest(execution_mode, 8, 5); + RunWASMSelectAlignTest(execution_mode, 8, 6); + RunWASMSelectAlignTest(execution_mode, 8, 7); + RunWASMSelectAlignTest(execution_mode, 8, 8); } -TEST(Run_WASMSelectAlign_9) { +WASM_EXEC_TEST(Run_WASMSelectAlign_9) { CcTest::InitializeVM(); - RunWASMSelectAlignTest(9, 6); - RunWASMSelectAlignTest(9, 7); - RunWASMSelectAlignTest(9, 8); - RunWASMSelectAlignTest(9, 9); + RunWASMSelectAlignTest(execution_mode, 9, 6); + RunWASMSelectAlignTest(execution_mode, 9, 7); + RunWASMSelectAlignTest(execution_mode, 9, 8); + RunWASMSelectAlignTest(execution_mode, 9, 9); } -TEST(Run_WASMSelectAlign_10) { +WASM_EXEC_TEST(Run_WASMSelectAlign_10) { CcTest::InitializeVM(); - RunWASMSelectAlignTest(10, 7); - RunWASMSelectAlignTest(10, 8); - RunWASMSelectAlignTest(10, 9); - RunWASMSelectAlignTest(10, 10); + RunWASMSelectAlignTest(execution_mode, 10, 7); + RunWASMSelectAlignTest(execution_mode, 10, 8); + RunWASMSelectAlignTest(execution_mode, 10, 9); + RunWASMSelectAlignTest(execution_mode, 10, 10); } -void RunJSSelectAlignTest(int num_args, int num_params) { +void RunJSSelectAlignTest(WasmExecutionMode mode, int num_args, + int num_params) { PredictableInputValues inputs(0x400); Isolate* isolate = CcTest::InitIsolateOnce(); Factory* factory = isolate->factory(); @@ -416,8 +417,11 @@ void RunJSSelectAlignTest(int num_args, int num_params) { // Call different select JS functions. for (int which = 0; which < num_params; which++) { - WasmRunner<void> r(kExecuteCompiled); - uint32_t js_index = AddJSSelector(&r.builder(), &sig, which); + WasmRunner<void> r(mode); + Handle<FixedArray> js_imports_table = + factory->NewFixedArray(2 * 3 + 1, TENURED); + uint32_t js_index = + AddJSSelector(&r.builder(), &sig, which, js_imports_table); CHECK_EQ(predicted_js_index, js_index); WasmFunctionCompiler& t = r.NewFunction(&sig); t.Build(&code[0], &code[end]); @@ -443,64 +447,70 @@ void RunJSSelectAlignTest(int num_args, int num_params) { } } -TEST(Run_JSSelectAlign_0) { +WASM_EXEC_TEST(Run_JSSelectAlign_0) { CcTest::InitializeVM(); - RunJSSelectAlignTest(0, 1); - RunJSSelectAlignTest(0, 2); + RunJSSelectAlignTest(execution_mode, 0, 1); + RunJSSelectAlignTest(execution_mode, 0, 2); } -TEST(Run_JSSelectAlign_1) { +WASM_EXEC_TEST(Run_JSSelectAlign_1) { CcTest::InitializeVM(); - RunJSSelectAlignTest(1, 2); - RunJSSelectAlignTest(1, 3); + RunJSSelectAlignTest(execution_mode, 1, 2); + RunJSSelectAlignTest(execution_mode, 1, 3); } -TEST(Run_JSSelectAlign_2) { +WASM_EXEC_TEST(Run_JSSelectAlign_2) { CcTest::InitializeVM(); - RunJSSelectAlignTest(2, 3); - RunJSSelectAlignTest(2, 4); + RunJSSelectAlignTest(execution_mode, 2, 3); + RunJSSelectAlignTest(execution_mode, 2, 4); } -TEST(Run_JSSelectAlign_3) { +WASM_EXEC_TEST(Run_JSSelectAlign_3) { CcTest::InitializeVM(); - RunJSSelectAlignTest(3, 3); - RunJSSelectAlignTest(3, 4); + RunJSSelectAlignTest(execution_mode, 3, 3); + RunJSSelectAlignTest(execution_mode, 3, 4); } -TEST(Run_JSSelectAlign_4) { +WASM_EXEC_TEST(Run_JSSelectAlign_4) { CcTest::InitializeVM(); - RunJSSelectAlignTest(4, 3); - RunJSSelectAlignTest(4, 4); + RunJSSelectAlignTest(execution_mode, 4, 3); + RunJSSelectAlignTest(execution_mode, 4, 4); } -TEST(Run_JSSelectAlign_7) { +WASM_EXEC_TEST(Run_JSSelectAlign_7) { CcTest::InitializeVM(); - RunJSSelectAlignTest(7, 3); - RunJSSelectAlignTest(7, 4); - RunJSSelectAlignTest(7, 4); - RunJSSelectAlignTest(7, 4); + RunJSSelectAlignTest(execution_mode, 7, 3); + RunJSSelectAlignTest(execution_mode, 7, 4); + RunJSSelectAlignTest(execution_mode, 7, 4); + RunJSSelectAlignTest(execution_mode, 7, 4); } -TEST(Run_JSSelectAlign_8) { +WASM_EXEC_TEST(Run_JSSelectAlign_8) { CcTest::InitializeVM(); - RunJSSelectAlignTest(8, 5); - RunJSSelectAlignTest(8, 6); - RunJSSelectAlignTest(8, 7); - RunJSSelectAlignTest(8, 8); + RunJSSelectAlignTest(execution_mode, 8, 5); + RunJSSelectAlignTest(execution_mode, 8, 6); + RunJSSelectAlignTest(execution_mode, 8, 7); + RunJSSelectAlignTest(execution_mode, 8, 8); } -TEST(Run_JSSelectAlign_9) { +WASM_EXEC_TEST(Run_JSSelectAlign_9) { CcTest::InitializeVM(); - RunJSSelectAlignTest(9, 6); - RunJSSelectAlignTest(9, 7); - RunJSSelectAlignTest(9, 8); - RunJSSelectAlignTest(9, 9); + RunJSSelectAlignTest(execution_mode, 9, 6); + RunJSSelectAlignTest(execution_mode, 9, 7); + RunJSSelectAlignTest(execution_mode, 9, 8); + RunJSSelectAlignTest(execution_mode, 9, 9); } -TEST(Run_JSSelectAlign_10) { +WASM_EXEC_TEST(Run_JSSelectAlign_10) { CcTest::InitializeVM(); - RunJSSelectAlignTest(10, 7); - RunJSSelectAlignTest(10, 8); - RunJSSelectAlignTest(10, 9); - RunJSSelectAlignTest(10, 10); + RunJSSelectAlignTest(execution_mode, 10, 7); + RunJSSelectAlignTest(execution_mode, 10, 8); + RunJSSelectAlignTest(execution_mode, 10, 9); + RunJSSelectAlignTest(execution_mode, 10, 10); } + +#undef ADD_CODE + +} // namespace wasm +} // namespace internal +} // namespace v8 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 268e0d5a93..72ed1f03f5 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-module.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-module.cc @@ -5,24 +5,27 @@ #include <stdlib.h> #include <string.h> +#include "src/api.h" #include "src/objects-inl.h" #include "src/snapshot/code-serializer.h" #include "src/version.h" +#include "src/wasm/module-compiler.h" #include "src/wasm/module-decoder.h" +#include "src/wasm/wasm-memory.h" #include "src/wasm/wasm-module-builder.h" #include "src/wasm/wasm-module.h" -#include "src/wasm/wasm-objects.h" +#include "src/wasm/wasm-objects-inl.h" #include "src/wasm/wasm-opcodes.h" #include "test/cctest/cctest.h" +#include "test/common/wasm/flag-utils.h" #include "test/common/wasm/test-signatures.h" #include "test/common/wasm/wasm-macro-gen.h" #include "test/common/wasm/wasm-module-runner.h" -using namespace v8::base; -using namespace v8::internal; -using namespace v8::internal::compiler; -using namespace v8::internal::wasm; +namespace v8 { +namespace internal { +namespace wasm { namespace { void Cleanup(Isolate* isolate = nullptr) { @@ -287,7 +290,7 @@ class WasmSerializationTest { Handle<Object>(Smi::FromInt(41), current_isolate())}; int32_t result = testing::CallWasmFunctionForTesting( current_isolate(), instance, &thrower, kFunctionName, 1, params); - CHECK(result == 42); + CHECK_EQ(42, result); } Isolate* current_isolate() { @@ -318,6 +321,10 @@ class WasmSerializationTest { WasmSerializationTest::BuildWireBytes(zone(), &buffer); Isolate* serialization_isolate = CcTest::InitIsolateOnce(); + // Isolates do not have serialization enabled by default. We must enable it + // here or else the assembler will not mark external references so that the + // serializer can handle them correctly. + serialization_isolate->set_serializer_enabled_for_test(true); ErrorThrower thrower(serialization_isolate, ""); uint8_t* bytes = nullptr; size_t bytes_size = 0; @@ -452,7 +459,7 @@ TEST(ModuleBuilder) { size_t third = buffer.size() / 3; size_t first_mark = third - 2; size_t second_mark = buffer.size() - 2 - third; - CHECK(0 < first_mark); + CHECK_LT(0, first_mark); CHECK(first_mark < second_mark); CHECK(second_mark < buffer.size()); Isolate* i_isolate = CcTest::InitIsolateOnce(); @@ -482,7 +489,7 @@ TEST(FailingModuleBuilder) { size_t third = buffer.size() / 3; size_t first_mark = third - 2; size_t second_mark = buffer.size() - 2 - third; - CHECK(0 < first_mark); + CHECK_LT(0, first_mark); CHECK(first_mark < second_mark); CHECK(second_mark < buffer.size()); Isolate* i_isolate = CcTest::InitIsolateOnce(); @@ -501,23 +508,6 @@ bool False(v8::Local<v8::Context> context, v8::Local<v8::String> source) { return false; } -TEST(BlockWasmCodeGen) { - v8::internal::AccountingAllocator allocator; - Zone zone(&allocator, ZONE_NAME); - ZoneBuffer buffer(&zone); - WasmSerializationTest::BuildWireBytes(&zone, &buffer); - Isolate* isolate = CcTest::InitIsolateOnce(); - HandleScope scope(isolate); - testing::SetupIsolateForWasmModule(isolate); - CcTest::isolate()->SetAllowCodeGenerationFromStringsCallback(False); - - ErrorThrower thrower(isolate, "block codegen"); - MaybeHandle<WasmModuleObject> ret = wasm::SyncCompile( - isolate, &thrower, ModuleWireBytes(buffer.begin(), buffer.end())); - CHECK(ret.is_null()); - CHECK(thrower.error()); -} - TEST(BlockWasmCodeGenAtDeserialization) { WasmSerializationTest test; { @@ -557,13 +547,16 @@ TEST(TransferrableWasmModules) { 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::WasmCompiledModule::FromTransferrableModule(to_isolate, store[0]); - CHECK(!mod.IsEmpty()); + { + 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::WasmCompiledModule::FromTransferrableModule(to_isolate, store[0]); + CHECK(!mod.IsEmpty()); + } + to_isolate->Dispose(); } } @@ -795,7 +788,7 @@ TEST(Run_WasmModule_GrowMemOobFixedIndex) { Handle<Object> params[1] = {Handle<Object>(Smi::FromInt(1), isolate)}; int32_t result = testing::RunWasmModuleForTesting(isolate, instance, 1, params); - CHECK(result == 0xaced); + CHECK_EQ(0xaced, result); } Cleanup(); } @@ -846,7 +839,7 @@ TEST(Run_WasmModule_GrowMemOobVariableIndex) { Handle<Object>(Smi::FromInt((20 + i) * kPageSize - 4), isolate)}; int32_t result = testing::RunWasmModuleForTesting(isolate, instance, 1, params); - CHECK(result == 0xaced); + CHECK_EQ(0xaced, result); } v8::TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate)); @@ -1095,18 +1088,22 @@ TEST(Run_WasmModule_Buffer_Externalized_GrowMem) { {}, {}) .ToHandleChecked(); Handle<JSArrayBuffer> memory(instance->memory_buffer(), isolate); + Handle<WasmMemoryObject> mem_obj(instance->memory_object(), isolate); void* const old_allocation_base = memory->allocation_base(); size_t const old_allocation_length = memory->allocation_length(); - // Fake the Embedder flow by creating a memory object, externalize and grow. - Handle<WasmMemoryObject> mem_obj = - WasmMemoryObject::New(isolate, memory, 100); - + // Fake the Embedder flow by externalizing the memory object, and grow. v8::Utils::ToLocal(memory)->Externalize(); uint32_t result = WasmMemoryObject::Grow(isolate, mem_obj, 4); - const bool free_memory = true; - wasm::DetachWebAssemblyMemoryBuffer(isolate, memory, free_memory); + bool free_memory = !memory->has_guard_region(); + if (!free_memory) { + // current_pages = Initial memory size(16) + GrowWebAssemblyMemory(4) + const uint32_t current_pages = 20; + i::WasmMemoryObject::SetupNewBufferWithSameBackingStore(isolate, mem_obj, + current_pages); + } + wasm::DetachMemoryBuffer(isolate, memory, free_memory); CHECK_EQ(16, result); memory = handle(mem_obj->array_buffer()); instance->set_memory_buffer(*memory); @@ -1122,8 +1119,12 @@ TEST(Run_WasmModule_Buffer_Externalized_GrowMem) { isolate->array_buffer_allocator()->Free(memory->allocation_base(), memory->allocation_length(), allocation_mode); - isolate->array_buffer_allocator()->Free( - old_allocation_base, old_allocation_length, allocation_mode); + if (free_memory) { + // GrowMemory without guard pages enabled allocates an extra buffer, + // that needs to be freed as well + isolate->array_buffer_allocator()->Free( + old_allocation_base, old_allocation_length, allocation_mode); + } memory->set_allocation_base(nullptr); memory->set_allocation_length(0); } @@ -1143,7 +1144,7 @@ TEST(Run_WasmModule_Buffer_Externalized_GrowMemMemSize) { WasmMemoryObject::New(isolate, buffer, 100); v8::Utils::ToLocal(buffer)->Externalize(); int32_t result = WasmMemoryObject::Grow(isolate, mem_obj, 0); - wasm::DetachWebAssemblyMemoryBuffer(isolate, buffer, false); + wasm::DetachMemoryBuffer(isolate, buffer, false); CHECK_EQ(16, result); isolate->array_buffer_allocator()->Free(backing_store, @@ -1164,9 +1165,52 @@ TEST(Run_WasmModule_Buffer_Externalized_Detach) { isolate, backing_store, 16 * WasmModule::kPageSize, backing_store, 16 * WasmModule::kPageSize, false, false); v8::Utils::ToLocal(buffer)->Externalize(); - wasm::DetachWebAssemblyMemoryBuffer(isolate, buffer, true); + wasm::DetachMemoryBuffer(isolate, buffer, true); isolate->array_buffer_allocator()->Free(backing_store, 16 * WasmModule::kPageSize); } Cleanup(); } + +TEST(AtomicOpDisassembly) { + { + EXPERIMENTAL_FLAG_SCOPE(threads); + TestSignatures sigs; + Isolate* isolate = CcTest::InitIsolateOnce(); + v8::internal::AccountingAllocator allocator; + Zone zone(&allocator, ZONE_NAME); + + WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone); + builder->SetHasSharedMemory(); + builder->SetMaxMemorySize(16); + WasmFunctionBuilder* f = builder->AddFunction(sigs.i_i()); + ExportAsMain(f); + byte code[] = { + WASM_ATOMICS_STORE_OP(kExprI32AtomicStore, WASM_ZERO, WASM_GET_LOCAL(0), + MachineRepresentation::kWord32), + WASM_ATOMICS_LOAD_OP(kExprI32AtomicLoad, WASM_ZERO, + MachineRepresentation::kWord32)}; + EMIT_CODE_WITH_END(f, code); + + HandleScope scope(isolate); + ZoneBuffer buffer(&zone); + builder->WriteTo(buffer); + testing::SetupIsolateForWasmModule(isolate); + + ErrorThrower thrower(isolate, "Test"); + MaybeHandle<WasmModuleObject> module_object = SyncCompile( + isolate, &thrower, ModuleWireBytes(buffer.begin(), buffer.end())); + + MaybeHandle<WasmCompiledModule> compiled_module( + module_object.ToHandleChecked()->compiled_module(), isolate); + CHECK(!compiled_module.is_null()); + compiled_module.ToHandleChecked()->DisassembleFunction(0); + } + Cleanup(); +} + +#undef EMIT_CODE_WITH_END + +} // namespace wasm +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/wasm/test-run-wasm-relocation.cc b/deps/v8/test/cctest/wasm/test-run-wasm-relocation.cc index f82d39a49c..030b7a4288 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-relocation.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-relocation.cc @@ -12,8 +12,10 @@ #include "test/cctest/wasm/wasm-run-utils.h" #include "test/common/wasm/wasm-macro-gen.h" -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace wasm { +namespace test_run_wasm_relocation { #define FOREACH_TYPE(TEST_BODY) \ TEST_BODY(int32_t, WASM_I32_ADD) \ @@ -22,8 +24,8 @@ using namespace v8::internal::compiler; TEST_BODY(double, WASM_F64_ADD) #define LOAD_SET_GLOBAL_TEST_BODY(C_TYPE, ADD) \ - TEST(WasmRelocateGlobal_##C_TYPE) { \ - WasmRunner<C_TYPE, C_TYPE> r(kExecuteCompiled); \ + WASM_EXEC_TEST(WasmRelocateGlobal_##C_TYPE) { \ + WasmRunner<C_TYPE, C_TYPE> r(execution_mode); \ Isolate* isolate = CcTest::i_isolate(); \ \ r.builder().AddGlobal<C_TYPE>(); \ @@ -60,3 +62,11 @@ using namespace v8::internal::compiler; } FOREACH_TYPE(LOAD_SET_GLOBAL_TEST_BODY) + +#undef FOREACH_TYPE +#undef LOAD_SET_GLOBAL_TEST_BODY + +} // namespace test_run_wasm_relocation +} // namespace wasm +} // namespace internal +} // namespace v8 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 f980b1a90e..5c5d74e747 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-simd.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-simd.cc @@ -8,10 +8,10 @@ #include "test/cctest/wasm/wasm-run-utils.h" #include "test/common/wasm/wasm-macro-gen.h" -using namespace v8::base; -using namespace v8::internal; -using namespace v8::internal::compiler; -using namespace v8::internal::wasm; +namespace v8 { +namespace internal { +namespace wasm { +namespace test_run_wasm_simd { namespace { @@ -31,20 +31,25 @@ typedef int8_t (*Int8BinOp)(int8_t, int8_t); typedef int (*Int8CompareOp)(int8_t, int8_t); typedef int8_t (*Int8ShiftOp)(int8_t, int); -#if !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_X64 && \ - !V8_TARGET_ARCH_IA32 && !V8_TARGET_ARCH_MIPS && !V8_TARGET_ARCH_MIPS64 -#define SIMD_LOWERING_TARGET 1 -#else -#define SIMD_LOWERING_TARGET 0 -#endif - -#define WASM_SIMD_TEST(name) \ - void RunWasm_##name##_Impl(); \ - TEST(RunWasm_##name) { \ - EXPERIMENTAL_FLAG_SCOPE(simd); \ - RunWasm_##name##_Impl(); \ - } \ - void RunWasm_##name##_Impl() +#define WASM_SIMD_TEST(name) \ + void RunWasm_##name##_Impl(WasmExecutionMode execution_mode); \ + TEST(RunWasm_##name##_compiled) { \ + EXPERIMENTAL_FLAG_SCOPE(simd); \ + RunWasm_##name##_Impl(kExecuteCompiled); \ + } \ + TEST(RunWasm_##name##_simd_lowered) { \ + EXPERIMENTAL_FLAG_SCOPE(simd); \ + RunWasm_##name##_Impl(kExecuteSimdLowered); \ + } \ + void RunWasm_##name##_Impl(WasmExecutionMode execution_mode) + +#define WASM_SIMD_COMPILED_TEST(name) \ + void RunWasm_##name##_Impl(WasmExecutionMode execution_mode); \ + TEST(RunWasm_##name##_compiled) { \ + EXPERIMENTAL_FLAG_SCOPE(simd); \ + RunWasm_##name##_Impl(kExecuteCompiled); \ + } \ + void RunWasm_##name##_Impl(WasmExecutionMode execution_mode) // Generic expected value functions. template <typename T> @@ -82,25 +87,6 @@ T Maximum(T a, T b) { return a >= b ? a : b; } -// For float operands, Min and Max must return NaN if either operand is NaN. -#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || SIMD_LOWERING_TARGET || \ - V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 -template <> -float Minimum(float a, float b) { - if (std::isnan(a) || std::isnan(b)) - return std::numeric_limits<float>::quiet_NaN(); - return a <= b ? a : b; -} - -template <> -float Maximum(float a, float b) { - if (std::isnan(a) || std::isnan(b)) - return std::numeric_limits<float>::quiet_NaN(); - return a >= b ? a : b; -} -#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || SIMD_LOWERING_TARGET || - // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 - template <typename T> T UnsignedMinimum(T a, T b) { using UnsignedT = typename std::make_unsigned<T>::type; @@ -419,10 +405,10 @@ bool SkipFPValue(float x) { // doesn't handle NaNs. Also skip extreme values. bool SkipFPExpectedValue(float x) { return std::isnan(x) || SkipFPValue(x); } -#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || SIMD_LOWERING_TARGET || \ - V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 +#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || \ + V8_TARGET_ARCH_MIPS64 WASM_SIMD_TEST(F32x4Splat) { - WasmRunner<int32_t, float> r(kExecuteCompiled); + WasmRunner<int32_t, float> r(execution_mode); byte lane_val = 0; byte simd = r.AllocateLocal(kWasmS128); BUILD(r, @@ -436,7 +422,7 @@ WASM_SIMD_TEST(F32x4Splat) { } WASM_SIMD_TEST(F32x4ReplaceLane) { - WasmRunner<int32_t, float, float> r(kExecuteCompiled); + WasmRunner<int32_t, float, float> r(execution_mode); byte old_val = 0; byte new_val = 1; byte simd = r.AllocateLocal(kWasmS128); @@ -463,7 +449,7 @@ WASM_SIMD_TEST(F32x4ReplaceLane) { // Tests both signed and unsigned conversion. WASM_SIMD_TEST(F32x4ConvertI32x4) { - WasmRunner<int32_t, int32_t, float, float> r(kExecuteCompiled); + WasmRunner<int32_t, int32_t, float, float> r(execution_mode); byte a = 0; byte expected_signed = 1; byte expected_unsigned = 2; @@ -484,14 +470,10 @@ WASM_SIMD_TEST(F32x4ConvertI32x4) { static_cast<float>(static_cast<uint32_t>(*i)))); } } -#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || SIMD_LOWERING_TARGET || - // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 -#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || SIMD_LOWERING_TARGET || \ - V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 -void RunF32x4UnOpTest(WasmOpcode simd_op, FloatUnOp expected_op, - float error = 0.0f) { - WasmRunner<int32_t, float, float, float> r(kExecuteCompiled); +void RunF32x4UnOpTest(WasmExecutionMode execution_mode, WasmOpcode simd_op, + FloatUnOp expected_op, float error = 0.0f) { + WasmRunner<int32_t, float, float, float> r(execution_mode); byte a = 0; byte low = 1; byte high = 2; @@ -510,29 +492,27 @@ void RunF32x4UnOpTest(WasmOpcode simd_op, FloatUnOp expected_op, } } -WASM_SIMD_TEST(F32x4Abs) { RunF32x4UnOpTest(kExprF32x4Abs, std::abs); } -WASM_SIMD_TEST(F32x4Neg) { RunF32x4UnOpTest(kExprF32x4Neg, Negate); } -#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || SIMD_LOWERING_TARGET || - // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 +WASM_SIMD_TEST(F32x4Abs) { + RunF32x4UnOpTest(execution_mode, kExprF32x4Abs, std::abs); +} +WASM_SIMD_TEST(F32x4Neg) { + RunF32x4UnOpTest(execution_mode, kExprF32x4Neg, Negate); +} -#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || \ - V8_TARGET_ARCH_MIPS64 static const float kApproxError = 0.01f; -WASM_SIMD_TEST(F32x4RecipApprox) { - RunF32x4UnOpTest(kExprF32x4RecipApprox, Recip, kApproxError); +WASM_SIMD_COMPILED_TEST(F32x4RecipApprox) { + RunF32x4UnOpTest(execution_mode, kExprF32x4RecipApprox, Recip, kApproxError); } -WASM_SIMD_TEST(F32x4RecipSqrtApprox) { - RunF32x4UnOpTest(kExprF32x4RecipSqrtApprox, RecipSqrt, kApproxError); +WASM_SIMD_COMPILED_TEST(F32x4RecipSqrtApprox) { + RunF32x4UnOpTest(execution_mode, kExprF32x4RecipSqrtApprox, RecipSqrt, + kApproxError); } -#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || - // V8_TARGET_ARCH_MIPS64 -#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || SIMD_LOWERING_TARGET || \ - V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 -void RunF32x4BinOpTest(WasmOpcode simd_op, FloatBinOp expected_op) { - WasmRunner<int32_t, float, float, float> r(kExecuteCompiled); +void RunF32x4BinOpTest(WasmExecutionMode execution_mode, WasmOpcode simd_op, + FloatBinOp expected_op) { + WasmRunner<int32_t, float, float, float> r(execution_mode); byte a = 0; byte b = 1; byte expected = 2; @@ -555,18 +535,25 @@ void RunF32x4BinOpTest(WasmOpcode simd_op, FloatBinOp expected_op) { } } -WASM_SIMD_TEST(F32x4Add) { RunF32x4BinOpTest(kExprF32x4Add, Add); } -WASM_SIMD_TEST(F32x4Sub) { RunF32x4BinOpTest(kExprF32x4Sub, Sub); } -WASM_SIMD_TEST(F32x4Mul) { RunF32x4BinOpTest(kExprF32x4Mul, Mul); } -WASM_SIMD_TEST(F32x4_Min) { RunF32x4BinOpTest(kExprF32x4Min, Minimum); } -WASM_SIMD_TEST(F32x4_Max) { RunF32x4BinOpTest(kExprF32x4Max, Maximum); } -#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || SIMD_LOWERING_TARGET || - // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 +WASM_SIMD_TEST(F32x4Add) { + RunF32x4BinOpTest(execution_mode, kExprF32x4Add, Add); +} +WASM_SIMD_TEST(F32x4Sub) { + RunF32x4BinOpTest(execution_mode, kExprF32x4Sub, Sub); +} +WASM_SIMD_TEST(F32x4Mul) { + RunF32x4BinOpTest(execution_mode, kExprF32x4Mul, Mul); +} +WASM_SIMD_TEST(F32x4_Min) { + RunF32x4BinOpTest(execution_mode, kExprF32x4Min, JSMin); +} +WASM_SIMD_TEST(F32x4_Max) { + RunF32x4BinOpTest(execution_mode, kExprF32x4Max, JSMax); +} -#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || SIMD_LOWERING_TARGET || \ - V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 -void RunF32x4CompareOpTest(WasmOpcode simd_op, FloatCompareOp expected_op) { - WasmRunner<int32_t, float, float, int32_t> r(kExecuteCompiled); +void RunF32x4CompareOpTest(WasmExecutionMode execution_mode, WasmOpcode simd_op, + FloatCompareOp expected_op) { + WasmRunner<int32_t, float, float, int32_t> r(execution_mode); byte a = 0; byte b = 1; byte expected = 2; @@ -589,19 +576,31 @@ void RunF32x4CompareOpTest(WasmOpcode simd_op, FloatCompareOp expected_op) { } } -WASM_SIMD_TEST(F32x4Eq) { RunF32x4CompareOpTest(kExprF32x4Eq, Equal); } +WASM_SIMD_TEST(F32x4Eq) { + RunF32x4CompareOpTest(execution_mode, kExprF32x4Eq, Equal); +} -WASM_SIMD_TEST(F32x4Ne) { RunF32x4CompareOpTest(kExprF32x4Ne, NotEqual); } +WASM_SIMD_TEST(F32x4Ne) { + RunF32x4CompareOpTest(execution_mode, kExprF32x4Ne, NotEqual); +} -WASM_SIMD_TEST(F32x4Gt) { RunF32x4CompareOpTest(kExprF32x4Gt, Greater); } +WASM_SIMD_TEST(F32x4Gt) { + RunF32x4CompareOpTest(execution_mode, kExprF32x4Gt, Greater); +} -WASM_SIMD_TEST(F32x4Ge) { RunF32x4CompareOpTest(kExprF32x4Ge, GreaterEqual); } +WASM_SIMD_TEST(F32x4Ge) { + RunF32x4CompareOpTest(execution_mode, kExprF32x4Ge, GreaterEqual); +} -WASM_SIMD_TEST(F32x4Lt) { RunF32x4CompareOpTest(kExprF32x4Lt, Less); } +WASM_SIMD_TEST(F32x4Lt) { + RunF32x4CompareOpTest(execution_mode, kExprF32x4Lt, Less); +} -WASM_SIMD_TEST(F32x4Le) { RunF32x4CompareOpTest(kExprF32x4Le, LessEqual); } -#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || SIMD_LOWERING_TARGET || - // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 +WASM_SIMD_TEST(F32x4Le) { + RunF32x4CompareOpTest(execution_mode, kExprF32x4Le, LessEqual); +} +#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || + // V8_TARGET_ARCH_MIPS64 WASM_SIMD_TEST(I32x4Splat) { // Store SIMD value in a local variable, use extract lane to check lane values @@ -614,7 +613,7 @@ WASM_SIMD_TEST(I32x4Splat) { // return 0 // // return 1 - WasmRunner<int32_t, int32_t> r(kExecuteCompiled); + WasmRunner<int32_t, int32_t> r(execution_mode); byte lane_val = 0; byte simd = r.AllocateLocal(kWasmS128); BUILD(r, @@ -625,7 +624,7 @@ WASM_SIMD_TEST(I32x4Splat) { } WASM_SIMD_TEST(I32x4ReplaceLane) { - WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); + WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); byte old_val = 0; byte new_val = 1; byte simd = r.AllocateLocal(kWasmS128); @@ -651,7 +650,7 @@ WASM_SIMD_TEST(I32x4ReplaceLane) { } WASM_SIMD_TEST(I16x8Splat) { - WasmRunner<int32_t, int32_t> r(kExecuteCompiled); + WasmRunner<int32_t, int32_t> r(execution_mode); byte lane_val = 0; byte simd = r.AllocateLocal(kWasmS128); BUILD(r, @@ -662,7 +661,7 @@ WASM_SIMD_TEST(I16x8Splat) { } WASM_SIMD_TEST(I16x8ReplaceLane) { - WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); + WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); byte old_val = 0; byte new_val = 1; byte simd = r.AllocateLocal(kWasmS128); @@ -711,7 +710,7 @@ WASM_SIMD_TEST(I16x8ReplaceLane) { } WASM_SIMD_TEST(I8x16Splat) { - WasmRunner<int32_t, int32_t> r(kExecuteCompiled); + WasmRunner<int32_t, int32_t> r(execution_mode); byte lane_val = 0; byte simd = r.AllocateLocal(kWasmS128); BUILD(r, @@ -722,7 +721,7 @@ WASM_SIMD_TEST(I8x16Splat) { } WASM_SIMD_TEST(I8x16ReplaceLane) { - WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); + WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); byte old_val = 0; byte new_val = 1; byte simd = r.AllocateLocal(kWasmS128); @@ -825,8 +824,8 @@ WASM_SIMD_TEST(I8x16ReplaceLane) { CHECK_EQ(1, r.Call(1, 2)); } -#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || SIMD_LOWERING_TARGET || \ - V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 +#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || \ + V8_TARGET_ARCH_MIPS64 // Determines if conversion from float to int will be valid. bool CanRoundToZeroAndConvert(double val, bool unsigned_integer) { const double max_uint = static_cast<double>(0xffffffffu); @@ -869,7 +868,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(kExecuteCompiled); + WasmRunner<int32_t, float, int32_t, int32_t> r(execution_mode); byte a = 0; byte expected_signed = 1; byte expected_unsigned = 2; @@ -891,14 +890,10 @@ WASM_SIMD_TEST(I32x4ConvertF32x4) { CHECK_EQ(1, r.Call(*i, signed_value, unsigned_value)); } } -#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || SIMD_LOWERING_TARGET || - // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 -#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || \ - V8_TARGET_ARCH_MIPS64 // Tests both signed and unsigned conversion from I16x8 (unpacking). -WASM_SIMD_TEST(I32x4ConvertI16x8) { - WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); +WASM_SIMD_COMPILED_TEST(I32x4ConvertI16x8) { + WasmRunner<int32_t, int32_t, int32_t, int32_t> r(execution_mode); byte a = 0; byte unpacked_signed = 1; byte unpacked_unsigned = 2; @@ -923,8 +918,9 @@ WASM_SIMD_TEST(I32x4ConvertI16x8) { #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || // V8_TARGET_ARCH_MIPS64 -void RunI32x4UnOpTest(WasmOpcode simd_op, Int32UnOp expected_op) { - WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); +void RunI32x4UnOpTest(WasmExecutionMode execution_mode, WasmOpcode simd_op, + Int32UnOp expected_op) { + WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); byte a = 0; byte expected = 1; byte simd = r.AllocateLocal(kWasmS128); @@ -935,16 +931,17 @@ void RunI32x4UnOpTest(WasmOpcode simd_op, Int32UnOp expected_op) { FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i))); } } -WASM_SIMD_TEST(I32x4Neg) { RunI32x4UnOpTest(kExprI32x4Neg, Negate); } +WASM_SIMD_TEST(I32x4Neg) { + RunI32x4UnOpTest(execution_mode, kExprI32x4Neg, Negate); +} -#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || SIMD_LOWERING_TARGET || \ - V8_TARGET_ARCH_X64 -WASM_SIMD_TEST(S128Not) { RunI32x4UnOpTest(kExprS128Not, Not); } -#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || SIMD_LOWERING_TARGET - // V8_TARGET_ARCH_X64 +#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_X64 +WASM_SIMD_TEST(S128Not) { RunI32x4UnOpTest(execution_mode, kExprS128Not, Not); } +#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_X64 -void RunI32x4BinOpTest(WasmOpcode simd_op, Int32BinOp expected_op) { - WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); +void RunI32x4BinOpTest(WasmExecutionMode execution_mode, WasmOpcode simd_op, + Int32BinOp expected_op) { + WasmRunner<int32_t, int32_t, int32_t, int32_t> r(execution_mode); byte a = 0; byte b = 1; byte expected = 2; @@ -961,36 +958,51 @@ void RunI32x4BinOpTest(WasmOpcode simd_op, Int32BinOp expected_op) { } } -WASM_SIMD_TEST(I32x4Add) { RunI32x4BinOpTest(kExprI32x4Add, Add); } +WASM_SIMD_TEST(I32x4Add) { + RunI32x4BinOpTest(execution_mode, kExprI32x4Add, Add); +} -WASM_SIMD_TEST(I32x4Sub) { RunI32x4BinOpTest(kExprI32x4Sub, Sub); } +WASM_SIMD_TEST(I32x4Sub) { + RunI32x4BinOpTest(execution_mode, kExprI32x4Sub, Sub); +} -WASM_SIMD_TEST(I32x4Mul) { RunI32x4BinOpTest(kExprI32x4Mul, Mul); } +WASM_SIMD_TEST(I32x4Mul) { + RunI32x4BinOpTest(execution_mode, kExprI32x4Mul, Mul); +} -WASM_SIMD_TEST(I32x4MinS) { RunI32x4BinOpTest(kExprI32x4MinS, Minimum); } +WASM_SIMD_TEST(I32x4MinS) { + RunI32x4BinOpTest(execution_mode, kExprI32x4MinS, Minimum); +} -WASM_SIMD_TEST(I32x4MaxS) { RunI32x4BinOpTest(kExprI32x4MaxS, Maximum); } +WASM_SIMD_TEST(I32x4MaxS) { + RunI32x4BinOpTest(execution_mode, kExprI32x4MaxS, Maximum); +} WASM_SIMD_TEST(I32x4MinU) { - RunI32x4BinOpTest(kExprI32x4MinU, UnsignedMinimum); + RunI32x4BinOpTest(execution_mode, kExprI32x4MinU, UnsignedMinimum); } WASM_SIMD_TEST(I32x4MaxU) { - RunI32x4BinOpTest(kExprI32x4MaxU, UnsignedMaximum); + RunI32x4BinOpTest(execution_mode, kExprI32x4MaxU, UnsignedMaximum); } #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_X64 || \ - SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 -WASM_SIMD_TEST(S128And) { RunI32x4BinOpTest(kExprS128And, And); } + V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 +WASM_SIMD_TEST(S128And) { + RunI32x4BinOpTest(execution_mode, kExprS128And, And); +} -WASM_SIMD_TEST(S128Or) { RunI32x4BinOpTest(kExprS128Or, Or); } +WASM_SIMD_TEST(S128Or) { RunI32x4BinOpTest(execution_mode, kExprS128Or, Or); } -WASM_SIMD_TEST(S128Xor) { RunI32x4BinOpTest(kExprS128Xor, Xor); } +WASM_SIMD_TEST(S128Xor) { + RunI32x4BinOpTest(execution_mode, kExprS128Xor, Xor); +} #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_X64 || - // SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 + // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 -void RunI32x4CompareOpTest(WasmOpcode simd_op, Int32CompareOp expected_op) { - WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); +void RunI32x4CompareOpTest(WasmExecutionMode execution_mode, WasmOpcode simd_op, + Int32CompareOp expected_op) { + WasmRunner<int32_t, int32_t, int32_t, int32_t> r(execution_mode); byte a = 0; byte b = 1; byte expected = 2; @@ -1007,35 +1019,49 @@ void RunI32x4CompareOpTest(WasmOpcode simd_op, Int32CompareOp expected_op) { } } -WASM_SIMD_TEST(I32x4Eq) { RunI32x4CompareOpTest(kExprI32x4Eq, Equal); } +WASM_SIMD_TEST(I32x4Eq) { + RunI32x4CompareOpTest(execution_mode, kExprI32x4Eq, Equal); +} -WASM_SIMD_TEST(I32x4Ne) { RunI32x4CompareOpTest(kExprI32x4Ne, NotEqual); } +WASM_SIMD_TEST(I32x4Ne) { + RunI32x4CompareOpTest(execution_mode, kExprI32x4Ne, NotEqual); +} -WASM_SIMD_TEST(I32x4LtS) { RunI32x4CompareOpTest(kExprI32x4LtS, Less); } +WASM_SIMD_TEST(I32x4LtS) { + RunI32x4CompareOpTest(execution_mode, kExprI32x4LtS, Less); +} -WASM_SIMD_TEST(I32x4LeS) { RunI32x4CompareOpTest(kExprI32x4LeS, LessEqual); } +WASM_SIMD_TEST(I32x4LeS) { + RunI32x4CompareOpTest(execution_mode, kExprI32x4LeS, LessEqual); +} -WASM_SIMD_TEST(I32x4GtS) { RunI32x4CompareOpTest(kExprI32x4GtS, Greater); } +WASM_SIMD_TEST(I32x4GtS) { + RunI32x4CompareOpTest(execution_mode, kExprI32x4GtS, Greater); +} -WASM_SIMD_TEST(I32x4GeS) { RunI32x4CompareOpTest(kExprI32x4GeS, GreaterEqual); } +WASM_SIMD_TEST(I32x4GeS) { + RunI32x4CompareOpTest(execution_mode, kExprI32x4GeS, GreaterEqual); +} -WASM_SIMD_TEST(I32x4LtU) { RunI32x4CompareOpTest(kExprI32x4LtU, UnsignedLess); } +WASM_SIMD_TEST(I32x4LtU) { + RunI32x4CompareOpTest(execution_mode, kExprI32x4LtU, UnsignedLess); +} WASM_SIMD_TEST(I32x4LeU) { - RunI32x4CompareOpTest(kExprI32x4LeU, UnsignedLessEqual); + RunI32x4CompareOpTest(execution_mode, kExprI32x4LeU, UnsignedLessEqual); } WASM_SIMD_TEST(I32x4GtU) { - RunI32x4CompareOpTest(kExprI32x4GtU, UnsignedGreater); + RunI32x4CompareOpTest(execution_mode, kExprI32x4GtU, UnsignedGreater); } WASM_SIMD_TEST(I32x4GeU) { - RunI32x4CompareOpTest(kExprI32x4GeU, UnsignedGreaterEqual); + RunI32x4CompareOpTest(execution_mode, kExprI32x4GeU, UnsignedGreaterEqual); } -void RunI32x4ShiftOpTest(WasmOpcode simd_op, Int32ShiftOp expected_op, - int shift) { - WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); +void RunI32x4ShiftOpTest(WasmExecutionMode execution_mode, WasmOpcode simd_op, + Int32ShiftOp expected_op, int shift) { + WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); byte a = 0; byte expected = 1; byte simd = r.AllocateLocal(kWasmS128); @@ -1048,22 +1074,22 @@ void RunI32x4ShiftOpTest(WasmOpcode simd_op, Int32ShiftOp expected_op, } WASM_SIMD_TEST(I32x4Shl) { - RunI32x4ShiftOpTest(kExprI32x4Shl, LogicalShiftLeft, 1); + RunI32x4ShiftOpTest(execution_mode, kExprI32x4Shl, LogicalShiftLeft, 1); } WASM_SIMD_TEST(I32x4ShrS) { - RunI32x4ShiftOpTest(kExprI32x4ShrS, ArithmeticShiftRight, 1); + RunI32x4ShiftOpTest(execution_mode, kExprI32x4ShrS, ArithmeticShiftRight, 1); } WASM_SIMD_TEST(I32x4ShrU) { - RunI32x4ShiftOpTest(kExprI32x4ShrU, LogicalShiftRight, 1); + RunI32x4ShiftOpTest(execution_mode, kExprI32x4ShrU, LogicalShiftRight, 1); } #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || \ V8_TARGET_ARCH_MIPS64 // Tests both signed and unsigned conversion from I8x16 (unpacking). -WASM_SIMD_TEST(I16x8ConvertI8x16) { - WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); +WASM_SIMD_COMPILED_TEST(I16x8ConvertI8x16) { + WasmRunner<int32_t, int32_t, int32_t, int32_t> r(execution_mode); byte a = 0; byte unpacked_signed = 1; byte unpacked_unsigned = 2; @@ -1087,10 +1113,11 @@ WASM_SIMD_TEST(I16x8ConvertI8x16) { #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || // V8_TARGET_ARCH_MIPS64 -#if SIMD_LOWERING_TARGET || V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || \ - V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_X64 -void RunI16x8UnOpTest(WasmOpcode simd_op, Int16UnOp expected_op) { - WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); +#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || \ + V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_X64 +void RunI16x8UnOpTest(WasmExecutionMode execution_mode, WasmOpcode simd_op, + Int16UnOp expected_op) { + WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); byte a = 0; byte expected = 1; byte simd = r.AllocateLocal(kWasmS128); @@ -1101,15 +1128,17 @@ void RunI16x8UnOpTest(WasmOpcode simd_op, Int16UnOp expected_op) { FOR_INT16_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i))); } } -WASM_SIMD_TEST(I16x8Neg) { RunI16x8UnOpTest(kExprI16x8Neg, Negate); } -#endif // SIMD_LOWERING_TARGET || V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || - // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_X64 +WASM_SIMD_TEST(I16x8Neg) { + RunI16x8UnOpTest(execution_mode, kExprI16x8Neg, Negate); +} +#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || + // V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_X64 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || \ V8_TARGET_ARCH_MIPS64 // Tests both signed and unsigned conversion from I32x4 (packing). -WASM_SIMD_TEST(I16x8ConvertI32x4) { - WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); +WASM_SIMD_COMPILED_TEST(I16x8ConvertI32x4) { + WasmRunner<int32_t, int32_t, int32_t, int32_t> r(execution_mode); byte a = 0; byte packed_signed = 1; byte packed_unsigned = 2; @@ -1138,9 +1167,10 @@ WASM_SIMD_TEST(I16x8ConvertI32x4) { // V8_TARGET_ARCH_MIPS64 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_X64 || \ - SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 -void RunI16x8BinOpTest(WasmOpcode simd_op, Int16BinOp expected_op) { - WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); + V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 +void RunI16x8BinOpTest(WasmExecutionMode execution_mode, WasmOpcode simd_op, + Int16BinOp expected_op) { + WasmRunner<int32_t, int32_t, int32_t, int32_t> r(execution_mode); byte a = 0; byte b = 1; byte expected = 2; @@ -1157,42 +1187,55 @@ void RunI16x8BinOpTest(WasmOpcode simd_op, Int16BinOp expected_op) { } } -WASM_SIMD_TEST(I16x8Add) { RunI16x8BinOpTest(kExprI16x8Add, Add); } +WASM_SIMD_TEST(I16x8Add) { + RunI16x8BinOpTest(execution_mode, kExprI16x8Add, Add); +} WASM_SIMD_TEST(I16x8AddSaturateS) { - RunI16x8BinOpTest(kExprI16x8AddSaturateS, AddSaturate); + RunI16x8BinOpTest(execution_mode, kExprI16x8AddSaturateS, AddSaturate); } -WASM_SIMD_TEST(I16x8Sub) { RunI16x8BinOpTest(kExprI16x8Sub, Sub); } +WASM_SIMD_TEST(I16x8Sub) { + RunI16x8BinOpTest(execution_mode, kExprI16x8Sub, Sub); +} WASM_SIMD_TEST(I16x8SubSaturateS) { - RunI16x8BinOpTest(kExprI16x8SubSaturateS, SubSaturate); + RunI16x8BinOpTest(execution_mode, kExprI16x8SubSaturateS, SubSaturate); } -WASM_SIMD_TEST(I16x8Mul) { RunI16x8BinOpTest(kExprI16x8Mul, Mul); } +WASM_SIMD_TEST(I16x8Mul) { + RunI16x8BinOpTest(execution_mode, kExprI16x8Mul, Mul); +} -WASM_SIMD_TEST(I16x8MinS) { RunI16x8BinOpTest(kExprI16x8MinS, Minimum); } +WASM_SIMD_TEST(I16x8MinS) { + RunI16x8BinOpTest(execution_mode, kExprI16x8MinS, Minimum); +} -WASM_SIMD_TEST(I16x8MaxS) { RunI16x8BinOpTest(kExprI16x8MaxS, Maximum); } +WASM_SIMD_TEST(I16x8MaxS) { + RunI16x8BinOpTest(execution_mode, kExprI16x8MaxS, Maximum); +} WASM_SIMD_TEST(I16x8AddSaturateU) { - RunI16x8BinOpTest(kExprI16x8AddSaturateU, UnsignedAddSaturate); + RunI16x8BinOpTest(execution_mode, kExprI16x8AddSaturateU, + UnsignedAddSaturate); } WASM_SIMD_TEST(I16x8SubSaturateU) { - RunI16x8BinOpTest(kExprI16x8SubSaturateU, UnsignedSubSaturate); + RunI16x8BinOpTest(execution_mode, kExprI16x8SubSaturateU, + UnsignedSubSaturate); } WASM_SIMD_TEST(I16x8MinU) { - RunI16x8BinOpTest(kExprI16x8MinU, UnsignedMinimum); + RunI16x8BinOpTest(execution_mode, kExprI16x8MinU, UnsignedMinimum); } WASM_SIMD_TEST(I16x8MaxU) { - RunI16x8BinOpTest(kExprI16x8MaxU, UnsignedMaximum); + RunI16x8BinOpTest(execution_mode, kExprI16x8MaxU, UnsignedMaximum); } -void RunI16x8CompareOpTest(WasmOpcode simd_op, Int16CompareOp expected_op) { - WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); +void RunI16x8CompareOpTest(WasmExecutionMode execution_mode, WasmOpcode simd_op, + Int16CompareOp expected_op) { + WasmRunner<int32_t, int32_t, int32_t, int32_t> r(execution_mode); byte a = 0; byte b = 1; byte expected = 2; @@ -1209,35 +1252,49 @@ void RunI16x8CompareOpTest(WasmOpcode simd_op, Int16CompareOp expected_op) { } } -WASM_SIMD_TEST(I16x8Eq) { RunI16x8CompareOpTest(kExprI16x8Eq, Equal); } +WASM_SIMD_TEST(I16x8Eq) { + RunI16x8CompareOpTest(execution_mode, kExprI16x8Eq, Equal); +} -WASM_SIMD_TEST(I16x8Ne) { RunI16x8CompareOpTest(kExprI16x8Ne, NotEqual); } +WASM_SIMD_TEST(I16x8Ne) { + RunI16x8CompareOpTest(execution_mode, kExprI16x8Ne, NotEqual); +} -WASM_SIMD_TEST(I16x8LtS) { RunI16x8CompareOpTest(kExprI16x8LtS, Less); } +WASM_SIMD_TEST(I16x8LtS) { + RunI16x8CompareOpTest(execution_mode, kExprI16x8LtS, Less); +} -WASM_SIMD_TEST(I16x8LeS) { RunI16x8CompareOpTest(kExprI16x8LeS, LessEqual); } +WASM_SIMD_TEST(I16x8LeS) { + RunI16x8CompareOpTest(execution_mode, kExprI16x8LeS, LessEqual); +} -WASM_SIMD_TEST(I16x8GtS) { RunI16x8CompareOpTest(kExprI16x8GtS, Greater); } +WASM_SIMD_TEST(I16x8GtS) { + RunI16x8CompareOpTest(execution_mode, kExprI16x8GtS, Greater); +} -WASM_SIMD_TEST(I16x8GeS) { RunI16x8CompareOpTest(kExprI16x8GeS, GreaterEqual); } +WASM_SIMD_TEST(I16x8GeS) { + RunI16x8CompareOpTest(execution_mode, kExprI16x8GeS, GreaterEqual); +} WASM_SIMD_TEST(I16x8GtU) { - RunI16x8CompareOpTest(kExprI16x8GtU, UnsignedGreater); + RunI16x8CompareOpTest(execution_mode, kExprI16x8GtU, UnsignedGreater); } WASM_SIMD_TEST(I16x8GeU) { - RunI16x8CompareOpTest(kExprI16x8GeU, UnsignedGreaterEqual); + RunI16x8CompareOpTest(execution_mode, kExprI16x8GeU, UnsignedGreaterEqual); } -WASM_SIMD_TEST(I16x8LtU) { RunI16x8CompareOpTest(kExprI16x8LtU, UnsignedLess); } +WASM_SIMD_TEST(I16x8LtU) { + RunI16x8CompareOpTest(execution_mode, kExprI16x8LtU, UnsignedLess); +} WASM_SIMD_TEST(I16x8LeU) { - RunI16x8CompareOpTest(kExprI16x8LeU, UnsignedLessEqual); + RunI16x8CompareOpTest(execution_mode, kExprI16x8LeU, UnsignedLessEqual); } -void RunI16x8ShiftOpTest(WasmOpcode simd_op, Int16ShiftOp expected_op, - int shift) { - WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); +void RunI16x8ShiftOpTest(WasmExecutionMode execution_mode, WasmOpcode simd_op, + Int16ShiftOp expected_op, int shift) { + WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); byte a = 0; byte expected = 1; byte simd = r.AllocateLocal(kWasmS128); @@ -1250,19 +1307,20 @@ void RunI16x8ShiftOpTest(WasmOpcode simd_op, Int16ShiftOp expected_op, } WASM_SIMD_TEST(I16x8Shl) { - RunI16x8ShiftOpTest(kExprI16x8Shl, LogicalShiftLeft, 1); + RunI16x8ShiftOpTest(execution_mode, kExprI16x8Shl, LogicalShiftLeft, 1); } WASM_SIMD_TEST(I16x8ShrS) { - RunI16x8ShiftOpTest(kExprI16x8ShrS, ArithmeticShiftRight, 1); + RunI16x8ShiftOpTest(execution_mode, kExprI16x8ShrS, ArithmeticShiftRight, 1); } WASM_SIMD_TEST(I16x8ShrU) { - RunI16x8ShiftOpTest(kExprI16x8ShrU, LogicalShiftRight, 1); + RunI16x8ShiftOpTest(execution_mode, kExprI16x8ShrU, LogicalShiftRight, 1); } -void RunI8x16UnOpTest(WasmOpcode simd_op, Int8UnOp expected_op) { - WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); +void RunI8x16UnOpTest(WasmExecutionMode execution_mode, WasmOpcode simd_op, + Int8UnOp expected_op) { + WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); byte a = 0; byte expected = 1; byte simd = r.AllocateLocal(kWasmS128); @@ -1273,15 +1331,17 @@ void RunI8x16UnOpTest(WasmOpcode simd_op, Int8UnOp expected_op) { FOR_INT8_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i))); } } -WASM_SIMD_TEST(I8x16Neg) { RunI8x16UnOpTest(kExprI8x16Neg, Negate); } +WASM_SIMD_TEST(I8x16Neg) { + RunI8x16UnOpTest(execution_mode, kExprI8x16Neg, Negate); +} #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_X64 || - // SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 + // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || \ V8_TARGET_ARCH_MIPS64 // Tests both signed and unsigned conversion from I16x8 (packing). -WASM_SIMD_TEST(I8x16ConvertI16x8) { - WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); +WASM_SIMD_COMPILED_TEST(I8x16ConvertI16x8) { + WasmRunner<int32_t, int32_t, int32_t, int32_t> r(execution_mode); byte a = 0; byte packed_signed = 1; byte packed_unsigned = 2; @@ -1310,9 +1370,10 @@ WASM_SIMD_TEST(I8x16ConvertI16x8) { // V8_TARGET_ARCH_MIPS64 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_X64 || \ - SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 -void RunI8x16BinOpTest(WasmOpcode simd_op, Int8BinOp expected_op) { - WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); + V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 +void RunI8x16BinOpTest(WasmExecutionMode execution_mode, WasmOpcode simd_op, + Int8BinOp expected_op) { + WasmRunner<int32_t, int32_t, int32_t, int32_t> r(execution_mode); byte a = 0; byte b = 1; byte expected = 2; @@ -1329,40 +1390,51 @@ void RunI8x16BinOpTest(WasmOpcode simd_op, Int8BinOp expected_op) { } } -WASM_SIMD_TEST(I8x16Add) { RunI8x16BinOpTest(kExprI8x16Add, Add); } +WASM_SIMD_TEST(I8x16Add) { + RunI8x16BinOpTest(execution_mode, kExprI8x16Add, Add); +} WASM_SIMD_TEST(I8x16AddSaturateS) { - RunI8x16BinOpTest(kExprI8x16AddSaturateS, AddSaturate); + RunI8x16BinOpTest(execution_mode, kExprI8x16AddSaturateS, AddSaturate); } -WASM_SIMD_TEST(I8x16Sub) { RunI8x16BinOpTest(kExprI8x16Sub, Sub); } +WASM_SIMD_TEST(I8x16Sub) { + RunI8x16BinOpTest(execution_mode, kExprI8x16Sub, Sub); +} WASM_SIMD_TEST(I8x16SubSaturateS) { - RunI8x16BinOpTest(kExprI8x16SubSaturateS, SubSaturate); + RunI8x16BinOpTest(execution_mode, kExprI8x16SubSaturateS, SubSaturate); } -WASM_SIMD_TEST(I8x16MinS) { RunI8x16BinOpTest(kExprI8x16MinS, Minimum); } +WASM_SIMD_TEST(I8x16MinS) { + RunI8x16BinOpTest(execution_mode, kExprI8x16MinS, Minimum); +} -WASM_SIMD_TEST(I8x16MaxS) { RunI8x16BinOpTest(kExprI8x16MaxS, Maximum); } +WASM_SIMD_TEST(I8x16MaxS) { + RunI8x16BinOpTest(execution_mode, kExprI8x16MaxS, Maximum); +} WASM_SIMD_TEST(I8x16AddSaturateU) { - RunI8x16BinOpTest(kExprI8x16AddSaturateU, UnsignedAddSaturate); + RunI8x16BinOpTest(execution_mode, kExprI8x16AddSaturateU, + UnsignedAddSaturate); } WASM_SIMD_TEST(I8x16SubSaturateU) { - RunI8x16BinOpTest(kExprI8x16SubSaturateU, UnsignedSubSaturate); + RunI8x16BinOpTest(execution_mode, kExprI8x16SubSaturateU, + UnsignedSubSaturate); } WASM_SIMD_TEST(I8x16MinU) { - RunI8x16BinOpTest(kExprI8x16MinU, UnsignedMinimum); + RunI8x16BinOpTest(execution_mode, kExprI8x16MinU, UnsignedMinimum); } WASM_SIMD_TEST(I8x16MaxU) { - RunI8x16BinOpTest(kExprI8x16MaxU, UnsignedMaximum); + RunI8x16BinOpTest(execution_mode, kExprI8x16MaxU, UnsignedMaximum); } -void RunI8x16CompareOpTest(WasmOpcode simd_op, Int8CompareOp expected_op) { - WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); +void RunI8x16CompareOpTest(WasmExecutionMode execution_mode, WasmOpcode simd_op, + Int8CompareOp expected_op) { + WasmRunner<int32_t, int32_t, int32_t, int32_t> r(execution_mode); byte a = 0; byte b = 1; byte expected = 2; @@ -1379,43 +1451,59 @@ void RunI8x16CompareOpTest(WasmOpcode simd_op, Int8CompareOp expected_op) { } } -WASM_SIMD_TEST(I8x16Eq) { RunI8x16CompareOpTest(kExprI8x16Eq, Equal); } +WASM_SIMD_TEST(I8x16Eq) { + RunI8x16CompareOpTest(execution_mode, kExprI8x16Eq, Equal); +} -WASM_SIMD_TEST(I8x16Ne) { RunI8x16CompareOpTest(kExprI8x16Ne, NotEqual); } +WASM_SIMD_TEST(I8x16Ne) { + RunI8x16CompareOpTest(execution_mode, kExprI8x16Ne, NotEqual); +} -WASM_SIMD_TEST(I8x16GtS) { RunI8x16CompareOpTest(kExprI8x16GtS, Greater); } +WASM_SIMD_TEST(I8x16GtS) { + RunI8x16CompareOpTest(execution_mode, kExprI8x16GtS, Greater); +} -WASM_SIMD_TEST(I8x16GeS) { RunI8x16CompareOpTest(kExprI8x16GeS, GreaterEqual); } +WASM_SIMD_TEST(I8x16GeS) { + RunI8x16CompareOpTest(execution_mode, kExprI8x16GeS, GreaterEqual); +} -WASM_SIMD_TEST(I8x16LtS) { RunI8x16CompareOpTest(kExprI8x16LtS, Less); } +WASM_SIMD_TEST(I8x16LtS) { + RunI8x16CompareOpTest(execution_mode, kExprI8x16LtS, Less); +} -WASM_SIMD_TEST(I8x16LeS) { RunI8x16CompareOpTest(kExprI8x16LeS, LessEqual); } +WASM_SIMD_TEST(I8x16LeS) { + RunI8x16CompareOpTest(execution_mode, kExprI8x16LeS, LessEqual); +} WASM_SIMD_TEST(I8x16GtU) { - RunI8x16CompareOpTest(kExprI8x16GtU, UnsignedGreater); + RunI8x16CompareOpTest(execution_mode, kExprI8x16GtU, UnsignedGreater); } WASM_SIMD_TEST(I8x16GeU) { - RunI8x16CompareOpTest(kExprI8x16GeU, UnsignedGreaterEqual); + RunI8x16CompareOpTest(execution_mode, kExprI8x16GeU, UnsignedGreaterEqual); } -WASM_SIMD_TEST(I8x16LtU) { RunI8x16CompareOpTest(kExprI8x16LtU, UnsignedLess); } +WASM_SIMD_TEST(I8x16LtU) { + RunI8x16CompareOpTest(execution_mode, kExprI8x16LtU, UnsignedLess); +} WASM_SIMD_TEST(I8x16LeU) { - RunI8x16CompareOpTest(kExprI8x16LeU, UnsignedLessEqual); + RunI8x16CompareOpTest(execution_mode, kExprI8x16LeU, UnsignedLessEqual); } #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_X64 || - // SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 - -#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || SIMD_LOWERING_TARGET || \ - V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 -WASM_SIMD_TEST(I8x16Mul) { RunI8x16BinOpTest(kExprI8x16Mul, Mul); } -#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_X64 || // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 -void RunI8x16ShiftOpTest(WasmOpcode simd_op, Int8ShiftOp expected_op, - int shift) { - WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); +#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || \ + V8_TARGET_ARCH_MIPS64 +WASM_SIMD_TEST(I8x16Mul) { + RunI8x16BinOpTest(execution_mode, kExprI8x16Mul, Mul); +} +#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || + // V8_TARGET_ARCH_MIPS64 + +void RunI8x16ShiftOpTest(WasmExecutionMode execution_mode, WasmOpcode simd_op, + Int8ShiftOp expected_op, int shift) { + WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); byte a = 0; byte expected = 1; byte simd = r.AllocateLocal(kWasmS128); @@ -1428,20 +1516,20 @@ void RunI8x16ShiftOpTest(WasmOpcode simd_op, Int8ShiftOp expected_op, } #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || \ - V8_TARGET_ARCH_MIPS64 || SIMD_LOWERING_TARGET + V8_TARGET_ARCH_MIPS64 WASM_SIMD_TEST(I8x16Shl) { - RunI8x16ShiftOpTest(kExprI8x16Shl, LogicalShiftLeft, 1); + RunI8x16ShiftOpTest(execution_mode, kExprI8x16Shl, LogicalShiftLeft, 1); } WASM_SIMD_TEST(I8x16ShrS) { - RunI8x16ShiftOpTest(kExprI8x16ShrS, ArithmeticShiftRight, 1); + RunI8x16ShiftOpTest(execution_mode, kExprI8x16ShrS, ArithmeticShiftRight, 1); } WASM_SIMD_TEST(I8x16ShrU) { - RunI8x16ShiftOpTest(kExprI8x16ShrU, LogicalShiftRight, 1); + RunI8x16ShiftOpTest(execution_mode, kExprI8x16ShrU, LogicalShiftRight, 1); } #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || - // V8_TARGET_ARCH_MIPS64 || SIMD_LOWERING_TARGET + // V8_TARGET_ARCH_MIPS64 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_X64 || \ V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 @@ -1449,8 +1537,8 @@ WASM_SIMD_TEST(I8x16ShrU) { // rest false, and comparing for non-equality with zero to convert to a boolean // vector. #define WASM_SIMD_SELECT_TEST(format) \ - WASM_SIMD_TEST(S##format##Select) { \ - WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); \ + WASM_SIMD_COMPILED_TEST(S##format##Select) { \ + WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); \ byte val1 = 0; \ byte val2 = 1; \ byte src1 = r.AllocateLocal(kWasmS128); \ @@ -1489,8 +1577,8 @@ WASM_SIMD_SELECT_TEST(8x16) // Test Select by making a mask where the 0th and 3rd lanes are non-zero and the // 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(kExecuteCompiled); \ + WASM_SIMD_COMPILED_TEST(S##format##NonCanonicalSelect) { \ + WasmRunner<int32_t, int32_t, int32_t, int32_t> r(execution_mode); \ byte val1 = 0; \ byte val2 = 1; \ byte combined = 2; \ @@ -1522,17 +1610,13 @@ WASM_SIMD_SELECT_TEST(8x16) WASM_SIMD_NON_CANONICAL_SELECT_TEST(32x4) WASM_SIMD_NON_CANONICAL_SELECT_TEST(16x8) WASM_SIMD_NON_CANONICAL_SELECT_TEST(8x16) -#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_X64 || - // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 -#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_X64 || \ - V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 // Test binary ops with two lane test patterns, all lanes distinct. template <typename T> void RunBinaryLaneOpTest( - WasmOpcode simd_op, + WasmExecutionMode execution_mode, WasmOpcode simd_op, const std::array<T, kSimd128Size / sizeof(T)>& expected) { - WasmRunner<int32_t> r(kExecuteCompiled); + WasmRunner<int32_t> r(execution_mode); // 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); @@ -1559,17 +1643,14 @@ void RunBinaryLaneOpTest( CHECK_EQ(src0[i], expected[i]); } } -#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_MIPS || - // V8_TARGET_ARCH_MIPS64 -#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_X64 || \ - V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 -WASM_SIMD_TEST(I32x4AddHoriz) { - RunBinaryLaneOpTest<int32_t>(kExprI32x4AddHoriz, {{1, 5, 9, 13}}); +WASM_SIMD_COMPILED_TEST(I32x4AddHoriz) { + RunBinaryLaneOpTest<int32_t>(execution_mode, kExprI32x4AddHoriz, + {{1, 5, 9, 13}}); } -WASM_SIMD_TEST(I16x8AddHoriz) { - RunBinaryLaneOpTest<int16_t>(kExprI16x8AddHoriz, +WASM_SIMD_COMPILED_TEST(I16x8AddHoriz) { + RunBinaryLaneOpTest<int16_t>(execution_mode, kExprI16x8AddHoriz, {{1, 5, 9, 13, 17, 21, 25, 29}}); } #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_X64 || @@ -1577,251 +1658,270 @@ WASM_SIMD_TEST(I16x8AddHoriz) { #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || \ V8_TARGET_ARCH_MIPS64 -WASM_SIMD_TEST(F32x4AddHoriz) { - RunBinaryLaneOpTest<float>(kExprF32x4AddHoriz, {{1.0f, 5.0f, 9.0f, 13.0f}}); +WASM_SIMD_COMPILED_TEST(F32x4AddHoriz) { + RunBinaryLaneOpTest<float>(execution_mode, kExprF32x4AddHoriz, + {{1.0f, 5.0f, 9.0f, 13.0f}}); } -#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || - // V8_TARGET_ARCH_MIPS64 -#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || \ - V8_TARGET_ARCH_MIPS64 // Test some regular shuffles that may have special handling on some targets. // Test a normal and unary versions (where second operand isn't used). -WASM_SIMD_TEST(S32x4Dup) { +WASM_SIMD_COMPILED_TEST(S32x4Dup) { RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, + execution_mode, kExprS8x16Shuffle, {{16, 17, 18, 19, 16, 17, 18, 19, 16, 17, 18, 19, 16, 17, 18, 19}}); RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, {{4, 5, 6, 7, 4, 5, 6, 7, 4, 5, 6, 7, 4, 5, 6, 7}}); + execution_mode, kExprS8x16Shuffle, + {{4, 5, 6, 7, 4, 5, 6, 7, 4, 5, 6, 7, 4, 5, 6, 7}}); } -WASM_SIMD_TEST(S32x4ZipLeft) { +WASM_SIMD_COMPILED_TEST(S32x4ZipLeft) { RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, + execution_mode, kExprS8x16Shuffle, {{0, 1, 2, 3, 16, 17, 18, 19, 4, 5, 6, 7, 20, 21, 22, 23}}); RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, {{0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 6, 7, 4, 5, 6, 7}}); + execution_mode, kExprS8x16Shuffle, + {{0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 6, 7, 4, 5, 6, 7}}); } -WASM_SIMD_TEST(S32x4ZipRight) { +WASM_SIMD_COMPILED_TEST(S32x4ZipRight) { RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, + execution_mode, kExprS8x16Shuffle, {{8, 9, 10, 11, 24, 25, 26, 27, 12, 13, 14, 15, 28, 29, 30, 31}}); RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, + execution_mode, kExprS8x16Shuffle, {{8, 9, 10, 11, 8, 9, 10, 11, 12, 13, 14, 15, 12, 13, 14, 15}}); } -WASM_SIMD_TEST(S32x4UnzipLeft) { +WASM_SIMD_COMPILED_TEST(S32x4UnzipLeft) { RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, + execution_mode, kExprS8x16Shuffle, {{0, 1, 2, 3, 8, 9, 10, 11, 16, 17, 18, 19, 24, 25, 26, 27}}); - RunBinaryLaneOpTest<int8_t>(kExprS8x16Shuffle, {{0, 1, 2, 3, 8, 9, 10, 11, 0, - 1, 2, 3, 8, 9, 10, 11}}); + RunBinaryLaneOpTest<int8_t>( + execution_mode, kExprS8x16Shuffle, + {{0, 1, 2, 3, 8, 9, 10, 11, 0, 1, 2, 3, 8, 9, 10, 11}}); } -WASM_SIMD_TEST(S32x4UnzipRight) { +WASM_SIMD_COMPILED_TEST(S32x4UnzipRight) { RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, + execution_mode, kExprS8x16Shuffle, {{4, 5, 6, 7, 12, 13, 14, 15, 20, 21, 22, 23, 28, 29, 30, 31}}); RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, + execution_mode, kExprS8x16Shuffle, {{4, 5, 6, 7, 12, 13, 14, 15, 4, 5, 6, 7, 12, 13, 14, 15}}); } -WASM_SIMD_TEST(S32x4TransposeLeft) { +WASM_SIMD_COMPILED_TEST(S32x4TransposeLeft) { RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, + execution_mode, kExprS8x16Shuffle, {{0, 1, 2, 3, 16, 17, 18, 19, 8, 9, 10, 11, 24, 25, 26, 27}}); - RunBinaryLaneOpTest<int8_t>(kExprS8x16Shuffle, {{0, 1, 2, 3, 0, 1, 2, 3, 8, 9, - 10, 11, 8, 9, 10, 11}}); + RunBinaryLaneOpTest<int8_t>( + execution_mode, kExprS8x16Shuffle, + {{0, 1, 2, 3, 0, 1, 2, 3, 8, 9, 10, 11, 8, 9, 10, 11}}); } -WASM_SIMD_TEST(S32x4TransposeRight) { +WASM_SIMD_COMPILED_TEST(S32x4TransposeRight) { RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, + execution_mode, kExprS8x16Shuffle, {{4, 5, 6, 7, 20, 21, 22, 23, 12, 13, 14, 15, 28, 29, 30, 31}}); RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, + execution_mode, kExprS8x16Shuffle, {{4, 5, 6, 7, 4, 5, 6, 7, 12, 13, 14, 15, 12, 13, 14, 15}}); } // Reverses are only unary. -WASM_SIMD_TEST(S32x2Reverse) { - RunBinaryLaneOpTest<int8_t>(kExprS8x16Shuffle, {{4, 5, 6, 7, 0, 1, 2, 3, 12, - 13, 14, 15, 8, 9, 10, 11}}); +WASM_SIMD_COMPILED_TEST(S32x2Reverse) { + RunBinaryLaneOpTest<int8_t>( + execution_mode, kExprS8x16Shuffle, + {{4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15, 8, 9, 10, 11}}); } // Test irregular shuffle. -WASM_SIMD_TEST(S32x4Irregular) { +WASM_SIMD_COMPILED_TEST(S32x4Irregular) { RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, + execution_mode, kExprS8x16Shuffle, {{0, 1, 2, 3, 16, 17, 18, 19, 16, 17, 18, 19, 20, 21, 22, 23}}); RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, {{0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 6, 7}}); + execution_mode, kExprS8x16Shuffle, + {{0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 6, 7}}); } -WASM_SIMD_TEST(S16x8Dup) { +WASM_SIMD_COMPILED_TEST(S16x8Dup) { RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, + execution_mode, kExprS8x16Shuffle, {{18, 19, 18, 19, 18, 19, 18, 19, 18, 19, 18, 19, 18, 19, 18, 19}}); RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, {{6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7}}); + execution_mode, kExprS8x16Shuffle, + {{6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7}}); } -WASM_SIMD_TEST(S16x8ZipLeft) { +WASM_SIMD_COMPILED_TEST(S16x8ZipLeft) { RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, + execution_mode, kExprS8x16Shuffle, {{0, 1, 16, 17, 2, 3, 18, 19, 4, 5, 20, 21, 6, 7, 22, 23}}); RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, {{0, 1, 0, 1, 2, 3, 2, 3, 4, 5, 4, 5, 6, 7, 6, 7}}); + execution_mode, kExprS8x16Shuffle, + {{0, 1, 0, 1, 2, 3, 2, 3, 4, 5, 4, 5, 6, 7, 6, 7}}); } -WASM_SIMD_TEST(S16x8ZipRight) { +WASM_SIMD_COMPILED_TEST(S16x8ZipRight) { RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, + execution_mode, kExprS8x16Shuffle, {{8, 9, 24, 25, 10, 11, 26, 27, 12, 13, 28, 29, 14, 15, 30, 31}}); RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, + execution_mode, kExprS8x16Shuffle, {{8, 9, 8, 9, 10, 11, 10, 11, 12, 13, 12, 13, 14, 15, 14, 15}}); } -WASM_SIMD_TEST(S16x8UnzipLeft) { +WASM_SIMD_COMPILED_TEST(S16x8UnzipLeft) { RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, + execution_mode, kExprS8x16Shuffle, {{0, 1, 4, 5, 8, 9, 12, 13, 16, 17, 20, 21, 24, 25, 28, 29}}); - RunBinaryLaneOpTest<int8_t>(kExprS8x16Shuffle, {{0, 1, 4, 5, 8, 9, 12, 13, 0, - 1, 4, 5, 8, 9, 12, 13}}); + RunBinaryLaneOpTest<int8_t>( + execution_mode, kExprS8x16Shuffle, + {{0, 1, 4, 5, 8, 9, 12, 13, 0, 1, 4, 5, 8, 9, 12, 13}}); } -WASM_SIMD_TEST(S16x8UnzipRight) { +WASM_SIMD_COMPILED_TEST(S16x8UnzipRight) { RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, + execution_mode, kExprS8x16Shuffle, {{2, 3, 6, 7, 10, 11, 14, 15, 18, 19, 22, 23, 26, 27, 30, 31}}); RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, + execution_mode, kExprS8x16Shuffle, {{2, 3, 6, 7, 10, 11, 14, 15, 2, 3, 6, 7, 10, 11, 14, 15}}); } -WASM_SIMD_TEST(S16x8TransposeLeft) { +WASM_SIMD_COMPILED_TEST(S16x8TransposeLeft) { RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, + execution_mode, kExprS8x16Shuffle, {{0, 1, 16, 17, 4, 5, 20, 21, 8, 9, 24, 25, 12, 13, 28, 29}}); - RunBinaryLaneOpTest<int8_t>(kExprS8x16Shuffle, {{0, 1, 0, 1, 4, 5, 4, 5, 8, 9, - 8, 9, 12, 13, 12, 13}}); + RunBinaryLaneOpTest<int8_t>( + execution_mode, kExprS8x16Shuffle, + {{0, 1, 0, 1, 4, 5, 4, 5, 8, 9, 8, 9, 12, 13, 12, 13}}); } -WASM_SIMD_TEST(S16x8TransposeRight) { +WASM_SIMD_COMPILED_TEST(S16x8TransposeRight) { RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, + execution_mode, kExprS8x16Shuffle, {{2, 3, 18, 19, 6, 7, 22, 23, 10, 11, 26, 27, 14, 15, 30, 31}}); RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, + execution_mode, kExprS8x16Shuffle, {{2, 3, 2, 3, 6, 7, 6, 7, 10, 11, 10, 11, 14, 15, 14, 15}}); } -WASM_SIMD_TEST(S16x4Reverse) { - RunBinaryLaneOpTest<int8_t>(kExprS8x16Shuffle, {{6, 7, 4, 5, 2, 3, 0, 1, 14, - 15, 12, 13, 10, 11, 8, 9}}); +WASM_SIMD_COMPILED_TEST(S16x4Reverse) { + RunBinaryLaneOpTest<int8_t>( + execution_mode, kExprS8x16Shuffle, + {{6, 7, 4, 5, 2, 3, 0, 1, 14, 15, 12, 13, 10, 11, 8, 9}}); } -WASM_SIMD_TEST(S16x2Reverse) { - RunBinaryLaneOpTest<int8_t>(kExprS8x16Shuffle, {{2, 3, 0, 1, 6, 7, 4, 5, 10, - 11, 8, 9, 14, 15, 12, 13}}); +WASM_SIMD_COMPILED_TEST(S16x2Reverse) { + RunBinaryLaneOpTest<int8_t>( + execution_mode, kExprS8x16Shuffle, + {{2, 3, 0, 1, 6, 7, 4, 5, 10, 11, 8, 9, 14, 15, 12, 13}}); } -WASM_SIMD_TEST(S16x8Irregular) { +WASM_SIMD_COMPILED_TEST(S16x8Irregular) { RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, + execution_mode, kExprS8x16Shuffle, {{0, 1, 16, 17, 16, 17, 0, 1, 4, 5, 20, 21, 6, 7, 22, 23}}); RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, {{0, 1, 0, 1, 0, 1, 0, 1, 4, 5, 4, 5, 6, 7, 6, 7}}); + execution_mode, kExprS8x16Shuffle, + {{0, 1, 0, 1, 0, 1, 0, 1, 4, 5, 4, 5, 6, 7, 6, 7}}); } -WASM_SIMD_TEST(S8x16Dup) { +WASM_SIMD_COMPILED_TEST(S8x16Dup) { RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, + execution_mode, kExprS8x16Shuffle, {{19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19}}); RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, {{7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}}); + execution_mode, kExprS8x16Shuffle, + {{7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}}); } -WASM_SIMD_TEST(S8x16ZipLeft) { +WASM_SIMD_COMPILED_TEST(S8x16ZipLeft) { RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, + execution_mode, kExprS8x16Shuffle, {{0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23}}); RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, {{0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7}}); + execution_mode, kExprS8x16Shuffle, + {{0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7}}); } -WASM_SIMD_TEST(S8x16ZipRight) { +WASM_SIMD_COMPILED_TEST(S8x16ZipRight) { RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, + execution_mode, kExprS8x16Shuffle, {{8, 24, 9, 25, 10, 26, 11, 27, 12, 28, 13, 29, 14, 30, 15, 31}}); RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, + execution_mode, kExprS8x16Shuffle, {{8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15}}); } -WASM_SIMD_TEST(S8x16UnzipLeft) { +WASM_SIMD_COMPILED_TEST(S8x16UnzipLeft) { RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, + execution_mode, kExprS8x16Shuffle, {{0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30}}); - RunBinaryLaneOpTest<int8_t>(kExprS8x16Shuffle, {{0, 2, 4, 6, 8, 10, 12, 14, 0, - 2, 4, 6, 8, 10, 12, 14}}); + RunBinaryLaneOpTest<int8_t>( + execution_mode, kExprS8x16Shuffle, + {{0, 2, 4, 6, 8, 10, 12, 14, 0, 2, 4, 6, 8, 10, 12, 14}}); } -WASM_SIMD_TEST(S8x16UnzipRight) { +WASM_SIMD_COMPILED_TEST(S8x16UnzipRight) { RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, + execution_mode, kExprS8x16Shuffle, {{1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31}}); - RunBinaryLaneOpTest<int8_t>(kExprS8x16Shuffle, {{1, 3, 5, 7, 9, 11, 13, 15, 1, - 3, 5, 7, 9, 11, 13, 15}}); + RunBinaryLaneOpTest<int8_t>( + execution_mode, kExprS8x16Shuffle, + {{1, 3, 5, 7, 9, 11, 13, 15, 1, 3, 5, 7, 9, 11, 13, 15}}); } -WASM_SIMD_TEST(S8x16TransposeLeft) { +WASM_SIMD_COMPILED_TEST(S8x16TransposeLeft) { RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, + execution_mode, kExprS8x16Shuffle, {{0, 16, 2, 18, 4, 20, 6, 22, 8, 24, 10, 26, 12, 28, 14, 30}}); - RunBinaryLaneOpTest<int8_t>(kExprS8x16Shuffle, {{0, 0, 2, 2, 4, 4, 6, 6, 8, 8, - 10, 10, 12, 12, 14, 14}}); + RunBinaryLaneOpTest<int8_t>( + execution_mode, kExprS8x16Shuffle, + {{0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14}}); } -WASM_SIMD_TEST(S8x16TransposeRight) { +WASM_SIMD_COMPILED_TEST(S8x16TransposeRight) { RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, + execution_mode, kExprS8x16Shuffle, {{1, 17, 3, 19, 5, 21, 7, 23, 9, 25, 11, 27, 13, 29, 15, 31}}); - RunBinaryLaneOpTest<int8_t>(kExprS8x16Shuffle, {{1, 1, 3, 3, 5, 5, 7, 7, 9, 9, - 11, 11, 13, 13, 15, 15}}); + RunBinaryLaneOpTest<int8_t>( + execution_mode, kExprS8x16Shuffle, + {{1, 1, 3, 3, 5, 5, 7, 7, 9, 9, 11, 11, 13, 13, 15, 15}}); } -WASM_SIMD_TEST(S8x8Reverse) { - RunBinaryLaneOpTest<int8_t>(kExprS8x16Shuffle, {{7, 6, 5, 4, 3, 2, 1, 0, 15, - 14, 13, 12, 11, 10, 9, 8}}); +WASM_SIMD_COMPILED_TEST(S8x8Reverse) { + RunBinaryLaneOpTest<int8_t>( + execution_mode, kExprS8x16Shuffle, + {{7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8}}); } -WASM_SIMD_TEST(S8x4Reverse) { - RunBinaryLaneOpTest<int8_t>(kExprS8x16Shuffle, {{3, 2, 1, 0, 7, 6, 5, 4, 11, - 10, 9, 8, 15, 14, 13, 12}}); +WASM_SIMD_COMPILED_TEST(S8x4Reverse) { + RunBinaryLaneOpTest<int8_t>( + execution_mode, kExprS8x16Shuffle, + {{3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12}}); } -WASM_SIMD_TEST(S8x2Reverse) { - RunBinaryLaneOpTest<int8_t>(kExprS8x16Shuffle, {{1, 0, 3, 2, 5, 4, 7, 6, 9, 8, - 11, 10, 13, 12, 15, 14}}); +WASM_SIMD_COMPILED_TEST(S8x2Reverse) { + RunBinaryLaneOpTest<int8_t>( + execution_mode, kExprS8x16Shuffle, + {{1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14}}); } -WASM_SIMD_TEST(S8x16Irregular) { +WASM_SIMD_COMPILED_TEST(S8x16Irregular) { RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, + execution_mode, kExprS8x16Shuffle, {{0, 16, 0, 16, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23}}); RunBinaryLaneOpTest<int8_t>( - kExprS8x16Shuffle, {{0, 0, 0, 0, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7}}); + execution_mode, kExprS8x16Shuffle, + {{0, 0, 0, 0, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7}}); } // Test shuffles that concatenate the two vectors. -void RunConcatOpTest() {} -WASM_SIMD_TEST(S8x16Concat) { +WASM_SIMD_COMPILED_TEST(S8x16Concat) { static const int kLanes = 16; std::array<uint8_t, kLanes> expected; for (int bias = 1; bias < kLanes; bias++) { @@ -1834,20 +1934,16 @@ WASM_SIMD_TEST(S8x16Concat) { for (int j = 0; j < bias; j++) { expected[i++] = j + kLanes; } - RunBinaryLaneOpTest(kExprS8x16Shuffle, expected); + RunBinaryLaneOpTest(execution_mode, kExprS8x16Shuffle, expected); } } -#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || - // V8_TARGET_ARCH_MIPS64 -#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || \ - V8_TARGET_ARCH_MIPS64 // Boolean unary operations are 'AllTrue' and 'AnyTrue', which return an integer // result. Use relational ops on numeric vectors to create the boolean vector // 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(kExecuteCompiled); \ + WASM_SIMD_COMPILED_TEST(ReductionTest##lanes) { \ + WasmRunner<int32_t> r(execution_mode); \ byte zero = r.AllocateLocal(kWasmS128); \ byte one_one = r.AllocateLocal(kWasmS128); \ byte reduced = r.AllocateLocal(kWasmI32); \ @@ -1919,13 +2015,8 @@ WASM_SIMD_BOOL_REDUCTION_TEST(32x4, 4) WASM_SIMD_BOOL_REDUCTION_TEST(16x8, 8) WASM_SIMD_BOOL_REDUCTION_TEST(8x16, 16) -#endif // !V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || - // V8_TARGET_ARCH_MIPS64 - -#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || SIMD_LOWERING_TARGET || \ - V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 WASM_SIMD_TEST(SimdI32x4ExtractWithF32x4) { - WasmRunner<int32_t> r(kExecuteCompiled); + WasmRunner<int32_t> r(execution_mode); BUILD(r, WASM_IF_ELSE_I( WASM_I32_EQ(WASM_SIMD_I32x4_EXTRACT_LANE( 0, WASM_SIMD_F32x4_SPLAT(WASM_F32(30.5))), @@ -1935,7 +2026,7 @@ WASM_SIMD_TEST(SimdI32x4ExtractWithF32x4) { } WASM_SIMD_TEST(SimdF32x4ExtractWithI32x4) { - WasmRunner<int32_t> r(kExecuteCompiled); + WasmRunner<int32_t> r(execution_mode); BUILD(r, WASM_IF_ELSE_I(WASM_F32_EQ(WASM_SIMD_F32x4_EXTRACT_LANE( 0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(15))), @@ -1949,7 +2040,7 @@ WASM_SIMD_TEST(SimdF32x4AddWithI32x4) { // representable as a float. const int kOne = 0x3f800000; const int kTwo = 0x40000000; - WasmRunner<int32_t> r(kExecuteCompiled); + WasmRunner<int32_t> r(execution_mode); BUILD(r, WASM_IF_ELSE_I( WASM_F32_EQ( @@ -1964,7 +2055,7 @@ WASM_SIMD_TEST(SimdF32x4AddWithI32x4) { } WASM_SIMD_TEST(SimdI32x4AddWithF32x4) { - WasmRunner<int32_t> r(kExecuteCompiled); + WasmRunner<int32_t> r(execution_mode); BUILD(r, WASM_IF_ELSE_I( WASM_I32_EQ( @@ -1977,13 +2068,13 @@ WASM_SIMD_TEST(SimdI32x4AddWithF32x4) { WASM_I32V(1), WASM_I32V(0))); CHECK_EQ(1, r.Call()); } -#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || SIMD_LOWERING_TARGET || - // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 +#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || + // V8_TARGET_ARCH_MIPS64 -#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || SIMD_LOWERING_TARGET || \ - V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 +#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_X64 || \ + V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 WASM_SIMD_TEST(SimdI32x4Local) { - WasmRunner<int32_t> r(kExecuteCompiled); + WasmRunner<int32_t> r(execution_mode); r.AllocateLocal(kWasmS128); BUILD(r, WASM_SET_LOCAL(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(31))), @@ -1992,7 +2083,7 @@ WASM_SIMD_TEST(SimdI32x4Local) { } WASM_SIMD_TEST(SimdI32x4SplatFromExtract) { - WasmRunner<int32_t> r(kExecuteCompiled); + WasmRunner<int32_t> r(execution_mode); r.AllocateLocal(kWasmI32); r.AllocateLocal(kWasmS128); BUILD(r, WASM_SET_LOCAL(0, WASM_SIMD_I32x4_EXTRACT_LANE( @@ -2003,7 +2094,7 @@ WASM_SIMD_TEST(SimdI32x4SplatFromExtract) { } WASM_SIMD_TEST(SimdI32x4For) { - WasmRunner<int32_t> r(kExecuteCompiled); + WasmRunner<int32_t> r(execution_mode); r.AllocateLocal(kWasmI32); r.AllocateLocal(kWasmS128); BUILD(r, @@ -2035,13 +2126,13 @@ WASM_SIMD_TEST(SimdI32x4For) { WASM_GET_LOCAL(0)); CHECK_EQ(1, r.Call()); } -#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || SIMD_LOWERING_TARGET || - // V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 +#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_X64 || + // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 -#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || SIMD_LOWERING_TARGET || \ - V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 +#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || \ + V8_TARGET_ARCH_MIPS64 WASM_SIMD_TEST(SimdF32x4For) { - WasmRunner<int32_t> r(kExecuteCompiled); + WasmRunner<int32_t> r(execution_mode); r.AllocateLocal(kWasmI32); r.AllocateLocal(kWasmS128); BUILD(r, WASM_SET_LOCAL(1, WASM_SIMD_F32x4_SPLAT(WASM_F32(21.25))), @@ -2063,11 +2154,11 @@ WASM_SIMD_TEST(SimdF32x4For) { WASM_GET_LOCAL(0)); CHECK_EQ(1, r.Call()); } -#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || SIMD_LOWERING_TARGET || - // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 +#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || + // V8_TARGET_ARCH_MIPS64 -#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || SIMD_LOWERING_TARGET || \ - V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 +#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_X64 || \ + V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 template <typename T, int numLanes = 4> void SetVectorByLanes(T* v, const std::array<T, numLanes>& arr) { @@ -2095,7 +2186,7 @@ const T& GetScalar(T* v, int lane) { } WASM_SIMD_TEST(SimdI32x4GetGlobal) { - WasmRunner<int32_t, int32_t> r(kExecuteCompiled); + WasmRunner<int32_t, int32_t> r(execution_mode); int32_t* global = r.builder().AddGlobal<int32_t>(kWasmS128); SetVectorByLanes(global, {{0, 1, 2, 3}}); r.AllocateLocal(kWasmI32); @@ -2118,7 +2209,7 @@ WASM_SIMD_TEST(SimdI32x4GetGlobal) { } WASM_SIMD_TEST(SimdI32x4SetGlobal) { - WasmRunner<int32_t, int32_t> r(kExecuteCompiled); + WasmRunner<int32_t, int32_t> r(execution_mode); int32_t* global = r.builder().AddGlobal<int32_t>(kWasmS128); BUILD(r, WASM_SET_GLOBAL(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(23))), WASM_SET_GLOBAL(0, WASM_SIMD_I32x4_REPLACE_LANE(1, WASM_GET_GLOBAL(0), @@ -2134,13 +2225,13 @@ WASM_SIMD_TEST(SimdI32x4SetGlobal) { CHECK_EQ(GetScalar(global, 2), 45); CHECK_EQ(GetScalar(global, 3), 56); } -#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || SIMD_LOWERING_TARGET || - // V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 +#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_X64 || + // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 -#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || SIMD_LOWERING_TARGET || \ - V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 +#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || \ + V8_TARGET_ARCH_MIPS64 WASM_SIMD_TEST(SimdF32x4GetGlobal) { - WasmRunner<int32_t, int32_t> r(kExecuteCompiled); + WasmRunner<int32_t, int32_t> r(execution_mode); float* global = r.builder().AddGlobal<float>(kWasmS128); SetVectorByLanes<float>(global, {{0.0, 1.5, 2.25, 3.5}}); r.AllocateLocal(kWasmI32); @@ -2163,7 +2254,7 @@ WASM_SIMD_TEST(SimdF32x4GetGlobal) { } WASM_SIMD_TEST(SimdF32x4SetGlobal) { - WasmRunner<int32_t, int32_t> r(kExecuteCompiled); + WasmRunner<int32_t, int32_t> r(execution_mode); 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), @@ -2179,13 +2270,13 @@ WASM_SIMD_TEST(SimdF32x4SetGlobal) { CHECK_EQ(GetScalar(global, 2), 32.25f); CHECK_EQ(GetScalar(global, 3), 65.0f); } -#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || SIMD_LOWERING_TARGET || - // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 +#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || + // V8_TARGET_ARCH_MIPS64 -#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || SIMD_LOWERING_TARGET || \ - V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 -WASM_SIMD_TEST(SimdLoadStoreLoad) { - WasmRunner<int32_t> r(kExecuteCompiled); +#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_X64 || \ + V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 +WASM_SIMD_COMPILED_TEST(SimdLoadStoreLoad) { + WasmRunner<int32_t> r(execution_mode); int32_t* memory = r.builder().AddMemoryElems<int32_t>(4); BUILD(r, WASM_SIMD_STORE_MEM(WASM_ZERO, WASM_SIMD_LOAD_MEM(WASM_ZERO)), @@ -2197,5 +2288,51 @@ WASM_SIMD_TEST(SimdLoadStoreLoad) { CHECK_EQ(expected, r.Call()); } } -#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || SIMD_LOWERING_TARGET || - // V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 +#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_X64 || + // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 + +#undef WASM_SIMD_TEST +#undef WASM_SIMD_COMPILED_TEST +#undef WASM_SIMD_CHECK_LANE +#undef WASM_SIMD_CHECK4 +#undef WASM_SIMD_CHECK_SPLAT4 +#undef WASM_SIMD_CHECK8 +#undef WASM_SIMD_CHECK_SPLAT8 +#undef WASM_SIMD_CHECK16 +#undef WASM_SIMD_CHECK_SPLAT16 +#undef WASM_SIMD_CHECK_F32_LANE +#undef WASM_SIMD_CHECK_F32x4 +#undef WASM_SIMD_CHECK_SPLAT_F32x4 +#undef WASM_SIMD_CHECK_F32_LANE_ESTIMATE +#undef WASM_SIMD_CHECK_SPLAT_F32x4_ESTIMATE +#undef TO_BYTE +#undef WASM_SIMD_OP +#undef WASM_SIMD_SPLAT +#undef WASM_SIMD_UNOP +#undef WASM_SIMD_BINOP +#undef WASM_SIMD_SHIFT_OP +#undef WASM_SIMD_CONCAT_OP +#undef WASM_SIMD_SELECT +#undef WASM_SIMD_F32x4_SPLAT +#undef WASM_SIMD_F32x4_EXTRACT_LANE +#undef WASM_SIMD_F32x4_REPLACE_LANE +#undef WASM_SIMD_I32x4_SPLAT +#undef WASM_SIMD_I32x4_EXTRACT_LANE +#undef WASM_SIMD_I32x4_REPLACE_LANE +#undef WASM_SIMD_I16x8_SPLAT +#undef WASM_SIMD_I16x8_EXTRACT_LANE +#undef WASM_SIMD_I16x8_REPLACE_LANE +#undef WASM_SIMD_I8x16_SPLAT +#undef WASM_SIMD_I8x16_EXTRACT_LANE +#undef WASM_SIMD_I8x16_REPLACE_LANE +#undef WASM_SIMD_S8x16_SHUFFLE_OP +#undef WASM_SIMD_LOAD_MEM +#undef WASM_SIMD_STORE_MEM +#undef WASM_SIMD_SELECT_TEST +#undef WASM_SIMD_NON_CANONICAL_SELECT_TEST +#undef WASM_SIMD_BOOL_REDUCTION_TEST + +} // namespace test_run_wasm_simd +} // namespace wasm +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/wasm/test-run-wasm.cc b/deps/v8/test/cctest/wasm/test-run-wasm.cc index 53bfc06674..3b27c78f60 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm.cc @@ -15,15 +15,14 @@ #include "test/common/wasm/test-signatures.h" #include "test/common/wasm/wasm-macro-gen.h" -using namespace v8::base; -using namespace v8::internal; -using namespace v8::internal::compiler; -using namespace v8::internal::wasm; +namespace v8 { +namespace internal { +namespace wasm { +namespace test_run_wasm { // for even shorter tests. #define B1(a) WASM_BLOCK(a) #define B2(a, b) WASM_BLOCK(a, b) -#define B3(a, b, c) WASM_BLOCK(a, b, c) #define RET(x) x, kExprReturn #define RET_I8(x) WASM_I32V_2(x), kExprReturn @@ -650,7 +649,6 @@ WASM_EXEC_TEST(IfElse_P) { CHECK_EQ(expected, r.Call(*i)); } } -#define EMPTY WASM_EXEC_TEST(If_empty1) { WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_mode); @@ -1941,18 +1939,21 @@ static void TestBuildGraphForSimpleExpression(WasmOpcode opcode) { Zone zone(isolate->allocator(), ZONE_NAME); HandleScope scope(isolate); // Enable all optional operators. - CommonOperatorBuilder common(&zone); - MachineOperatorBuilder machine(&zone, MachineType::PointerRepresentation(), - MachineOperatorBuilder::kAllOptionalOps); - Graph graph(&zone); - JSGraph jsgraph(isolate, &graph, &common, nullptr, nullptr, &machine); + compiler::CommonOperatorBuilder common(&zone); + compiler::MachineOperatorBuilder machine( + &zone, MachineType::PointerRepresentation(), + compiler::MachineOperatorBuilder::kAllOptionalOps); + compiler::Graph graph(&zone); + compiler::JSGraph jsgraph(isolate, &graph, &common, nullptr, nullptr, + &machine); FunctionSig* sig = WasmOpcodes::Signature(opcode); if (sig->parameter_count() == 1) { byte code[] = {WASM_NO_LOCALS, kExprGetLocal, 0, static_cast<byte>(opcode), WASM_END}; TestBuildingGraph(&zone, &jsgraph, nullptr, sig, nullptr, code, - code + arraysize(code)); + code + arraysize(code), + compiler::kNoRuntimeExceptionSupport); } else { CHECK_EQ(2, sig->parameter_count()); byte code[] = {WASM_NO_LOCALS, @@ -1963,7 +1964,8 @@ static void TestBuildGraphForSimpleExpression(WasmOpcode opcode) { static_cast<byte>(opcode), WASM_END}; TestBuildingGraph(&zone, &jsgraph, nullptr, sig, nullptr, code, - code + arraysize(code)); + code + arraysize(code), + compiler::kNoRuntimeExceptionSupport); } } @@ -2381,7 +2383,7 @@ 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(AddCall) { - WasmRunner<int32_t, int32_t> r(kExecuteCompiled); + WasmRunner<int32_t, int32_t> r(execution_mode); WasmFunctionCompiler& t1 = r.NewFunction<int32_t, int32_t, int32_t>(); BUILD(t1, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); @@ -3037,6 +3039,47 @@ WASM_EXEC_TEST(BranchOverUnreachableCode) { CHECK_EQ(18, r.Call()); } +WASM_EXEC_TEST(BranchOverUnreachableCodeInLoop0) { + WasmRunner<int32_t> r(execution_mode); + BUILD(r, + WASM_BLOCK_I( + // Start a loop which breaks in the middle (hence unreachable code + // afterwards) and continue execution after this loop. + // This should validate even though there is no value on the stack + // at the end of the loop. + WASM_LOOP_I(WASM_BRV(1, WASM_I32V_1(17)))), + // Add one to the 17 returned from the block. + WASM_ONE, kExprI32Add); + CHECK_EQ(18, r.Call()); +} + +WASM_EXEC_TEST(BranchOverUnreachableCodeInLoop1) { + WasmRunner<int32_t> r(execution_mode); + BUILD(r, + WASM_BLOCK_I( + // Start a loop which breaks in the middle (hence unreachable code + // afterwards) and continue execution after this loop. + // Even though unreachable, the loop leaves one value on the stack. + WASM_LOOP_I(WASM_BRV(1, WASM_I32V_1(17)), WASM_ONE)), + // Add one to the 17 returned from the block. + WASM_ONE, kExprI32Add); + CHECK_EQ(18, r.Call()); +} + +WASM_EXEC_TEST(BranchOverUnreachableCodeInLoop2) { + WasmRunner<int32_t> r(execution_mode); + BUILD(r, + WASM_BLOCK_I( + // Start a loop which breaks in the middle (hence unreachable code + // afterwards) and continue execution after this loop. + // The unreachable code is allowed to pop non-existing values off + // the stack and push back the result. + WASM_LOOP_I(WASM_BRV(1, WASM_I32V_1(17)), kExprI32Add)), + // Add one to the 17 returned from the block. + WASM_ONE, kExprI32Add); + CHECK_EQ(18, r.Call()); +} + WASM_EXEC_TEST(BlockInsideUnreachable) { WasmRunner<int32_t> r(execution_mode); BUILD(r, WASM_RETURN1(WASM_I32V_1(17)), WASM_BLOCK(WASM_BR(0))); @@ -3050,3 +3093,14 @@ WASM_EXEC_TEST(IfInsideUnreachable) { WASM_IF_ELSE_I(WASM_ONE, WASM_BRV(0, WASM_ONE), WASM_RETURN1(WASM_ONE))); CHECK_EQ(17, r.Call()); } + +#undef B1 +#undef B2 +#undef RET +#undef RET_I8 +#undef ADD_CODE + +} // namespace test_run_wasm +} // namespace wasm +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/wasm/test-streaming-compilation.cc b/deps/v8/test/cctest/wasm/test-streaming-compilation.cc new file mode 100644 index 0000000000..0e541efbbd --- /dev/null +++ b/deps/v8/test/cctest/wasm/test-streaming-compilation.cc @@ -0,0 +1,820 @@ +// Copyright 2017 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.h" +#include "src/objects-inl.h" +#include "src/v8.h" +#include "src/vector.h" + +#include "src/wasm/compilation-manager.h" +#include "src/wasm/module-decoder.h" +#include "src/wasm/streaming-decoder.h" +#include "src/wasm/wasm-module-builder.h" +#include "src/wasm/wasm-module.h" + +#include "test/cctest/cctest.h" + +#include "test/common/wasm/test-signatures.h" +#include "test/common/wasm/wasm-macro-gen.h" + +namespace v8 { +namespace internal { +namespace wasm { + +class MockPlatform final : public TestPlatform { + public: + MockPlatform() : old_platform_(i::V8::GetCurrentPlatform()) { + // Now that it's completely constructed, make this the current platform. + i::V8::SetPlatformForTesting(this); + } + virtual ~MockPlatform() { + // Delete all remaining tasks in the queue. + while (!tasks_.empty()) { + Task* task = tasks_.back(); + tasks_.pop_back(); + delete task; + } + i::V8::SetPlatformForTesting(old_platform_); + } + + void CallOnForegroundThread(v8::Isolate* isolate, Task* task) override { + tasks_.push_back(task); + } + + void CallOnBackgroundThread(v8::Task* task, + ExpectedRuntime expected_runtime) override { + tasks_.push_back(task); + } + + bool IdleTasksEnabled(v8::Isolate* isolate) override { return false; } + + void ExecuteTasks() { + while (!tasks_.empty()) { + Task* task = tasks_.back(); + tasks_.pop_back(); + task->Run(); + delete task; + } + } + + private: + // We do not execute tasks concurrently, so we only need one list of tasks. + std::vector<Task*> tasks_; + v8::Platform* old_platform_; +}; + +namespace { + +class StreamTester { + public: + StreamTester() : zone_(&allocator_, "StreamTester") { + v8::Isolate* isolate = CcTest::isolate(); + i::Isolate* i_isolate = CcTest::i_isolate(); + + // Create the promise for the streaming compilation. + v8::Local<v8::Context> context = isolate->GetCurrentContext(); + v8::Local<Promise::Resolver> resolver; + CHECK(Promise::Resolver::New(context).ToLocal(&resolver)); + CHECK(!i_isolate->has_scheduled_exception()); + promise_ = resolver->GetPromise(); + + i::Handle<i::JSPromise> i_promise = v8::Utils::OpenHandle(*promise_); + + stream_ = i_isolate->wasm_compilation_manager()->StartStreamingCompilation( + i_isolate, v8::Utils::OpenHandle(*context), i_promise); + } + + std::shared_ptr<StreamingDecoder> stream() { return stream_; } + + // Run all compiler tasks, both foreground and background tasks. + void RunCompilerTasks() { + static_cast<MockPlatform*>(i::V8::GetCurrentPlatform())->ExecuteTasks(); + } + + bool IsPromiseFulfilled() { + return promise_->State() == v8::Promise::kFulfilled; + } + + bool IsPromiseRejected() { + return promise_->State() == v8::Promise::kRejected; + } + + bool IsPromisePending() { return promise_->State() == v8::Promise::kPending; } + + void OnBytesReceived(const uint8_t* start, size_t length) { + stream_->OnBytesReceived(Vector<const uint8_t>(start, length)); + } + + void FinishStream() { stream_->Finish(); } + + Zone* zone() { return &zone_; } + + private: + AccountingAllocator allocator_; + Zone zone_; + v8::Local<v8::Promise> promise_; + std::shared_ptr<StreamingDecoder> stream_; +}; +} // namespace + +#define STREAM_TEST(name) \ + void RunStream_##name(); \ + TEST(name) { \ + MockPlatform platform; \ + CcTest::InitializeVM(); \ + v8::HandleScope handle_scope(CcTest::isolate()); \ + i::HandleScope internal_scope(CcTest::i_isolate()); \ + RunStream_##name(); \ + } \ + void RunStream_##name() + +// Create a valid module with 3 functions. +ZoneBuffer GetValidModuleBytes(Zone* zone) { + ZoneBuffer buffer(zone); + TestSignatures sigs; + WasmModuleBuilder builder(zone); + { + WasmFunctionBuilder* f = builder.AddFunction(sigs.i_iii()); + uint8_t code[] = {kExprGetLocal, 0, kExprEnd}; + f->EmitCode(code, arraysize(code)); + } + { + WasmFunctionBuilder* f = builder.AddFunction(sigs.i_iii()); + uint8_t code[] = {kExprGetLocal, 1, kExprEnd}; + f->EmitCode(code, arraysize(code)); + } + { + WasmFunctionBuilder* f = builder.AddFunction(sigs.i_iii()); + uint8_t code[] = {kExprGetLocal, 2, kExprEnd}; + f->EmitCode(code, arraysize(code)); + } + builder.WriteTo(buffer); + return buffer; +} + +// Test that all bytes arrive before doing any compilation. FinishStream is +// called immediately. +STREAM_TEST(TestAllBytesArriveImmediatelyStreamFinishesFirst) { + StreamTester tester; + ZoneBuffer buffer = GetValidModuleBytes(tester.zone()); + + tester.OnBytesReceived(buffer.begin(), buffer.end() - buffer.begin()); + tester.FinishStream(); + + tester.RunCompilerTasks(); + + CHECK(tester.IsPromiseFulfilled()); +} + +// Test that all bytes arrive before doing any compilation. FinishStream is +// called after the compilation is done. +STREAM_TEST(TestAllBytesArriveAOTCompilerFinishesFirst) { + StreamTester tester; + ZoneBuffer buffer = GetValidModuleBytes(tester.zone()); + + tester.OnBytesReceived(buffer.begin(), buffer.end() - buffer.begin()); + + tester.RunCompilerTasks(); + tester.FinishStream(); + tester.RunCompilerTasks(); + + CHECK(tester.IsPromiseFulfilled()); +} + +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); + CHECK(result.ok()); + std::unique_ptr<WasmModule> module = std::move(result.val); + const WasmFunction* func = &module->functions[1]; + return func->code.offset(); +} + +// Test that some functions come in the beginning, some come after some +// functions already got compiled. +STREAM_TEST(TestCutAfterOneFunctionStreamFinishesFirst) { + i::Isolate* isolate = CcTest::i_isolate(); + StreamTester tester; + ZoneBuffer buffer = GetValidModuleBytes(tester.zone()); + + size_t offset = GetFunctionOffset(isolate, buffer.begin(), buffer.size(), 1); + tester.OnBytesReceived(buffer.begin(), offset); + tester.RunCompilerTasks(); + CHECK(tester.IsPromisePending()); + tester.OnBytesReceived(buffer.begin() + offset, buffer.size() - offset); + tester.FinishStream(); + tester.RunCompilerTasks(); + CHECK(tester.IsPromiseFulfilled()); +} + +// Test that some functions come in the beginning, some come after some +// functions already got compiled. Call FinishStream after the compilation is +// done. +STREAM_TEST(TestCutAfterOneFunctionCompilerFinishesFirst) { + i::Isolate* isolate = CcTest::i_isolate(); + StreamTester tester; + ZoneBuffer buffer = GetValidModuleBytes(tester.zone()); + + size_t offset = GetFunctionOffset(isolate, buffer.begin(), buffer.size(), 1); + tester.OnBytesReceived(buffer.begin(), offset); + tester.RunCompilerTasks(); + CHECK(tester.IsPromisePending()); + tester.OnBytesReceived(buffer.begin() + offset, buffer.size() - offset); + tester.RunCompilerTasks(); + tester.FinishStream(); + tester.RunCompilerTasks(); + CHECK(tester.IsPromiseFulfilled()); +} + +// Create a module with an invalid global section. +ZoneBuffer GetModuleWithInvalidSection(Zone* zone) { + ZoneBuffer buffer(zone); + TestSignatures sigs; + WasmModuleBuilder builder(zone); + // Add an invalid global to the module. The decoder will fail there. + builder.AddGlobal(kWasmStmt, false, true, + WasmInitExpr(WasmInitExpr::kGlobalIndex, 12)); + { + WasmFunctionBuilder* f = builder.AddFunction(sigs.i_iii()); + uint8_t code[] = {kExprGetLocal, 0, kExprEnd}; + f->EmitCode(code, arraysize(code)); + } + { + WasmFunctionBuilder* f = builder.AddFunction(sigs.i_iii()); + uint8_t code[] = {kExprGetLocal, 1, kExprEnd}; + f->EmitCode(code, arraysize(code)); + } + { + WasmFunctionBuilder* f = builder.AddFunction(sigs.i_iii()); + uint8_t code[] = {kExprGetLocal, 2, kExprEnd}; + f->EmitCode(code, arraysize(code)); + } + builder.WriteTo(buffer); + return buffer; +} + +// Test an error in a section, found by the ModuleDecoder. +STREAM_TEST(TestErrorInSectionStreamFinishesFirst) { + StreamTester tester; + ZoneBuffer buffer = GetModuleWithInvalidSection(tester.zone()); + + tester.OnBytesReceived(buffer.begin(), buffer.end() - buffer.begin()); + tester.FinishStream(); + + tester.RunCompilerTasks(); + + CHECK(tester.IsPromiseRejected()); +} + +STREAM_TEST(TestErrorInSectionCompilerFinishesFirst) { + StreamTester tester; + ZoneBuffer buffer = GetModuleWithInvalidSection(tester.zone()); + + tester.OnBytesReceived(buffer.begin(), buffer.end() - buffer.begin()); + tester.RunCompilerTasks(); + tester.FinishStream(); + tester.RunCompilerTasks(); + + CHECK(tester.IsPromiseRejected()); +} + +STREAM_TEST(TestErrorInSectionWithCuts) { + StreamTester tester; + ZoneBuffer buffer = GetModuleWithInvalidSection(tester.zone()); + + const uint8_t* current = buffer.begin(); + size_t remaining = buffer.end() - buffer.begin(); + while (current < buffer.end()) { + size_t size = std::min(remaining, size_t{10}); + tester.OnBytesReceived(current, size); + tester.RunCompilerTasks(); + current += 10; + remaining -= size; + } + tester.FinishStream(); + tester.RunCompilerTasks(); + + CHECK(tester.IsPromiseRejected()); +} + +ZoneBuffer GetModuleWithInvalidSectionSize(Zone* zone) { + // We get a valid module and overwrite the size of the first section with an + // invalid value. + ZoneBuffer buffer = GetValidModuleBytes(zone); + // 9 == 4 (wasm magic) + 4 (version) + 1 (section code) + uint8_t* section_size_address = const_cast<uint8_t*>(buffer.begin()) + 9; + // 0x808080800f is an invalid module size in leb encoding. + section_size_address[0] = 0x80; + section_size_address[1] = 0x80; + section_size_address[2] = 0x80; + section_size_address[3] = 0x80; + section_size_address[4] = 0x0f; + return buffer; +} + +STREAM_TEST(TestErrorInSectionSizeStreamFinishesFirst) { + StreamTester tester; + ZoneBuffer buffer = GetModuleWithInvalidSectionSize(tester.zone()); + tester.OnBytesReceived(buffer.begin(), buffer.end() - buffer.begin()); + tester.FinishStream(); + tester.RunCompilerTasks(); + + CHECK(tester.IsPromiseRejected()); +} + +STREAM_TEST(TestErrorInSectionSizeCompilerFinishesFirst) { + StreamTester tester; + ZoneBuffer buffer = GetModuleWithInvalidSectionSize(tester.zone()); + tester.OnBytesReceived(buffer.begin(), buffer.end() - buffer.begin()); + tester.RunCompilerTasks(); + tester.FinishStream(); + tester.RunCompilerTasks(); + + CHECK(tester.IsPromiseRejected()); +} + +STREAM_TEST(TestErrorInSectionSizeWithCuts) { + StreamTester tester; + ZoneBuffer buffer = GetModuleWithInvalidSectionSize(tester.zone()); + const uint8_t* current = buffer.begin(); + size_t remaining = buffer.end() - buffer.begin(); + while (current < buffer.end()) { + size_t size = std::min(remaining, size_t{10}); + tester.OnBytesReceived(current, size); + tester.RunCompilerTasks(); + current += 10; + remaining -= size; + } + tester.RunCompilerTasks(); + tester.FinishStream(); + tester.RunCompilerTasks(); + + CHECK(tester.IsPromiseRejected()); +} + +// Test an error in the code section, found by the ModuleDecoder. The error is a +// functions count in the code section which differs from the functions count in +// the function section. +STREAM_TEST(TestErrorInCodeSectionDetectedByModuleDecoder) { + StreamTester tester; + + uint8_t code[] = { + U32V_1(4), // body size + U32V_1(0), // locals count + kExprGetLocal, 0, kExprEnd // body + }; + + const uint8_t bytes[] = { + WASM_MODULE_HEADER, // module header + kTypeSectionCode, // section code + U32V_1(1 + SIZEOF_SIG_ENTRY_x_x), // section size + U32V_1(1), // type count + SIG_ENTRY_x_x(kLocalI32, kLocalI32), // signature entry + kFunctionSectionCode, // section code + U32V_1(1 + 3), // section size + U32V_1(3), // functions count + 0, // signature index + 0, // signature index + 0, // signature index + kCodeSectionCode, // section code + U32V_1(1 + arraysize(code) * 2), // section size + U32V_1(2), // !!! invalid function count !!! + }; + + tester.OnBytesReceived(bytes, arraysize(bytes)); + tester.OnBytesReceived(code, arraysize(code)); + tester.OnBytesReceived(code, arraysize(code)); + tester.FinishStream(); + + tester.RunCompilerTasks(); + + CHECK(tester.IsPromiseRejected()); +} + +// Test an error in the code section, found by the StreamingDecoder. The error +// is an invalid function body size, so that there are not enough bytes in the +// code section for the function body. +STREAM_TEST(TestErrorInCodeSectionDetectedByStreamingDecoder) { + StreamTester tester; + + uint8_t code[] = { + U32V_1(26), // !!! invalid body size !!! + U32V_1(0), // locals count + kExprGetLocal, 0, kExprEnd // body + }; + + const uint8_t bytes[] = { + WASM_MODULE_HEADER, // module header + kTypeSectionCode, // section code + U32V_1(1 + SIZEOF_SIG_ENTRY_x_x), // section size + U32V_1(1), // type count + SIG_ENTRY_x_x(kLocalI32, kLocalI32), // signature entry + kFunctionSectionCode, // section code + U32V_1(1 + 3), // section size + U32V_1(3), // functions count + 0, // signature index + 0, // signature index + 0, // signature index + kCodeSectionCode, // section code + U32V_1(1 + arraysize(code) * 3), // section size + U32V_1(3), // functions count + }; + + tester.OnBytesReceived(bytes, arraysize(bytes)); + tester.OnBytesReceived(code, arraysize(code)); + tester.OnBytesReceived(code, arraysize(code)); + tester.OnBytesReceived(code, arraysize(code)); + tester.FinishStream(); + + tester.RunCompilerTasks(); + + CHECK(tester.IsPromiseRejected()); +} + +// Test an error in the code section, found by the Compiler. The error is an +// invalid return type. +STREAM_TEST(TestErrorInCodeSectionDetectedByCompiler) { + StreamTester tester; + + uint8_t code[] = { + U32V_1(4), // !!! invalid body size !!! + U32V_1(0), // locals count + kExprGetLocal, 0, kExprEnd // body + }; + + uint8_t invalid_code[] = { + U32V_1(4), // !!! invalid body size !!! + U32V_1(0), // locals count + kExprI64Const, 0, kExprEnd // body + }; + + const uint8_t bytes[] = { + WASM_MODULE_HEADER, // module header + kTypeSectionCode, // section code + U32V_1(1 + SIZEOF_SIG_ENTRY_x_x), // section size + U32V_1(1), // type count + SIG_ENTRY_x_x(kLocalI32, kLocalI32), // signature entry + kFunctionSectionCode, // section code + U32V_1(1 + 3), // section size + U32V_1(3), // functions count + 0, // signature index + 0, // signature index + 0, // signature index + kCodeSectionCode, // section code + U32V_1(1 + arraysize(code) * 2 + + arraysize(invalid_code)), // section size + U32V_1(3), // functions count + }; + + tester.OnBytesReceived(bytes, arraysize(bytes)); + tester.RunCompilerTasks(); + tester.OnBytesReceived(code, arraysize(code)); + tester.RunCompilerTasks(); + tester.OnBytesReceived(invalid_code, arraysize(invalid_code)); + tester.RunCompilerTasks(); + tester.OnBytesReceived(code, arraysize(code)); + tester.RunCompilerTasks(); + tester.FinishStream(); + tester.RunCompilerTasks(); + + CHECK(tester.IsPromiseRejected()); +} + +// Test Abort before any bytes arrive. +STREAM_TEST(TestAbortImmediately) { + StreamTester tester; + tester.stream()->Abort(); + tester.RunCompilerTasks(); +} + +// Test Abort within a section. +STREAM_TEST(TestAbortWithinSection1) { + StreamTester tester; + const uint8_t bytes[] = { + WASM_MODULE_HEADER, // module header + kTypeSectionCode, // section code + U32V_1(1 + SIZEOF_SIG_ENTRY_x_x), // section size + U32V_1(1) // type count + // Type section is not yet complete. + }; + tester.OnBytesReceived(bytes, arraysize(bytes)); + tester.RunCompilerTasks(); + tester.stream()->Abort(); + tester.RunCompilerTasks(); +} + +// Test Abort within a section. +STREAM_TEST(TestAbortWithinSection2) { + StreamTester tester; + const uint8_t bytes[] = { + WASM_MODULE_HEADER, // module header + kTypeSectionCode, // section code + U32V_1(1 + SIZEOF_SIG_ENTRY_x_x), // section size + U32V_1(1), // type count + SIG_ENTRY_x_x(kLocalI32, kLocalI32), // signature entry + kFunctionSectionCode, // section code + U32V_1(1 + 3), // section size + U32V_1(3), // functions count + // Function section is not yet complete. + }; + tester.OnBytesReceived(bytes, arraysize(bytes)); + tester.RunCompilerTasks(); + tester.stream()->Abort(); + tester.RunCompilerTasks(); +} + +// Test Abort just before the code section. +STREAM_TEST(TestAbortAfterSection) { + StreamTester tester; + const uint8_t bytes[] = { + WASM_MODULE_HEADER, // module header + kTypeSectionCode, // section code + U32V_1(1 + SIZEOF_SIG_ENTRY_x_x), // section size + U32V_1(1), // type count + SIG_ENTRY_x_x(kLocalI32, kLocalI32), // signature entry + }; + tester.OnBytesReceived(bytes, arraysize(bytes)); + tester.RunCompilerTasks(); + tester.stream()->Abort(); + tester.RunCompilerTasks(); +} + +// Test Abort after the function count in the code section. The compiler tasks +// execute before the abort. +STREAM_TEST(TestAbortAfterFunctionsCount1) { + StreamTester tester; + const uint8_t bytes[] = { + WASM_MODULE_HEADER, // module header + kTypeSectionCode, // section code + U32V_1(1 + SIZEOF_SIG_ENTRY_x_x), // section size + U32V_1(1), // type count + SIG_ENTRY_x_x(kLocalI32, kLocalI32), // signature entry + kFunctionSectionCode, // section code + U32V_1(1 + 3), // section size + U32V_1(3), // functions count + 0, // signature index + 0, // signature index + 0, // signature index + kCodeSectionCode, // section code + U32V_1(20), // section size + U32V_1(3), // functions count + }; + tester.OnBytesReceived(bytes, arraysize(bytes)); + tester.RunCompilerTasks(); + tester.stream()->Abort(); + tester.RunCompilerTasks(); +} + +// Test Abort after the function count in the code section. The compiler tasks +// do not execute before the abort. +STREAM_TEST(TestAbortAfterFunctionsCount2) { + StreamTester tester; + const uint8_t bytes[] = { + WASM_MODULE_HEADER, // module header + kTypeSectionCode, // section code + U32V_1(1 + SIZEOF_SIG_ENTRY_x_x), // section size + U32V_1(1), // type count + SIG_ENTRY_x_x(kLocalI32, kLocalI32), // signature entry + kFunctionSectionCode, // section code + U32V_1(1 + 3), // section size + U32V_1(3), // functions count + 0, // signature index + 0, // signature index + 0, // signature index + kCodeSectionCode, // section code + U32V_1(20), // section size + U32V_1(3), // functions count + }; + tester.OnBytesReceived(bytes, arraysize(bytes)); + tester.stream()->Abort(); + tester.RunCompilerTasks(); +} + +// Test Abort after some functions got compiled. The compiler tasks execute +// before the abort. +STREAM_TEST(TestAbortAfterFunctionGotCompiled1) { + StreamTester tester; + + uint8_t code[] = { + U32V_1(4), // !!! invalid body size !!! + U32V_1(0), // locals count + kExprGetLocal, 0, kExprEnd // body + }; + + const uint8_t bytes[] = { + WASM_MODULE_HEADER, // module header + kTypeSectionCode, // section code + U32V_1(1 + SIZEOF_SIG_ENTRY_x_x), // section size + U32V_1(1), // type count + SIG_ENTRY_x_x(kLocalI32, kLocalI32), // signature entry + kFunctionSectionCode, // section code + U32V_1(1 + 3), // section size + U32V_1(3), // functions count + 0, // signature index + 0, // signature index + 0, // signature index + kCodeSectionCode, // section code + U32V_1(20), // section size + U32V_1(3), // functions count + }; + tester.OnBytesReceived(bytes, arraysize(bytes)); + tester.OnBytesReceived(code, arraysize(code)); + tester.RunCompilerTasks(); + tester.stream()->Abort(); + tester.RunCompilerTasks(); +} + +// Test Abort after some functions got compiled. The compiler tasks execute +// before the abort. +STREAM_TEST(TestAbortAfterFunctionGotCompiled2) { + StreamTester tester; + + uint8_t code[] = { + U32V_1(4), // !!! invalid body size !!! + U32V_1(0), // locals count + kExprGetLocal, 0, kExprEnd // body + }; + + const uint8_t bytes[] = { + WASM_MODULE_HEADER, // module header + kTypeSectionCode, // section code + U32V_1(1 + SIZEOF_SIG_ENTRY_x_x), // section size + U32V_1(1), // type count + SIG_ENTRY_x_x(kLocalI32, kLocalI32), // signature entry + kFunctionSectionCode, // section code + U32V_1(1 + 3), // section size + U32V_1(3), // functions count + 0, // signature index + 0, // signature index + 0, // signature index + kCodeSectionCode, // section code + U32V_1(20), // section size + U32V_1(3), // functions count + }; + tester.OnBytesReceived(bytes, arraysize(bytes)); + tester.OnBytesReceived(code, arraysize(code)); + tester.stream()->Abort(); + tester.RunCompilerTasks(); +} + +// Test Abort after all functions got compiled. +STREAM_TEST(TestAbortAfterCodeSection1) { + StreamTester tester; + + uint8_t code[] = { + U32V_1(4), // body size + U32V_1(0), // locals count + kExprGetLocal, 0, kExprEnd // body + }; + + const uint8_t bytes[] = { + WASM_MODULE_HEADER, // module header + kTypeSectionCode, // section code + U32V_1(1 + SIZEOF_SIG_ENTRY_x_x), // section size + U32V_1(1), // type count + SIG_ENTRY_x_x(kLocalI32, kLocalI32), // signature entry + kFunctionSectionCode, // section code + U32V_1(1 + 3), // section size + U32V_1(3), // functions count + 0, // signature index + 0, // signature index + 0, // signature index + kCodeSectionCode, // section code + U32V_1(1 + arraysize(code) * 3), // section size + U32V_1(3), // functions count + }; + + tester.OnBytesReceived(bytes, arraysize(bytes)); + tester.OnBytesReceived(code, arraysize(code)); + tester.OnBytesReceived(code, arraysize(code)); + tester.OnBytesReceived(code, arraysize(code)); + tester.RunCompilerTasks(); + tester.stream()->Abort(); + tester.RunCompilerTasks(); +} + +// Test Abort after all functions got compiled. +STREAM_TEST(TestAbortAfterCodeSection2) { + StreamTester tester; + + uint8_t code[] = { + U32V_1(4), // body size + U32V_1(0), // locals count + kExprGetLocal, 0, kExprEnd // body + }; + + const uint8_t bytes[] = { + WASM_MODULE_HEADER, // module header + kTypeSectionCode, // section code + U32V_1(1 + SIZEOF_SIG_ENTRY_x_x), // section size + U32V_1(1), // type count + SIG_ENTRY_x_x(kLocalI32, kLocalI32), // signature entry + kFunctionSectionCode, // section code + U32V_1(1 + 3), // section size + U32V_1(3), // functions count + 0, // signature index + 0, // signature index + 0, // signature index + kCodeSectionCode, // section code + U32V_1(1 + arraysize(code) * 3), // section size + U32V_1(3), // functions count + }; + + tester.OnBytesReceived(bytes, arraysize(bytes)); + tester.OnBytesReceived(code, arraysize(code)); + tester.OnBytesReceived(code, arraysize(code)); + tester.OnBytesReceived(code, arraysize(code)); + tester.stream()->Abort(); + tester.RunCompilerTasks(); +} + +STREAM_TEST(TestAbortAfterCompilationError1) { + StreamTester tester; + + uint8_t code[] = { + U32V_1(4), // !!! invalid body size !!! + U32V_1(0), // locals count + kExprGetLocal, 0, kExprEnd // body + }; + + uint8_t invalid_code[] = { + U32V_1(4), // !!! invalid body size !!! + U32V_1(0), // locals count + kExprI64Const, 0, kExprEnd // body + }; + + const uint8_t bytes[] = { + WASM_MODULE_HEADER, // module header + kTypeSectionCode, // section code + U32V_1(1 + SIZEOF_SIG_ENTRY_x_x), // section size + U32V_1(1), // type count + SIG_ENTRY_x_x(kLocalI32, kLocalI32), // signature entry + kFunctionSectionCode, // section code + U32V_1(1 + 3), // section size + U32V_1(3), // functions count + 0, // signature index + 0, // signature index + 0, // signature index + kCodeSectionCode, // section code + U32V_1(1 + arraysize(code) * 2 + + arraysize(invalid_code)), // section size + U32V_1(3), // functions count + }; + + tester.OnBytesReceived(bytes, arraysize(bytes)); + tester.OnBytesReceived(code, arraysize(code)); + tester.OnBytesReceived(invalid_code, arraysize(invalid_code)); + tester.OnBytesReceived(code, arraysize(code)); + tester.RunCompilerTasks(); + tester.stream()->Abort(); + tester.RunCompilerTasks(); +} + +STREAM_TEST(TestAbortAfterCompilationError2) { + StreamTester tester; + + uint8_t code[] = { + U32V_1(4), // !!! invalid body size !!! + U32V_1(0), // locals count + kExprGetLocal, 0, kExprEnd // body + }; + + uint8_t invalid_code[] = { + U32V_1(4), // !!! invalid body size !!! + U32V_1(0), // locals count + kExprI64Const, 0, kExprEnd // body + }; + + const uint8_t bytes[] = { + WASM_MODULE_HEADER, // module header + kTypeSectionCode, // section code + U32V_1(1 + SIZEOF_SIG_ENTRY_x_x), // section size + U32V_1(1), // type count + SIG_ENTRY_x_x(kLocalI32, kLocalI32), // signature entry + kFunctionSectionCode, // section code + U32V_1(1 + 3), // section size + U32V_1(3), // functions count + 0, // signature index + 0, // signature index + 0, // signature index + kCodeSectionCode, // section code + U32V_1(1 + arraysize(code) * 2 + + arraysize(invalid_code)), // section size + U32V_1(3), // functions count + }; + + tester.OnBytesReceived(bytes, arraysize(bytes)); + tester.OnBytesReceived(code, arraysize(code)); + tester.OnBytesReceived(invalid_code, arraysize(invalid_code)); + tester.OnBytesReceived(code, arraysize(code)); + tester.stream()->Abort(); + tester.RunCompilerTasks(); +} + +#undef STREAM_TEST + +} // namespace wasm +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/wasm/test-wasm-breakpoints.cc b/deps/v8/test/cctest/wasm/test-wasm-breakpoints.cc index 67909c5264..492ec4670e 100644 --- a/deps/v8/test/cctest/wasm/test-wasm-breakpoints.cc +++ b/deps/v8/test/cctest/wasm/test-wasm-breakpoints.cc @@ -7,7 +7,7 @@ #include "src/frames-inl.h" #include "src/property-descriptor.h" #include "src/utils.h" -#include "src/wasm/wasm-objects.h" +#include "src/wasm/wasm-objects-inl.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/value-helper.h" @@ -15,9 +15,9 @@ #include "test/common/wasm/test-signatures.h" #include "test/common/wasm/wasm-macro-gen.h" -using namespace v8::internal; -using namespace v8::internal::wasm; -namespace debug = v8::debug; +namespace v8 { +namespace internal { +namespace wasm { namespace { @@ -422,3 +422,7 @@ TEST(WasmGetLocalsAndStack) { Handle<Object> args[]{handle(Smi::FromInt(7), isolate)}; CHECK(!Execution::Call(isolate, main_fun_wrapper, global, 1, args).is_null()); } + +} // namespace wasm +} // namespace internal +} // namespace v8 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 ca85e5fcd4..4f7b66ead4 100644 --- a/deps/v8/test/cctest/wasm/test-wasm-interpreter-entry.cc +++ b/deps/v8/test/cctest/wasm/test-wasm-interpreter-entry.cc @@ -12,9 +12,9 @@ #include "test/cctest/wasm/wasm-run-utils.h" #include "test/common/wasm/wasm-macro-gen.h" -using namespace v8::internal; -using namespace v8::internal::wasm; -namespace debug = v8::debug; +namespace v8 { +namespace internal { +namespace wasm { /** * We test the interface from Wasm compiled code to the Wasm interpreter by @@ -257,3 +257,7 @@ TEST(TestArgumentPassing_AllTypes) { CheckCall(i32, i64, f32, f64); } } + +} // namespace wasm +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/wasm/test-wasm-stack.cc b/deps/v8/test/cctest/wasm/test-wasm-stack.cc index b5d771b2c8..2a489b58b6 100644 --- a/deps/v8/test/cctest/wasm/test-wasm-stack.cc +++ b/deps/v8/test/cctest/wasm/test-wasm-stack.cc @@ -2,6 +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/assembler-inl.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/value-helper.h" @@ -9,10 +10,10 @@ #include "test/common/wasm/test-signatures.h" #include "test/common/wasm/wasm-macro-gen.h" -using namespace v8::base; -using namespace v8::internal; -using namespace v8::internal::compiler; -using namespace v8::internal::wasm; +namespace v8 { +namespace internal { +namespace wasm { +namespace test_wasm_stack { using v8::Local; using v8::Utils; @@ -47,8 +48,8 @@ void PrintStackTrace(v8::Isolate* isolate, v8::Local<v8::StackTrace> stack) { struct ExceptionInfo { const char* func_name; - int line_nr; - int column; + int line_nr; // 1-based + int column; // 1-based }; template <int N> @@ -70,11 +71,33 @@ void CheckExceptionInfos(v8::internal::Isolate* i_isolate, Handle<Object> exc, v8::Local<v8::StackFrame> frame = stack->GetFrame(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. CHECK_EQ(excInfos[frameNr].line_nr, frame->GetLineNumber()); CHECK_EQ(excInfos[frameNr].column, frame->GetColumn()); } + + CheckComputeLocation(i_isolate, exc, excInfos[0]); +} + +void CheckComputeLocation(v8::internal::Isolate* i_isolate, Handle<Object> exc, + const ExceptionInfo& topLocation) { + MessageLocation loc; + CHECK(i_isolate->ComputeLocationFromStackTrace(&loc, exc)); + printf("loc start: %d, end: %d\n", loc.start_pos(), loc.end_pos()); + Handle<JSMessageObject> message = i_isolate->CreateMessage(exc, nullptr); + printf("msg start: %d, end: %d, line: %d, col: %d\n", + message->start_position(), message->end_position(), + message->GetLineNumber(), message->GetColumnNumber()); + CHECK_EQ(loc.start_pos(), message->start_position()); + CHECK_EQ(loc.end_pos(), message->end_position()); + // In the message, the line is 1-based, but the column is 0-based. + CHECK_EQ(topLocation.line_nr, message->GetLineNumber()); + CHECK_LE(1, topLocation.column); + CHECK_EQ(topLocation.column - 1, message->GetColumnNumber()); } +#undef CHECK_CSTREQ + } // namespace // Call from JS to wasm to JS and throw an Error from JS. @@ -82,9 +105,12 @@ TEST(CollectDetailedWasmStack_ExplicitThrowFromJs) { WasmRunner<void> r(kExecuteCompiled); TestSignatures sigs; + Handle<FixedArray> js_imports_table = + r.main_isolate()->factory()->NewFixedArray(2 * 3 + 1, TENURED); uint32_t js_throwing_index = r.builder().AddJsFunction( sigs.v_v(), - "(function js() {\n function a() {\n throw new Error(); };\n a(); })"); + "(function js() {\n function a() {\n throw new Error(); };\n a(); })", + js_imports_table); // Add a nop such that we don't always get position 1. BUILD(r, WASM_NOP, WASM_CALL_FUNCTION0(js_throwing_index)); @@ -125,40 +151,55 @@ TEST(CollectDetailedWasmStack_ExplicitThrowFromJs) { // Trigger a trap in wasm, stack should be JS -> wasm -> wasm. TEST(CollectDetailedWasmStack_WasmError) { - TestSignatures sigs; - // Create a WasmRunner with stack checks and traps enabled. - WasmRunner<int> r(kExecuteCompiled, "main", true); - - BUILD(r, WASM_UNREACHABLE); - uint32_t wasm_index_1 = r.function()->func_index; - - WasmFunctionCompiler& f2 = r.NewFunction<int>("call_main"); - BUILD(f2, WASM_CALL_FUNCTION0(0)); - uint32_t wasm_index_2 = f2.function_index(); - - Handle<JSFunction> js_wasm_wrapper = r.builder().WrapCode(wasm_index_2); - - Handle<JSFunction> js_trampoline = Handle<JSFunction>::cast( - v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast( - CompileRun("(function callFn(fn) { fn(); })")))); - - Isolate* isolate = js_wasm_wrapper->GetIsolate(); - isolate->SetCaptureStackTraceForUncaughtExceptions(true, 10, - v8::StackTrace::kOverview); - Handle<Object> global(isolate->context()->global_object(), isolate); - MaybeHandle<Object> maybe_exc; - Handle<Object> args[] = {js_wasm_wrapper}; - MaybeHandle<Object> maybe_return_obj = - Execution::TryCall(isolate, js_trampoline, global, 1, args, - Execution::MessageHandling::kReport, &maybe_exc); - CHECK(maybe_return_obj.is_null()); - - // Line and column are 1-based, so add 1 for the expected wasm output. - ExceptionInfo expected_exceptions[] = { - {"main", static_cast<int>(wasm_index_1) + 1, 2}, // - - {"call_main", static_cast<int>(wasm_index_2) + 1, 2}, // - - {"callFn", 1, 24} //- - }; - CheckExceptionInfos(isolate, maybe_exc.ToHandleChecked(), - expected_exceptions); + for (int pos_shift = 0; pos_shift < 3; ++pos_shift) { + // Test a position with 1, 2 or 3 bytes needed to represent it. + int unreachable_pos = 1 << (8 * pos_shift); + TestSignatures sigs; + // Create a WasmRunner with stack checks and traps enabled. + WasmRunner<int> r(kExecuteCompiled, "main", + compiler::kRuntimeExceptionSupport); + + std::vector<byte> code(unreachable_pos + 1, kExprNop); + code[unreachable_pos] = kExprUnreachable; + r.Build(code.data(), code.data() + code.size()); + + uint32_t wasm_index_1 = r.function()->func_index; + + WasmFunctionCompiler& f2 = r.NewFunction<int>("call_main"); + BUILD(f2, WASM_CALL_FUNCTION0(0)); + uint32_t wasm_index_2 = f2.function_index(); + + Handle<JSFunction> js_wasm_wrapper = r.builder().WrapCode(wasm_index_2); + + Handle<JSFunction> js_trampoline = Handle<JSFunction>::cast( + v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast( + CompileRun("(function callFn(fn) { fn(); })")))); + + Isolate* isolate = js_wasm_wrapper->GetIsolate(); + isolate->SetCaptureStackTraceForUncaughtExceptions( + true, 10, v8::StackTrace::kOverview); + Handle<Object> global(isolate->context()->global_object(), isolate); + MaybeHandle<Object> maybe_exc; + Handle<Object> args[] = {js_wasm_wrapper}; + MaybeHandle<Object> maybe_return_obj = + Execution::TryCall(isolate, js_trampoline, global, 1, args, + Execution::MessageHandling::kReport, &maybe_exc); + CHECK(maybe_return_obj.is_null()); + Handle<Object> exception = maybe_exc.ToHandleChecked(); + + static constexpr int kMainLocalsLength = 1; + // Line and column are 1-based, so add 1 for the expected wasm output. + const int expected_main_pos = unreachable_pos + kMainLocalsLength + 1; + ExceptionInfo expected_exceptions[] = { + {"main", static_cast<int>(wasm_index_1) + 1, expected_main_pos}, // - + {"call_main", static_cast<int>(wasm_index_2) + 1, 2}, // - + {"callFn", 1, 24} //- + }; + CheckExceptionInfos(isolate, exception, expected_exceptions); + } } + +} // namespace test_wasm_stack +} // namespace wasm +} // namespace internal +} // namespace v8 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 7e9e595a81..0926ab0754 100644 --- a/deps/v8/test/cctest/wasm/test-wasm-trap-position.cc +++ b/deps/v8/test/cctest/wasm/test-wasm-trap-position.cc @@ -2,6 +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/assembler-inl.h" #include "src/trap-handler/trap-handler.h" #include "test/cctest/cctest.h" @@ -10,10 +11,10 @@ #include "test/common/wasm/test-signatures.h" #include "test/common/wasm/wasm-macro-gen.h" -using namespace v8::base; -using namespace v8::internal; -using namespace v8::internal::compiler; -using namespace v8::internal::wasm; +namespace v8 { +namespace internal { +namespace wasm { +namespace test_wasm_trap_position { using v8::Local; using v8::Utils; @@ -61,12 +62,15 @@ void CheckExceptionInfos(v8::internal::Isolate* i_isolate, Handle<Object> exc, } } +#undef CHECK_CSTREQ + } // namespace // Trigger a trap for executing unreachable. -TEST(Unreachable) { +WASM_EXEC_TEST(Unreachable) { // Create a WasmRunner with stack checks and traps enabled. - WasmRunner<void> r(kExecuteCompiled, "main", true); + WasmRunner<void> r(execution_mode, "main", + compiler::kRuntimeExceptionSupport); TestSignatures sigs; BUILD(r, WASM_UNREACHABLE); @@ -99,8 +103,9 @@ TEST(Unreachable) { } // Trigger a trap for loading from out-of-bounds. -TEST(IllegalLoad) { - WasmRunner<void> r(kExecuteCompiled, "main", true); +WASM_EXEC_TEST(IllegalLoad) { + WasmRunner<void> r(execution_mode, "main", + compiler::kRuntimeExceptionSupport); TestSignatures sigs; r.builder().AddMemory(0L); @@ -141,3 +146,8 @@ TEST(IllegalLoad) { CheckExceptionInfos(isolate, maybe_exc.ToHandleChecked(), expected_exceptions); } + +} // namespace test_wasm_trap_position +} // namespace wasm +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/wasm/wasm-run-utils.cc b/deps/v8/test/cctest/wasm/wasm-run-utils.cc new file mode 100644 index 0000000000..1b674ab60c --- /dev/null +++ b/deps/v8/test/cctest/wasm/wasm-run-utils.cc @@ -0,0 +1,522 @@ +// Copyright 2017 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 "test/cctest/wasm/wasm-run-utils.h" + +#include "src/api.h" +#include "src/assembler-inl.h" +#include "src/wasm/wasm-memory.h" +#include "src/wasm/wasm-objects-inl.h" + +namespace v8 { +namespace internal { +namespace wasm { + +TestingModuleBuilder::TestingModuleBuilder( + Zone* zone, WasmExecutionMode mode, + compiler::RuntimeExceptionSupport exception_support) + : test_module_ptr_(&test_module_), + isolate_(CcTest::InitIsolateOnce()), + global_offset(0), + mem_start_(nullptr), + mem_size_(0), + interpreter_(nullptr), + runtime_exception_support_(exception_support), + lower_simd_(mode == kExecuteSimdLowered) { + WasmJs::Install(isolate_, true); + test_module_.globals_size = kMaxGlobalsSize; + memset(globals_data_, 0, sizeof(globals_data_)); + instance_object_ = InitInstanceObject(); + if (mode == kExecuteInterpreted) { + interpreter_ = WasmDebugInfo::SetupForTesting(instance_object_); + } +} + +byte* TestingModuleBuilder::AddMemory(uint32_t size) { + CHECK(!test_module_.has_memory); + CHECK_NULL(mem_start_); + CHECK_EQ(0, mem_size_); + DCHECK(!instance_object_->has_memory_buffer()); + DCHECK(!instance_object_->has_memory_object()); + test_module_.has_memory = true; + const bool enable_guard_regions = + trap_handler::UseTrapHandler() && test_module_.is_wasm(); + uint32_t alloc_size = + enable_guard_regions ? RoundUp(size, base::OS::CommitPageSize()) : size; + Handle<JSArrayBuffer> new_buffer = + wasm::NewArrayBuffer(isolate_, alloc_size, enable_guard_regions); + CHECK(!new_buffer.is_null()); + instance_object_->set_memory_buffer(*new_buffer); + mem_start_ = reinterpret_cast<byte*>(new_buffer->backing_store()); + mem_size_ = size; + CHECK(size == 0 || mem_start_); + memset(mem_start_, 0, size); + + if (interpreter_) { + interpreter_->UpdateMemory(mem_start_, mem_size_); + } + // Create the WasmMemoryObject. + Handle<WasmMemoryObject> memory_object = WasmMemoryObject::New( + isolate_, new_buffer, + (test_module_.maximum_pages != 0) ? test_module_.maximum_pages : -1); + instance_object_->set_memory_object(*memory_object); + WasmMemoryObject::AddInstance(isolate_, memory_object, instance_object_); + // TODO(wasm): Delete the following two lines when test-run-wasm will use a + // multiple of kPageSize as memory size. At the moment, the effect of these + // two lines is used to shrink the memory for testing purposes. + instance_object_->wasm_context()->mem_start = mem_start_; + instance_object_->wasm_context()->mem_size = mem_size_; + return mem_start_; +} + +uint32_t TestingModuleBuilder::AddFunction(FunctionSig* sig, Handle<Code> code, + const char* name) { + if (test_module_.functions.size() == 0) { + // TODO(titzer): Reserving space here to avoid the underlying WasmFunction + // structs from moving. + test_module_.functions.reserve(kMaxFunctions); + } + uint32_t index = static_cast<uint32_t>(test_module_.functions.size()); + test_module_.functions.push_back( + {sig, index, 0, {0, 0}, {0, 0}, false, false}); + if (name) { + Vector<const byte> name_vec = Vector<const byte>::cast(CStrVector(name)); + test_module_.functions.back().name = { + AddBytes(name_vec), static_cast<uint32_t>(name_vec.length())}; + } + function_code_.push_back(code); + if (interpreter_) { + interpreter_->AddFunctionForTesting(&test_module_.functions.back()); + } + DCHECK_LT(index, kMaxFunctions); // limited for testing. + return index; +} + +uint32_t TestingModuleBuilder::AddJsFunction( + FunctionSig* sig, const char* source, Handle<FixedArray> js_imports_table) { + Handle<JSFunction> jsfunc = Handle<JSFunction>::cast(v8::Utils::OpenHandle( + *v8::Local<v8::Function>::Cast(CompileRun(source)))); + uint32_t index = AddFunction(sig, Handle<Code>::null(), nullptr); + js_imports_table->set(0, *isolate_->native_context()); + Handle<Code> code = compiler::CompileWasmToJSWrapper( + isolate_, jsfunc, sig, index, test_module_.origin(), js_imports_table); + function_code_[index] = code; + return index; +} + +Handle<JSFunction> TestingModuleBuilder::WrapCode(uint32_t index) { + // Wrap the code so it can be called as a JS function. + Handle<Code> code = function_code_[index]; + byte* context_address = + test_module_.has_memory + ? reinterpret_cast<byte*>(instance_object_->wasm_context()) + : nullptr; + Handle<Code> ret_code = compiler::CompileJSToWasmWrapper( + isolate_, &test_module_, code, index, context_address); + Handle<JSFunction> ret = WasmExportedFunction::New( + isolate_, instance_object(), MaybeHandle<String>(), + static_cast<int>(index), + static_cast<int>(test_module_.functions[index].sig->parameter_count()), + ret_code); + + // Add weak reference to exported functions. + Handle<WasmCompiledModule> compiled_module( + instance_object()->compiled_module(), isolate_); + Handle<FixedArray> old_arr = compiled_module->weak_exported_functions(); + Handle<FixedArray> new_arr = + isolate_->factory()->NewFixedArray(old_arr->length() + 1); + old_arr->CopyTo(0, *new_arr, 0, old_arr->length()); + Handle<WeakCell> weak_fn = isolate_->factory()->NewWeakCell(ret); + new_arr->set(old_arr->length(), *weak_fn); + compiled_module->set_weak_exported_functions(new_arr); + + return ret; +} + +void TestingModuleBuilder::AddIndirectFunctionTable(uint16_t* function_indexes, + uint32_t table_size) { + test_module_.function_tables.emplace_back(); + WasmIndirectFunctionTable& table = test_module_.function_tables.back(); + table.initial_size = table_size; + table.maximum_size = table_size; + table.has_maximum_size = true; + for (uint32_t i = 0; i < table_size; ++i) { + table.values.push_back(function_indexes[i]); + table.map.FindOrInsert(test_module_.functions[function_indexes[i]].sig); + } + + function_tables_.push_back( + isolate_->global_handles() + ->Create(*isolate_->factory()->NewFixedArray(table_size)) + .address()); + signature_tables_.push_back( + isolate_->global_handles() + ->Create(*isolate_->factory()->NewFixedArray(table_size)) + .address()); +} + +void TestingModuleBuilder::PopulateIndirectFunctionTable() { + if (interpret()) return; + // Initialize the fixed arrays in instance->function_tables. + for (uint32_t i = 0; i < function_tables_.size(); i++) { + WasmIndirectFunctionTable& table = test_module_.function_tables[i]; + Handle<FixedArray> function_table( + reinterpret_cast<FixedArray**>(function_tables_[i])); + Handle<FixedArray> signature_table( + reinterpret_cast<FixedArray**>(signature_tables_[i])); + int table_size = static_cast<int>(table.values.size()); + for (int j = 0; j < table_size; j++) { + WasmFunction& function = test_module_.functions[table.values[j]]; + signature_table->set(j, Smi::FromInt(table.map.Find(function.sig))); + function_table->set(j, *function_code_[function.func_index]); + } + } +} + +uint32_t TestingModuleBuilder::AddBytes(Vector<const byte> bytes) { + Handle<SeqOneByteString> old_bytes( + instance_object_->compiled_module()->module_bytes(), isolate_); + uint32_t old_size = static_cast<uint32_t>(old_bytes->length()); + // Avoid placing strings at offset 0, this might be interpreted as "not + // set", e.g. for function names. + uint32_t bytes_offset = old_size ? old_size : 1; + ScopedVector<byte> new_bytes(bytes_offset + bytes.length()); + memcpy(new_bytes.start(), old_bytes->GetChars(), old_size); + memcpy(new_bytes.start() + bytes_offset, bytes.start(), bytes.length()); + Handle<SeqOneByteString> new_bytes_str = Handle<SeqOneByteString>::cast( + isolate_->factory()->NewStringFromOneByte(new_bytes).ToHandleChecked()); + instance_object_->compiled_module()->shared()->set_module_bytes( + *new_bytes_str); + return bytes_offset; +} + +compiler::ModuleEnv TestingModuleBuilder::CreateModuleEnv() { + std::vector<SignatureMap*> signature_maps; + for (size_t i = 0; i < test_module_.function_tables.size(); i++) { + auto& function_table = test_module_.function_tables[i]; + signature_maps.push_back(&function_table.map); + } + return { + &test_module_, + function_tables_, + signature_tables_, + signature_maps, + function_code_, + Handle<Code>::null(), + reinterpret_cast<uintptr_t>(globals_data_), + }; +} + +const WasmGlobal* TestingModuleBuilder::AddGlobal(ValueType type) { + byte size = WasmOpcodes::MemSize(WasmOpcodes::MachineTypeFor(type)); + global_offset = (global_offset + size - 1) & ~(size - 1); // align + test_module_.globals.push_back( + {type, true, WasmInitExpr(), global_offset, false, false}); + global_offset += size; + // limit number of globals. + CHECK_LT(global_offset, kMaxGlobalsSize); + return &test_module_.globals.back(); +} + +Handle<WasmInstanceObject> TestingModuleBuilder::InitInstanceObject() { + Handle<SeqOneByteString> empty_string = Handle<SeqOneByteString>::cast( + isolate_->factory()->NewStringFromOneByte({}).ToHandleChecked()); + // The lifetime of the wasm module is tied to this object's, and we cannot + // rely on the mechanics of Managed<T>. + Handle<Foreign> module_wrapper = isolate_->factory()->NewForeign( + reinterpret_cast<Address>(&test_module_ptr_)); + Handle<Script> script = + isolate_->factory()->NewScript(isolate_->factory()->empty_string()); + script->set_type(Script::TYPE_WASM); + Handle<WasmSharedModuleData> shared_module_data = + WasmSharedModuleData::New(isolate_, module_wrapper, empty_string, script, + Handle<ByteArray>::null()); + Handle<FixedArray> code_table = isolate_->factory()->NewFixedArray(0); + Handle<FixedArray> export_wrappers = isolate_->factory()->NewFixedArray(0); + Handle<WasmCompiledModule> compiled_module = WasmCompiledModule::New( + isolate_, shared_module_data, code_table, export_wrappers, + function_tables_, signature_tables_); + // 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. + WasmCompiledModule::recreate_globals_start( + compiled_module, isolate_->factory(), + reinterpret_cast<size_t>(globals_data_)); + Handle<FixedArray> weak_exported = isolate_->factory()->NewFixedArray(0); + compiled_module->set_weak_exported_functions(weak_exported); + DCHECK(WasmCompiledModule::IsWasmCompiledModule(*compiled_module)); + script->set_wasm_compiled_module(*compiled_module); + return WasmInstanceObject::New(isolate_, compiled_module); +} + +void TestBuildingGraph( + Zone* zone, compiler::JSGraph* jsgraph, compiler::ModuleEnv* module, + FunctionSig* sig, compiler::SourcePositionTable* source_position_table, + const byte* start, const byte* end, + compiler::RuntimeExceptionSupport runtime_exception_support) { + compiler::WasmGraphBuilder builder( + module, zone, jsgraph, CEntryStub(jsgraph->isolate(), 1).GetCode(), sig, + source_position_table, runtime_exception_support); + + DecodeResult result = + BuildTFGraph(zone->allocator(), &builder, sig, start, end); + if (result.failed()) { + 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); + } + + uint32_t pc = result.error_offset(); + std::ostringstream str; + str << "Verification failed; pc = +" << pc + << ", msg = " << result.error_msg().c_str(); + FATAL(str.str().c_str()); + } + builder.LowerInt64(); + if (!CpuFeatures::SupportsWasmSimd128()) { + builder.SimdScalarLoweringForTesting(); + } +} + +WasmFunctionWrapper::WasmFunctionWrapper(Zone* zone, int num_params) + : GraphAndBuilders(zone), + inner_code_node_(nullptr), + context_address_(nullptr), + signature_(nullptr) { + // One additional parameter for the pointer to the return value memory. + Signature<MachineType>::Builder sig_builder(zone, 1, num_params + 1); + + sig_builder.AddReturn(MachineType::Int32()); + for (int i = 0; i < num_params + 1; i++) { + sig_builder.AddParam(MachineType::Pointer()); + } + signature_ = sig_builder.Build(); +} + +void WasmFunctionWrapper::Init(CallDescriptor* descriptor, + MachineType return_type, + Vector<MachineType> param_types) { + DCHECK_NOT_NULL(descriptor); + DCHECK_EQ(signature_->parameter_count(), param_types.length() + 1); + + // Create the TF graph for the wrapper. + + // Function, context_address, effect, and control. + Node** parameters = zone()->NewArray<Node*>(param_types.length() + 4); + graph()->SetStart(graph()->NewNode(common()->Start(7))); + Node* effect = graph()->start(); + int parameter_count = 0; + + // Dummy node which gets replaced in SetInnerCode. + inner_code_node_ = graph()->NewNode(common()->Int32Constant(0)); + parameters[parameter_count++] = inner_code_node_; + + // Dummy node that gets replaced in SetContextAddress. + context_address_ = graph()->NewNode(IntPtrConstant(0)); + parameters[parameter_count++] = context_address_; + + int param_idx = 0; + for (MachineType t : param_types) { + DCHECK_NE(MachineType::None(), t); + parameters[parameter_count] = graph()->NewNode( + machine()->Load(t), + graph()->NewNode(common()->Parameter(param_idx++), graph()->start()), + graph()->NewNode(common()->Int32Constant(0)), effect, graph()->start()); + effect = parameters[parameter_count++]; + } + + parameters[parameter_count++] = effect; + parameters[parameter_count++] = graph()->start(); + Node* call = + graph()->NewNode(common()->Call(descriptor), parameter_count, parameters); + + if (!return_type.IsNone()) { + effect = graph()->NewNode( + machine()->Store(compiler::StoreRepresentation( + return_type.representation(), WriteBarrierKind::kNoWriteBarrier)), + graph()->NewNode(common()->Parameter(param_types.length()), + graph()->start()), + graph()->NewNode(common()->Int32Constant(0)), call, effect, + graph()->start()); + } + Node* zero = graph()->NewNode(common()->Int32Constant(0)); + Node* r = graph()->NewNode( + common()->Return(), zero, + graph()->NewNode(common()->Int32Constant(WASM_WRAPPER_RETURN_VALUE)), + effect, graph()->start()); + graph()->SetEnd(graph()->NewNode(common()->End(1), r)); +} + +Handle<Code> WasmFunctionWrapper::GetWrapperCode() { + if (code_.is_null()) { + Isolate* isolate = CcTest::InitIsolateOnce(); + + CallDescriptor* descriptor = + compiler::Linkage::GetSimplifiedCDescriptor(zone(), signature_, true); + + if (kPointerSize == 4) { + size_t num_params = signature_->parameter_count(); + // One additional parameter for the pointer of the return value. + Signature<MachineRepresentation>::Builder rep_builder(zone(), 1, + num_params + 1); + + rep_builder.AddReturn(MachineRepresentation::kWord32); + for (size_t i = 0; i < num_params + 1; i++) { + rep_builder.AddParam(MachineRepresentation::kWord32); + } + compiler::Int64Lowering r(graph(), machine(), common(), zone(), + rep_builder.Build()); + r.LowerGraph(); + } + + CompilationInfo info(ArrayVector("testing"), isolate, graph()->zone(), + Code::STUB); + code_ = compiler::Pipeline::GenerateCodeForTesting(&info, descriptor, + graph(), nullptr); + CHECK(!code_.is_null()); +#ifdef ENABLE_DISASSEMBLER + if (FLAG_print_opt_code) { + OFStream os(stdout); + code_->Disassemble("wasm wrapper", os); + } +#endif + } + + return code_; +} + +void WasmFunctionCompiler::Build(const byte* start, const byte* end) { + size_t locals_size = local_decls.Size(); + size_t total_size = end - start + locals_size + 1; + byte* buffer = static_cast<byte*>(zone()->New(total_size)); + // Prepend the local decls to the code. + local_decls.Emit(buffer); + // Emit the code. + memcpy(buffer + locals_size, start, end - start); + // Append an extra end opcode. + buffer[total_size - 1] = kExprEnd; + + start = buffer; + end = buffer + total_size; + + CHECK_GE(kMaxInt, end - start); + int len = static_cast<int>(end - start); + function_->code = {builder_->AddBytes(Vector<const byte>(start, len)), + static_cast<uint32_t>(len)}; + + if (interpreter_) { + // Add the code to the interpreter. + interpreter_->SetFunctionCodeForTesting(function_, start, end); + } + + Handle<WasmCompiledModule> compiled_module( + builder_->instance_object()->compiled_module(), isolate()); + Handle<SeqOneByteString> wire_bytes(compiled_module->module_bytes(), + isolate()); + + compiler::ModuleEnv module_env = builder_->CreateModuleEnv(); + ErrorThrower thrower(isolate(), "WasmFunctionCompiler::Build"); + ScopedVector<uint8_t> func_wire_bytes(function_->code.length()); + memcpy(func_wire_bytes.start(), + wire_bytes->GetChars() + function_->code.offset(), + func_wire_bytes.length()); + ScopedVector<char> func_name(function_->name.length()); + memcpy(func_name.start(), wire_bytes->GetChars() + function_->name.offset(), + func_name.length()); + + FunctionBody func_body{function_->sig, function_->code.offset(), + func_wire_bytes.start(), func_wire_bytes.end()}; + compiler::WasmCompilationUnit unit( + isolate(), &module_env, func_body, func_name, function_->func_index, + CEntryStub(isolate(), 1).GetCode(), isolate()->counters(), + builder_->runtime_exception_support(), builder_->lower_simd()); + unit.ExecuteCompilation(); + Handle<Code> code = unit.FinishCompilation(&thrower).ToHandleChecked(); + CHECK(!thrower.error()); + + // Manually add the deoptimization info that would otherwise be added + // during instantiation. Deopt data holds <WeakCell<wasm_instance>, + // func_index>. + DCHECK_EQ(0, code->deoptimization_data()->length()); + Handle<FixedArray> deopt_data = + isolate()->factory()->NewFixedArray(2, TENURED); + Handle<Object> weak_instance = + isolate()->factory()->NewWeakCell(builder_->instance_object()); + deopt_data->set(0, *weak_instance); + deopt_data->set(1, Smi::FromInt(static_cast<int>(function_index()))); + code->set_deoptimization_data(*deopt_data); + + // Build the TurboFan graph. + builder_->SetFunctionCode(function_index(), code); + + // Add to code table. + Handle<FixedArray> code_table = compiled_module->code_table(); + if (static_cast<int>(function_index()) >= code_table->length()) { + Handle<FixedArray> new_arr = isolate()->factory()->NewFixedArray( + static_cast<int>(function_index()) + 1); + code_table->CopyTo(0, *new_arr, 0, code_table->length()); + code_table = new_arr; + compiled_module->ReplaceCodeTableForTesting(code_table); + } + DCHECK(code_table->get(static_cast<int>(function_index())) + ->IsUndefined(isolate())); + code_table->set(static_cast<int>(function_index()), *code); + if (trap_handler::UseTrapHandler()) { + UnpackAndRegisterProtectedInstructions(isolate(), code_table); + } +} + +WasmFunctionCompiler::WasmFunctionCompiler(Zone* zone, FunctionSig* sig, + TestingModuleBuilder* builder, + const char* name) + : GraphAndBuilders(zone), + jsgraph(builder->isolate(), this->graph(), this->common(), nullptr, + nullptr, this->machine()), + sig(sig), + descriptor_(nullptr), + builder_(builder), + local_decls(zone, sig), + source_position_table_(this->graph()), + interpreter_(builder->interpreter()) { + // Get a new function from the testing module. + int index = builder->AddFunction(sig, Handle<Code>::null(), name); + function_ = builder_->GetFunctionAt(index); +} + +WasmFunctionCompiler::~WasmFunctionCompiler() { + if (trap_handler::UseTrapHandler() && + !builder_->GetFunctionCode(function_index()).is_null()) { + const int handler_index = builder_->GetFunctionCode(function_index()) + ->trap_handler_index() + ->value(); + trap_handler::ReleaseHandlerData(handler_index); + } +} + +FunctionSig* WasmRunnerBase::CreateSig(MachineType return_type, + Vector<MachineType> param_types) { + int return_count = return_type.IsNone() ? 0 : 1; + int param_count = param_types.length(); + + // Allocate storage array in zone. + ValueType* sig_types = zone_.NewArray<ValueType>(return_count + param_count); + + // Convert machine types to local types, and check that there are no + // MachineType::None()'s in the parameters. + int idx = 0; + if (return_count) sig_types[idx++] = WasmOpcodes::ValueTypeFor(return_type); + for (MachineType param : param_types) { + CHECK_NE(MachineType::None(), param); + sig_types[idx++] = WasmOpcodes::ValueTypeFor(param); + } + return new (&zone_) FunctionSig(return_count, param_count, sig_types); +} + +// static +bool WasmRunnerBase::trap_happened; + +} // namespace wasm +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/wasm/wasm-run-utils.h b/deps/v8/test/cctest/wasm/wasm-run-utils.h index 1b98d10ec3..562e3b12ce 100644 --- a/deps/v8/test/cctest/wasm/wasm-run-utils.h +++ b/deps/v8/test/cctest/wasm/wasm-run-utils.h @@ -29,6 +29,7 @@ #include "src/wasm/wasm-interpreter.h" #include "src/wasm/wasm-js.h" #include "src/wasm/wasm-module.h" +#include "src/wasm/wasm-objects-inl.h" #include "src/wasm/wasm-objects.h" #include "src/wasm/wasm-opcodes.h" #include "src/zone/accounting-allocator.h" @@ -39,9 +40,22 @@ #include "test/cctest/compiler/graph-builder-tester.h" #include "test/common/wasm/flag-utils.h" -static const uint32_t kMaxFunctions = 10; +namespace v8 { +namespace internal { +namespace wasm { -enum WasmExecutionMode { kExecuteInterpreted, kExecuteCompiled }; +constexpr uint32_t kMaxFunctions = 10; +constexpr uint32_t kMaxGlobalsSize = 128; + +enum WasmExecutionMode { + kExecuteInterpreted, + kExecuteCompiled, + kExecuteSimdLowered +}; + +using compiler::CallDescriptor; +using compiler::MachineTypeForC; +using compiler::Node; // TODO(titzer): check traps more robustly in tests. // Currently, in tests, we just return 0xdeadbeef from the function in which @@ -61,72 +75,18 @@ enum WasmExecutionMode { kExecuteInterpreted, kExecuteCompiled }; r.Build(code, code + arraysize(code)); \ } while (false) -namespace { -using namespace v8::base; -using namespace v8::internal; -using namespace v8::internal::compiler; -using namespace v8::internal::wasm; - -const uint32_t kMaxGlobalsSize = 128; - // A buildable ModuleEnv. Globals are pre-set, however, memory and code may be // progressively added by a test. In turn, we piecemeal update the runtime // objects, i.e. {WasmInstanceObject}, {WasmCompiledModule} and, if necessary, // the interpreter. class TestingModuleBuilder { public: - explicit TestingModuleBuilder(Zone* zone, - WasmExecutionMode mode = kExecuteCompiled) - : test_module_ptr_(&test_module_), - isolate_(CcTest::InitIsolateOnce()), - global_offset(0), - mem_start_(nullptr), - mem_size_(0), - interpreter_(nullptr) { - WasmJs::Install(isolate_); - test_module_.globals_size = kMaxGlobalsSize; - memset(globals_data_, 0, sizeof(globals_data_)); - instance_object_ = InitInstanceObject(); - if (mode == kExecuteInterpreted) { - interpreter_ = WasmDebugInfo::SetupForTesting(instance_object_); - } - } + TestingModuleBuilder(Zone*, WasmExecutionMode, + compiler::RuntimeExceptionSupport); void ChangeOriginToAsmjs() { test_module_.set_origin(kAsmJsOrigin); } - byte* AddMemory(uint32_t size) { - CHECK(!test_module_.has_memory); - CHECK_NULL(mem_start_); - CHECK_EQ(0, mem_size_); - DCHECK(!instance_object_->has_memory_buffer()); - test_module_.has_memory = true; - bool enable_guard_regions = EnableGuardRegions() && test_module_.is_wasm(); - uint32_t alloc_size = - enable_guard_regions ? RoundUp(size, OS::CommitPageSize()) : size; - Handle<JSArrayBuffer> new_buffer = - wasm::NewArrayBuffer(isolate_, alloc_size, enable_guard_regions); - CHECK(!new_buffer.is_null()); - instance_object_->set_memory_buffer(*new_buffer); - mem_start_ = reinterpret_cast<byte*>(new_buffer->backing_store()); - mem_size_ = size; - CHECK(size == 0 || mem_start_); - memset(mem_start_, 0, size); - Handle<WasmCompiledModule> compiled_module = - handle(instance_object_->compiled_module()); - Factory* factory = CcTest::i_isolate()->factory(); - // It's not really necessary we recreate the Number objects, - // if we happened to have one, but this is a reasonable inefficiencly, - // given this is test. - WasmCompiledModule::recreate_embedded_mem_size(compiled_module, factory, - mem_size_); - WasmCompiledModule::recreate_embedded_mem_start( - compiled_module, factory, reinterpret_cast<size_t>(mem_start_)); - - if (interpreter_) { - interpreter_->UpdateMemory(mem_start_, mem_size_); - } - return mem_start_; - } + byte* AddMemory(uint32_t size); size_t CodeTableLength() const { return function_code_.size(); } @@ -146,7 +106,7 @@ class TestingModuleBuilder { byte AddSignature(FunctionSig* sig) { test_module_.signatures.push_back(sig); size_t size = test_module_.signatures.size(); - CHECK(size < 127); + CHECK_GT(127, size); return static_cast<byte>(size - 1); } @@ -200,126 +160,30 @@ class TestingModuleBuilder { void SetMaxMemPages(uint32_t maximum_pages) { test_module_.maximum_pages = maximum_pages; - } - - uint32_t AddFunction(FunctionSig* sig, Handle<Code> code, const char* name) { - if (test_module_.functions.size() == 0) { - // TODO(titzer): Reserving space here to avoid the underlying WasmFunction - // structs from moving. - test_module_.functions.reserve(kMaxFunctions); - } - uint32_t index = static_cast<uint32_t>(test_module_.functions.size()); - test_module_.functions.push_back( - {sig, index, 0, {0, 0}, {0, 0}, false, false}); - if (name) { - Vector<const byte> name_vec = Vector<const byte>::cast(CStrVector(name)); - test_module_.functions.back().name = { - AddBytes(name_vec), static_cast<uint32_t>(name_vec.length())}; + if (instance_object()->has_memory_object()) { + instance_object()->memory_object()->set_maximum_pages(maximum_pages); } - function_code_.push_back(code); - if (interpreter_) { - interpreter_->AddFunctionForTesting(&test_module_.functions.back()); - } - DCHECK_LT(index, kMaxFunctions); // limited for testing. - return index; } - uint32_t AddJsFunction(FunctionSig* sig, const char* source) { - Handle<JSFunction> jsfunc = Handle<JSFunction>::cast(v8::Utils::OpenHandle( - *v8::Local<v8::Function>::Cast(CompileRun(source)))); - uint32_t index = AddFunction(sig, Handle<Code>::null(), nullptr); - Handle<Code> code = CompileWasmToJSWrapper( - isolate_, jsfunc, sig, index, Handle<String>::null(), - Handle<String>::null(), test_module_.origin()); - function_code_[index] = code; - return index; - } + void SetHasSharedMemory() { test_module_.has_shared_memory = true; } - Handle<JSFunction> WrapCode(uint32_t index) { - // Wrap the code so it can be called as a JS function. - Handle<Code> code = function_code_[index]; - Handle<Code> ret_code = - compiler::CompileJSToWasmWrapper(isolate_, &test_module_, code, index); - Handle<JSFunction> ret = WasmExportedFunction::New( - isolate_, instance_object(), MaybeHandle<String>(), - static_cast<int>(index), - static_cast<int>(test_module_.functions[index].sig->parameter_count()), - ret_code); - - // Add weak reference to exported functions. - Handle<WasmCompiledModule> compiled_module( - instance_object()->compiled_module(), isolate_); - Handle<FixedArray> old_arr = compiled_module->weak_exported_functions(); - Handle<FixedArray> new_arr = - isolate_->factory()->NewFixedArray(old_arr->length() + 1); - old_arr->CopyTo(0, *new_arr, 0, old_arr->length()); - Handle<WeakCell> weak_fn = isolate_->factory()->NewWeakCell(ret); - new_arr->set(old_arr->length(), *weak_fn); - compiled_module->set_weak_exported_functions(new_arr); - - return ret; - } + uint32_t AddFunction(FunctionSig* sig, Handle<Code> code, const char* name); + + uint32_t AddJsFunction(FunctionSig* sig, const char* source, + Handle<FixedArray> js_imports_table); + + Handle<JSFunction> WrapCode(uint32_t index); void SetFunctionCode(uint32_t index, Handle<Code> code) { function_code_[index] = code; } void AddIndirectFunctionTable(uint16_t* function_indexes, - uint32_t table_size) { - test_module_.function_tables.emplace_back(); - WasmIndirectFunctionTable& table = test_module_.function_tables.back(); - table.initial_size = table_size; - table.maximum_size = table_size; - table.has_maximum_size = true; - for (uint32_t i = 0; i < table_size; ++i) { - table.values.push_back(function_indexes[i]); - table.map.FindOrInsert(test_module_.functions[function_indexes[i]].sig); - } - - function_tables_.push_back( - isolate_->global_handles() - ->Create(*isolate_->factory()->NewFixedArray(table_size)) - .address()); - signature_tables_.push_back( - isolate_->global_handles() - ->Create(*isolate_->factory()->NewFixedArray(table_size)) - .address()); - } + uint32_t table_size); - void PopulateIndirectFunctionTable() { - if (interpret()) return; - // Initialize the fixed arrays in instance->function_tables. - for (uint32_t i = 0; i < function_tables_.size(); i++) { - WasmIndirectFunctionTable& table = test_module_.function_tables[i]; - Handle<FixedArray> function_table( - reinterpret_cast<FixedArray**>(function_tables_[i])); - Handle<FixedArray> signature_table( - reinterpret_cast<FixedArray**>(signature_tables_[i])); - int table_size = static_cast<int>(table.values.size()); - for (int j = 0; j < table_size; j++) { - WasmFunction& function = test_module_.functions[table.values[j]]; - signature_table->set(j, Smi::FromInt(table.map.Find(function.sig))); - function_table->set(j, *function_code_[function.func_index]); - } - } - } + void PopulateIndirectFunctionTable(); - uint32_t AddBytes(Vector<const byte> bytes) { - Handle<SeqOneByteString> old_bytes( - instance_object_->compiled_module()->module_bytes(), isolate_); - uint32_t old_size = static_cast<uint32_t>(old_bytes->length()); - // Avoid placing strings at offset 0, this might be interpreted as "not - // set", e.g. for function names. - uint32_t bytes_offset = old_size ? old_size : 1; - ScopedVector<byte> new_bytes(bytes_offset + bytes.length()); - memcpy(new_bytes.start(), old_bytes->GetChars(), old_size); - memcpy(new_bytes.start() + bytes_offset, bytes.start(), bytes.length()); - Handle<SeqOneByteString> new_bytes_str = Handle<SeqOneByteString>::cast( - isolate_->factory()->NewStringFromOneByte(new_bytes).ToHandleChecked()); - instance_object_->compiled_module()->shared()->set_module_bytes( - *new_bytes_str); - return bytes_offset; - } + uint32_t AddBytes(Vector<const byte> bytes); WasmFunction* GetFunctionAt(int index) { return &test_module_.functions[index]; @@ -327,6 +191,7 @@ class TestingModuleBuilder { WasmInterpreter* interpreter() { return interpreter_; } bool interpret() { return interpreter_ != nullptr; } + bool lower_simd() { return lower_simd_; } Isolate* isolate() { return isolate_; } Handle<WasmInstanceObject> instance_object() { return instance_object_; } Handle<Code> GetFunctionCode(int index) { return function_code_[index]; } @@ -335,23 +200,10 @@ class TestingModuleBuilder { } Address globals_start() { return reinterpret_cast<Address>(globals_data_); } - compiler::ModuleEnv CreateModuleEnv() { - std::vector<SignatureMap*> signature_maps; - for (size_t i = 0; i < test_module_.function_tables.size(); i++) { - auto& function_table = test_module_.function_tables[i]; - signature_maps.push_back(&function_table.map); - } - return { - &test_module_, - function_tables_, - signature_tables_, - signature_maps, - function_code_, - Handle<Code>::null(), - reinterpret_cast<uintptr_t>(mem_start_), - mem_size_, - reinterpret_cast<uintptr_t>(globals_data_), - }; + compiler::ModuleEnv CreateModuleEnv(); + + compiler::RuntimeExceptionSupport runtime_exception_support() const { + return runtime_exception_support_; } private: @@ -367,143 +219,26 @@ class TestingModuleBuilder { V8_ALIGNED(8) byte globals_data_[kMaxGlobalsSize]; WasmInterpreter* interpreter_; Handle<WasmInstanceObject> instance_object_; + compiler::RuntimeExceptionSupport runtime_exception_support_; + bool lower_simd_; - const WasmGlobal* AddGlobal(ValueType type) { - byte size = WasmOpcodes::MemSize(WasmOpcodes::MachineTypeFor(type)); - global_offset = (global_offset + size - 1) & ~(size - 1); // align - test_module_.globals.push_back( - {type, true, WasmInitExpr(), global_offset, false, false}); - global_offset += size; - // limit number of globals. - CHECK_LT(global_offset, kMaxGlobalsSize); - return &test_module_.globals.back(); - } + const WasmGlobal* AddGlobal(ValueType type); - Handle<WasmInstanceObject> InitInstanceObject() { - Handle<SeqOneByteString> empty_string = Handle<SeqOneByteString>::cast( - isolate_->factory()->NewStringFromOneByte({}).ToHandleChecked()); - // The lifetime of the wasm module is tied to this object's, and we cannot - // rely on the mechanics of Managed<T>. - Handle<Foreign> module_wrapper = isolate_->factory()->NewForeign( - reinterpret_cast<Address>(&test_module_ptr_)); - Handle<Script> script = - isolate_->factory()->NewScript(isolate_->factory()->empty_string()); - script->set_type(Script::TYPE_WASM); - Handle<WasmSharedModuleData> shared_module_data = - WasmSharedModuleData::New(isolate_, module_wrapper, empty_string, - script, Handle<ByteArray>::null()); - Handle<FixedArray> code_table = isolate_->factory()->NewFixedArray(0); - Handle<FixedArray> export_wrappers = isolate_->factory()->NewFixedArray(0); - Handle<WasmCompiledModule> compiled_module = WasmCompiledModule::New( - isolate_, shared_module_data, code_table, export_wrappers, - function_tables_, signature_tables_); - // 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. - WasmCompiledModule::recreate_globals_start( - compiled_module, isolate_->factory(), - reinterpret_cast<size_t>(globals_data_)); - Handle<FixedArray> weak_exported = isolate_->factory()->NewFixedArray(0); - compiled_module->set_weak_exported_functions(weak_exported); - DCHECK(WasmCompiledModule::IsWasmCompiledModule(*compiled_module)); - return WasmInstanceObject::New(isolate_, compiled_module); - } + Handle<WasmInstanceObject> InitInstanceObject(); }; -inline void TestBuildingGraph(Zone* zone, JSGraph* jsgraph, ModuleEnv* module, - FunctionSig* sig, - SourcePositionTable* source_position_table, - const byte* start, const byte* end, - bool runtime_exception_support = false) { - compiler::WasmGraphBuilder builder( - module, zone, jsgraph, CEntryStub(jsgraph->isolate(), 1).GetCode(), sig, - source_position_table); - builder.SetRuntimeExceptionSupport(runtime_exception_support); - - DecodeResult result = - BuildTFGraph(zone->allocator(), &builder, sig, start, end); - if (result.failed()) { - 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); - } +void TestBuildingGraph( + Zone* zone, compiler::JSGraph* jsgraph, compiler::ModuleEnv* module, + FunctionSig* sig, compiler::SourcePositionTable* source_position_table, + const byte* start, const byte* end, + compiler::RuntimeExceptionSupport runtime_exception_support); - uint32_t pc = result.error_offset(); - std::ostringstream str; - str << "Verification failed; pc = +" << pc - << ", msg = " << result.error_msg().c_str(); - FATAL(str.str().c_str()); - } - builder.LowerInt64(); - if (!CpuFeatures::SupportsWasmSimd128()) { - builder.SimdScalarLoweringForTesting(); - } -} - -class WasmFunctionWrapper : private GraphAndBuilders { +class WasmFunctionWrapper : private compiler::GraphAndBuilders { public: - explicit WasmFunctionWrapper(Zone* zone, int num_params) - : GraphAndBuilders(zone), inner_code_node_(nullptr), signature_(nullptr) { - // One additional parameter for the pointer to the return value memory. - Signature<MachineType>::Builder sig_builder(zone, 1, num_params + 1); - - sig_builder.AddReturn(MachineType::Int32()); - for (int i = 0; i < num_params + 1; i++) { - sig_builder.AddParam(MachineType::Pointer()); - } - signature_ = sig_builder.Build(); - } + WasmFunctionWrapper(Zone* zone, int num_params); void Init(CallDescriptor* descriptor, MachineType return_type, - Vector<MachineType> param_types) { - DCHECK_NOT_NULL(descriptor); - DCHECK_EQ(signature_->parameter_count(), param_types.length() + 1); - - // Create the TF graph for the wrapper. - - // Function, effect, and control. - Node** parameters = zone()->NewArray<Node*>(param_types.length() + 3); - graph()->SetStart(graph()->NewNode(common()->Start(6))); - Node* effect = graph()->start(); - int parameter_count = 0; - - // Dummy node which gets replaced in SetInnerCode. - inner_code_node_ = graph()->NewNode(common()->Int32Constant(0)); - parameters[parameter_count++] = inner_code_node_; - - int param_idx = 0; - for (MachineType t : param_types) { - DCHECK_NE(MachineType::None(), t); - parameters[parameter_count] = graph()->NewNode( - machine()->Load(t), - graph()->NewNode(common()->Parameter(param_idx++), graph()->start()), - graph()->NewNode(common()->Int32Constant(0)), effect, - graph()->start()); - effect = parameters[parameter_count++]; - } - - parameters[parameter_count++] = effect; - parameters[parameter_count++] = graph()->start(); - Node* call = graph()->NewNode(common()->Call(descriptor), parameter_count, - parameters); - - if (!return_type.IsNone()) { - effect = graph()->NewNode( - machine()->Store(StoreRepresentation( - return_type.representation(), WriteBarrierKind::kNoWriteBarrier)), - graph()->NewNode(common()->Parameter(param_types.length()), - graph()->start()), - graph()->NewNode(common()->Int32Constant(0)), call, effect, - graph()->start()); - } - Node* zero = graph()->NewNode(common()->Int32Constant(0)); - Node* r = graph()->NewNode( - common()->Return(), zero, - graph()->NewNode(common()->Int32Constant(WASM_WRAPPER_RETURN_VALUE)), - effect, graph()->start()); - graph()->SetEnd(graph()->NewNode(common()->End(1), r)); - } + Vector<MachineType> param_types); template <typename ReturnType, typename... ParamTypes> void Init(CallDescriptor* descriptor) { @@ -515,52 +250,28 @@ class WasmFunctionWrapper : private GraphAndBuilders { } void SetInnerCode(Handle<Code> code_handle) { - NodeProperties::ChangeOp(inner_code_node_, - common()->HeapConstant(code_handle)); + compiler::NodeProperties::ChangeOp(inner_code_node_, + common()->HeapConstant(code_handle)); } - Handle<Code> GetWrapperCode() { - if (code_.is_null()) { - Isolate* isolate = CcTest::InitIsolateOnce(); - - CallDescriptor* descriptor = - Linkage::GetSimplifiedCDescriptor(zone(), signature_, true); - - if (kPointerSize == 4) { - size_t num_params = signature_->parameter_count(); - // One additional parameter for the pointer of the return value. - Signature<MachineRepresentation>::Builder rep_builder(zone(), 1, - num_params + 1); - - rep_builder.AddReturn(MachineRepresentation::kWord32); - for (size_t i = 0; i < num_params + 1; i++) { - rep_builder.AddParam(MachineRepresentation::kWord32); - } - Int64Lowering r(graph(), machine(), common(), zone(), - rep_builder.Build()); - r.LowerGraph(); - } - - CompilationInfo info(ArrayVector("testing"), isolate, graph()->zone(), - Code::ComputeFlags(Code::STUB)); - code_ = - Pipeline::GenerateCodeForTesting(&info, descriptor, graph(), nullptr); - CHECK(!code_.is_null()); -#ifdef ENABLE_DISASSEMBLER - if (FLAG_print_opt_code) { - OFStream os(stdout); - code_->Disassemble("wasm wrapper", os); - } -#endif - } + const compiler::Operator* IntPtrConstant(intptr_t value) { + return machine()->Is32() + ? common()->Int32Constant(static_cast<int32_t>(value)) + : common()->Int64Constant(static_cast<int64_t>(value)); + } - return code_; + void SetContextAddress(Address value) { + compiler::NodeProperties::ChangeOp( + context_address_, IntPtrConstant(reinterpret_cast<uintptr_t>(value))); } + Handle<Code> GetWrapperCode(); + Signature<MachineType>* signature() const { return signature_; } private: Node* inner_code_node_; + Node* context_address_; Handle<Code> code_; Signature<MachineType>* signature_; }; @@ -568,13 +279,11 @@ class WasmFunctionWrapper : private GraphAndBuilders { // A helper for compiling wasm functions for testing. // It contains the internal state for compilation (i.e. TurboFan graph) and // interpretation (by adding to the interpreter manually). -class WasmFunctionCompiler : private GraphAndBuilders { +class WasmFunctionCompiler : public compiler::GraphAndBuilders { public: + ~WasmFunctionCompiler(); + Isolate* isolate() { return builder_->isolate(); } - Graph* graph() const { return main_graph_; } - Zone* zone() const { return graph()->zone(); } - CommonOperatorBuilder* common() { return &main_common_; } - MachineOperatorBuilder* machine() { return &main_machine_; } CallDescriptor* descriptor() { if (descriptor_ == nullptr) { descriptor_ = compiler::GetWasmCallDescriptor(zone(), sig); @@ -583,56 +292,7 @@ class WasmFunctionCompiler : private GraphAndBuilders { } uint32_t function_index() { return function_->func_index; } - void Build(const byte* start, const byte* end) { - size_t locals_size = local_decls.Size(); - size_t total_size = end - start + locals_size + 1; - byte* buffer = static_cast<byte*>(zone()->New(total_size)); - // Prepend the local decls to the code. - local_decls.Emit(buffer); - // Emit the code. - memcpy(buffer + locals_size, start, end - start); - // Append an extra end opcode. - buffer[total_size - 1] = kExprEnd; - - start = buffer; - end = buffer + total_size; - - CHECK_GE(kMaxInt, end - start); - int len = static_cast<int>(end - start); - function_->code = {builder_->AddBytes(Vector<const byte>(start, len)), - static_cast<uint32_t>(len)}; - - if (interpreter_) { - // Add the code to the interpreter. - interpreter_->SetFunctionCodeForTesting(function_, start, end); - } - - // Build the TurboFan graph. - compiler::ModuleEnv module_env = builder_->CreateModuleEnv(); - TestBuildingGraph(zone(), &jsgraph, &module_env, sig, - &source_position_table_, start, end, - runtime_exception_support_); - Handle<Code> code = Compile(); - builder_->SetFunctionCode(function_index(), code); - - // Add to code table. - Handle<WasmCompiledModule> compiled_module( - builder_->instance_object()->compiled_module(), isolate()); - Handle<FixedArray> code_table = compiled_module->code_table(); - if (static_cast<int>(function_index()) >= code_table->length()) { - Handle<FixedArray> new_arr = isolate()->factory()->NewFixedArray( - static_cast<int>(function_index()) + 1); - code_table->CopyTo(0, *new_arr, 0, code_table->length()); - code_table = new_arr; - compiled_module->ReplaceCodeTableForTesting(code_table); - } - DCHECK(code_table->get(static_cast<int>(function_index())) - ->IsUndefined(isolate())); - code_table->set(static_cast<int>(function_index()), *code); - if (trap_handler::UseTrapHandler()) { - UnpackAndRegisterProtectedInstructions(isolate(), code_table); - } - } + void Build(const byte* start, const byte* end); byte AllocateLocal(ValueType type) { uint32_t index = local_decls.AddLocals(1, type); @@ -646,87 +306,29 @@ class WasmFunctionCompiler : private GraphAndBuilders { private: friend class WasmRunnerBase; - explicit WasmFunctionCompiler(Zone* zone, FunctionSig* sig, - TestingModuleBuilder* builder, const char* name, - bool runtime_exception_support) - : GraphAndBuilders(zone), - jsgraph(builder->isolate(), this->graph(), this->common(), nullptr, - nullptr, this->machine()), - sig(sig), - descriptor_(nullptr), - builder_(builder), - local_decls(zone, sig), - source_position_table_(this->graph()), - interpreter_(builder->interpreter()), - runtime_exception_support_(runtime_exception_support) { - // Get a new function from the testing module. - int index = builder->AddFunction(sig, Handle<Code>::null(), name); - function_ = builder_->GetFunctionAt(index); - } + WasmFunctionCompiler(Zone* zone, FunctionSig* sig, + TestingModuleBuilder* builder, const char* name); - Handle<Code> Compile() { - CallDescriptor* desc = descriptor(); - if (kPointerSize == 4) { - desc = compiler::GetI32WasmCallDescriptor(this->zone(), desc); - } - EmbeddedVector<char, 16> comp_name; - int comp_name_len = SNPrintF(comp_name, "wasm#%u", this->function_index()); - comp_name.Truncate(comp_name_len); - CompilationInfo info(comp_name, this->isolate(), this->zone(), - Code::ComputeFlags(Code::WASM_FUNCTION)); - std::unique_ptr<CompilationJob> job(Pipeline::NewWasmCompilationJob( - &info, &jsgraph, desc, &source_position_table_, nullptr, - ModuleOrigin::kAsmJsOrigin)); - if (job->ExecuteJob() != CompilationJob::SUCCEEDED || - job->FinalizeJob() != CompilationJob::SUCCEEDED) - return Handle<Code>::null(); - - Handle<Code> code = info.code(); - - // Deopt data holds <WeakCell<wasm_instance>, func_index>. - DCHECK(code->deoptimization_data() == nullptr || - code->deoptimization_data()->length() == 0); - Handle<FixedArray> deopt_data = - isolate()->factory()->NewFixedArray(2, TENURED); - Handle<Object> weak_instance = - isolate()->factory()->NewWeakCell(builder_->instance_object()); - deopt_data->set(0, *weak_instance); - deopt_data->set(1, Smi::FromInt(static_cast<int>(function_index()))); - code->set_deoptimization_data(*deopt_data); - -#ifdef ENABLE_DISASSEMBLER - if (FLAG_print_opt_code) { - OFStream os(stdout); - code->Disassemble("wasm code", os); - } -#endif - - return code; - } - - JSGraph jsgraph; + compiler::JSGraph jsgraph; FunctionSig* sig; // The call descriptor is initialized when the function is compiled. CallDescriptor* descriptor_; TestingModuleBuilder* builder_; - Vector<const char> debug_name_; WasmFunction* function_; LocalDeclEncoder local_decls; - SourcePositionTable source_position_table_; + compiler::SourcePositionTable source_position_table_; WasmInterpreter* interpreter_; - bool runtime_exception_support_ = false; }; // A helper class to build a module around Wasm bytecode, generate machine // code, and run that code. class WasmRunnerBase : public HandleAndZoneScope { public: - explicit WasmRunnerBase(WasmExecutionMode execution_mode, int num_params, - bool runtime_exception_support) + WasmRunnerBase(WasmExecutionMode execution_mode, int num_params, + compiler::RuntimeExceptionSupport runtime_exception_support) : zone_(&allocator_, ZONE_NAME), - builder_(&zone_, execution_mode), - wrapper_(&zone_, num_params), - runtime_exception_support_(runtime_exception_support) {} + builder_(&zone_, execution_mode, runtime_exception_support), + wrapper_(&zone_, num_params) {} // Builds a graph from the given Wasm code and generates the machine // code and call wrapper for that graph. This method must not be called @@ -749,8 +351,8 @@ class WasmRunnerBase : public HandleAndZoneScope { // Returns the index of the previously built function. WasmFunctionCompiler& NewFunction(FunctionSig* sig, const char* name = nullptr) { - functions_.emplace_back(new WasmFunctionCompiler( - &zone_, sig, &builder_, name, runtime_exception_support_)); + functions_.emplace_back( + new WasmFunctionCompiler(&zone_, sig, &builder_, name)); return *functions_.back(); } @@ -781,24 +383,7 @@ class WasmRunnerBase : public HandleAndZoneScope { private: FunctionSig* CreateSig(MachineType return_type, - Vector<MachineType> param_types) { - int return_count = return_type.IsNone() ? 0 : 1; - int param_count = param_types.length(); - - // Allocate storage array in zone. - ValueType* sig_types = - zone_.NewArray<ValueType>(return_count + param_count); - - // Convert machine types to local types, and check that there are no - // MachineType::None()'s in the parameters. - int idx = 0; - if (return_count) sig_types[idx++] = WasmOpcodes::ValueTypeFor(return_type); - for (MachineType param : param_types) { - CHECK_NE(MachineType::None(), param); - sig_types[idx++] = WasmOpcodes::ValueTypeFor(param); - } - return new (&zone_) FunctionSig(return_count, param_count, sig_types); - } + Vector<MachineType> param_types); protected: v8::internal::AccountingAllocator allocator_; @@ -808,7 +393,6 @@ class WasmRunnerBase : public HandleAndZoneScope { WasmFunctionWrapper wrapper_; bool compiled_ = false; bool possible_nondeterminism_ = false; - bool runtime_exception_support_ = false; public: // This field has to be static. Otherwise, gcc complains about the use in @@ -819,9 +403,10 @@ class WasmRunnerBase : public HandleAndZoneScope { template <typename ReturnType, typename... ParamTypes> class WasmRunner : public WasmRunnerBase { public: - explicit WasmRunner(WasmExecutionMode execution_mode, - const char* main_fn_name = "main", - bool runtime_exception_support = false) + WasmRunner(WasmExecutionMode execution_mode, + const char* main_fn_name = "main", + compiler::RuntimeExceptionSupport runtime_exception_support = + compiler::kNoRuntimeExceptionSupport) : WasmRunnerBase(execution_mode, sizeof...(ParamTypes), runtime_exception_support) { NewFunction<ReturnType, ParamTypes...>(main_fn_name); @@ -843,8 +428,13 @@ class WasmRunner : public WasmRunnerBase { set_trap_callback_for_testing(trap_callback); wrapper_.SetInnerCode(builder_.GetFunctionCode(0)); - CodeRunner<int32_t> runner(CcTest::InitIsolateOnce(), - wrapper_.GetWrapperCode(), wrapper_.signature()); + if (builder().instance_object()->has_memory_object()) { + wrapper_.SetContextAddress(reinterpret_cast<Address>( + builder().instance_object()->wasm_context())); + } + compiler::CodeRunner<int32_t> runner(CcTest::InitIsolateOnce(), + wrapper_.GetWrapperCode(), + wrapper_.signature()); int32_t result = runner.Call(static_cast<void*>(&p)..., static_cast<void*>(&return_value)); CHECK_EQ(WASM_WRAPPER_RETURN_VALUE, result); @@ -875,9 +465,6 @@ class WasmRunner : public WasmRunnerBase { } }; -// Declare static variable. -bool WasmRunnerBase::trap_happened; - // A macro to define tests that run in different engine configurations. #define WASM_EXEC_TEST(name) \ void RunWasm_##name(WasmExecutionMode execution_mode); \ @@ -901,6 +488,8 @@ bool WasmRunnerBase::trap_happened; } \ void RunWasm_##name(WasmExecutionMode execution_mode) -} // namespace +} // namespace wasm +} // namespace internal +} // namespace v8 #endif diff --git a/deps/v8/test/common/wasm/flag-utils.h b/deps/v8/test/common/wasm/flag-utils.h index 9bc5981dcd..b9675a2130 100644 --- a/deps/v8/test/common/wasm/flag-utils.h +++ b/deps/v8/test/common/wasm/flag-utils.h @@ -21,8 +21,10 @@ class FlagScope { T previous_value_; }; -#define EXPERIMENTAL_FLAG_SCOPE(flag) \ - FlagScope<bool> __scope_##__LINE__(&FLAG_experimental_wasm_##flag, true) +#define FLAG_SCOPE(flag) \ + FlagScope<bool> __scope_##flag##__LINE__(&FLAG_##flag, true) + +#define EXPERIMENTAL_FLAG_SCOPE(flag) FLAG_SCOPE(experimental_wasm_##flag) } // namespace internal } // namespace v8 diff --git a/deps/v8/test/common/wasm/wasm-macro-gen.h b/deps/v8/test/common/wasm/wasm-macro-gen.h index 0586d075a6..2d15bbc815 100644 --- a/deps/v8/test/common/wasm/wasm-macro-gen.h +++ b/deps/v8/test/common/wasm/wasm-macro-gen.h @@ -583,4 +583,21 @@ inline WasmOpcode LoadStoreOpcodeOf(MachineType type, bool store) { #define WASM_BR_TABLEV(val, key, count, ...) \ val, key, kExprBrTable, U32V_1(count), __VA_ARGS__ +//------------------------------------------------------------------------------ +// Atomic Operations. +//------------------------------------------------------------------------------ +#define WASM_ATOMICS_OP(op) kAtomicPrefix, static_cast<byte>(op) +#define WASM_ATOMICS_BINOP(op, x, y, representation) \ + x, y, WASM_ATOMICS_OP(op), \ + static_cast<byte>(ElementSizeLog2Of(representation)), ZERO_OFFSET +#define WASM_ATOMICS_TERNARY_OP(op, x, y, z, representation) \ + x, y, z, WASM_ATOMICS_OP(op), \ + static_cast<byte>(ElementSizeLog2Of(representation)), ZERO_OFFSET +#define WASM_ATOMICS_LOAD_OP(op, x, representation) \ + x, WASM_ATOMICS_OP(op), \ + static_cast<byte>(ElementSizeLog2Of(representation)), ZERO_OFFSET +#define WASM_ATOMICS_STORE_OP(op, x, y, representation) \ + x, y, WASM_ATOMICS_OP(op), \ + static_cast<byte>(ElementSizeLog2Of(representation)), ZERO_OFFSET + #endif // V8_WASM_MACRO_GEN_H_ diff --git a/deps/v8/test/common/wasm/wasm-module-runner.cc b/deps/v8/test/common/wasm/wasm-module-runner.cc index 70beed5fda..d2f5e68fef 100644 --- a/deps/v8/test/common/wasm/wasm-module-runner.cc +++ b/deps/v8/test/common/wasm/wasm-module-runner.cc @@ -9,6 +9,7 @@ #include "src/objects-inl.h" #include "src/objects.h" #include "src/property-descriptor.h" +#include "src/wasm/module-compiler.h" #include "src/wasm/module-decoder.h" #include "src/wasm/wasm-interpreter.h" #include "src/wasm/wasm-js.h" @@ -42,6 +43,59 @@ std::unique_ptr<WasmModule> DecodeWasmModuleForTesting( return std::move(decoding_result.val); } +bool InterpretWasmModuleForTesting(Isolate* isolate, + Handle<WasmInstanceObject> instance, + const char* name, size_t argc, + WasmValue* args) { + MaybeHandle<WasmExportedFunction> maybe_function = + GetExportedFunction(isolate, instance, "main"); + Handle<WasmExportedFunction> function; + if (!maybe_function.ToHandle(&function)) { + return false; + } + int function_index = function->function_index(); + FunctionSig* signature = instance->module()->functions[function_index].sig; + size_t param_count = signature->parameter_count(); + std::unique_ptr<WasmValue[]> arguments(new WasmValue[param_count]); + + memcpy(arguments.get(), args, std::min(param_count, argc)); + + // Fill the parameters up with default values. + for (size_t i = argc; i < param_count; ++i) { + switch (signature->GetParam(i)) { + case MachineRepresentation::kWord32: + arguments[i] = WasmValue(int32_t{0}); + break; + case MachineRepresentation::kWord64: + arguments[i] = WasmValue(int64_t{0}); + break; + case MachineRepresentation::kFloat32: + arguments[i] = WasmValue(0.0f); + break; + case MachineRepresentation::kFloat64: + arguments[i] = WasmValue(0.0); + break; + default: + UNREACHABLE(); + } + } + + // Don't execute more than 16k steps. + constexpr int kMaxNumSteps = 16 * 1024; + + Zone zone(isolate->allocator(), ZONE_NAME); + + WasmInterpreter* interpreter = WasmDebugInfo::SetupForTesting(instance); + WasmInterpreter::HeapObjectsScope heap_objects_scope(interpreter, instance); + WasmInterpreter::Thread* thread = interpreter->GetThread(0); + thread->Reset(); + thread->InitFrame(&instance->module()->functions[function_index], + arguments.get()); + WasmInterpreter::State interpreter_result = thread->Run(kMaxNumSteps); + + return interpreter_result != WasmInterpreter::PAUSED; +} + int32_t RunWasmModuleForTesting(Isolate* isolate, Handle<JSObject> instance, int argc, Handle<Object> argv[]) { ErrorThrower thrower(isolate, "RunWasmModule"); @@ -111,9 +165,9 @@ int32_t InterpretWasmModule(Isolate* isolate, } } -int32_t CallWasmFunctionForTesting(Isolate* isolate, Handle<JSObject> instance, - ErrorThrower* thrower, const char* name, - int argc, Handle<Object> argv[]) { +MaybeHandle<WasmExportedFunction> GetExportedFunction(Isolate* isolate, + Handle<JSObject> instance, + const char* name) { Handle<JSObject> exports_object; Handle<Name> exports = isolate->factory()->InternalizeUtf8String("exports"); exports_object = Handle<JSObject>::cast( @@ -123,9 +177,21 @@ int32_t CallWasmFunctionForTesting(Isolate* isolate, Handle<JSObject> instance, PropertyDescriptor desc; Maybe<bool> property_found = JSReceiver::GetOwnPropertyDescriptor( isolate, exports_object, main_name, &desc); - if (!property_found.FromMaybe(false)) return -1; + if (!property_found.FromMaybe(false)) return {}; + if (!desc.value()->IsJSFunction()) return {}; - Handle<JSFunction> main_export = Handle<JSFunction>::cast(desc.value()); + return Handle<WasmExportedFunction>::cast(desc.value()); +} + +int32_t CallWasmFunctionForTesting(Isolate* isolate, Handle<JSObject> instance, + ErrorThrower* thrower, const char* name, + int argc, Handle<Object> argv[]) { + MaybeHandle<WasmExportedFunction> maybe_export = + GetExportedFunction(isolate, instance, name); + Handle<WasmExportedFunction> main_export; + if (!maybe_export.ToHandle(&main_export)) { + return -1; + } // Call the JS function. Handle<Object> undefined = isolate->factory()->undefined_value(); @@ -152,7 +218,7 @@ int32_t CallWasmFunctionForTesting(Isolate* isolate, Handle<JSObject> instance, } void SetupIsolateForWasmModule(Isolate* isolate) { - WasmJs::Install(isolate); + WasmJs::Install(isolate, true); } } // namespace testing diff --git a/deps/v8/test/common/wasm/wasm-module-runner.h b/deps/v8/test/common/wasm/wasm-module-runner.h index cd3e5a1af9..4fa2ca67c1 100644 --- a/deps/v8/test/common/wasm/wasm-module-runner.h +++ b/deps/v8/test/common/wasm/wasm-module-runner.h @@ -27,6 +27,12 @@ std::unique_ptr<WasmModule> DecodeWasmModuleForTesting( Isolate* isolate, ErrorThrower* thrower, const byte* module_start, const byte* module_end, ModuleOrigin origin, bool verify_functions = false); +// Returns a MaybeHandle to the JsToWasm wrapper of the wasm function exported +// with the given name by the provided instance. +MaybeHandle<WasmExportedFunction> GetExportedFunction(Isolate* isolate, + Handle<JSObject> instance, + const char* name); + // Call an exported wasm function by name. Returns -1 if the export does not // exist or throws an error. Errors are cleared from the isolate before // returning. @@ -34,6 +40,15 @@ int32_t CallWasmFunctionForTesting(Isolate* isolate, Handle<JSObject> instance, ErrorThrower* thrower, const char* name, int argc, Handle<Object> argv[]); +// Interprets an exported wasm function by name. Returns false if it was not +// possible to execute the function (e.g. because it does not exist), or if the +// interpretation does not finish after kMaxNumSteps. Otherwise returns true. +// The arguments array is extended with default values if necessary. +bool InterpretWasmModuleForTesting(Isolate* isolate, + Handle<WasmInstanceObject> instance, + const char* name, size_t argc, + WasmValue* args); + // Decode, verify, and run the function labeled "main" in the // given encoded module. The module should have no imports. int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start, diff --git a/deps/v8/test/debugger/debug/debug-break-microtask.js b/deps/v8/test/debugger/debug/debug-break-microtask.js new file mode 100644 index 0000000000..4a244b051d --- /dev/null +++ b/deps/v8/test/debugger/debug/debug-break-microtask.js @@ -0,0 +1,52 @@ +// Copyright 2017 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. + +Debug = debug.Debug +var exception = null; +var log = []; + +function listener(event, exec_state, event_data, data) { + try { + if (event == Debug.DebugEvent.Break) { + var line = exec_state.frame(0).sourceLineText(); + log.push(line); + if (!/STOP/.test(line)) { + exec_state.prepareStep(Debug.StepAction.StepIn); + } + } + } catch (e) { + exception = e; + } +}; + +Debug.setListener(listener); + +function f() { + print(1); +} + +Promise.resolve().then(f).then( +function() { + return 2; +} +).then( +function() { + throw new Error(); +} +).catch( +function() { + print(3); +} // STOP +); + +setTimeout(function() { + Debug.setListener(null); + assertNull(exception); + var expectation = + [" print(1);","}"," return 2;"," return 2;", + " throw new Error();"," print(3);","} // STOP"]; + assertEquals(log, expectation); +}); + +Debug.setBreakPoint(f, 1); diff --git a/deps/v8/test/debugger/debug/debug-compile-optimized.js b/deps/v8/test/debugger/debug/debug-compile-optimized.js index c25bdfd4c0..33f199ac51 100644 --- a/deps/v8/test/debugger/debug/debug-compile-optimized.js +++ b/deps/v8/test/debugger/debug/debug-compile-optimized.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --opt +// Flags: --opt --no-always-opt Debug = debug.Debug; @@ -15,4 +15,17 @@ f(); f(); assertOptimized(f); +var bp = Debug.setBreakPoint(f); +assertUnoptimized(f); +f(); +f(); +%OptimizeFunctionOnNextCall(f); +f(); +assertUnoptimized(f); + +Debug.clearBreakPoint(bp); +%OptimizeFunctionOnNextCall(f); +f(); +assertOptimized(f); + Debug.setListener(null); diff --git a/deps/v8/test/debugger/debug/debug-evaluate-no-side-effect-ops.js b/deps/v8/test/debugger/debug/debug-evaluate-no-side-effect-ops.js index e56645d05b..b7e49dc88f 100644 --- a/deps/v8/test/debugger/debug/debug-evaluate-no-side-effect-ops.js +++ b/deps/v8/test/debugger/debug/debug-evaluate-no-side-effect-ops.js @@ -57,6 +57,8 @@ function listener(event, exec_state, event_data, data) { success(true, `T||F`); success(false, `T?F:T`); success(false, `!T`); + success(1, `+one`); + success(-1, `-one`); success(-2, `~one`); success(4, `one << two`); success(1, `two >> one`); diff --git a/deps/v8/test/debugger/debug/debug-liveedit-inline.js b/deps/v8/test/debugger/debug/debug-liveedit-inline.js new file mode 100644 index 0000000000..4d20991fbc --- /dev/null +++ b/deps/v8/test/debugger/debug/debug-liveedit-inline.js @@ -0,0 +1,30 @@ +// Copyright 2017 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 + +// Flags: --allow-natives-syntax --enable-inspector + +Debug = debug.Debug + +eval("var something1 = 25; " + + " function ChooseAnimal() { return 'Cat'; } " + + " ChooseAnimal.Helper = function() { return 'Help!'; }"); + +function foo() { return ChooseAnimal() } + +assertEquals("Cat", foo()); + %OptimizeFunctionOnNextCall(foo); + +foo(); + +var script = Debug.findScript(ChooseAnimal); + +var orig_animal = "Cat"; +var patch_pos = script.source.indexOf(orig_animal); +var new_animal_patch = "Cap' + 'y' + 'bara"; + +var change_log = new Array(); + +Debug.LiveEdit.TestApi.ApplySingleChunkPatch(script, patch_pos, orig_animal.length, new_animal_patch, change_log); + +assertEquals("Capybara", foo()); diff --git a/deps/v8/test/debugger/debug/debug-step-microtask.js b/deps/v8/test/debugger/debug/debug-step-microtask.js new file mode 100644 index 0000000000..258f235c58 --- /dev/null +++ b/deps/v8/test/debugger/debug/debug-step-microtask.js @@ -0,0 +1,52 @@ +// Copyright 2017 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. + +Debug = debug.Debug +var exception = null; +var log = []; + +function listener(event, exec_state, event_data, data) { + try { + if (event == Debug.DebugEvent.Break) { + var line = exec_state.frame(0).sourceLineText(); + log.push(line); + if (!/STOP/.test(line)) { + exec_state.prepareStep(Debug.StepAction.StepIn); + } + } + } catch (e) { + exception = e; + } +}; + +Debug.setListener(listener); + +Promise.resolve().then( +function() { + print(1); +} +).then( +function() { + return 2; +} +).then( +function() { + throw new Error(); +} +).catch( +function() { + print(3); +} // STOP +); + +setTimeout(function() { + Debug.setListener(null); + assertNull(exception); + var expectation = + ["debugger;","debugger;"," print(1);","}"," return 2;"," return 2;", + " throw new Error();"," print(3);","} // STOP"]; + assertEquals(log, expectation); +}); + +debugger; diff --git a/deps/v8/test/debugger/debug/es8/promise-finally.js b/deps/v8/test/debugger/debug/es8/promise-finally.js new file mode 100644 index 0000000000..2598ae0d82 --- /dev/null +++ b/deps/v8/test/debugger/debug/es8/promise-finally.js @@ -0,0 +1,46 @@ +// Copyright 2017 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. + +// Flags: --harmony-promise-finally + +Debug = debug.Debug + +var exception = null; +var step = 0; + +function listener(event, exec_state, event_data, data) { + if (event != Debug.DebugEvent.Exception) return; + try { + var line = exec_state.frame(0).sourceLineText(); + var match = /Exception/.exec(line); + assertNotNull(match); + step++; + } catch (e) { + exception = e; + } +} + +// Caught throw, events on any exception. +Debug.setListener(listener); +Debug.setBreakOnException(); + +var thenable = { + get then() { + throw new Error('err'); // Exception + } +}; + +var caughtException = null; + +Promise.resolve() + .finally(() => thenable) + .catch(e => caughtException = e); + +%RunMicrotasks(); + +Debug.setListener(null); +Debug.clearBreakOnException(); +assertNull(exception); +assertNotNull(caughtException); +assertEquals(1, step); diff --git a/deps/v8/test/debugger/debug/regress/regress-crbug-222893.js b/deps/v8/test/debugger/debug/regress/regress-crbug-222893.js index a0fc6d56fb..b7838bb8ea 100644 --- a/deps/v8/test/debugger/debug/regress/regress-crbug-222893.js +++ b/deps/v8/test/debugger/debug/regress/regress-crbug-222893.js @@ -31,12 +31,12 @@ Debug = debug.Debug var error = null; var array = ["a", "b", "c"]; +var result = null; function listener(event, exec_state, event_data, data) { try { if (event == Debug.DebugEvent.Break) { - assertArrayEquals(array, - exec_state.frame(0).evaluate('arguments').value()); + result = exec_state.frame(0).evaluate('arguments').value(); } } catch (e) { error = e; @@ -51,13 +51,35 @@ function f(a, b) { debugger; // Arguments object is already materialized. } +result = null; f.apply(this, array); +assertArrayEquals(array, result); +result = null; f("a", "b", "c"); +assertArrayEquals(array, result); assertNull(error); function g(a, b) { debugger; // Arguments object is not yet materialized. } + +result = null; g.apply(this, array); +assertArrayEquals(array, result); +result = null; g("a", "b", "c"); +assertArrayEquals(array, result); +assertNull(error); + +function h(a, b) { + var arguments = undefined; + debugger; // Arguments already used as local variable. +} + +result = null; +h.apply(this, array); +assertEquals(undefined, result); +result = null; +h("a", "b", "c"); +assertEquals(undefined, result); assertNull(error); diff --git a/deps/v8/test/debugger/debugger.status b/deps/v8/test/debugger/debugger.status index bbb4507bdf..98a95ebc02 100644 --- a/deps/v8/test/debugger/debugger.status +++ b/deps/v8/test/debugger/debugger.status @@ -44,6 +44,12 @@ }], # variant == stress ############################################################################## +['variant == stress_incremental_marking', { + # BUG(chromium:772010). + 'debug/debug-*': [PASS, ['system == windows', SKIP]], +}], # variant == stress_incremental_marking + +############################################################################## ['gc_stress == True', { # Skip tests not suitable for GC stress. # Tests taking too long diff --git a/deps/v8/test/fuzzer/README.md b/deps/v8/test/fuzzer/README.md index ed0ce1fa2a..5f10d47ec4 100644 --- a/deps/v8/test/fuzzer/README.md +++ b/deps/v8/test/fuzzer/README.md @@ -79,7 +79,7 @@ new fuzzer to cluster fuzz. for more information. 2. Compile the fuzzer in chromium (for different configurations see: - https://chromium.googlesource.com/chromium/src/+/master/testing/libfuzzer/reproducing.md): + https://chromium.googlesource.com/chromium/src/+/master/testing/libfuzzer/reference.md): * `gn gen out/libfuzzer '--args=use_libfuzzer=true is_asan=true is_debug=false enable_nacl=false'` diff --git a/deps/v8/test/fuzzer/fuzzer-support.cc b/deps/v8/test/fuzzer/fuzzer-support.cc index 2ca35800f8..f800f49b8f 100644 --- a/deps/v8/test/fuzzer/fuzzer-support.cc +++ b/deps/v8/test/fuzzer/fuzzer-support.cc @@ -53,8 +53,9 @@ FuzzerSupport::FuzzerSupport(int* argc, char*** argv) { FuzzerSupport::~FuzzerSupport() { { v8::Isolate::Scope isolate_scope(isolate_); - while (PumpMessageLoop()) /* empty */ - ; + while (PumpMessageLoop()) { + // empty + } v8::HandleScope handle_scope(isolate_); context_.Reset(); diff --git a/deps/v8/test/fuzzer/fuzzer-support.h b/deps/v8/test/fuzzer/fuzzer-support.h index 60c870ca38..e72dcc3613 100644 --- a/deps/v8/test/fuzzer/fuzzer-support.h +++ b/deps/v8/test/fuzzer/fuzzer-support.h @@ -34,6 +34,6 @@ class FuzzerSupport { v8::Global<v8::Context> context_; }; -} // namespace +} // namespace v8_fuzzer #endif // TEST_FUZZER_FUZZER_SUPPORT_H_ diff --git a/deps/v8/test/fuzzer/fuzzer.cc b/deps/v8/test/fuzzer/fuzzer.cc index cb4a287d70..96c381e0b6 100644 --- a/deps/v8/test/fuzzer/fuzzer.cc +++ b/deps/v8/test/fuzzer/fuzzer.cc @@ -29,13 +29,13 @@ int main(int argc, char* argv[]) { } fseek(input, 0, SEEK_END); - long size = ftell(input); + size_t size = ftell(input); fseek(input, 0, SEEK_SET); uint8_t* data = reinterpret_cast<uint8_t*>(malloc(size)); if (!data) { fclose(input); - fprintf(stderr, "Failed to allocate %ld bytes\n", size); + fprintf(stderr, "Failed to allocate %zu bytes\n", size); return 1; } diff --git a/deps/v8/test/fuzzer/fuzzer.gyp b/deps/v8/test/fuzzer/fuzzer.gyp index 863f90ae02..3d76018d55 100644 --- a/deps/v8/test/fuzzer/fuzzer.gyp +++ b/deps/v8/test/fuzzer/fuzzer.gyp @@ -116,6 +116,8 @@ 'wasm.cc', '../common/wasm/wasm-module-runner.cc', '../common/wasm/wasm-module-runner.h', + 'wasm-fuzzer-common.cc', + 'wasm-fuzzer-common.h', ], }, { @@ -145,6 +147,8 @@ 'wasm-async.cc', '../common/wasm/wasm-module-runner.cc', '../common/wasm/wasm-module-runner.h', + 'wasm-fuzzer-common.cc', + 'wasm-fuzzer-common.h', ], }, { diff --git a/deps/v8/test/fuzzer/parser.cc b/deps/v8/test/fuzzer/parser.cc index 76666e85be..9321207c23 100644 --- a/deps/v8/test/fuzzer/parser.cc +++ b/deps/v8/test/fuzzer/parser.cc @@ -6,6 +6,9 @@ #include <stddef.h> #include <stdint.h> +#include <cctype> +#include <list> + #include "include/v8.h" #include "src/objects-inl.h" #include "src/objects.h" @@ -14,9 +17,6 @@ #include "src/parsing/preparser.h" #include "test/fuzzer/fuzzer-support.h" -#include <cctype> -#include <list> - bool IsValidInput(const uint8_t* data, size_t size) { std::list<char> parentheses; const char* ptr = reinterpret_cast<const char*>(data); diff --git a/deps/v8/test/fuzzer/wasm-async.cc b/deps/v8/test/fuzzer/wasm-async.cc index b408d9c454..13b15a9d70 100644 --- a/deps/v8/test/fuzzer/wasm-async.cc +++ b/deps/v8/test/fuzzer/wasm-async.cc @@ -7,31 +7,26 @@ #include <stdint.h> #include "include/v8.h" +#include "src/api.h" #include "src/factory.h" #include "src/isolate-inl.h" #include "src/isolate.h" #include "src/objects-inl.h" #include "src/objects.h" +#include "src/wasm/module-compiler.h" #include "src/wasm/wasm-api.h" #include "src/wasm/wasm-module.h" #include "test/common/wasm/flag-utils.h" #include "test/common/wasm/wasm-module-runner.h" #include "test/fuzzer/fuzzer-support.h" +#include "test/fuzzer/wasm-fuzzer-common.h" -#if __clang__ -// TODO(mostynb@opera.com): remove the using statements and these pragmas. -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wheader-hygiene" -#endif - -using namespace v8::internal; -using namespace v8::internal::wasm; -using namespace v8::internal::wasm::testing; +namespace v8 { +namespace internal { +class WasmModuleObject; -#if __clang__ -// TODO(mostynb@opera.com): remove the using statements and these pragmas. -#pragma clang diagnostic pop -#endif +namespace wasm { +namespace fuzzer { #define ASSIGN(type, var, expr) \ v8::Local<type> var; \ @@ -44,12 +39,6 @@ using namespace v8::internal::wasm::testing; } \ } while (false) -namespace v8 { -namespace internal { -class WasmModuleObject; -} -} - namespace { // We need this helper function because we cannot use // Handle<WasmModuleObject>::cast here. To use this function we would have to @@ -59,44 +48,33 @@ Handle<WasmModuleObject> ToWasmModuleObjectUnchecked(Handle<Object> that) { } } -void InstantiateCallback(const v8::FunctionCallbackInfo<v8::Value>& args) { +void InstantiateCallback(const FunctionCallbackInfo<Value>& args) { DCHECK_GE(args.Length(), 1); v8::Isolate* isolate = args.GetIsolate(); - v8::MicrotasksScope does_not_run_microtasks( + MicrotasksScope does_not_run_microtasks( isolate, v8::MicrotasksScope::kDoNotRunMicrotasks); v8::HandleScope scope(isolate); - v8::Local<v8::Value> module = args[0]; + Local<v8::Value> module = args[0]; i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); - ScheduledErrorThrower thrower(i_isolate, "WebAssembly Instantiation"); - - i::Handle<i::WasmModuleObject> module_obj = ToWasmModuleObjectUnchecked( - v8::Utils::OpenHandle(v8::Object::Cast(*module))); - i::MaybeHandle<WasmInstanceObject> maybe_instance = - i::wasm::SyncInstantiate(i_isolate, &thrower, module_obj, - Handle<JSReceiver>::null(), // imports - MaybeHandle<JSArrayBuffer>()); // memory - Handle<WasmInstanceObject> instance; - if (!maybe_instance.ToHandle(&instance)) { - return; - } - RunWasmModuleForTesting(i_isolate, instance, 0, nullptr); + Handle<WasmModuleObject> module_obj = + ToWasmModuleObjectUnchecked(Utils::OpenHandle(v8::Object::Cast(*module))); + InterpretAndExecuteModule(i_isolate, module_obj); } extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { - v8::internal::FlagScope<bool> turn_on_async_compile( + FlagScope<bool> turn_on_async_compile( &v8::internal::FLAG_wasm_async_compilation, true); - v8::internal::FlagScope<uint32_t> max_mem_flag_scope( - &v8::internal::FLAG_wasm_max_mem_pages, 32); - v8::internal::FlagScope<uint32_t> max_table_size_scope( + FlagScope<uint32_t> max_mem_flag_scope(&v8::internal::FLAG_wasm_max_mem_pages, + 32); + FlagScope<uint32_t> max_table_size_scope( &v8::internal::FLAG_wasm_max_table_size, 100); v8_fuzzer::FuzzerSupport* support = v8_fuzzer::FuzzerSupport::Get(); v8::Isolate* isolate = support->GetIsolate(); - v8::internal::Isolate* i_isolate = - reinterpret_cast<v8::internal::Isolate*>(isolate); + i::Isolate* i_isolate = reinterpret_cast<v8::internal::Isolate*>(isolate); // Clear any pending exceptions from a prior run. if (i_isolate->has_pending_exception()) { @@ -105,30 +83,37 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { v8::Isolate::Scope isolate_scope(isolate); v8::HandleScope handle_scope(isolate); - HandleScope internal_scope(i_isolate); + i::HandleScope internal_scope(i_isolate); v8::Context::Scope context_scope(support->GetContext()); - v8::TryCatch try_catch(isolate); - v8::internal::wasm::testing::SetupIsolateForWasmModule(i_isolate); + TryCatch try_catch(isolate); + testing::SetupIsolateForWasmModule(i_isolate); // Get the promise for async compilation. - ASSIGN(v8::Promise::Resolver, resolver, - v8::Promise::Resolver::New(support->GetContext())); - v8::Local<v8::Promise> promise = resolver->GetPromise(); + ASSIGN(Promise::Resolver, resolver, + Promise::Resolver::New(support->GetContext())); + Local<Promise> promise = resolver->GetPromise(); - AsyncCompile(i_isolate, v8::Utils::OpenHandle(*promise), + AsyncCompile(i_isolate, Utils::OpenHandle(*promise), ModuleWireBytes(data, data + size)); - ASSIGN(v8::Function, instantiate_impl, - v8::Function::New(support->GetContext(), &InstantiateCallback, - v8::Undefined(isolate))); + ASSIGN(Function, instantiate_impl, + Function::New(support->GetContext(), &InstantiateCallback, + Undefined(isolate))); - ASSIGN(v8::Promise, result, + ASSIGN(Promise, result, promise->Then(support->GetContext(), instantiate_impl)); // Wait for the promise to resolve. - while (result->State() == v8::Promise::kPending) { - support->PumpMessageLoop(v8::platform::MessageLoopBehavior::kWaitForWork); + while (result->State() == Promise::kPending) { + support->PumpMessageLoop(platform::MessageLoopBehavior::kWaitForWork); isolate->RunMicrotasks(); } return 0; } + +#undef ASSIGN + +} // namespace fuzzer +} // namespace wasm +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/fuzzer/wasm-call.cc b/deps/v8/test/fuzzer/wasm-call.cc index 24a0841a09..5c85502381 100644 --- a/deps/v8/test/fuzzer/wasm-call.cc +++ b/deps/v8/test/fuzzer/wasm-call.cc @@ -18,23 +18,13 @@ #include "test/fuzzer/fuzzer-support.h" #include "test/fuzzer/wasm-fuzzer-common.h" -#define MAX_NUM_FUNCTIONS 3 -#define MAX_NUM_PARAMS 3 +namespace v8 { +namespace internal { +namespace wasm { +namespace fuzzer { -#if __clang__ -// TODO(mostynb@opera.com): remove the using statements and these pragmas. -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wheader-hygiene" -#endif - -using namespace v8::internal; -using namespace v8::internal::wasm; -using namespace v8::internal::wasm::fuzzer; - -#if __clang__ -// TODO(mostynb@opera.com): remove the using statements and these pragmas. -#pragma clang diagnostic pop -#endif +static constexpr uint32_t kMaxNumFunctions = 3; +static constexpr uint32_t kMaxNumParams = 3; class WasmCallFuzzer : public WasmExecutionFuzzer { template <typename V> @@ -43,17 +33,16 @@ class WasmCallFuzzer : public WasmExecutionFuzzer { // that a value of type V can be read without problems. *ok &= (*size > sizeof(V)); if (!(*ok)) return 0; - V result = v8::internal::ReadLittleEndianValue<V>(*data); + V result = ReadLittleEndianValue<V>(*data); *data += sizeof(V); *size -= sizeof(V); return result; } - static void add_argument( - v8::internal::Isolate* isolate, ValueType type, - WasmValue* interpreter_args, - v8::internal::Handle<v8::internal::Object>* compiler_args, int* argc, - const uint8_t** data, size_t* size, bool* ok) { + static void add_argument(Isolate* isolate, ValueType type, + WasmValue* interpreter_args, + Handle<Object>* compiler_args, int* argc, + const uint8_t** data, size_t* size, bool* ok) { if (!(*ok)) return; switch (type) { case kWasmF32: { @@ -82,14 +71,14 @@ class WasmCallFuzzer : public WasmExecutionFuzzer { (*argc)++; } - virtual bool GenerateModule( + bool GenerateModule( Isolate* isolate, Zone* zone, const uint8_t* data, size_t size, ZoneBuffer& buffer, int32_t& num_args, std::unique_ptr<WasmValue[]>& interpreter_args, std::unique_ptr<Handle<Object>[]>& compiler_args) override { bool ok = true; uint8_t num_functions = - (read_value<uint8_t>(&data, &size, &ok) % MAX_NUM_FUNCTIONS) + 1; + (read_value<uint8_t>(&data, &size, &ok) % kMaxNumFunctions) + 1; ValueType types[] = {kWasmF32, kWasmF64, kWasmI32, kWasmI64}; @@ -99,7 +88,7 @@ class WasmCallFuzzer : public WasmExecutionFuzzer { WasmModuleBuilder builder(zone); for (int fun = 0; fun < num_functions; fun++) { size_t num_params = static_cast<size_t>( - (read_value<uint8_t>(&data, &size, &ok) % MAX_NUM_PARAMS) + 1); + (read_value<uint8_t>(&data, &size, &ok) % kMaxNumParams) + 1); FunctionSig::Builder sig_builder(zone, 1, num_params); sig_builder.AddReturn(kWasmI32); for (size_t param = 0; param < num_params; param++) { @@ -112,8 +101,7 @@ class WasmCallFuzzer : public WasmExecutionFuzzer { compiler_args.get(), &num_args, &data, &size, &ok); } } - v8::internal::wasm::WasmFunctionBuilder* f = - builder.AddFunction(sig_builder.Build()); + WasmFunctionBuilder* f = builder.AddFunction(sig_builder.Build()); uint32_t code_size = static_cast<uint32_t>(size / num_functions); f->EmitCode(data, code_size); uint8_t end_opcode = kExprEnd; @@ -121,7 +109,7 @@ class WasmCallFuzzer : public WasmExecutionFuzzer { data += code_size; size -= code_size; if (fun == 0) { - builder.AddExport(v8::internal::CStrVector("main"), f); + builder.AddExport(CStrVector("main"), f); } } @@ -139,3 +127,8 @@ class WasmCallFuzzer : public WasmExecutionFuzzer { extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { return WasmCallFuzzer().FuzzWasmModule(data, size); } + +} // namespace fuzzer +} // namespace wasm +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/fuzzer/wasm-code.cc b/deps/v8/test/fuzzer/wasm-code.cc index d74e26c944..54a3da5768 100644 --- a/deps/v8/test/fuzzer/wasm-code.cc +++ b/deps/v8/test/fuzzer/wasm-code.cc @@ -13,23 +13,13 @@ #include "test/common/wasm/test-signatures.h" #include "test/fuzzer/wasm-fuzzer-common.h" -#if __clang__ -// TODO(mostynb@opera.com): remove the using statements and these pragmas. -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wheader-hygiene" -#endif - -using namespace v8::internal; -using namespace v8::internal::wasm; -using namespace v8::internal::wasm::fuzzer; - -#if __clang__ -// TODO(mostynb@opera.com): remove the using statements and these pragmas. -#pragma clang diagnostic pop -#endif +namespace v8 { +namespace internal { +namespace wasm { +namespace fuzzer { class WasmCodeFuzzer : public WasmExecutionFuzzer { - virtual bool GenerateModule( + bool GenerateModule( Isolate* isolate, Zone* zone, const uint8_t* data, size_t size, ZoneBuffer& buffer, int32_t& num_args, std::unique_ptr<WasmValue[]>& interpreter_args, @@ -58,3 +48,8 @@ class WasmCodeFuzzer : public WasmExecutionFuzzer { extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { return WasmCodeFuzzer().FuzzWasmModule(data, size); } + +} // namespace fuzzer +} // namespace wasm +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/fuzzer/wasm-compile.cc b/deps/v8/test/fuzzer/wasm-compile.cc index 8d73cf852e..5b59a63e97 100644 --- a/deps/v8/test/fuzzer/wasm-compile.cc +++ b/deps/v8/test/fuzzer/wasm-compile.cc @@ -23,20 +23,10 @@ typedef uint8_t byte; -#if __clang__ -// TODO(mostynb@opera.com): remove the using statements and these pragmas. -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wheader-hygiene" -#endif - -using namespace v8::internal; -using namespace v8::internal::wasm; -using namespace v8::internal::wasm::fuzzer; - -#if __clang__ -// TODO(mostynb@opera.com): remove the using statements and these pragmas. -#pragma clang diagnostic pop -#endif +namespace v8 { +namespace internal { +namespace wasm { +namespace fuzzer { namespace { @@ -123,7 +113,7 @@ class WasmGenerator { } public: - WasmGenerator(v8::internal::wasm::WasmFunctionBuilder* fn) : builder_(fn) {} + explicit WasmGenerator(WasmFunctionBuilder* fn) : builder_(fn) {} void Generate(ValueType type, DataRange data); @@ -138,7 +128,7 @@ class WasmGenerator { } private: - v8::internal::wasm::WasmFunctionBuilder* builder_; + WasmFunctionBuilder* builder_; std::vector<ValueType> blocks_; }; @@ -307,10 +297,10 @@ void WasmGenerator::Generate(ValueType type, DataRange data) { UNREACHABLE(); } } -} +} // namespace class WasmCompileFuzzer : public WasmExecutionFuzzer { - virtual bool GenerateModule( + bool GenerateModule( Isolate* isolate, Zone* zone, const uint8_t* data, size_t size, ZoneBuffer& buffer, int32_t& num_args, std::unique_ptr<WasmValue[]>& interpreter_args, @@ -319,15 +309,14 @@ class WasmCompileFuzzer : public WasmExecutionFuzzer { WasmModuleBuilder builder(zone); - v8::internal::wasm::WasmFunctionBuilder* f = - builder.AddFunction(sigs.i_iii()); + WasmFunctionBuilder* f = builder.AddFunction(sigs.i_iii()); WasmGenerator gen(f); gen.Generate<kWasmI32>(DataRange(data, static_cast<uint32_t>(size))); uint8_t end_opcode = kExprEnd; f->EmitCode(&end_opcode, 1); - builder.AddExport(v8::internal::CStrVector("main"), f); + builder.AddExport(CStrVector("main"), f); builder.SetMaxMemorySize(32); builder.WriteTo(buffer); @@ -346,3 +335,8 @@ class WasmCompileFuzzer : public WasmExecutionFuzzer { extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { return WasmCompileFuzzer().FuzzWasmModule(data, size); } + +} // namespace fuzzer +} // namespace wasm +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/fuzzer/wasm-fuzzer-common.cc b/deps/v8/test/fuzzer/wasm-fuzzer-common.cc index 8d83653a4d..f02d2b957e 100644 --- a/deps/v8/test/fuzzer/wasm-fuzzer-common.cc +++ b/deps/v8/test/fuzzer/wasm-fuzzer-common.cc @@ -7,6 +7,8 @@ #include "include/v8.h" #include "src/isolate.h" #include "src/objects-inl.h" +#include "src/wasm/module-compiler.h" +#include "src/wasm/wasm-api.h" #include "src/wasm/wasm-module-builder.h" #include "src/wasm/wasm-module.h" #include "src/zone/accounting-allocator.h" @@ -14,32 +16,20 @@ #include "test/common/wasm/wasm-module-runner.h" #include "test/fuzzer/fuzzer-support.h" -#define WASM_CODE_FUZZER_HASH_SEED 83 +namespace v8 { +namespace internal { +namespace wasm { +namespace fuzzer { -#if __clang__ -// TODO(mostynb@opera.com): remove the using statements and these pragmas. -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wheader-hygiene" -#endif +static constexpr uint32_t kWasmCodeFuzzerHashSeed = 83; -using namespace v8::internal; -using namespace v8::internal::wasm; -using namespace v8::internal::wasm::fuzzer; +static constexpr const char* kNameString = "name"; +static constexpr size_t kNameStringLength = 4; -#if __clang__ -// TODO(mostynb@opera.com): remove the using statements and these pragmas. -#pragma clang diagnostic pop -#endif - -static const char* kNameString = "name"; -static const size_t kNameStringLength = 4; - -int v8::internal::wasm::fuzzer::FuzzWasmSection(SectionCode section, - const uint8_t* data, - size_t size) { +int FuzzWasmSection(SectionCode section, const uint8_t* data, size_t size) { v8_fuzzer::FuzzerSupport* support = v8_fuzzer::FuzzerSupport::Get(); v8::Isolate* isolate = support->GetIsolate(); - v8::internal::Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate); + i::Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate); // Clear any pending exceptions from a prior run. if (i_isolate->has_pending_exception()) { @@ -78,8 +68,31 @@ int v8::internal::wasm::fuzzer::FuzzWasmSection(SectionCode section, return 0; } -int WasmExecutionFuzzer::FuzzWasmModule( +void InterpretAndExecuteModule(i::Isolate* isolate, + Handle<WasmModuleObject> module_object) { + ScheduledErrorThrower thrower(isolate, "WebAssembly Instantiation"); + // Try to instantiate and interpret the module_object. + MaybeHandle<WasmInstanceObject> maybe_instance = + SyncInstantiate(isolate, &thrower, module_object, + Handle<JSReceiver>::null(), // imports + MaybeHandle<JSArrayBuffer>()); // memory + Handle<WasmInstanceObject> instance; + if (!maybe_instance.ToHandle(&instance)) return; + if (!testing::InterpretWasmModuleForTesting(isolate, instance, "main", 0, + nullptr)) { + return; + } + + // Instantiate and execute the module_object. + maybe_instance = SyncInstantiate(isolate, &thrower, module_object, + Handle<JSReceiver>::null(), // imports + MaybeHandle<JSArrayBuffer>()); // memory + if (!maybe_instance.ToHandle(&instance)) return; + testing::RunWasmModuleForTesting(isolate, instance, 0, nullptr); +} + +int WasmExecutionFuzzer::FuzzWasmModule( const uint8_t* data, size_t size) { // Save the flag so that we can change it and restore it later. bool generate_test = FLAG_wasm_code_fuzzer_gen_test; @@ -104,7 +117,7 @@ int WasmExecutionFuzzer::FuzzWasmModule( } v8_fuzzer::FuzzerSupport* support = v8_fuzzer::FuzzerSupport::Get(); v8::Isolate* isolate = support->GetIsolate(); - Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate); + i::Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate); // Clear any pending exceptions from a prior run. if (i_isolate->has_pending_exception()) { @@ -129,7 +142,7 @@ int WasmExecutionFuzzer::FuzzWasmModule( return 0; } - v8::internal::wasm::testing::SetupIsolateForWasmModule(i_isolate); + testing::SetupIsolateForWasmModule(i_isolate); ErrorThrower interpreter_thrower(i_isolate, "Interpreter"); ModuleWireBytes wire_bytes(buffer.begin(), buffer.end()); @@ -155,11 +168,11 @@ int WasmExecutionFuzzer::FuzzWasmModule( os << "})();" << std::endl; } - bool validates = wasm::SyncValidate(i_isolate, wire_bytes); + bool validates = SyncValidate(i_isolate, wire_bytes); if (compiles != validates) { uint32_t hash = StringHasher::HashSequentialString( - data, static_cast<int>(size), WASM_CODE_FUZZER_HASH_SEED); + data, static_cast<int>(size), kWasmCodeFuzzerHashSeed); V8_Fatal(__FILE__, __LINE__, "compiles != validates (%d vs %d); WasmCodeFuzzerHash=%x", compiles, validates, hash); @@ -215,8 +228,13 @@ int WasmExecutionFuzzer::FuzzWasmModule( if (result_interpreted != result_compiled) { V8_Fatal(__FILE__, __LINE__, "WasmCodeFuzzerHash=%x", StringHasher::HashSequentialString(data, static_cast<int>(size), - WASM_CODE_FUZZER_HASH_SEED)); + kWasmCodeFuzzerHashSeed)); } } return 0; } + +} // namespace fuzzer +} // namespace wasm +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/fuzzer/wasm-fuzzer-common.h b/deps/v8/test/fuzzer/wasm-fuzzer-common.h index 6aa36e1c8c..8830d716b8 100644 --- a/deps/v8/test/fuzzer/wasm-fuzzer-common.h +++ b/deps/v8/test/fuzzer/wasm-fuzzer-common.h @@ -17,8 +17,14 @@ namespace internal { namespace wasm { namespace fuzzer { -int FuzzWasmSection(v8::internal::wasm::SectionCode section, - const uint8_t* data, size_t size); +int FuzzWasmSection(SectionCode section, const uint8_t* data, size_t size); + +// First instantiates and interprets the "main" function within module_object if +// possible. If the interpretation finishes within kMaxSteps steps, +// module_object is instantiated again and the compiled "main" function is +// executed. +void InterpretAndExecuteModule(Isolate* isolate, + Handle<WasmModuleObject> module_object); class WasmExecutionFuzzer { public: diff --git a/deps/v8/test/fuzzer/wasm.cc b/deps/v8/test/fuzzer/wasm.cc index 547dd44c1d..567e68b40a 100644 --- a/deps/v8/test/fuzzer/wasm.cc +++ b/deps/v8/test/fuzzer/wasm.cc @@ -12,20 +12,22 @@ #include "src/isolate.h" #include "src/objects-inl.h" #include "src/objects.h" +#include "src/wasm/module-compiler.h" #include "src/wasm/wasm-module.h" #include "test/common/wasm/flag-utils.h" #include "test/common/wasm/wasm-module-runner.h" #include "test/fuzzer/fuzzer-support.h" +#include "test/fuzzer/wasm-fuzzer-common.h" + +namespace i = v8::internal; extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { - v8::internal::FlagScope<uint32_t> max_mem_flag_scope( - &v8::internal::FLAG_wasm_max_mem_pages, 32); - v8::internal::FlagScope<uint32_t> max_table_size_scope( - &v8::internal::FLAG_wasm_max_table_size, 100); + i::FlagScope<uint32_t> max_mem_flag_scope(&i::FLAG_wasm_max_mem_pages, 32); + i::FlagScope<uint32_t> max_table_size_scope(&i::FLAG_wasm_max_table_size, + 100); v8_fuzzer::FuzzerSupport* support = v8_fuzzer::FuzzerSupport::Get(); v8::Isolate* isolate = support->GetIsolate(); - v8::internal::Isolate* i_isolate = - reinterpret_cast<v8::internal::Isolate*>(isolate); + i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); // Clear any pending exceptions from a prior run. if (i_isolate->has_pending_exception()) { @@ -36,8 +38,15 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { v8::HandleScope handle_scope(isolate); v8::Context::Scope context_scope(support->GetContext()); v8::TryCatch try_catch(isolate); - v8::internal::wasm::testing::SetupIsolateForWasmModule(i_isolate); - v8::internal::wasm::testing::CompileAndRunWasmModule(i_isolate, data, - data + size); + i::wasm::testing::SetupIsolateForWasmModule(i_isolate); + + i::HandleScope scope(i_isolate); + i::wasm::ErrorThrower thrower(i_isolate, "wasm fuzzer"); + i::MaybeHandle<i::WasmModuleObject> maybe_object = SyncCompile( + i_isolate, &thrower, i::wasm::ModuleWireBytes(data, data + size)); + i::Handle<i::WasmModuleObject> module_object; + if (maybe_object.ToHandle(&module_object)) { + i::wasm::fuzzer::InterpretAndExecuteModule(i_isolate, module_object); + } return 0; } diff --git a/deps/v8/test/fuzzer/wasm_async/regression-761784.wasm b/deps/v8/test/fuzzer/wasm_async/regression-761784.wasm Binary files differnew file mode 100644 index 0000000000..29cde166e1 --- /dev/null +++ b/deps/v8/test/fuzzer/wasm_async/regression-761784.wasm diff --git a/deps/v8/test/inspector/cpu-profiler/coverage.js b/deps/v8/test/inspector/cpu-profiler/coverage.js index 0fde457688..dbad54b6d6 100644 --- a/deps/v8/test/inspector/cpu-profiler/coverage.js +++ b/deps/v8/test/inspector/cpu-profiler/coverage.js @@ -226,7 +226,7 @@ InspectorTest.runTestSuite([ { // Enabling the debugger holds onto script objects even though its // functions can be garbage collected. We would get empty ScriptCoverage - // entires unless we remove them. + // entries unless we remove them. Protocol.Debugger.enable() .then(Protocol.Runtime.enable) .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL: arguments.callee.name, persistScript: true })) diff --git a/deps/v8/test/inspector/debugger/breakpoints-expected.txt b/deps/v8/test/inspector/debugger/breakpoints-expected.txt new file mode 100644 index 0000000000..9d0bae5666 --- /dev/null +++ b/deps/v8/test/inspector/debugger/breakpoints-expected.txt @@ -0,0 +1,66 @@ +Checks breakpoints. + +Running test: testRemoveBreakpoint +Debugger.removeBreakpoint when agent is disabled: +{ + error : { + code : -32000 + message : Debugger agent is not enabled + } + id : <messageId> +} +Remove breakpoint with invalid breakpoint id: +{ + id : <messageId> + result : { + } +} +{ + id : <messageId> + result : { + } +} + +Running test: testSetBreakpointByUrl +Adding conditional (arg === 1) breakpoint +evaluating foo1(0): + not paused +evaluating foo1(1): + hit expected breakpoint + +Evaluating another script with the same url +evaluating foo2(0): + not paused +evaluating foo2(1): + hit expected breakpoint + +Removing breakpoint +evaluating foo1(1): + not paused +evaluating foo2(1): + not paused + +Adding breakpoint back +evaluating foo1(0): + not paused +evaluating foo1(1): + hit expected breakpoint + +Disabling debugger agent +evaluating foo1(1): + not paused +evaluating foo2(1): + not paused + +Enabling debugger agent +evaluating foo1(1): + not paused +evaluating foo2(1): + not paused + +Running test: testSetBreakpointInScriptsWithDifferentOffsets +Adding breakpoint +evaluating foo1(0): + hit expected breakpoint +evaluating foo2(0): + not paused diff --git a/deps/v8/test/inspector/debugger/breakpoints.js b/deps/v8/test/inspector/debugger/breakpoints.js new file mode 100644 index 0000000000..ce9ab47665 --- /dev/null +++ b/deps/v8/test/inspector/debugger/breakpoints.js @@ -0,0 +1,117 @@ +// Copyright 2017 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. + +let {session, contextGroup, Protocol} = InspectorTest.start('Checks breakpoints.'); + +session.setupScriptMap(); +InspectorTest.runAsyncTestSuite([ + async function testRemoveBreakpoint() { + InspectorTest.log('Debugger.removeBreakpoint when agent is disabled:'); + InspectorTest.logMessage(await Protocol.Debugger.removeBreakpoint({ + breakpointId: '1:test.js:0:0' + })); + Protocol.Debugger.enable(); + InspectorTest.log('Remove breakpoint with invalid breakpoint id:') + InspectorTest.logMessage(await Protocol.Debugger.removeBreakpoint({ + breakpointId: '' + })); + InspectorTest.logMessage(await Protocol.Debugger.removeBreakpoint({ + breakpointId: ':::' + })); + await Protocol.Debugger.disable(); + }, + + async function testSetBreakpointByUrl() { + await Protocol.Debugger.enable(); + Protocol.Runtime.evaluate({expression: ` +function foo1(arg) { + return arg; +} +//# sourceURL=testSetBreakpointByUrl.js`}); + InspectorTest.log('Adding conditional (arg === 1) breakpoint'); + let {result:{breakpointId}} = await Protocol.Debugger.setBreakpointByUrl({ + lineNumber: 2, + url: 'testSetBreakpointByUrl.js', + columnNumber: 2, + condition: 'arg === 1' + }); + await evaluate('foo1(0)'); + await evaluate('foo1(1)', breakpointId); + + InspectorTest.log('\nEvaluating another script with the same url') + Protocol.Runtime.evaluate({expression: ` +function foo2(arg) { + return arg; +} +//# sourceURL=testSetBreakpointByUrl.js`}); + await evaluate('foo2(0)'); + await evaluate('foo2(1)', breakpointId); + + InspectorTest.log('\nRemoving breakpoint'); + await Protocol.Debugger.removeBreakpoint({breakpointId}); + await evaluate('foo1(1)'); + await evaluate('foo2(1)'); + + InspectorTest.log('\nAdding breakpoint back'); + ({result:{breakpointId}} = await Protocol.Debugger.setBreakpointByUrl({ + lineNumber: 2, + url: 'testSetBreakpointByUrl.js', + columnNumber: 2, + condition: 'arg === 1' + })); + await evaluate('foo1(0)'); + await evaluate('foo1(1)', breakpointId); + + InspectorTest.log('\nDisabling debugger agent'); + await Protocol.Debugger.disable(); + await evaluate('foo1(1)'); + await evaluate('foo2(1)'); + + InspectorTest.log('\nEnabling debugger agent'); + await Protocol.Debugger.enable(); + await evaluate('foo1(1)'); + await evaluate('foo2(1)'); + }, + + async function testSetBreakpointInScriptsWithDifferentOffsets() { + await Protocol.Debugger.enable(); + InspectorTest.log('Adding breakpoint'); + let {result:{breakpointId}} = await Protocol.Debugger.setBreakpointByUrl({ + lineNumber: 2, + url: 'test2.js', + columnNumber: 2, + }); + contextGroup.addScript(` +function foo1(arg) { + return arg; +} +//# sourceURL=test2.js`); + contextGroup.addScript(` +function foo2(arg) { + return arg; +} +//# sourceURL=test2.js`, 5); + await evaluate('foo1(0)', breakpointId); + await evaluate('foo2(0)'); +} +]); + +async function evaluate(expression, expectedBreakpoint) { + InspectorTest.log('evaluating ' + expression + ':'); + let paused = Protocol.Debugger.oncePaused(); + let evaluate = Protocol.Runtime.evaluate({expression}); + let result = await Promise.race([paused, evaluate]); + if (result.method === 'Debugger.paused') { + if (result.params.hitBreakpoints) { + if (result.params.hitBreakpoints.find(b => b === expectedBreakpoint)) { + InspectorTest.log(' hit expected breakpoint') + } else { + InspectorTest.log(' hit unexpected breakpoint'); + } + } + await Protocol.Debugger.resume(); + } else { + InspectorTest.log(' not paused'); + } +} diff --git a/deps/v8/test/inspector/debugger/call-frame-url-expected.txt b/deps/v8/test/inspector/debugger/call-frame-url-expected.txt new file mode 100644 index 0000000000..b27b40dd3d --- /dev/null +++ b/deps/v8/test/inspector/debugger/call-frame-url-expected.txt @@ -0,0 +1,15 @@ +Tests url in Debugger.CallFrame. +[ + [0] : { + url : + } + [1] : { + url : source-url.js + } + [2] : { + url : test.js + } + [3] : { + url : expr.js + } +] diff --git a/deps/v8/test/inspector/debugger/call-frame-url.js b/deps/v8/test/inspector/debugger/call-frame-url.js new file mode 100644 index 0000000000..af8e908ca5 --- /dev/null +++ b/deps/v8/test/inspector/debugger/call-frame-url.js @@ -0,0 +1,20 @@ +// Copyright 2017 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. + +let {session, contextGroup, Protocol} = + InspectorTest.start('Tests url in Debugger.CallFrame.'); + +contextGroup.addScript(` +eval('function foo1() { debugger; }'); +eval('function foo2() { foo1() } //# sourceURL=source-url.js'); +function foo3() { foo2(); } +`, 0, 0, 'test.js'); + +(async function test() { + Protocol.Debugger.enable(); + Protocol.Runtime.evaluate({expression: 'foo3()//# sourceURL=expr.js'}); + let {params:{callFrames}} = await Protocol.Debugger.oncePaused(); + InspectorTest.logMessage(callFrames.map(frame => ({url: frame.url}))); + InspectorTest.completeTest(); +})(); diff --git a/deps/v8/test/inspector/debugger/caught-uncaught-exceptions-expected.txt b/deps/v8/test/inspector/debugger/caught-uncaught-exceptions-expected.txt index 039b8bd912..9c40b1c556 100644 --- a/deps/v8/test/inspector/debugger/caught-uncaught-exceptions-expected.txt +++ b/deps/v8/test/inspector/debugger/caught-uncaught-exceptions-expected.txt @@ -8,4 +8,6 @@ uncaught: false paused in promiseUncaught uncaught: true paused in throwInMapConstructor +uncaught: true +paused in throwInAsyncIterator uncaught: true
\ No newline at end of file diff --git a/deps/v8/test/inspector/debugger/caught-uncaught-exceptions.js b/deps/v8/test/inspector/debugger/caught-uncaught-exceptions.js index 8789943a89..b7c4bd4ab7 100644 --- a/deps/v8/test/inspector/debugger/caught-uncaught-exceptions.js +++ b/deps/v8/test/inspector/debugger/caught-uncaught-exceptions.js @@ -16,6 +16,10 @@ contextGroup.addScript( new Promise(function promiseUncaught() { throw new Error(); }); } function throwInMapConstructor() { new Map('a'); } + function throwInAsyncIterator() { + let it = (async function*() {})(); + it.next.call({}); + } function schedule(f) { setTimeout(f, 0); } `); @@ -37,4 +41,6 @@ Protocol.Runtime.evaluate({ "expression": "schedule(throwCaught);" }) { "expression": "schedule(throwInPromiseUncaught);"})) .then(() => Protocol.Runtime.evaluate( { "expression": "schedule(throwInMapConstructor);"})) + .then(() => Protocol.Runtime.evaluate( + { "expression": "schedule(throwInAsyncIterator);"})) .then(() => InspectorTest.completeTest()); diff --git a/deps/v8/test/inspector/debugger/provisional-breakpoint-for-anonymous-script-expected.txt b/deps/v8/test/inspector/debugger/provisional-breakpoint-for-anonymous-script-expected.txt new file mode 100644 index 0000000000..43fdca6d05 --- /dev/null +++ b/deps/v8/test/inspector/debugger/provisional-breakpoint-for-anonymous-script-expected.txt @@ -0,0 +1,11 @@ +Checks provisional breakpoints by hash in anonymous scripts + +Running test: testNextScriptParsed +function foo(){#} + + +Running test: testPreviousScriptParsed +var list = list ? list.concat(foo) : [foo]; function foo(){#} + +var list = list ? list.concat(foo) : [foo]; function foo(){#} + diff --git a/deps/v8/test/inspector/debugger/provisional-breakpoint-for-anonymous-script.js b/deps/v8/test/inspector/debugger/provisional-breakpoint-for-anonymous-script.js new file mode 100644 index 0000000000..7d97753d59 --- /dev/null +++ b/deps/v8/test/inspector/debugger/provisional-breakpoint-for-anonymous-script.js @@ -0,0 +1,69 @@ +// Copyright 2017 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. + +let {session, contextGroup, Protocol} = + InspectorTest.start('Checks provisional breakpoints by hash in anonymous scripts'); +session.setupScriptMap(); + +InspectorTest.runAsyncTestSuite([ + async function testNextScriptParsed() { + await Protocol.Debugger.enable(); + // set breakpoint in anonymous script.. + Protocol.Runtime.evaluate({expression: 'function foo(){}'}); + let {params:{hash}} = await Protocol.Debugger.onceScriptParsed(); + let {result:{breakpointId}} = await Protocol.Debugger.setBreakpointByUrl({ + scriptHash: hash, + lineNumber: 0, + columnNumber: 15 + }); + // evaluate the same anonymous script again.. + Protocol.Runtime.evaluate({expression: 'function foo(){}'}); + // run function and check Debugger.paused event.. + let evaluation = Protocol.Runtime.evaluate({expression: 'foo()'}); + let result = await Promise.race([evaluation, Protocol.Debugger.oncePaused()]); + if (result.method !== 'Debugger.paused') { + InspectorTest.log('FAIL: breakpoint was ignored'); + } else { + await session.logSourceLocation(result.params.callFrames[0].location); + } + // remove breakpoint and run again.. + await Protocol.Debugger.removeBreakpoint({breakpointId}); + evaluation = Protocol.Runtime.evaluate({expression: 'foo()'}); + result = await Promise.race([evaluation, Protocol.Debugger.oncePaused()]); + if (result.method === 'Debugger.paused') { + InspectorTest.log('FAIL: breakpoint was not removed'); + } + await Protocol.Debugger.disable(); + }, + async function testPreviousScriptParsed() { + await Protocol.Debugger.enable(); + // run script and store function to global list.. + await Protocol.Runtime.evaluate({expression: 'var list = list ? list.concat(foo) : [foo]; function foo(){}'}); + // run same script again.. + Protocol.Runtime.evaluate({expression: 'var list = list ? list.concat(foo) : [foo]; function foo(){}'}); + let {params:{hash}} = await Protocol.Debugger.onceScriptParsed(); + // set breakpoint by hash of latest script.. + let {result:{breakpointId}} = await Protocol.Debugger.setBreakpointByUrl({ + scriptHash: hash, + lineNumber: 0, + columnNumber: 49 + }); + // call each function in global list and wait for Debugger.paused events.. + let evaluation = Protocol.Runtime.evaluate({expression: 'list.forEach(x => x())'}); + let result = await Promise.race([evaluation, Protocol.Debugger.oncePaused()]); + while (result.method === 'Debugger.paused') { + await session.logSourceLocation(result.params.callFrames[0].location); + Protocol.Debugger.resume(); + result = await Promise.race([evaluation, Protocol.Debugger.oncePaused()]); + } + // remove breakpoint and call functions again.. + await Protocol.Debugger.removeBreakpoint({breakpointId}); + evaluation = Protocol.Runtime.evaluate({expression: 'foo()'}); + result = await Promise.race([evaluation, Protocol.Debugger.oncePaused()]); + if (result.method === 'Debugger.paused') { + InspectorTest.log('FAIL: breakpoint was not removed'); + } + await Protocol.Debugger.disable(); + } +]); diff --git a/deps/v8/test/inspector/debugger/restore-breakpoint.js b/deps/v8/test/inspector/debugger/restore-breakpoint.js index e0d2b84766..020143f6d1 100644 --- a/deps/v8/test/inspector/debugger/restore-breakpoint.js +++ b/deps/v8/test/inspector/debugger/restore-breakpoint.js @@ -5,6 +5,7 @@ let {session, contextGroup, Protocol} = InspectorTest.start('Checks that debugger agent uses source content to restore breakpoints.'); Protocol.Debugger.enable(); +var finishedTests = 0; InspectorTest.runTestSuite([ function testSameSource(next) { var source = 'function foo() {\nboo();\n}'; @@ -43,27 +44,28 @@ InspectorTest.runTestSuite([ } ]); -var finishedTests = 0; async function test(source, newSource, location, next) { - var firstBreakpoint = true; - Protocol.Debugger.onBreakpointResolved(message => { - var lineNumber = message.params.location.lineNumber; - var columnNumber = message.params.location.columnNumber; - var currentSource = firstBreakpoint ? source : newSource; - var lines = currentSource.split('\n'); + function dumpSourceWithBreakpoint(source, location) { + var lineNumber = location.lineNumber; + var columnNumber = location.columnNumber; + var lines = source.split('\n'); lines = lines.map(line => line.length > 80 ? line.substring(0, 77) + '...' : line); lines[lineNumber] = lines[lineNumber].slice(0, columnNumber) + '#' + lines[lineNumber].slice(columnNumber); InspectorTest.log(lines.join('\n')); - firstBreakpoint = false; - }); + } + + Protocol.Debugger.onBreakpointResolved(message => { + dumpSourceWithBreakpoint(newSource, message.params.location); + }) var sourceURL = `test${++finishedTests}.js`; - await Protocol.Debugger.setBreakpointByUrl({ + await Protocol.Runtime.evaluate({ expression: `${source}\n//# sourceURL=${sourceURL}` }); + let {result:{locations}} = await Protocol.Debugger.setBreakpointByUrl({ url: sourceURL, lineNumber: location.lineNumber, columnNumber: location.columnNumber }); - await Protocol.Runtime.evaluate({ expression: `${source}\n//# sourceURL=${sourceURL}` }); + dumpSourceWithBreakpoint(source, locations[0]); await Protocol.Runtime.evaluate({ expression: `${newSource}\n//# sourceURL=${sourceURL}` }); next(); } diff --git a/deps/v8/test/inspector/debugger/suspended-generator-scopes-expected.txt b/deps/v8/test/inspector/debugger/suspended-generator-scopes-expected.txt index a59bc3281c..57dc2aa6ee 100644 --- a/deps/v8/test/inspector/debugger/suspended-generator-scopes-expected.txt +++ b/deps/v8/test/inspector/debugger/suspended-generator-scopes-expected.txt @@ -1,65 +1,55 @@ Tests that suspended generators produce scopes Running test: testScopesPaused -{ - id : <messageId> - result : { - result : [ - [0] : { - configurable : true - enumerable : true - isOwn : true - name : b - value : { - description : 42 - type : number - value : 42 - } - writable : true - } - [1] : { - configurable : true - enumerable : true - isOwn : true - name : a - value : { - description : 420 - type : number - value : 420 - } - writable : true - } - ] +[ + [0] : { + configurable : true + enumerable : true + isOwn : true + name : b + value : { + description : 42 + type : number + value : 42 + } + writable : true } -} + [1] : { + configurable : true + enumerable : true + isOwn : true + name : a + value : { + description : 420 + type : number + value : 420 + } + writable : true + } +] Running test: testScopesNonPaused -{ - id : <messageId> - result : { - result : [ - [0] : { - configurable : true - enumerable : true - isOwn : true - name : b - value : { - type : undefined - } - writable : true - } - [1] : { - configurable : true - enumerable : true - isOwn : true - name : a - value : { - description : 430 - type : number - value : 430 - } - writable : true - } - ] +[ + [0] : { + configurable : true + enumerable : true + isOwn : true + name : b + value : { + type : undefined + } + writable : true + } + [1] : { + configurable : true + enumerable : true + isOwn : true + name : a + value : { + description : 430 + type : number + value : 430 + } + writable : true } -} +] diff --git a/deps/v8/test/inspector/debugger/suspended-generator-scopes.js b/deps/v8/test/inspector/debugger/suspended-generator-scopes.js index f7d389072a..55a1fd57ca 100644 --- a/deps/v8/test/inspector/debugger/suspended-generator-scopes.js +++ b/deps/v8/test/inspector/debugger/suspended-generator-scopes.js @@ -4,78 +4,66 @@ let {session, contextGroup, Protocol} = InspectorTest.start('Tests that suspended generators produce scopes'); -contextGroup.addScript( -`function *gen(a) { +contextGroup.addScript(` +function *gen(a) { var b = 42; yield a; return b; } -function testSuspendedGenerator() -{ + +function testSuspendedGenerator() { var g = gen(420); g.next(); - debugger; return g; }`); -Protocol.Debugger.enable().then(testSuite); - -function dumpInnermostScope(msg) { - var scopes = msg.result.result; - var inner_scope = scopes[0].value; - return Protocol.Runtime.getProperties({ objectId : inner_scope.objectId }) - .then(InspectorTest.logMessage); -} - -function dumpGeneratorScopes(msg) -{ - var props = msg.result.internalProperties; - var promises = props - .filter(prop => prop.name == "[[Scopes]]") - .map(prop => prop.value.objectId) - .map(scopesId => Protocol.Runtime.getProperties({ objectId : scopesId }) - .then(dumpInnermostScope)); - return Promise.all(promises); -} - -function fetchGeneratorProperties(objectId) { - return Protocol.Runtime.getProperties({ objectId : objectId }); -} +InspectorTest.runAsyncTestSuite([ + async function testScopesPaused() { + Protocol.Debugger.enable(); + Protocol.Runtime.evaluate({expression: 'testSuspendedGenerator()'}); + let {params:{callFrames:[callFrame]}} = await Protocol.Debugger.oncePaused(); + // Current local scope. + let localScope = callFrame.scopeChain.find(scope => scope.type === 'local'); + let variables = (await Protocol.Runtime.getProperties({ + objectId: localScope.object.objectId + })).result.result; + let genObjectId = + variables.find(variable => variable.name === 'g').value.objectId; + let {result:{internalProperties}} = await Protocol.Runtime.getProperties({ + objectId: genObjectId + }); + // Generator [[Scopes]]. + let scopes = internalProperties.find(prop => prop.name === '[[Scopes]]'); + let {result:{result}} = await Protocol.Runtime.getProperties({ + objectId: scopes.value.objectId + }); + // Locals from generator. + let scope = result.find(scope => scope.value.description === 'Local (gen)'); + ({result:{result}} = await Protocol.Runtime.getProperties({ + objectId: scope.value.objectId + })); + InspectorTest.logMessage(result); + await Protocol.Debugger.disable(); + }, -function extractGeneratorObjectFromScope(scopeId) { - return Protocol.Runtime.getProperties({ objectId : scopeId }) - .then(msg => { - var generatorObjectId = msg.result.result[0].value.objectId; - return fetchGeneratorProperties(generatorObjectId); - }); -} - -function dumpGeneratorScopesOnPause(msg) { - var scopeChain = msg.params.callFrames[0].scopeChain; - var promises = scopeChain - .filter(scope => scope.type === "local") - .map(scope => scope.object.objectId) - .map(scopeId => extractGeneratorObjectFromScope(scopeId) - .then(dumpGeneratorScopes)); - return Promise.all(promises).then(Protocol.Debugger.resume); -} - -function testSuite() { - InspectorTest.runTestSuite([ - - function testScopesPaused(next) { - Protocol.Debugger.oncePaused() - .then(dumpGeneratorScopesOnPause) - .then(next); - Protocol.Runtime.evaluate({ expression : "testSuspendedGenerator()" }); - }, - - function testScopesNonPaused(next) { - Protocol.Runtime.evaluate({ expression : "gen(430)"}) - .then(msg => fetchGeneratorProperties(msg.result.result.objectId)) - .then(dumpGeneratorScopes) - .then(next); - }, - ]); -} + async function testScopesNonPaused() { + let {result:{result:{objectId}}} = await Protocol.Runtime.evaluate({ + expression: 'gen(430)' + }); + let {result:{internalProperties}} = await Protocol.Runtime.getProperties({ + objectId + }); + // Generator [[Scopes]]. + let scopes = internalProperties.find(prop => prop.name === '[[Scopes]]'); + let {result:{result}} = await Protocol.Runtime.getProperties({ + objectId: scopes.value.objectId + }); + // Locals from generator. + let scope = result.find(scope => scope.value.description === 'Local (gen)'); + ({result:{result}} = await Protocol.Runtime.getProperties({ + objectId: scope.value.objectId + })); + InspectorTest.logMessage(result); + } +]); diff --git a/deps/v8/test/inspector/inspector.isolate b/deps/v8/test/inspector/inspector.isolate index afce94b2e5..38a96c57c6 100644 --- a/deps/v8/test/inspector/inspector.isolate +++ b/deps/v8/test/inspector/inspector.isolate @@ -15,6 +15,7 @@ './runtime/', './sessions/', './testcfg.py', + './type-profiler/', '../../src/inspector/injected-script-source.js', '<(PRODUCT_DIR)/inspector-test<(EXECUTABLE_SUFFIX)', ], diff --git a/deps/v8/test/inspector/isolate-data.cc b/deps/v8/test/inspector/isolate-data.cc index 4c1d81670f..8362dd4488 100644 --- a/deps/v8/test/inspector/isolate-data.cc +++ b/deps/v8/test/inspector/isolate-data.cc @@ -359,7 +359,7 @@ void IsolateData::SetCurrentTimeMS(double time) { double IsolateData::currentTimeMS() { if (current_time_set_) return current_time_; - return v8::base::OS::TimeCurrentMillis(); + return v8::internal::V8::GetCurrentPlatform()->CurrentClockTimeMillis(); } void IsolateData::SetMemoryInfo(v8::Local<v8::Value> memory_info) { diff --git a/deps/v8/test/inspector/protocol-test.js b/deps/v8/test/inspector/protocol-test.js index 87910cc3e4..4ae96614dc 100644 --- a/deps/v8/test/inspector/protocol-test.js +++ b/deps/v8/test/inspector/protocol-test.js @@ -45,8 +45,8 @@ InspectorTest.logMessage = function(originalMessage) { for (var key in object) { if (nonStableFields.has(key)) object[key] = `<${key}>`; - else if (typeof object[key] === "string" && object[key].match(/\d+:\d+:\d+:debug/)) - object[key] = object[key].replace(/\d+/, '<scriptId>'); + else if (typeof object[key] === "string" && object[key].match(/\d+:\d+:\d+:\d+/)) + object[key] = object[key].substring(0, object[key].lastIndexOf(':')) + ":<scriptId>"; else if (typeof object[key] === "object") objects.push(object[key]); } @@ -277,6 +277,25 @@ InspectorTest.Session = class { } } + async logTypeProfile(typeProfile, source) { + let entries = typeProfile.entries; + + // Sort in reverse order so we can replace entries without invalidating + // the other offsets. + entries = entries.sort((a, b) => b.offset - a.offset); + + for (let entry of entries) { + source = source.slice(0, entry.offset) + typeAnnotation(entry.types) + + source.slice(entry.offset); + } + InspectorTest.log(source); + return typeProfile; + + function typeAnnotation(types) { + return `/*${types.map(t => t.name).join(', ')}*/`; + } + } + logAsyncStackTrace(asyncStackTrace) { while (asyncStackTrace) { if (asyncStackTrace.promiseCreationFrame) { diff --git a/deps/v8/test/inspector/runtime/call-function-on-async-expected.txt b/deps/v8/test/inspector/runtime/call-function-on-async-expected.txt index ed6342996a..0cbf6f1c08 100644 --- a/deps/v8/test/inspector/runtime/call-function-on-async-expected.txt +++ b/deps/v8/test/inspector/runtime/call-function-on-async-expected.txt @@ -68,6 +68,24 @@ Running test: testExceptionInFunctionExpression exceptionId : <exceptionId> lineNumber : 0 scriptId : <scriptId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 21 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + [1] : { + columnNumber : 35 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } text : Uncaught } result : { @@ -154,3 +172,24 @@ Running test: testFunctionReturnRejectedPromise } } } + +Running test: testEvaluateOnExecutionContext +{ + id : <messageId> + result : { + result : { + description : 70 + type : number + value : 70 + } + } +} + +Running test: testPassingBothObjectIdAndExecutionContextId +{ + error : { + code : -32000 + message : ObjectId must not be specified together with executionContextId + } + id : <messageId> +} diff --git a/deps/v8/test/inspector/runtime/call-function-on-async.js b/deps/v8/test/inspector/runtime/call-function-on-async.js index a08b0777a6..277a01c468 100644 --- a/deps/v8/test/inspector/runtime/call-function-on-async.js +++ b/deps/v8/test/inspector/runtime/call-function-on-async.js @@ -7,13 +7,22 @@ let callFunctionOn = Protocol.Runtime.callFunctionOn.bind(Protocol.Runtime); let remoteObject1; let remoteObject2; +let executionContextId; -InspectorTest.runAsyncTestSuite([ +Protocol.Runtime.enable(); +Protocol.Runtime.onExecutionContextCreated(messageObject => { + executionContextId = messageObject.params.context.id; + InspectorTest.runAsyncTestSuite(testSuite); +}); + +let testSuite = [ async function prepareTestSuite() { let result = await Protocol.Runtime.evaluate({ expression: '({a : 1})' }); remoteObject1 = result.result.result; result = await Protocol.Runtime.evaluate({ expression: '({a : 2})' }); remoteObject2 = result.result.result; + + await Protocol.Runtime.evaluate({ expression: 'globalObjectProperty = 42;' }); }, async function testArguments() { @@ -102,8 +111,31 @@ InspectorTest.runAsyncTestSuite([ generatePreview: false, awaitPromise: true })); - } -]); + }, + + async function testEvaluateOnExecutionContext() { + InspectorTest.logMessage(await callFunctionOn({ + executionContextId, + functionDeclaration: '(function(arg) { return this.globalObjectProperty + arg; })', + arguments: prepareArguments([ 28 ]), + returnByValue: true, + generatePreview: false, + awaitPromise: false + })); + }, + + async function testPassingBothObjectIdAndExecutionContextId() { + InspectorTest.logMessage(await callFunctionOn({ + executionContextId, + objectId: remoteObject1.objectId, + functionDeclaration: '(function() { return 42; })', + arguments: prepareArguments([]), + returnByValue: true, + generatePreview: false, + awaitPromise: false + })); + }, +]; function prepareArguments(args) { return args.map(arg => { diff --git a/deps/v8/test/inspector/runtime/command-line-api-expected.txt b/deps/v8/test/inspector/runtime/command-line-api-expected.txt index f655e7b783..11e60d9535 100644 --- a/deps/v8/test/inspector/runtime/command-line-api-expected.txt +++ b/deps/v8/test/inspector/runtime/command-line-api-expected.txt @@ -255,12 +255,12 @@ Running test: testDebug foo (:0:16) (anonymous) (:0:0) [ - [0] : <scriptId>:0:12:debug + [0] : 5:0:12:<scriptId> ] foo (:0:16) (anonymous) (:0:0) [ - [0] : <scriptId>:0:12:debug + [0] : 5:0:12:<scriptId> ] Running test: testMonitor diff --git a/deps/v8/test/inspector/runtime/console-methods-expected.txt b/deps/v8/test/inspector/runtime/console-methods-expected.txt index 100789a773..81c3c76813 100644 --- a/deps/v8/test/inspector/runtime/console-methods-expected.txt +++ b/deps/v8/test/inspector/runtime/console-methods-expected.txt @@ -317,6 +317,85 @@ Checks console methods params : { args : [ [0] : { + className : Array + description : Array(2) + objectId : <objectId> + preview : { + description : Array(2) + overflow : false + properties : [ + [0] : { + name : 0 + subtype : array + type : object + valuePreview : { + description : Array(2) + overflow : false + properties : [ + [0] : { + name : 1 + type : number + value : 2 + } + ] + subtype : array + type : object + } + } + [1] : { + name : 1 + subtype : array + type : object + valuePreview : { + description : Array(2) + overflow : false + properties : [ + [0] : { + name : 1 + type : number + value : 4 + } + ] + subtype : array + type : object + } + } + ] + subtype : array + type : object + } + subtype : array + type : object + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 10 + functionName : testFunction + lineNumber : 17 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : table + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { type : string value : trace } @@ -327,7 +406,7 @@ Checks console methods [0] : { columnNumber : 10 functionName : testFunction - lineNumber : 17 + lineNumber : 18 scriptId : <scriptId> url : test.js } @@ -359,7 +438,7 @@ Checks console methods [0] : { columnNumber : 10 functionName : testFunction - lineNumber : 18 + lineNumber : 19 scriptId : <scriptId> url : test.js } @@ -391,7 +470,7 @@ Checks console methods [0] : { columnNumber : 10 functionName : testFunction - lineNumber : 19 + lineNumber : 20 scriptId : <scriptId> url : test.js } @@ -423,7 +502,7 @@ Checks console methods [0] : { columnNumber : 10 functionName : testFunction - lineNumber : 20 + lineNumber : 21 scriptId : <scriptId> url : test.js } @@ -455,7 +534,7 @@ Checks console methods [0] : { columnNumber : 10 functionName : testFunction - lineNumber : 21 + lineNumber : 22 scriptId : <scriptId> url : test.js } @@ -487,7 +566,7 @@ Checks console methods [0] : { columnNumber : 10 functionName : testFunction - lineNumber : 22 + lineNumber : 23 scriptId : <scriptId> url : test.js } @@ -519,7 +598,7 @@ Checks console methods [0] : { columnNumber : 10 functionName : testFunction - lineNumber : 23 + lineNumber : 24 scriptId : <scriptId> url : test.js } @@ -551,7 +630,7 @@ Checks console methods [0] : { columnNumber : 10 functionName : testFunction - lineNumber : 24 + lineNumber : 25 scriptId : <scriptId> url : test.js } @@ -583,14 +662,14 @@ Checks console methods [0] : { columnNumber : 12 functionName : foo - lineNumber : 26 + lineNumber : 27 scriptId : <scriptId> url : test.js } [1] : { columnNumber : 2 functionName : testFunction - lineNumber : 28 + lineNumber : 29 scriptId : <scriptId> url : test.js } @@ -622,14 +701,14 @@ Checks console methods [0] : { columnNumber : 12 functionName : foo - lineNumber : 26 + lineNumber : 27 scriptId : <scriptId> url : test.js } [1] : { columnNumber : 2 functionName : testFunction - lineNumber : 29 + lineNumber : 30 scriptId : <scriptId> url : test.js } diff --git a/deps/v8/test/inspector/runtime/console-methods.js b/deps/v8/test/inspector/runtime/console-methods.js index 38ab5bd83f..c9e0e1d89b 100644 --- a/deps/v8/test/inspector/runtime/console-methods.js +++ b/deps/v8/test/inspector/runtime/console-methods.js @@ -4,6 +4,7 @@ let {session, contextGroup, Protocol} = InspectorTest.start('Checks console methods'); +contextGroup.setupInjectedScriptEnvironment(); contextGroup.addScript(` function testFunction() { console.debug('debug'); @@ -14,6 +15,7 @@ function testFunction() { console.dir('dir'); console.dirxml('dirxml'); console.table([[1,2],[3,4]]); + console.table([[1,2],[3,4]], [1,2]); console.trace('trace'); console.trace(); console.group(); diff --git a/deps/v8/test/inspector/runtime/es6-module-expected.txt b/deps/v8/test/inspector/runtime/es6-module-expected.txt index cbe63fe718..646fd018ea 100644 --- a/deps/v8/test/inspector/runtime/es6-module-expected.txt +++ b/deps/v8/test/inspector/runtime/es6-module-expected.txt @@ -117,6 +117,7 @@ console.log(239) this : { type : undefined } + url : module3 } ] hitBreakpoints : [ diff --git a/deps/v8/test/inspector/runtime/function-scopes-expected.txt b/deps/v8/test/inspector/runtime/function-scopes-expected.txt new file mode 100644 index 0000000000..0503e31b82 --- /dev/null +++ b/deps/v8/test/inspector/runtime/function-scopes-expected.txt @@ -0,0 +1,53 @@ +Checks [[Scopes]] for functions +Catch: +{ + configurable : true + enumerable : true + isOwn : true + name : a + value : { + description : 1 + type : number + value : 1 + } + writable : true +} +With block: +{ + configurable : true + enumerable : true + isOwn : true + name : b + value : { + description : 2 + type : number + value : 2 + } + writable : true +} +Closure (closure): +{ + configurable : true + enumerable : true + isOwn : true + name : c + value : { + description : 3 + type : number + value : 3 + } + writable : true +} +Global: +{ + configurable : false + enumerable : true + isOwn : true + name : e + value : { + description : 5 + type : number + value : 5 + } + writable : true +} diff --git a/deps/v8/test/inspector/runtime/function-scopes.js b/deps/v8/test/inspector/runtime/function-scopes.js new file mode 100644 index 0000000000..bda069bd9a --- /dev/null +++ b/deps/v8/test/inspector/runtime/function-scopes.js @@ -0,0 +1,56 @@ +// Copyright 2017 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. + +let {session, contextGroup, Protocol} = InspectorTest.start('Checks [[Scopes]] for functions'); + +contextGroup.addScript(` +var f; +try { + throw 1; +} catch (a) { + with({b:2}) { + function closure() { + var c = 3; + function foo() { + var d = 4; + return a + b + c + d; + } + return foo; + } + f = closure; + } +} +var e = 5; +//# sourceURL=test.js`); + +(async function test() { + let {result:{result:{objectId}}} = await Protocol.Runtime.evaluate({ + expression: 'f()' + }); + let {result:{internalProperties}} = await Protocol.Runtime.getProperties({ + objectId + }); + let scopes = internalProperties.find(prop => prop.name === '[[Scopes]]'); + let {result:{result}} = await Protocol.Runtime.getProperties({ + objectId: scopes.value.objectId + }); + await Promise.all(result.map(async scope => { + scope.variables = (await Protocol.Runtime.getProperties({ + objectId: scope.value.objectId + })).result.result; + })); + let catchScope = result.find(scope => scope.value.description === 'Catch'); + InspectorTest.log('Catch:'); + InspectorTest.logMessage(catchScope.variables.find(variable => variable.name === 'a')); + InspectorTest.log('With block:'); + let withScope = result.find(scope => scope.value.description === 'With Block'); + InspectorTest.logMessage(withScope.variables.find(variable => variable.name === 'b')); + InspectorTest.log('Closure (closure):'); + let closureScope = result.find(scope => scope.value.description === 'Closure (closure)'); + InspectorTest.logMessage(closureScope.variables.find(variable => variable.name === 'c')); + InspectorTest.log('Global:'); + let globalScope = result.find(scope => scope.value.description === 'Global'); + InspectorTest.logMessage(globalScope.variables.find(variable => variable.name === 'e')); + InspectorTest.completeTest(); +})(); diff --git a/deps/v8/test/inspector/runtime/internal-properties-expected.txt b/deps/v8/test/inspector/runtime/internal-properties-expected.txt index 10c2f83b7e..a44c50b673 100644 --- a/deps/v8/test/inspector/runtime/internal-properties-expected.txt +++ b/deps/v8/test/inspector/runtime/internal-properties-expected.txt @@ -387,6 +387,16 @@ expression: gen2 } } } + [4] : { + name : [[Scopes]] + value : { + className : Array + description : Scopes[2] + objectId : <objectId> + subtype : internal#scopeList + type : object + } + } ] } } @@ -433,6 +443,16 @@ expression: gen2.next();gen2 } } } + [4] : { + name : [[Scopes]] + value : { + className : Array + description : Scopes[2] + objectId : <objectId> + subtype : internal#scopeList + type : object + } + } ] } } diff --git a/deps/v8/test/inspector/sessions/debugger-stepping-and-breakpoints-expected.txt b/deps/v8/test/inspector/sessions/debugger-stepping-and-breakpoints-expected.txt index 2b7cc167e2..b81fde9f35 100644 --- a/deps/v8/test/inspector/sessions/debugger-stepping-and-breakpoints-expected.txt +++ b/deps/v8/test/inspector/sessions/debugger-stepping-and-breakpoints-expected.txt @@ -20,12 +20,12 @@ Setting breakpoints in 2 Evaluating common breakpoint in 1 Paused in 1: reason: other - hit breakpoints: test.js:11:0 + hit breakpoints: 1:11:0:test.js location: foo@11 data: null Paused in 2: reason: other - hit breakpoints: test.js:11:0 + hit breakpoints: 1:11:0:test.js location: foo@11 data: null Resuming in 1 @@ -48,7 +48,7 @@ Resumed in 2 Evaluating exclusive breakpoint in 1 Paused in 1: reason: other - hit breakpoints: test.js:14:0 + hit breakpoints: 1:14:0:test.js location: baz@14 data: null Paused in 2: @@ -62,12 +62,12 @@ Resumed in 2 Evaluating common breakpoint in 2 Paused in 1: reason: other - hit breakpoints: test.js:11:0 + hit breakpoints: 1:11:0:test.js location: foo@11 data: null Paused in 2: reason: other - hit breakpoints: test.js:11:0 + hit breakpoints: 1:11:0:test.js location: foo@11 data: null Resuming in 2 @@ -90,7 +90,7 @@ Resumed in 2 Evaluating exclusive breakpoint in 2 Paused in 1: reason: other - hit breakpoints: test.js:14:0 + hit breakpoints: 1:14:0:test.js location: baz@14 data: null Paused in 2: @@ -197,7 +197,7 @@ Skipping pauses in 1 Evaluating common breakpoint in 1 Paused in 2: reason: other - hit breakpoints: test.js:11:0 + hit breakpoints: 1:11:0:test.js location: foo@11 data: null Resuming in 2 @@ -210,7 +210,7 @@ Deactivating breakpoints in 1 Evaluating common breakpoint in 1 Paused in 2: reason: other - hit breakpoints: test.js:11:0 + hit breakpoints: 1:11:0:test.js location: foo@11 data: null Resuming in 2 diff --git a/deps/v8/test/inspector/task-runner.cc b/deps/v8/test/inspector/task-runner.cc index 4128a86cff..921317d0c0 100644 --- a/deps/v8/test/inspector/task-runner.cc +++ b/deps/v8/test/inspector/task-runner.cc @@ -78,7 +78,7 @@ void TaskRunner::RunMessageLoop(bool only_protocol) { } void TaskRunner::QuitMessageLoop() { - DCHECK(nested_loop_count_ > 0); + DCHECK_LT(0, nested_loop_count_); --nested_loop_count_; } diff --git a/deps/v8/test/inspector/type-profiler/type-profile-disable-expected.txt b/deps/v8/test/inspector/type-profiler/type-profile-disable-expected.txt new file mode 100644 index 0000000000..b70acbac0e --- /dev/null +++ b/deps/v8/test/inspector/type-profiler/type-profile-disable-expected.txt @@ -0,0 +1,9 @@ +Turn Profiler.startTypeProfile on and off. + +function g(/*Object*/a, /*Array*/b, /*null*/c) { + return 'bye'; +/*string*/}; +g({}, [], null); + +[ +]
\ No newline at end of file diff --git a/deps/v8/test/inspector/type-profiler/type-profile-disable.js b/deps/v8/test/inspector/type-profiler/type-profile-disable.js new file mode 100644 index 0000000000..38a3c6fa9b --- /dev/null +++ b/deps/v8/test/inspector/type-profiler/type-profile-disable.js @@ -0,0 +1,47 @@ +// Copyright 2017 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. + +// Flags: --type-profile + +const source = + ` +function g(a, b, c) { + return 'bye'; +}; +g({}, [], null); +`; + +let {session, contextGroup, Protocol} = InspectorTest.start("Turn " + + "Profiler.startTypeProfile on and off."); + +(async function testTypeProfile() { + Protocol.Runtime.enable(); + let {result: {scriptId}} = await Protocol.Runtime.compileScript({ + expression: source, + sourceURL: arguments.callee.name, persistScript: true + }); + await Protocol.Profiler.enable(); + // Start, run, take. + await Protocol.Profiler.startTypeProfile(); + Protocol.Runtime.runScript({scriptId}); + + let typeProfiles = await Protocol.Profiler.takeTypeProfile(); + session.logTypeProfile(typeProfiles.result.result[0], + source); + + // This should delete all data. + Protocol.Profiler.stopTypeProfile(); + + await Protocol.Profiler.startTypeProfile(); + typeProfiles = await Protocol.Profiler.takeTypeProfile(); + + // Should be empty because no code was run since start. + InspectorTest.logMessage(typeProfiles.result.result); + + Protocol.Profiler.stopTypeProfile(); + + Protocol.Profiler.disable(); + await Protocol.Runtime.disable(); + InspectorTest.completeTest(); +})(); diff --git a/deps/v8/test/inspector/type-profiler/type-profile-expected.txt b/deps/v8/test/inspector/type-profiler/type-profile-expected.txt new file mode 100644 index 0000000000..8001d8278e --- /dev/null +++ b/deps/v8/test/inspector/type-profiler/type-profile-expected.txt @@ -0,0 +1,8 @@ +Test collecting type profile data with Profiler.takeTypeProfile. + +function f(/*Object, number, undefined*/a, /*Array, number, null*/b, /*boolean, Object, symbol*/c) { + return 'bye'; +/*string*/}; +f({}, [], true); +f(3, 2.3, {a: 42}); +f(undefined, null, Symbol('hello'));/*string*/ diff --git a/deps/v8/test/inspector/type-profiler/type-profile-start-stop-expected.txt b/deps/v8/test/inspector/type-profiler/type-profile-start-stop-expected.txt new file mode 100644 index 0000000000..0db7882562 --- /dev/null +++ b/deps/v8/test/inspector/type-profiler/type-profile-start-stop-expected.txt @@ -0,0 +1,49 @@ +Turn Profiler.startTypeProfile on and off. + +Running test: testTypeProfile + +function g(/*Object*/a, /*Array*/b, /*null*/c) { + return 'first'; +/*string*/}; +g({}, [], null); + + +Running test: testTypeProfileFromDifferentSource + +function f(/*null*/a) { + return 'second'; +/*string*/}; +f(null); + + +Running test: testStopTypeProfileDeletesFeedback +[ +] + +Running test: testTypeProfileWithoutStartingItFirst +Type profile has not been started. + +Running test: testTypeProfileAfterStoppingIt +Type profile has not been started. + +Running test: testStartTypeProfileAfterRunning +{ + id : <messageId> + result : { + result : [ + ] + } +} + +Running test: testTypeProfileForTwoSources + +function g(/*Object*/a, /*Array*/b, /*null*/c) { + return 'first'; +/*string*/}; +g({}, [], null); + + +function f(/*null*/a) { + return 'second'; +/*string*/}; +f(null); diff --git a/deps/v8/test/inspector/type-profiler/type-profile-start-stop.js b/deps/v8/test/inspector/type-profiler/type-profile-start-stop.js new file mode 100644 index 0000000000..dad9874ff7 --- /dev/null +++ b/deps/v8/test/inspector/type-profiler/type-profile-start-stop.js @@ -0,0 +1,170 @@ +// Copyright 2017 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. + +// Flags: --type-profile + +const source1 = + ` +function g(a, b, c) { + return 'first'; +}; +g({}, [], null); +`; + +const source2 = + ` +function f(a) { + return 'second'; +}; +f(null); +`; + +let {session, contextGroup, Protocol} = InspectorTest.start("Turn " + + "Profiler.startTypeProfile on and off."); + +InspectorTest.runAsyncTestSuite([ + async function testTypeProfile() { + Protocol.Runtime.enable(); + let {result: {scriptId}} = await Protocol.Runtime.compileScript({ + expression: source1, + sourceURL: arguments.callee.name, persistScript: true + }); + await Protocol.Profiler.enable(); + + // Start, run, take. + await Protocol.Profiler.startTypeProfile(); + Protocol.Runtime.runScript({scriptId}); + + let typeProfiles = await Protocol.Profiler.takeTypeProfile(); + await session.logTypeProfile(typeProfiles.result.result[0], + source1); + + Protocol.Profiler.stopTypeProfile(); + Protocol.Profiler.disable(); + await Protocol.Runtime.disable(); + }, + async function testTypeProfileFromDifferentSource() { + Protocol.Runtime.enable(); + let {result: {scriptId}} = await Protocol.Runtime.compileScript({ + expression: source2, + sourceURL: arguments.callee.name, persistScript: true + }); + await Protocol.Profiler.enable(); + + // Start, run different script, take. + await Protocol.Profiler.startTypeProfile(); + Protocol.Runtime.runScript({scriptId}); + + let typeProfiles = await Protocol.Profiler.takeTypeProfile(); + await session.logTypeProfile(typeProfiles.result.result[0], + source2); + + Protocol.Profiler.stopTypeProfile(); + Protocol.Profiler.disable(); + await Protocol.Runtime.disable(); + }, + async function testStopTypeProfileDeletesFeedback() { + Protocol.Runtime.enable(); + let {result: {scriptId}} = await Protocol.Runtime.compileScript({ + expression: source1, + sourceURL: arguments.callee.name, persistScript: true + }); + await Protocol.Profiler.enable(); + + // Start, run, stop. + await Protocol.Profiler.startTypeProfile(); + Protocol.Runtime.runScript({scriptId}); + await Protocol.Profiler.stopTypeProfile(); + + // Start, take. Should be empty, because no code was run. + await Protocol.Profiler.startTypeProfile(); + let typeProfiles = await Protocol.Profiler.takeTypeProfile(); + InspectorTest.logMessage(typeProfiles.result.result); + await Protocol.Profiler.stopTypeProfile(); + + Protocol.Profiler.disable(); + await Protocol.Runtime.disable(); + }, + async function testTypeProfileWithoutStartingItFirst() { + Protocol.Runtime.enable(); + let {result: {scriptId}} = await Protocol.Runtime.compileScript({ expression: source1, + sourceURL: arguments.callee.name, persistScript: true }); + Protocol.Runtime.runScript({ scriptId }); + await Protocol.Profiler.enable(); + + // This should return an error because type profile was never started. + let typeProfiles = await Protocol.Profiler.takeTypeProfile(); + InspectorTest.logObject(typeProfiles.error.message); + + Protocol.Profiler.disable(); + await Protocol.Runtime.disable(); + }, + async function testTypeProfileAfterStoppingIt() { + Protocol.Runtime.enable(); + let {result: {scriptId}} = await Protocol.Runtime.compileScript({ expression: source1, + sourceURL: arguments.callee.name, persistScript: true }); + Protocol.Runtime.runScript({ scriptId }); + await Protocol.Profiler.enable(); + await Protocol.Profiler.startTypeProfile(); + + // Make sure that this turns off type profile. + await Protocol.Profiler.stopTypeProfile(); + + // This should return an error because type profile was stopped. + let typeProfiles = await Protocol.Profiler.takeTypeProfile(); + InspectorTest.logObject(typeProfiles.error.message); + + Protocol.Profiler.disable(); + await Protocol.Runtime.disable(); + }, + async function testStartTypeProfileAfterRunning() { + Protocol.Runtime.enable(); + let {result: {scriptId}} = await Protocol.Runtime.compileScript({ + expression: source1, + sourceURL: arguments.callee.name, persistScript: true + }); + Protocol.Runtime.runScript({scriptId}); + + await Protocol.Profiler.enable(); + await Protocol.Profiler.startTypeProfile(); + + let typeProfiles = await Protocol.Profiler.takeTypeProfile(); + + // This should be empty because type profile was started after compilation. + // Only the outer script is annotated with return value "string" because + // that does not depend on runScript(). + InspectorTest.logMessage(typeProfiles); + + Protocol.Profiler.stopTypeProfile(); + Protocol.Profiler.disable(); + await Protocol.Runtime.disable(); + }, + async function testTypeProfileForTwoSources() { + Protocol.Runtime.enable(); + let {result: {scriptId: scriptId1}} = await Protocol.Runtime.compileScript({ + expression: source1, + sourceURL: arguments.callee.name, persistScript: true + }); + let {result: {scriptId: scriptId2}} = await Protocol.Runtime.compileScript({ + expression: source2, + sourceURL: arguments.callee.name, persistScript: true + }); + await Protocol.Profiler.enable(); + + // Start, run different script, take. + await Protocol.Profiler.startTypeProfile(); + Protocol.Runtime.runScript({scriptId: scriptId1}); + Protocol.Runtime.runScript({scriptId: scriptId2}); + + let typeProfiles = await Protocol.Profiler.takeTypeProfile(); + await session.logTypeProfile(typeProfiles.result.result[0], + source1); + await session.logTypeProfile(typeProfiles.result.result[1], + source2); + + Protocol.Profiler.stopTypeProfile(); + Protocol.Profiler.disable(); + await Protocol.Runtime.disable(); + } +]); diff --git a/deps/v8/test/inspector/type-profiler/type-profile-with-classes-expected.txt b/deps/v8/test/inspector/type-profiler/type-profile-with-classes-expected.txt new file mode 100644 index 0000000000..3c1cb363d7 --- /dev/null +++ b/deps/v8/test/inspector/type-profiler/type-profile-with-classes-expected.txt @@ -0,0 +1,15 @@ +Test collecting type profile data with Profiler.takeTypeProfile. + +function f(/*number*/n) { +/*undefined*/}; +f(5); +function g(/*Object, number*/a, /*Array, number*/b, /*Flower, Object*/c) { + return 'bye'; +/*string*/}; +/*undefined*/class Tree {}; +/*Flower*/class Flower extends Tree{}; +var f = new Flower(); +f.constructor = {}; +f.constructor.name = "Not a flower."; +g({}, [], f); +g(3, 2.3, {a: 42});/*string*/ diff --git a/deps/v8/test/inspector/type-profiler/type-profile-with-classes.js b/deps/v8/test/inspector/type-profiler/type-profile-with-classes.js new file mode 100644 index 0000000000..b697ebfd3f --- /dev/null +++ b/deps/v8/test/inspector/type-profiler/type-profile-with-classes.js @@ -0,0 +1,43 @@ +// Copyright 2017 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. + +// Flags: --type-profile + +const source = + ` +function f(n) { +}; +f(5); +function g(a, b, c) { + return 'bye'; +}; +class Tree {}; +class Flower extends Tree{}; +var f = new Flower(); +f.constructor = {}; +f.constructor.name = "Not a flower."; +g({}, [], f); +g(3, 2.3, {a: 42}); +`; + +let {session, contextGroup, Protocol} = InspectorTest.start("Test collecting type profile data with Profiler.takeTypeProfile."); + +(async function testTypeProfile(next) { + await Protocol.Profiler.enable(); + await Protocol.Profiler.startTypeProfile(); + + Protocol.Runtime.enable(); + let {result: {scriptId}} = await Protocol.Runtime.compileScript({ expression: source, + sourceURL: arguments.callee.name, persistScript: true }); + + Protocol.Runtime.runScript({ scriptId }); + + let typeProfiles = await Protocol.Profiler.takeTypeProfile(); + await session.logTypeProfile(typeProfiles.result.result[0], + source); + + Protocol.Profiler.disable(); + await Protocol.Runtime.disable(); + InspectorTest.completeTest(); +})(); diff --git a/deps/v8/test/inspector/type-profiler/type-profile-with-to-string-tag-expected.txt b/deps/v8/test/inspector/type-profiler/type-profile-with-to-string-tag-expected.txt new file mode 100644 index 0000000000..fdba16517e --- /dev/null +++ b/deps/v8/test/inspector/type-profiler/type-profile-with-to-string-tag-expected.txt @@ -0,0 +1,16 @@ +Test collecting type profile data with Profiler.takeTypeProfile. + +function g(/*Object, number*/a, /*Array, number*/b, /*Dog, Object*/c) { + return 'bye'; +/*string*/}; +/*undefined*/class Tree {}; +/*Flower*/class Flower extends Tree{}; +var f = new Flower(); +// We store the type when a variable is used. If a toStringTag is +// changes the type, we want to collect that changed feedback. +// This tests ensures that we collect that information rather than +// for example infer the types from the internal map, which wouldn't +// know about a toStringTag. +f[Symbol.toStringTag] = 'Dog'; +g({}, [], f); +g(3, 2.3, {a: 42});/*string*/ diff --git a/deps/v8/test/inspector/type-profiler/type-profile-with-to-string-tag.js b/deps/v8/test/inspector/type-profiler/type-profile-with-to-string-tag.js new file mode 100644 index 0000000000..654f18afc5 --- /dev/null +++ b/deps/v8/test/inspector/type-profiler/type-profile-with-to-string-tag.js @@ -0,0 +1,46 @@ +// Copyright 2017 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. + +// Flags: --type-profile + +const source = + ` +function g(a, b, c) { + return 'bye'; +}; +class Tree {}; +class Flower extends Tree{}; +var f = new Flower(); +// We store the type when a variable is used. If a toStringTag is +// changes the type, we want to collect that changed feedback. +// This tests ensures that we collect that information rather than +// for example infer the types from the internal map, which wouldn't +// know about a toStringTag. +f[Symbol.toStringTag] = 'Dog'; +g({}, [], f); +g(3, 2.3, {a: 42}); +`; + +let {session, contextGroup, Protocol} = InspectorTest.start("Test collecting " + + "type profile data with Profiler.takeTypeProfile."); + +(async function testTypeProfile() { + await Protocol.Profiler.enable(); + await Protocol.Profiler.startTypeProfile(); + + Protocol.Runtime.enable(); + let {result: {scriptId}} = await Protocol.Runtime.compileScript({ expression: source, + sourceURL: arguments.callee.name, persistScript: true }); + Protocol.Runtime.runScript({ scriptId }); + await Protocol.Profiler.startTypeProfile(); + + let typeProfiles = await Protocol.Profiler.takeTypeProfile(); + await session.logTypeProfile(typeProfiles.result.result[0], + source); + + Protocol.Profiler.stopTypeProfile(); + Protocol.Profiler.disable(); + await Protocol.Runtime.disable(); + InspectorTest.completeTest(); +})(); diff --git a/deps/v8/test/inspector/type-profiler/type-profile.js b/deps/v8/test/inspector/type-profiler/type-profile.js new file mode 100644 index 0000000000..e912a4b940 --- /dev/null +++ b/deps/v8/test/inspector/type-profiler/type-profile.js @@ -0,0 +1,39 @@ +// Copyright 2017 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. + +// Flags: --type-profile + +const source = + ` +function f(a, b, c) { + return 'bye'; +}; +f({}, [], true); +f(3, 2.3, {a: 42}); +f(undefined, null, Symbol('hello')); +`; + +let {session, contextGroup, Protocol} = InspectorTest.start("Test collecting type profile data with Profiler.takeTypeProfile."); + +(async function testTypeProfile() { + await Protocol.Profiler.enable(); + await Protocol.Profiler.startTypeProfile(); + + Protocol.Runtime.enable(); + let {result: {scriptId}} = await Protocol.Runtime.compileScript({ + expression: source, + sourceURL: arguments.callee.name, + persistScript: true + }); + Protocol.Runtime.runScript({ scriptId }); + + let typeProfiles = await Protocol.Profiler.takeTypeProfile(); + await session.logTypeProfile(typeProfiles.result.result[0], + source); + + Protocol.Profiler.stoptTypeProfile(); + Protocol.Profiler.disable(); + await Protocol.Runtime.disable(); + InspectorTest.completeTest(); +})(); diff --git a/deps/v8/test/js-perf-test/Array/filter.js b/deps/v8/test/js-perf-test/Array/filter.js index ccaef0e5c9..94ba2651ec 100644 --- a/deps/v8/test/js-perf-test/Array/filter.js +++ b/deps/v8/test/js-perf-test/Array/filter.js @@ -13,7 +13,7 @@ benchy('NaiveFilterReplacement', NaiveFilter, NaiveFilterSetup); benchy('DoubleFilter', DoubleFilter, DoubleFilterSetup); benchy('SmiFilter', SmiFilter, SmiFilterSetup); benchy('FastFilter', FastFilter, FastFilterSetup); -benchy('ObjectFilter', GenericFilter, ObjectFilterSetup); +benchy('GenericFilter', GenericFilter, ObjectFilterSetup); benchy('OptFastFilter', OptFastFilter, FastFilterSetup); var array; diff --git a/deps/v8/test/js-perf-test/Array/join.js b/deps/v8/test/js-perf-test/Array/join.js index 59eaa24285..7330ae0459 100644 --- a/deps/v8/test/js-perf-test/Array/join.js +++ b/deps/v8/test/js-perf-test/Array/join.js @@ -10,7 +10,7 @@ function benchy(name, test, testSetup) { } benchy('SmiJoin', SmiJoin, SmiJoinSetup); -benchy('SmiJoin', SmiJoin, SmiJoinSetup); +benchy('StringJoin', StringJoin, StringJoinSetup); benchy('SparseSmiJoin', SparseSmiJoin, SparseSmiJoinSetup); benchy('SparseStringJoin', SparseStringJoin, SparseStringJoinSetup); diff --git a/deps/v8/test/js-perf-test/Array/map.js b/deps/v8/test/js-perf-test/Array/map.js index 33cd79af59..f4ab95b065 100644 --- a/deps/v8/test/js-perf-test/Array/map.js +++ b/deps/v8/test/js-perf-test/Array/map.js @@ -15,7 +15,7 @@ benchy('SmallSmiToDoubleMap', SmiMap, SmiToDoubleMapSetup); benchy('SmallSmiToFastMap', SmiMap, SmiToFastMapSetup); benchy('SmiMap', SmiMap, SmiMapSetup); benchy('FastMap', FastMap, FastMapSetup); -benchy('ObjectMap', GenericMap, ObjectMapSetup); +benchy('GenericMap', GenericMap, ObjectMapSetup); benchy('OptFastMap', OptFastMap, FastMapSetup); var array; diff --git a/deps/v8/test/js-perf-test/Array/to-string.js b/deps/v8/test/js-perf-test/Array/to-string.js index 6bfb661a36..c6a66d726b 100644 --- a/deps/v8/test/js-perf-test/Array/to-string.js +++ b/deps/v8/test/js-perf-test/Array/to-string.js @@ -10,7 +10,7 @@ function benchy(name, test, testSetup) { } benchy('SmiToString', SmiToString, SmiToStringSetup); -benchy('SmiToString', SmiToString, SmiToStringSetup); +benchy('StringToString', StringToString, StringToStringSetup); benchy('SparseSmiToString', SparseSmiToString, SparseSmiToStringSetup); benchy('SparseStringToString', SparseStringToString, SparseStringToStringSetup); diff --git a/deps/v8/test/js-perf-test/JSTests.json b/deps/v8/test/js-perf-test/JSTests.json index 04aade4f45..420421099a 100644 --- a/deps/v8/test/js-perf-test/JSTests.json +++ b/deps/v8/test/js-perf-test/JSTests.json @@ -30,7 +30,8 @@ {"name": "SetIndexWithoutTrap"}, {"name": "SetIndexWithTrap"}, {"name": "SetSymbolWithoutTrap"}, - {"name": "SetSymbolWithTrap"} + {"name": "SetSymbolWithTrap"}, + {"name": "HasInIdiom"} ] }, { @@ -385,42 +386,38 @@ {"name": "DoubleFilter"}, {"name": "SmiFilter"}, {"name": "FastFilter"}, - {"name": "ObjectFilter"}, + {"name": "GenericFilter"}, {"name": "OptFastFilter"}, {"name": "NaiveMapReplacement"}, {"name": "DoubleMap"}, {"name": "SmiMap"}, {"name": "FastMap"}, - {"name": "ObjectMap"}, - {"name": "OptFastMap"}, + {"name": "GenericMap"}, + {"name": "OptFastMap"}, {"name": "DoubleEvery"}, {"name": "SmiEvery"}, {"name": "FastEvery"}, - {"name": "ObjectEvery"}, - {"name": "OptFastEvery"}, - {"name": "SmiJoin"}, - {"name": "StringJoin"}, - {"name": "SparseSmiJoin"}, - {"name": "SparseStringJoin"}, + {"name": "OptFastEvery"}, + {"name": "SmiJoin"}, + {"name": "StringJoin"}, + {"name": "SparseSmiJoin"}, + {"name": "SparseStringJoin"}, {"name": "DoubleSome"}, {"name": "SmiSome"}, {"name": "FastSome"}, - {"name": "ObjectSome"}, - {"name": "OptFastSome"}, + {"name": "OptFastSome"}, {"name": "DoubleReduce"}, {"name": "SmiReduce"}, {"name": "FastReduce"}, - {"name": "ObjectReduce"}, - {"name": "OptFastReduce"}, + {"name": "OptFastReduce"}, {"name": "DoubleReduceRight"}, {"name": "SmiReduceRight"}, {"name": "FastReduceRight"}, - {"name": "ObjectReduceRight"}, - {"name": "OptFastReduceRight"}, - {"name": "SmiToString"}, - {"name": "StringToString"}, - {"name": "SparseSmiToString"}, - {"name": "SparseStringToString"} + {"name": "OptFastReduceRight"}, + {"name": "SmiToString"}, + {"name": "StringToString"}, + {"name": "SparseSmiToString"}, + {"name": "SparseStringToString"} ] }, { @@ -612,6 +609,19 @@ {"name": "Runtime.evaluate(String16Cstor)"}, {"name": "Debugger.getPossibleBreakpoints"} ] + }, + { + "name": "Parsing", + "path": ["Parsing"], + "main": "run.js", + "flags": ["--no-compilation-cache", "--allow-natives-syntax"], + "resources": [ "comments.js"], + "results_regexp": "^%s\\-Parsing\\(Score\\): (.+)$", + "tests": [ + {"name": "OneLineComment"}, + {"name": "OneLineComments"}, + {"name": "MultiLineComment"} + ] } ] } diff --git a/deps/v8/test/js-perf-test/Parsing/comments.js b/deps/v8/test/js-perf-test/Parsing/comments.js new file mode 100644 index 0000000000..e5dbab1c75 --- /dev/null +++ b/deps/v8/test/js-perf-test/Parsing/comments.js @@ -0,0 +1,41 @@ +// Copyright 2017 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. + +const iterations = 100; + +new BenchmarkSuite('OneLineComment', [1000], [ + new Benchmark('OneLineComment', false, true, iterations, Run, OneLineCommentSetup) +]); + +new BenchmarkSuite('OneLineComments', [1000], [ + new Benchmark('OneLineComments', false, true, iterations, Run, OneLineCommentsSetup) +]); + +new BenchmarkSuite('MultiLineComment', [1000], [ + new Benchmark('MultiLineComment', false, true, iterations, Run, MultiLineCommentSetup) +]); + +let code; + +function OneLineCommentSetup() { + code = "//" + " This is a comment... ".repeat(600); + %FlattenString(code); +} + +function OneLineCommentsSetup() { + code = "// This is a comment.\n".repeat(600); + %FlattenString(code); +} + +function MultiLineCommentSetup() { + code = "/*" + " This is a comment... ".repeat(600) + "*/"; + %FlattenString(code); +} + +function Run() { + if (code == undefined) { + throw new Error("No test data"); + } + eval(code); +} diff --git a/deps/v8/test/js-perf-test/Parsing/run.js b/deps/v8/test/js-perf-test/Parsing/run.js new file mode 100644 index 0000000000..e6531af5bb --- /dev/null +++ b/deps/v8/test/js-perf-test/Parsing/run.js @@ -0,0 +1,27 @@ +// Copyright 2017 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. + + +load('../base.js'); + +load('comments.js'); + +var success = true; + +function PrintResult(name, result) { + print(name + '-Parsing(Score): ' + result); +} + + +function PrintError(name, error) { + PrintResult(name, error); + success = false; +} + + +BenchmarkSuite.config.doWarmup = undefined; +BenchmarkSuite.config.doDeterministic = undefined; + +BenchmarkSuite.RunSuites({ NotifyResult: PrintResult, + NotifyError: PrintError }); diff --git a/deps/v8/test/js-perf-test/Proxies/proxies.js b/deps/v8/test/js-perf-test/Proxies/proxies.js index 6bb56bd97d..79d064e931 100644 --- a/deps/v8/test/js-perf-test/Proxies/proxies.js +++ b/deps/v8/test/js-perf-test/Proxies/proxies.js @@ -463,3 +463,43 @@ newBenchmark("SetSymbolWithTrap", { return value === SOME_OTHER_NUMBER; } }); + +// ---------------------------------------------------------------------------- + +var obj20prop = {}; +var measured; + +newBenchmark("HasInIdiom", { + setup() { + for (var i = 0; i < 20; ++i) { + obj20prop['prop' + i] = SOME_NUMBER; + } + p = new Proxy(obj20prop, { + has: function(target, propertyKey) { + return true; + }, + get: function(target, propertyKey, receiver) { + if (typeof propertyKey == 'string' && propertyKey.match('prop')) + return SOME_NUMBER; + else + return Reflect.get(target, propertyKey, receiver); + }, + }); + measured = function measured(o) { + var result = 0; + for (var x in o) { + if (Object.prototype.hasOwnProperty(o, x)) { + var v = o[x]; + result += v; + } + } + return result; + } + }, + run() { + result = measured(p); + }, + teardown() { + return result === 20 * SOME_NUMBER; + } +}); diff --git a/deps/v8/test/memory/Memory.json b/deps/v8/test/memory/Memory.json index c6b8cd50a2..a3c8dbc0d5 100644 --- a/deps/v8/test/memory/Memory.json +++ b/deps/v8/test/memory/Memory.json @@ -19,6 +19,10 @@ "results_regexp": "(\\d+) bytes for startup$" }, { + "name": "SnapshotSizeBuiltins", + "results_regexp": "(\\d+) bytes for builtins$" + }, + { "name": "SnapshotSizeContext", "results_regexp": "(\\d+) bytes for context #0$" } diff --git a/deps/v8/test/message/regress/regress-crbug-691194.out b/deps/v8/test/message/regress/regress-crbug-691194.out index 6d7db0f535..43453900db 100644 --- a/deps/v8/test/message/regress/regress-crbug-691194.out +++ b/deps/v8/test/message/regress/regress-crbug-691194.out @@ -6,5 +6,5 @@ "foo".repeat(1 << 30) ^ RangeError: Invalid string length - at String.repeat (native) + at String.repeat (<anonymous>) at *%(basename)s:5:7 diff --git a/deps/v8/test/message/settimeout.js b/deps/v8/test/message/settimeout.js new file mode 100644 index 0000000000..59ed1c6517 --- /dev/null +++ b/deps/v8/test/message/settimeout.js @@ -0,0 +1,26 @@ +// Copyright 2017 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. + +// Flags: --no-stress-opt + +var state = 0; +function inc() { + console.log("increment state"); + state++; +} + +function repeat() { + console.log("current state: " + state); + if (state < 3) { + setTimeout(inc, 0); + setTimeout(repeat, 0); + } else { + setTimeout(function() { throw new Error(); }); + } +} + +setTimeout(inc, 0); +console.log("state: " + state); +setTimeout(repeat, 0); +console.log("state: " + state); diff --git a/deps/v8/test/message/settimeout.out b/deps/v8/test/message/settimeout.out new file mode 100644 index 0000000000..7951436fdf --- /dev/null +++ b/deps/v8/test/message/settimeout.out @@ -0,0 +1,13 @@ +state: 0 +state: 0 +increment state +current state: 1 +increment state +current state: 2 +increment state +current state: 3 +*%(basename)s:19: Error + setTimeout(function() { throw new Error(); }); + ^ +Error + at *%(basename)s:19:35 diff --git a/deps/v8/test/message/typedarray.out b/deps/v8/test/message/typedarray.out index 038e49d52c..908dd7fa5e 100644 --- a/deps/v8/test/message/typedarray.out +++ b/deps/v8/test/message/typedarray.out @@ -1,9 +1,9 @@ # Copyright 2017 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. -*%(basename)s:6: RangeError: Start offset is negative +*%(basename)s:6: RangeError: offset is out of bounds a.set([2], -1); ^ -RangeError: Start offset is negative - at Uint8Array.set (native) +RangeError: offset is out of bounds + at Uint8Array.set (<anonymous>) at *%(basename)s:6:3
\ No newline at end of file diff --git a/deps/v8/test/message/wasm-trace-memory-interpreted.js b/deps/v8/test/message/wasm-trace-memory-interpreted.js new file mode 100644 index 0000000000..75f42e82e6 --- /dev/null +++ b/deps/v8/test/message/wasm-trace-memory-interpreted.js @@ -0,0 +1,7 @@ +// Copyright 2017 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. + +// Flags: --no-stress-opt --expose-wasm --wasm-trace-memory --wasm-interpret-all + +load("test/message/wasm-trace-memory.js"); diff --git a/deps/v8/test/message/wasm-trace-memory-interpreted.out b/deps/v8/test/message/wasm-trace-memory-interpreted.out new file mode 100644 index 0000000000..6854727885 --- /dev/null +++ b/deps/v8/test/message/wasm-trace-memory-interpreted.out @@ -0,0 +1,9 @@ +I 0+0x3 read @00000004 i32:0 / 00000000 +I 1+0x3 read @00000001 i8:0 / 00 +I 3+0x5 store @00000004 i32:305419896 / 12345678 +I 0+0x3 read @00000002 i32:1450704896 / 56780000 +I 1+0x3 read @00000006 i8:52 / 34 +I 2+0x3 read @00000002 f32:68169720922112.000000 / 56780000 +I 4+0x5 store @00000004 i8:171 / ab +I 0+0x3 read @00000002 i32:1454047232 / 56ab0000 +I 2+0x3 read @00000002 f32:94008244174848.000000 / 56ab0000 diff --git a/deps/v8/test/message/wasm-trace-memory.js b/deps/v8/test/message/wasm-trace-memory.js new file mode 100644 index 0000000000..6c33b900b1 --- /dev/null +++ b/deps/v8/test/message/wasm-trace-memory.js @@ -0,0 +1,37 @@ +// Copyright 2017 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. + +// Flags: --no-stress-opt --expose-wasm --wasm-trace-memory + +load("test/mjsunit/wasm/wasm-constants.js"); +load("test/mjsunit/wasm/wasm-module-builder.js"); + +var builder = new WasmModuleBuilder(); +builder.addMemory(1); +builder.addFunction('load', kSig_v_i) + .addBody([kExprGetLocal, 0, kExprI32LoadMem, 0, 0, kExprDrop]) + .exportFunc(); +builder.addFunction('load8', kSig_v_i) + .addBody([kExprGetLocal, 0, kExprI32LoadMem8U, 0, 0, kExprDrop]) + .exportFunc(); +builder.addFunction('loadf', kSig_v_i) + .addBody([kExprGetLocal, 0, kExprF32LoadMem, 0, 0, kExprDrop]) + .exportFunc(); +builder.addFunction('store', kSig_v_ii) + .addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprI32StoreMem, 0, 0]) + .exportFunc(); +builder.addFunction('store8', kSig_v_ii) + .addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprI32StoreMem8, 0, 0]) + .exportFunc(); +var module = builder.instantiate(); + +module.exports.load(4); +module.exports.load8(1); +module.exports.store(4, 0x12345678); +module.exports.load(2); +module.exports.load8(6); +module.exports.loadf(2); +module.exports.store8(4, 0xab); +module.exports.load(2); +module.exports.loadf(2); diff --git a/deps/v8/test/message/wasm-trace-memory.out b/deps/v8/test/message/wasm-trace-memory.out new file mode 100644 index 0000000000..12cbd180a0 --- /dev/null +++ b/deps/v8/test/message/wasm-trace-memory.out @@ -0,0 +1,9 @@ +C 0+0x3 read @00000004 i32:0 / 00000000 +C 1+0x3 read @00000001 i8:0 / 00 +C 3+0x5 store @00000004 i32:305419896 / 12345678 +C 0+0x3 read @00000002 i32:1450704896 / 56780000 +C 1+0x3 read @00000006 i8:52 / 34 +C 2+0x3 read @00000002 f32:68169720922112.000000 / 56780000 +C 4+0x5 store @00000004 i8:171 / ab +C 0+0x3 read @00000002 i32:1454047232 / 56ab0000 +C 2+0x3 read @00000002 f32:94008244174848.000000 / 56ab0000 diff --git a/deps/v8/test/mjsunit/array-constructor-feedback.js b/deps/v8/test/mjsunit/array-constructor-feedback.js index c1f386d983..fb4ad5a19a 100644 --- a/deps/v8/test/mjsunit/array-constructor-feedback.js +++ b/deps/v8/test/mjsunit/array-constructor-feedback.js @@ -106,14 +106,9 @@ function assertKind(expected, obj, name_opt) { a = bar(10); assertKind(elements_kind.fast, a); assertOptimized(bar); - bar(100000); + bar(10000); assertOptimized(bar); - // If the argument isn't a smi, things should still work. - a = bar("oops"); - assertOptimized(bar); - assertKind(elements_kind.fast, a); - function barn(one, two, three) { return new Array(one, two, three); } diff --git a/deps/v8/test/mjsunit/array-reduce.js b/deps/v8/test/mjsunit/array-reduce.js index f34d3ef6ff..4a4494a72c 100644 --- a/deps/v8/test/mjsunit/array-reduce.js +++ b/deps/v8/test/mjsunit/array-reduce.js @@ -537,3 +537,23 @@ var arr = []; Object.defineProperty(arr, "0", { get: function() { delete this[0] }, configurable: true}); assertEquals(undefined, arr.reduceRight(function(val) { return val })); + + +(function ReduceRightMaxIndex() { + const kMaxIndex = 0xffffffff-1; + let array = []; + array[kMaxIndex-2] = 'value-2'; + array[kMaxIndex-1] = 'value-1'; + // Use the maximum array index possible. + array[kMaxIndex] = 'value'; + // Add the next index which is a normal property and thus will not show up. + array[kMaxIndex+1] = 'normal property'; + assertThrowsEquals( () => { + array.reduceRight((sum, value) => { + assertEquals('initial', sum); + assertEquals('value', value); + // Throw at this point as we would very slowly loop down from kMaxIndex. + throw 'do not continue'; + }, 'initial') + }, 'do not continue'); +})(); diff --git a/deps/v8/test/mjsunit/asm/math-max.js b/deps/v8/test/mjsunit/asm/math-max.js new file mode 100644 index 0000000000..d5dc0d1617 --- /dev/null +++ b/deps/v8/test/mjsunit/asm/math-max.js @@ -0,0 +1,78 @@ +// Copyright 2017 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. + +function Module(stdlib) { + "use asm"; + + var max = stdlib.Math.max; + var fround = stdlib.Math.fround; + + // f: double, double -> double + function f(a, b) { + a = +a; b = +b; + return +max(a, b); + } + + // g: signed, signed -> signed + function g(a, b) { + a = a | 0; b = b | 0; + return max(a >> 0, b >> 0) | 0; + } + + // h: float, float -> float + function h(a, b) { + a = fround(a); b = fround(b); + return fround(max(a, b)); + } + + return { f: f, g: g, h: h }; +} + +var m = Module({ Math: Math }); +var f = m.f; +var g = m.g; +var h = m.h; + +assertTrue(isNaN(f(0, NaN))); +assertFalse(isFinite(f(0, Infinity))); +assertTrue(isFinite(f(0, -Infinity))); + +assertTrue(Object.is(+0, f(-0, +0))); +assertTrue(Object.is(+0, f(+0, -0))); + +assertEquals(0.1, f( 0, 0.1)); +assertEquals(0.5, f( 0.1, 0.5)); +assertEquals(0.5, f( 0.5, -0.1)); +assertEquals(-0.1, f(-0.1, -0.5)); +assertEquals(1, f(-0.5, 1)); +assertEquals(1.1, f( 1, 1.1)); +assertEquals(1.1, f( 1.1, -1)); +assertEquals(-1, f(-1, -1.1)); +assertEquals(0, f(-1.1, 0)); + +assertEquals( 1, g( 0, 1)); +assertEquals( 5, g( 1, 5)); +assertEquals( 5, g( 5, -1)); +assertEquals(-1, g(-1, -5)); +assertEquals( 1, g(-5, 1)); +assertEquals( 1, g( 1, -1)); +assertEquals( 0, g(-1, 0)); + +assertEquals(Math.fround(0.1), h( 0, 0.1)); +assertEquals(Math.fround(0.5), h( 0.1, 0.5)); +assertEquals(Math.fround(0.5), h( 0.5, -0.1)); +assertEquals(Math.fround(-0.1), h(-0.1, -0.5)); +assertEquals(Math.fround(1), h(-0.5, 1)); +assertEquals(Math.fround(1.1), h( 1, 1.1)); +assertEquals(Math.fround(1.1), h( 1.1, -1)); +assertEquals(Math.fround(-1), h(-1, -1.1)); +assertEquals(Math.fround(0), h(-1.1, 0)); + +assertEquals(1, g(0, Number.MIN_SAFE_INTEGER)); +assertEquals(0, g(0, Number.MAX_SAFE_INTEGER)); + +assertEquals(Number.MAX_VALUE, f(Number.MIN_VALUE, Number.MAX_VALUE)); +assertEquals(Number.MAX_VALUE, f(Number.MAX_VALUE, Number.MIN_VALUE)); +assertEquals(Number.POSITIVE_INFINITY, f(Number.POSITIVE_INFINITY, 0)); +assertEquals(0, f(Number.NEGATIVE_INFINITY, 0)); diff --git a/deps/v8/test/mjsunit/asm/math-min.js b/deps/v8/test/mjsunit/asm/math-min.js new file mode 100644 index 0000000000..5923d267d0 --- /dev/null +++ b/deps/v8/test/mjsunit/asm/math-min.js @@ -0,0 +1,78 @@ +// Copyright 2017 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. + +function Module(stdlib) { + "use asm"; + + var min = stdlib.Math.min; + var fround = stdlib.Math.fround; + + // f: double, double -> double + function f(a, b) { + a = +a; b = +b; + return +min(a, b); + } + + // g: signed, signed -> signed + function g(a, b) { + a = a | 0; b = b | 0; + return min(a >> 0, b >> 0) | 0; + } + + // h: float, float -> float + function h(a, b) { + a = fround(a); b = fround(b); + return fround(min(a, b)); + } + + return { f: f, g: g, h: h }; +} + +var m = Module({ Math: Math }); +var f = m.f; +var g = m.g; +var h = m.h; + +assertTrue(isNaN(f(0, NaN))); +assertTrue(isFinite(f(0, Infinity))); +assertFalse(isFinite(f(0, -Infinity))); + +assertTrue(Object.is(-0, f(-0, +0))); +assertTrue(Object.is(-0, f(+0, -0))); + +assertEquals(0, f( 0, 0.1)); +assertEquals(0.1, f( 0.1, 0.5)); +assertEquals(-0.1, f( 0.5, -0.1)); +assertEquals(-0.5, f(-0.1, -0.5)); +assertEquals(-0.5, f(-0.5, 1)); +assertEquals(1, f( 1, 1.1)); +assertEquals(-1, f( 1.1, -1)); +assertEquals(-1.1, f(-1, -1.1)); +assertEquals(-1.1, f(-1.1, 0)); + +assertEquals( 0, g( 0, 1)); +assertEquals( 1, g( 1, 5)); +assertEquals(-1, g( 5, -1)); +assertEquals(-5, g(-1, -5)); +assertEquals(-5, g(-5, 1)); +assertEquals(-1, g( 1, -1)); +assertEquals(-1, g(-1, 0)); + +assertEquals(Math.fround(0), h( 0, 0.1)); +assertEquals(Math.fround(0.1), h( 0.1, 0.5)); +assertEquals(Math.fround(-0.1), h( 0.5, -0.1)); +assertEquals(Math.fround(-0.5), h(-0.1, -0.5)); +assertEquals(Math.fround(-0.5), h(-0.5, 1)); +assertEquals(Math.fround(1), h( 1, 1.1)); +assertEquals(Math.fround(-1), h( 1.1, -1)); +assertEquals(Math.fround(-1.1), h(-1, -1.1)); +assertEquals(Math.fround(-1.1), h(-1.1, 0)); + +assertEquals(0, g(0, Number.MIN_SAFE_INTEGER)); +assertEquals(-1, g(0, Number.MAX_SAFE_INTEGER)); + +assertEquals(Number.MIN_VALUE, f(Number.MIN_VALUE, Number.MAX_VALUE)); +assertEquals(Number.MIN_VALUE, f(Number.MAX_VALUE, Number.MIN_VALUE)); +assertEquals(0, f(Number.POSITIVE_INFINITY, 0)); +assertEquals(Number.NEGATIVE_INFINITY, f(Number.NEGATIVE_INFINITY, 0)); diff --git a/deps/v8/test/mjsunit/asm/noexpose-wasm.js b/deps/v8/test/mjsunit/asm/noexpose-wasm.js new file mode 100644 index 0000000000..7336ab2727 --- /dev/null +++ b/deps/v8/test/mjsunit/asm/noexpose-wasm.js @@ -0,0 +1,37 @@ +// Copyright 2017 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. + +// Flags: --noexpose-wasm --validate-asm + +assertThrows(() => { let x = WebAssembly.Module; }); + +function Module(stdlib, foreign, heap) { + "use asm"; + function f1(i) { + i = i|0; + return (i | 0) / 3 | 0; + } + function f2(i) { + i = i|0; + return (i | 0) / 13 | 0; + } + function f3(i) { + i = i|0; + return (i | 0) / 1024 | 0; + } + function f4(i) { + i = i|0; + return (i | 0) / 3733331 | 0; + } + return { f1: f1, f2: f2, f3: f3, f4: f4 }; +} + +var m = Module(this, {}, new ArrayBuffer(1024)); + +for (var i = -2147483648; i < 2147483648; i += 3999777) { + assertEquals(i / 3 | 0, m.f1(i)); + assertEquals(i / 13 | 0, m.f2(i)); + assertEquals(i / 1024 | 0, m.f3(i)); + assertEquals(i / 3733331 | 0, m.f4(i)); +} diff --git a/deps/v8/test/mjsunit/code-coverage-precise.js b/deps/v8/test/mjsunit/code-coverage-precise.js index 3d5d5bac9e..c5569cf010 100644 --- a/deps/v8/test/mjsunit/code-coverage-precise.js +++ b/deps/v8/test/mjsunit/code-coverage-precise.js @@ -3,6 +3,7 @@ // found in the LICENSE file. // Flags: --allow-natives-syntax --no-always-opt +// Flags: --no-stress-incremental-marking // Files: test/mjsunit/code-coverage-utils.js // Test precise code coverage. diff --git a/deps/v8/test/mjsunit/compiler/array-push-1.js b/deps/v8/test/mjsunit/compiler/array-push-1.js new file mode 100644 index 0000000000..58afd6ffe6 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/array-push-1.js @@ -0,0 +1,239 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax --opt + +// Test multiple arguments push for PACKED_SMI_ELEMENTS. +(function() { + function push0(a) { + return a.push(); + } + + assertEquals(0, push0([])); + assertEquals(1, push0([1])); + %OptimizeFunctionOnNextCall(push0); + assertEquals(2, push0([1, 2])); + + function push1(a) { + return a.push(1); + } + + assertEquals(1, push1([])); + assertEquals(2, push1([1])); + %OptimizeFunctionOnNextCall(push1); + assertEquals(3, push1([1, 2])); + + function push2(a) { + return a.push(1, 2); + } + + assertEquals(2, push2([])); + assertEquals(3, push2([1])); + %OptimizeFunctionOnNextCall(push2); + assertEquals(4, push2([1, 2])); + + function push3(a) { + return a.push(1, 2, 3); + } + + assertEquals(3, push3([])); + assertEquals(4, push3([1])); + %OptimizeFunctionOnNextCall(push3); + assertEquals(5, push3([1, 2])); +})(); + +// Test multiple arguments push for HOLEY_SMI_ELEMENTS. +(function() { + function push0(a) { + return a.push(); + } + + assertEquals(1, push0(new Array(1))); + assertEquals(2, push0(new Array(2))); + %OptimizeFunctionOnNextCall(push0); + assertEquals(3, push0(new Array(3))); + + function push1(a) { + return a.push(1); + } + + assertEquals(2, push1(new Array(1))); + assertEquals(3, push1(new Array(2))); + %OptimizeFunctionOnNextCall(push1); + assertEquals(4, push1(new Array(3))); + + function push2(a) { + return a.push(1, 2); + } + + assertEquals(3, push2(new Array(1))); + assertEquals(4, push2(new Array(2))); + %OptimizeFunctionOnNextCall(push2); + assertEquals(5, push2(new Array(3))); + + function push3(a) { + return a.push(1, 2, 3); + } + + assertEquals(4, push3(new Array(1))); + assertEquals(5, push3(new Array(2))); + %OptimizeFunctionOnNextCall(push3); + assertEquals(6, push3(new Array(3))); +})(); + +// Test multiple arguments push for PACKED_DOUBLE_ELEMENTS. +(function() { + function push0(a) { + return a.push(); + } + + assertEquals(1, push0([1.1])); + assertEquals(2, push0([1.1, 2.2])); + %OptimizeFunctionOnNextCall(push0); + assertEquals(3, push0([1.1, 2.2, 3.3])); + + function push1(a) { + return a.push(1.1); + } + + assertEquals(2, push1([1.1])); + assertEquals(3, push1([1.1, 2.2])); + %OptimizeFunctionOnNextCall(push1); + assertEquals(4, push1([1.1, 2.2, 3.3])); + + function push2(a) { + return a.push(1.1, 2.2); + } + + assertEquals(3, push2([1.1])); + assertEquals(4, push2([1.1, 2.2])); + %OptimizeFunctionOnNextCall(push2); + assertEquals(5, push2([1.1, 2.2, 3.3])); + + function push3(a) { + return a.push(1.1, 2.2, 3.3); + } + + assertEquals(4, push3([1.1])); + assertEquals(5, push3([1.1, 2.2])); + %OptimizeFunctionOnNextCall(push3); + assertEquals(6, push3([1.1, 2.2, 3.3])); +})(); + +// Test multiple arguments push for HOLEY_DOUBLE_ELEMENTS. +(function() { + function push0(a) { + return a.push(); + } + + assertEquals(2, push0([, 1.1])); + assertEquals(3, push0([, 1.1, 2.2])); + %OptimizeFunctionOnNextCall(push0); + assertEquals(4, push0([, 1.1, 2.2, 3.3])); + + function push1(a) { + return a.push(1.1); + } + + assertEquals(3, push1([, 1.1])); + assertEquals(4, push1([, 1.1, 2.2])); + %OptimizeFunctionOnNextCall(push1); + assertEquals(5, push1([, 1.1, 2.2, 3.3])); + + function push2(a) { + return a.push(1.1, 2.2); + } + + assertEquals(4, push2([, 1.1])); + assertEquals(5, push2([, 1.1, 2.2])); + %OptimizeFunctionOnNextCall(push2); + assertEquals(6, push2([, 1.1, 2.2, 3.3])); + + function push3(a) { + return a.push(1.1, 2.2, 3.3); + } + + assertEquals(5, push3([, 1.1])); + assertEquals(6, push3([, 1.1, 2.2])); + %OptimizeFunctionOnNextCall(push3); + assertEquals(7, push3([, 1.1, 2.2, 3.3])); +})(); + +// Test multiple arguments push for PACKED_ELEMENTS. +(function() { + function push0(a) { + return a.push(); + } + + assertEquals(1, push0(['1'])); + assertEquals(2, push0(['1', '2'])); + %OptimizeFunctionOnNextCall(push0); + assertEquals(3, push0(['1', '2', '3'])); + + function push1(a) { + return a.push('1'); + } + + assertEquals(2, push1(['1'])); + assertEquals(3, push1(['1', '2'])); + %OptimizeFunctionOnNextCall(push1); + assertEquals(4, push1(['1', '2', '3'])); + + function push2(a) { + return a.push('1', '2'); + } + + assertEquals(3, push2(['1'])); + assertEquals(4, push2(['1', '2'])); + %OptimizeFunctionOnNextCall(push2); + assertEquals(5, push2(['1', '2', '3'])); + + function push3(a) { + return a.push('1', '2', '3'); + } + + assertEquals(4, push3(['1'])); + assertEquals(5, push3(['1', '2'])); + %OptimizeFunctionOnNextCall(push3); + assertEquals(6, push3(['1', '2', '3'])); +})(); + +// Test multiple arguments push for HOLEY_ELEMENTS. +(function() { + function push0(a) { + return a.push(); + } + + assertEquals(2, push0([, '1'])); + assertEquals(3, push0([, '1', '2'])); + %OptimizeFunctionOnNextCall(push0); + assertEquals(4, push0([, '1', '2', '3'])); + + function push1(a) { + return a.push('1'); + } + + assertEquals(3, push1([, '1'])); + assertEquals(4, push1([, '1', '2'])); + %OptimizeFunctionOnNextCall(push1); + assertEquals(5, push1([, '1', '2', '3'])); + + function push2(a) { + return a.push('1', '2'); + } + + assertEquals(4, push2([, '1'])); + assertEquals(5, push2([, '1', '2'])); + %OptimizeFunctionOnNextCall(push2); + assertEquals(6, push2([, '1', '2', '3'])); + + function push3(a) { + return a.push('1', '2', '3'); + } + + assertEquals(5, push3([, '1'])); + assertEquals(6, push3([, '1', '2'])); + %OptimizeFunctionOnNextCall(push3); + assertEquals(7, push3([, '1', '2', '3'])); +})(); diff --git a/deps/v8/test/mjsunit/compiler/array-push-2.js b/deps/v8/test/mjsunit/compiler/array-push-2.js new file mode 100644 index 0000000000..cb18d71d63 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/array-push-2.js @@ -0,0 +1,65 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax --opt + +// Test elements transition from SMI to DOUBLE. +(function() { + const a = []; + const foo = (x, y) => a.push(x, y); + foo(1, 2); + foo(3, 4); + %OptimizeFunctionOnNextCall(foo); + foo(5, 6.6); + assertEquals([1, 2, 3, 4, 5, 6.6], a); +})(); +(function() { + const a = []; + const foo = (x, y) => a.push(x, y); + foo(1, 2); + foo(3, 4); + %OptimizeFunctionOnNextCall(foo); + foo(5.5, 6.6); + assertEquals([1, 2, 3, 4, 5.5, 6.6], a); +})(); + +// Test elements transition from SMI to OBJECT. +(function() { + const a = []; + const foo = (x, y) => a.push(x, y); + foo(1, 2); + foo(3, 4); + %OptimizeFunctionOnNextCall(foo); + foo(5, '6'); + assertEquals([1, 2, 3, 4, 5, '6'], a); +})(); +(function() { + const a = []; + const foo = (x, y) => a.push(x, y); + foo(1, 2); + foo(3, 4); + %OptimizeFunctionOnNextCall(foo); + foo('5', '6'); + assertEquals([1, 2, 3, 4, '5', '6'], a); +})(); + +// Test elements transition from DOUBLE to OBJECT. +(function() { + const a = [0.5]; + const foo = (x, y) => a.push(x, y); + foo(1, 2); + foo(3, 4); + %OptimizeFunctionOnNextCall(foo); + foo(5, '6'); + assertEquals([0.5, 1, 2, 3, 4, 5, '6'], a); +})(); +(function() { + const a = [0.5]; + const foo = (x, y) => a.push(x, y); + foo(1, 2); + foo(3, 4); + %OptimizeFunctionOnNextCall(foo); + foo('5', '6'); + assertEquals([0.5, 1, 2, 3, 4, '5', '6'], a); +})(); diff --git a/deps/v8/test/mjsunit/compiler/array-push-3.js b/deps/v8/test/mjsunit/compiler/array-push-3.js new file mode 100644 index 0000000000..f648eb9ed9 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/array-push-3.js @@ -0,0 +1,51 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax --opt + +// Test side effects on arguments evaluation. +(function() { + const a = []; + const bar = x => { a.push(x); return x; }; + const foo = x => a.push(bar(x), bar(x)); + foo(1); + foo(2); + %OptimizeFunctionOnNextCall(foo); + foo(3); + assertEquals([1,1,1,1, 2,2,2,2, 3,3,3,3], a); +})(); + +// Test invalidation on arguments evaluation. +(function() { + let y = 1; + const a = []; + const bar = x => { a.push(y); return x; } + const foo = x => a.push(bar(x), bar(x)); + foo(1); + y = 2; + foo(2); + %OptimizeFunctionOnNextCall(foo); + y = 3; + foo(3); + assertOptimized(foo); + y = 4.4; + foo(4); + assertEquals([1,1,1,1, 2,2,2,2, 3,3,3,3, 4.4,4.4,4,4], a); +})(); +(function() { + let y = 1; + const a = [0.5]; + const bar = x => { a.push(y); return x; } + const foo = x => a.push(bar(x), bar(x)); + foo(1); + y = 2; + foo(2); + %OptimizeFunctionOnNextCall(foo); + y = 3; + foo(3); + assertOptimized(foo); + y = '4'; + foo(4); + assertEquals([0.5, 1,1,1,1, 2,2,2,2, 3,3,3,3, '4','4',4,4], a); +})(); diff --git a/deps/v8/test/mjsunit/compiler/array-subclass.js b/deps/v8/test/mjsunit/compiler/array-subclass.js new file mode 100644 index 0000000000..d20b669661 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/array-subclass.js @@ -0,0 +1,396 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax + +// Test Array subclass default constructor with no parameters. +(function() { + const A = class A extends Array { }; + + function foo() { return new A; } + + assertInstanceof(foo(), A); + assertEquals(0, foo().length); + assertInstanceof(foo(), A); + assertEquals(0, foo().length); + %OptimizeFunctionOnNextCall(foo); + assertInstanceof(foo(), A); + assertEquals(0, foo().length); +})(); + +// Test Array subclass default constructor with small constant length. +(function() { + const A = class A extends Array { }; + const L = 4; + + function foo() { return new A(L); } + + assertInstanceof(foo(), A); + assertEquals(L, foo().length); + assertInstanceof(foo(), A); + assertEquals(L, foo().length); + %OptimizeFunctionOnNextCall(foo); + assertInstanceof(foo(), A); + assertEquals(L, foo().length); +})(); + +// Test Array subclass default constructor with large constant length. +(function() { + const A = class A extends Array { }; + const L = 1024 * 1024; + + function foo() { return new A(L); } + + assertInstanceof(foo(), A); + assertEquals(L, foo().length); + assertInstanceof(foo(), A); + assertEquals(L, foo().length); + %OptimizeFunctionOnNextCall(foo); + assertInstanceof(foo(), A); + assertEquals(L, foo().length); +})(); + +// Test Array subclass default constructor with known boolean. +(function() { + const A = class A extends Array { }; + + function foo() { return new A(true); } + + assertInstanceof(foo(), A); + assertEquals(1, foo().length); + assertEquals(true, foo()[0]); + assertInstanceof(foo(), A); + assertEquals(1, foo().length); + assertEquals(true, foo()[0]); + %OptimizeFunctionOnNextCall(foo); + assertInstanceof(foo(), A); + assertEquals(1, foo().length); + assertEquals(true, foo()[0]); +})(); + +// Test Array subclass default constructor with known string. +(function() { + const A = class A extends Array { }; + + function foo() { return new A(""); } + + assertInstanceof(foo(), A); + assertEquals(1, foo().length); + assertEquals("", foo()[0]); + assertInstanceof(foo(), A); + assertEquals(1, foo().length); + assertEquals("", foo()[0]); + %OptimizeFunctionOnNextCall(foo); + assertInstanceof(foo(), A); + assertEquals(1, foo().length); + assertEquals("", foo()[0]); +})(); + +// Test Array subclass default constructor with known object. +(function() { + const A = class A extends Array { }; + const O = {foo: "foo"}; + + function foo() { return new A(O); } + + assertInstanceof(foo(), A); + assertEquals(1, foo().length); + assertSame(O, foo()[0]); + assertInstanceof(foo(), A); + assertEquals(1, foo().length); + assertSame(O, foo()[0]); + %OptimizeFunctionOnNextCall(foo); + assertInstanceof(foo(), A); + assertEquals(1, foo().length); + assertSame(O, foo()[0]); +})(); + +// Test Array subclass default constructor with known small integers. +(function() { + const A = class A extends Array { }; + + function foo() { return new A(1, 2, 3); } + + assertInstanceof(foo(), A); + assertEquals(3, foo().length); + assertEquals(1, foo()[0]); + assertEquals(2, foo()[1]); + assertEquals(3, foo()[2]); + %OptimizeFunctionOnNextCall(foo); + assertInstanceof(foo(), A); + assertEquals(3, foo().length); + assertEquals(1, foo()[0]); + assertEquals(2, foo()[1]); + assertEquals(3, foo()[2]); +})(); + +// Test Array subclass default constructor with known numbers. +(function() { + const A = class A extends Array { }; + + function foo() { return new A(1.1, 2.2, 3.3); } + + assertInstanceof(foo(), A); + assertEquals(3, foo().length); + assertEquals(1.1, foo()[0]); + assertEquals(2.2, foo()[1]); + assertEquals(3.3, foo()[2]); + %OptimizeFunctionOnNextCall(foo); + assertInstanceof(foo(), A); + assertEquals(3, foo().length); + assertEquals(1.1, foo()[0]); + assertEquals(2.2, foo()[1]); + assertEquals(3.3, foo()[2]); +})(); + +// Test Array subclass default constructor with known strings. +(function() { + const A = class A extends Array { }; + + function foo() { return new A("a", "b", "c", "d"); } + + assertInstanceof(foo(), A); + assertEquals(4, foo().length); + assertEquals("a", foo()[0]); + assertEquals("b", foo()[1]); + assertEquals("c", foo()[2]); + assertEquals("d", foo()[3]); + %OptimizeFunctionOnNextCall(foo); + assertInstanceof(foo(), A); + assertEquals(4, foo().length); + assertEquals("a", foo()[0]); + assertEquals("b", foo()[1]); + assertEquals("c", foo()[2]); + assertEquals("d", foo()[3]); +})(); + +// Test Array subclass constructor with no parameters. +(function() { + const A = class A extends Array { + constructor() { + super(); + this.bar = 1; + } + }; + + function foo() { return new A; } + + assertInstanceof(foo(), A); + assertEquals(0, foo().length); + assertEquals(1, foo().bar); + assertInstanceof(foo(), A); + assertEquals(0, foo().length); + assertEquals(1, foo().bar); + %OptimizeFunctionOnNextCall(foo); + assertInstanceof(foo(), A); + assertEquals(0, foo().length); + assertEquals(1, foo().bar); +})(); + +// Test Array subclass constructor with small constant length. +(function() { + const A = class A extends Array { + constructor(n) { + super(n); + this.bar = 1; + } + }; + const L = 4; + + function foo() { return new A(L); } + + assertInstanceof(foo(), A); + assertEquals(L, foo().length); + assertEquals(1, foo().bar); + assertInstanceof(foo(), A); + assertEquals(L, foo().length); + assertEquals(1, foo().bar); + %OptimizeFunctionOnNextCall(foo); + assertInstanceof(foo(), A); + assertEquals(L, foo().length); + assertEquals(1, foo().bar); +})(); + +// Test Array subclass constructor with large constant length. +(function() { + const A = class A extends Array { + constructor(n) { + super(n); + this.bar = 1; + } + }; + const L = 1024 * 1024; + + function foo() { return new A(L); } + + assertInstanceof(foo(), A); + assertEquals(L, foo().length); + assertEquals(1, foo().bar); + assertInstanceof(foo(), A); + assertEquals(L, foo().length); + assertEquals(1, foo().bar); + %OptimizeFunctionOnNextCall(foo); + assertInstanceof(foo(), A); + assertEquals(L, foo().length); + assertEquals(1, foo().bar); +})(); + +// Test Array subclass constructor with known boolean. +(function() { + const A = class A extends Array { + constructor(n) { + super(n); + this.bar = 1; + } + }; + + function foo() { return new A(true); } + + assertInstanceof(foo(), A); + assertEquals(1, foo().length); + assertEquals(true, foo()[0]); + assertEquals(1, foo().bar); + assertInstanceof(foo(), A); + assertEquals(1, foo().length); + assertEquals(true, foo()[0]); + assertEquals(1, foo().bar); + %OptimizeFunctionOnNextCall(foo); + assertInstanceof(foo(), A); + assertEquals(1, foo().length); + assertEquals(true, foo()[0]); + assertEquals(1, foo().bar); +})(); + +// Test Array subclass constructor with known string. +(function() { + const A = class A extends Array { + constructor(n) { + super(n); + this.bar = 1; + } + }; + + function foo() { return new A(""); } + + assertInstanceof(foo(), A); + assertEquals(1, foo().length); + assertEquals("", foo()[0]); + assertEquals(1, foo().bar); + assertInstanceof(foo(), A); + assertEquals(1, foo().length); + assertEquals("", foo()[0]); + assertEquals(1, foo().bar); + %OptimizeFunctionOnNextCall(foo); + assertInstanceof(foo(), A); + assertEquals(1, foo().length); + assertEquals("", foo()[0]); + assertEquals(1, foo().bar); +})(); + +// Test Array subclass constructor with known object. +(function() { + const A = class A extends Array { + constructor(n) { + super(n); + this.bar = 1; + } + }; + const O = {foo: "foo"}; + + function foo() { return new A(O); } + + assertInstanceof(foo(), A); + assertEquals(1, foo().length); + assertSame(O, foo()[0]); + assertEquals(1, foo().bar); + assertInstanceof(foo(), A); + assertEquals(1, foo().length); + assertSame(O, foo()[0]); + assertEquals(1, foo().bar); + %OptimizeFunctionOnNextCall(foo); + assertInstanceof(foo(), A); + assertEquals(1, foo().length); + assertSame(O, foo()[0]); + assertEquals(1, foo().bar); +})(); + +// Test Array subclass constructor with known small integers. +(function() { + const A = class A extends Array { + constructor(x, y, z) { + super(x, y, z); + this.bar = 1; + } + }; + + function foo() { return new A(1, 2, 3); } + + assertInstanceof(foo(), A); + assertEquals(3, foo().length); + assertEquals(1, foo()[0]); + assertEquals(2, foo()[1]); + assertEquals(3, foo()[2]); + assertEquals(1, foo().bar); + %OptimizeFunctionOnNextCall(foo); + assertInstanceof(foo(), A); + assertEquals(3, foo().length); + assertEquals(1, foo()[0]); + assertEquals(2, foo()[1]); + assertEquals(3, foo()[2]); + assertEquals(1, foo().bar); +})(); + +// Test Array subclass constructor with known numbers. +(function() { + const A = class A extends Array { + constructor(x, y, z) { + super(x, y, z); + this.bar = 1; + } + }; + + function foo() { return new A(1.1, 2.2, 3.3); } + + assertInstanceof(foo(), A); + assertEquals(3, foo().length); + assertEquals(1.1, foo()[0]); + assertEquals(2.2, foo()[1]); + assertEquals(3.3, foo()[2]); + assertEquals(1, foo().bar); + %OptimizeFunctionOnNextCall(foo); + assertInstanceof(foo(), A); + assertEquals(3, foo().length); + assertEquals(1.1, foo()[0]); + assertEquals(2.2, foo()[1]); + assertEquals(3.3, foo()[2]); + assertEquals(1, foo().bar); +})(); + +// Test Array subclass constructor with known strings. +(function() { + const A = class A extends Array { + constructor(a, b, c, d) { + super(a, b, c, d); + this.bar = 1; + } + }; + + function foo() { return new A("a", "b", "c", "d"); } + + assertInstanceof(foo(), A); + assertEquals(4, foo().length); + assertEquals("a", foo()[0]); + assertEquals("b", foo()[1]); + assertEquals("c", foo()[2]); + assertEquals("d", foo()[3]); + assertEquals(1, foo().bar); + %OptimizeFunctionOnNextCall(foo); + assertInstanceof(foo(), A); + assertEquals(4, foo().length); + assertEquals("a", foo()[0]); + assertEquals("b", foo()[1]); + assertEquals("c", foo()[2]); + assertEquals("d", foo()[3]); + assertEquals(1, foo().bar); +})(); diff --git a/deps/v8/test/mjsunit/compiler/constant-fold-cow-array.js b/deps/v8/test/mjsunit/compiler/constant-fold-cow-array.js new file mode 100644 index 0000000000..1ab022611c --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/constant-fold-cow-array.js @@ -0,0 +1,35 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax --no-always-opt --opt + +// Check that we properly deoptimize TurboFan'ed code when we constant-fold +// elements from a COW array and we change the length of the array. +(function() { + const a = [1, 2, 3]; + const foo = () => a[0]; + assertEquals(1, foo()); + assertEquals(1, foo()); + %OptimizeFunctionOnNextCall(foo); + assertEquals(1, foo()); + assertOptimized(foo); + a.length = 1; + assertEquals(1, foo()); + assertUnoptimized(foo); +})(); + +// Check that we properly deoptimize TurboFan'ed code when we constant-fold +// elements from a COW array and we change the element of the array. +(function() { + const a = [1, 2, 3]; + const foo = () => a[0]; + assertEquals(1, foo()); + assertEquals(1, foo()); + %OptimizeFunctionOnNextCall(foo); + assertEquals(1, foo()); + assertOptimized(foo); + a[0] = 42; + assertEquals(42, foo()); + assertUnoptimized(foo); +})(); diff --git a/deps/v8/test/mjsunit/compiler/constant-fold-tostring.js b/deps/v8/test/mjsunit/compiler/constant-fold-tostring.js new file mode 100644 index 0000000000..e9c6d916ce --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/constant-fold-tostring.js @@ -0,0 +1,26 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax --no-always-opt --opt + +// Check that constant-folding of ToString operations works properly for NaN. +(function() { + const foo = () => `${NaN}`; + assertEquals("NaN", foo()); + assertEquals("NaN", foo()); + %OptimizeFunctionOnNextCall(foo); + assertEquals("NaN", foo()); +})(); + +// Check that constant-folding of ToString operations works properly for 0/-0. +(function() { + const foo = x => `${x ? 0 : -0}`; + assertEquals("0", foo(true)); + assertEquals("0", foo(false)); + assertEquals("0", foo(true)); + assertEquals("0", foo(false)); + %OptimizeFunctionOnNextCall(foo); + assertEquals("0", foo(true)); + assertEquals("0", foo(false)); +})(); diff --git a/deps/v8/test/mjsunit/compiler/constructor-inlining.js b/deps/v8/test/mjsunit/compiler/constructor-inlining.js index d43545ada0..4ad426ff61 100644 --- a/deps/v8/test/mjsunit/compiler/constructor-inlining.js +++ b/deps/v8/test/mjsunit/compiler/constructor-inlining.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --harmony-restrict-constructor-return +// Flags: --harmony-restrict-constructor-return --allow-natives-syntax --stress-inline if (this.FLAG_harmony_restrict_constructor_return === undefined) this.FLAG_harmony_restrict_constructor_return = true; @@ -54,9 +54,6 @@ function Constr(use, x){ } } -%SetForceInlineFlag(Base); -%SetForceInlineFlag(Derived); -%SetForceInlineFlag(Constr); var a = {}; var b = {}; diff --git a/deps/v8/test/mjsunit/compiler/dead-string-char-code-at.js b/deps/v8/test/mjsunit/compiler/dead-string-char-code-at.js deleted file mode 100644 index 9f01541c90..0000000000 --- a/deps/v8/test/mjsunit/compiler/dead-string-char-code-at.js +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2013 the V8 project authors. All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials provided -// with the distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Flags: --allow-natives-syntax - -var S1 = "string1"; -var S2 = "@@string2"; - -function dead1(a, b) { - var x = %_StringCharCodeAt(a, 4); - return a; // x is dead code -} - -function dead2(a, b) { - var x = %_StringCharCodeAt(a, 3); - var y = %_StringCharCodeAt(b, 1); - return a; // x and y are both dead -} - -function dead3(a, b) { - a = a ? "11" : "12"; - b = b ? "13" : "14"; - var x = %_StringCharCodeAt(a, 2); - var y = %_StringCharCodeAt(b, 0); - return a; // x and y are both dead -} - -function test() { - var S3 = S1 + S2; - - assertEquals(S1, dead1(S1, S2)); - assertEquals(S1, dead2(S1, S2)); - assertEquals("11", dead3(S1, S2)); - - assertEquals(S2, dead1(S2, 677)); - assertEquals(S2, dead2(S2, S3)); - assertEquals("11", dead3(S2, S3)); - - assertEquals(S3, dead1(S3, 399)); - assertEquals(S3, dead2(S3, "false")); - assertEquals("12", dead3(0, 32)); - - assertEquals(S3, dead1(S3, 0)); - assertEquals(S3, dead2(S3, S1)); - assertEquals("11", dead3(S3, 0)); - - assertEquals("true", dead1("true", 0)); - assertEquals("true", dead2("true", S3)); - assertEquals("11", dead3("true", 0)); -} - -test(); -test(); -%OptimizeFunctionOnNextCall(dead1); -%OptimizeFunctionOnNextCall(dead2); -%OptimizeFunctionOnNextCall(dead3); -test(); diff --git a/deps/v8/test/mjsunit/compiler/dead-string-char-code-at2.js b/deps/v8/test/mjsunit/compiler/dead-string-char-code-at2.js deleted file mode 100644 index 9f01541c90..0000000000 --- a/deps/v8/test/mjsunit/compiler/dead-string-char-code-at2.js +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2013 the V8 project authors. All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials provided -// with the distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Flags: --allow-natives-syntax - -var S1 = "string1"; -var S2 = "@@string2"; - -function dead1(a, b) { - var x = %_StringCharCodeAt(a, 4); - return a; // x is dead code -} - -function dead2(a, b) { - var x = %_StringCharCodeAt(a, 3); - var y = %_StringCharCodeAt(b, 1); - return a; // x and y are both dead -} - -function dead3(a, b) { - a = a ? "11" : "12"; - b = b ? "13" : "14"; - var x = %_StringCharCodeAt(a, 2); - var y = %_StringCharCodeAt(b, 0); - return a; // x and y are both dead -} - -function test() { - var S3 = S1 + S2; - - assertEquals(S1, dead1(S1, S2)); - assertEquals(S1, dead2(S1, S2)); - assertEquals("11", dead3(S1, S2)); - - assertEquals(S2, dead1(S2, 677)); - assertEquals(S2, dead2(S2, S3)); - assertEquals("11", dead3(S2, S3)); - - assertEquals(S3, dead1(S3, 399)); - assertEquals(S3, dead2(S3, "false")); - assertEquals("12", dead3(0, 32)); - - assertEquals(S3, dead1(S3, 0)); - assertEquals(S3, dead2(S3, S1)); - assertEquals("11", dead3(S3, 0)); - - assertEquals("true", dead1("true", 0)); - assertEquals("true", dead2("true", S3)); - assertEquals("11", dead3("true", 0)); -} - -test(); -test(); -%OptimizeFunctionOnNextCall(dead1); -%OptimizeFunctionOnNextCall(dead2); -%OptimizeFunctionOnNextCall(dead3); -test(); diff --git a/deps/v8/test/mjsunit/compiler/deopt-closure.js b/deps/v8/test/mjsunit/compiler/deopt-closure.js new file mode 100644 index 0000000000..2ce531faf0 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/deopt-closure.js @@ -0,0 +1,47 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax + +(function TestMaterializeTargetOfInterpretedFrame() { + function f(x) { + function g() { + %_DeoptimizeNow(); + return x + 1; + } + return g(); + } + assertEquals(24, f(23)); + assertEquals(43, f(42)); + %OptimizeFunctionOnNextCall(f); + assertEquals(66, f(65)); +})(); + +(function TestMaterializeTargetOfArgumentsAdaptorFrame() { + function f(x) { + function g(a, b, c) { + %_DeoptimizeNow(); + return x + 1; + } + return g(); + } + assertEquals(24, f(23)); + assertEquals(43, f(42)); + %OptimizeFunctionOnNextCall(f); + assertEquals(66, f(65)); +})(); + +(function TestMaterializeTargetOfConstructStubFrame() { + function f(x) { + function g() { + %_DeoptimizeNow(); + this.val = x + 1; + } + return new g(); + } + assertEquals({ val: 24 }, f(23)); + assertEquals({ val: 43 }, f(42)); + %OptimizeFunctionOnNextCall(f); + assertEquals({ val: 66 }, f(65)); +})(); diff --git a/deps/v8/test/mjsunit/compiler/deopt-simple-try-catch.js b/deps/v8/test/mjsunit/compiler/deopt-simple-try-catch.js new file mode 100644 index 0000000000..b0e382e38c --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/deopt-simple-try-catch.js @@ -0,0 +1,28 @@ + +// Copyright 2017 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 + +// Flags: --allow-natives-syntax + +// Small program to test deoptimization with exception handling. + +function g() { + %DeoptimizeFunction(f); + throw 42; +} +%NeverOptimizeFunction(g); + +function f() { + var a = 1; + try { + g(); + } catch (e) { + return e + a; + } +} + +assertEquals(f(), 43); +assertEquals(f(), 43); +%OptimizeFunctionOnNextCall(f); +assertEquals(f(), 43); diff --git a/deps/v8/test/mjsunit/compiler/for-in-1.js b/deps/v8/test/mjsunit/compiler/for-in-1.js new file mode 100644 index 0000000000..80add89609 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/for-in-1.js @@ -0,0 +1,20 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax --opt + +// Ensure that we properly check for elements on the receiver. +function foo(o) { + var s = ""; + for (var i in o) s += i; + return s; +} + +var a = []; +assertEquals("", foo(a)); +assertEquals("", foo(a)); +%OptimizeFunctionOnNextCall(foo); +assertEquals("", foo(a)); +a[0] = 1; +assertEquals("0", foo(a)); diff --git a/deps/v8/test/mjsunit/compiler/for-in-2.js b/deps/v8/test/mjsunit/compiler/for-in-2.js new file mode 100644 index 0000000000..a586aff94e --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/for-in-2.js @@ -0,0 +1,20 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax --opt + +// Ensure that we properly check for elements on the prototypes. +function foo(o) { + var s = ""; + for (var i in o) s += i; + return s; +} + +var a = []; +assertEquals("", foo(a)); +assertEquals("", foo(a)); +%OptimizeFunctionOnNextCall(foo); +assertEquals("", foo(a)); +Array.prototype[0] = 1; +assertEquals("0", foo(a)); diff --git a/deps/v8/test/mjsunit/compiler/for-in-3.js b/deps/v8/test/mjsunit/compiler/for-in-3.js new file mode 100644 index 0000000000..80f3fa50c9 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/for-in-3.js @@ -0,0 +1,20 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax --opt + +// Ensure that we properly check for elements on the prototypes. +function foo(o) { + var s = ""; + for (var i in o) s += i; + return s; +} + +var o = {}; +assertEquals("", foo(o)); +assertEquals("", foo(o)); +%OptimizeFunctionOnNextCall(foo); +assertEquals("", foo(o)); +Object.prototype[0] = 1; +assertEquals("0", foo(o)); diff --git a/deps/v8/test/mjsunit/compiler/for-in-4.js b/deps/v8/test/mjsunit/compiler/for-in-4.js new file mode 100644 index 0000000000..d15c3484dd --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/for-in-4.js @@ -0,0 +1,20 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax --opt + +// Ensure that we properly check for properties on the prototypes. +function foo(o) { + var s = ""; + for (var i in o) s += i; + return s; +} + +var a = []; +assertEquals("", foo(a)); +assertEquals("", foo(a)); +%OptimizeFunctionOnNextCall(foo); +assertEquals("", foo(a)); +Array.prototype.x = 4; +assertEquals("x", foo(a)); diff --git a/deps/v8/test/mjsunit/compiler/for-in-5.js b/deps/v8/test/mjsunit/compiler/for-in-5.js new file mode 100644 index 0000000000..8f469ab1b3 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/for-in-5.js @@ -0,0 +1,19 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax --opt + +// Ensure that we properly check for properties on the prototypes. +function foo(o) { + var s = ""; + for (var i in o) s += i; + return s; +} +var o = {a:1, b:2, c:3}; +assertEquals("abc", foo(o)); +assertEquals("abc", foo(o)); +%OptimizeFunctionOnNextCall(foo); +assertEquals("abc", foo(o)); +Object.prototype.d = 4; +assertEquals("abcd", foo(o)); diff --git a/deps/v8/test/mjsunit/compiler/function-caller.js b/deps/v8/test/mjsunit/compiler/function-caller.js new file mode 100644 index 0000000000..1192e680cb --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/function-caller.js @@ -0,0 +1,25 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax + +(function TestInlineAllocatedCaller() { + function g() { + var caller = g.caller; + caller.foo = 23; + assertEquals(23, caller.foo); + assertEquals(23, g.caller.foo); + assertSame(caller, g.caller); + } + %NeverOptimizeFunction(g); + + function f() { + (function caller() { g() })(); + } + + f(); + f(); + %OptimizeFunctionOnNextCall(f); + f(); +})(); diff --git a/deps/v8/test/mjsunit/compiler/object-constructor.js b/deps/v8/test/mjsunit/compiler/object-constructor.js new file mode 100644 index 0000000000..162416fd57 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/object-constructor.js @@ -0,0 +1,51 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax + +// Common pattern in Webpack 3 generated bundles, see +// https://github.com/webpack/webpack/issues/5600 for details. +(function ObjectConstructorWithKnownFunction() { + "use strict"; + class A { + bar() { return this; } + }; + function foo(a) { + return Object(a.bar)(); + } + assertEquals(undefined, foo(new A)); + assertEquals(undefined, foo(new A)); + %OptimizeFunctionOnNextCall(foo); + assertEquals(undefined, foo(new A)); +})(); + +(function ObjectConstructorWithString() { + "use strict"; + function foo() { + return Object("a"); + } + assertEquals('object', typeof foo()); + assertEquals('object', typeof foo()); + %OptimizeFunctionOnNextCall(foo); + assertEquals('object', typeof foo()); +})(); + +// Object constructor subclassing via Class Factories, see +// https://twitter.com/FremyCompany/status/905977048006402048 +// for the hint. +(function ObjectConstructorSubClassing() { + "use strict"; + const Factory = Base => class A extends Base {}; + const A = Factory(Object); + function foo() { + return new A(1, 2, 3); + } + assertInstanceof(foo(), A); + assertInstanceof(foo(), Object); + assertInstanceof(foo(), A); + assertInstanceof(foo(), Object); + %OptimizeFunctionOnNextCall(foo); + assertInstanceof(foo(), A); + assertInstanceof(foo(), Object); +})(); diff --git a/deps/v8/test/mjsunit/compiler/object-is.js b/deps/v8/test/mjsunit/compiler/object-is.js new file mode 100644 index 0000000000..9537d78e3b --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/object-is.js @@ -0,0 +1,143 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax + +(function() { + function foo(o) { return Object.is(o, -0); } + assertTrue(foo(-0)); + assertFalse(foo(0)); + assertFalse(foo(NaN)); + assertFalse(foo('')); + assertFalse(foo([])); + assertFalse(foo({})); + %OptimizeFunctionOnNextCall(foo); + assertTrue(foo(-0)); + assertFalse(foo(0)); + assertFalse(foo(NaN)); + assertFalse(foo('')); + assertFalse(foo([])); + assertFalse(foo({})); +})(); + +(function() { + function foo(o) { return Object.is(-0, o); } + assertTrue(foo(-0)); + assertFalse(foo(0)); + assertFalse(foo(NaN)); + assertFalse(foo('')); + assertFalse(foo([])); + assertFalse(foo({})); + %OptimizeFunctionOnNextCall(foo); + assertTrue(foo(-0)); + assertFalse(foo(0)); + assertFalse(foo(NaN)); + assertFalse(foo('')); + assertFalse(foo([])); + assertFalse(foo({})); +})(); + +(function() { + function foo(o) { return Object.is(+o, -0); } + assertTrue(foo(-0)); + assertFalse(foo(0)); + assertFalse(foo(NaN)); + %OptimizeFunctionOnNextCall(foo); + assertTrue(foo(-0)); + assertFalse(foo(0)); + assertFalse(foo(NaN)); +})(); + +(function() { + function foo(o) { return Object.is(-0, +o); } + assertTrue(foo(-0)); + assertFalse(foo(0)); + assertFalse(foo(NaN)); + %OptimizeFunctionOnNextCall(foo); + assertTrue(foo(-0)); + assertFalse(foo(0)); + assertFalse(foo(NaN)); +})(); + +(function() { + function foo(o) { return Object.is(o, NaN); } + assertFalse(foo(-0)); + assertFalse(foo(0)); + assertTrue(foo(NaN)); + assertFalse(foo('')); + assertFalse(foo([])); + assertFalse(foo({})); + %OptimizeFunctionOnNextCall(foo); + assertFalse(foo(-0)); + assertFalse(foo(0)); + assertTrue(foo(NaN)); + assertFalse(foo('')); + assertFalse(foo([])); + assertFalse(foo({})); +})(); + +(function() { + function foo(o) { return Object.is(NaN, o); } + assertFalse(foo(-0)); + assertFalse(foo(0)); + assertTrue(foo(NaN)); + assertFalse(foo('')); + assertFalse(foo([])); + assertFalse(foo({})); + %OptimizeFunctionOnNextCall(foo); + assertFalse(foo(-0)); + assertFalse(foo(0)); + assertTrue(foo(NaN)); + assertFalse(foo('')); + assertFalse(foo([])); + assertFalse(foo({})); +})(); + +(function() { + function foo(o) { return Object.is(+o, NaN); } + assertFalse(foo(-0)); + assertFalse(foo(0)); + assertTrue(foo(NaN)); + %OptimizeFunctionOnNextCall(foo); + assertFalse(foo(-0)); + assertFalse(foo(0)); + assertTrue(foo(NaN)); +})(); + +(function() { + function foo(o) { return Object.is(NaN, +o); } + assertFalse(foo(-0)); + assertFalse(foo(0)); + assertTrue(foo(NaN)); + %OptimizeFunctionOnNextCall(foo); + assertFalse(foo(-0)); + assertFalse(foo(0)); + assertTrue(foo(NaN)); +})(); + +(function() { + function foo(o) { return Object.is(`${o}`, "foo"); } + assertFalse(foo("bar")); + assertTrue(foo("foo")); + %OptimizeFunctionOnNextCall(foo); + assertFalse(foo("bar")); + assertTrue(foo("foo")); +})(); + +(function() { + function foo(o) { return Object.is(o, o); } + assertTrue(foo(-0)); + assertTrue(foo(0)); + assertTrue(foo(NaN)); + assertTrue(foo('')); + assertTrue(foo([])); + assertTrue(foo({})); + %OptimizeFunctionOnNextCall(foo); + assertTrue(foo(-0)); + assertTrue(foo(0)); + assertTrue(foo(NaN)); + assertTrue(foo('')); + assertTrue(foo([])); + assertTrue(foo({})); +})(); diff --git a/deps/v8/test/mjsunit/compiler/polymorphic-symbols.js b/deps/v8/test/mjsunit/compiler/polymorphic-symbols.js new file mode 100644 index 0000000000..e954d50fa8 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/polymorphic-symbols.js @@ -0,0 +1,48 @@ +// Copyright 2015 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. + +// Flags: --allow-natives-syntax + +(function() { + const symbol = Symbol('symbol'); + const OBJS = [ + {[symbol]: 0, a: 1}, + {[symbol]: 1, b: 2}, + {[symbol]: 2, c: 3}, + {[symbol]: 3, d: 4} + ]; + function foo(o) { return o[symbol]; } + for (let i = 0; i < OBJS.length; ++i) { + assertEquals(i, foo(OBJS[i])); + assertEquals(i, foo(OBJS[i])); + } + %OptimizeFunctionOnNextCall(foo); + for (let i = 0; i < OBJS.length; ++i) { + assertEquals(i, foo(OBJS[i])); + assertEquals(i, foo(OBJS[i])); + } +})(); + +(function() { + const symbol = Symbol('symbol'); + const OBJS = [ + {[symbol]: 0, a: 1}, + {[symbol]: 1, b: 2}, + {[symbol]: 2, c: 3}, + {[symbol]: 3, d: 4} + ]; + function foo(o) { o[symbol] = o; } + for (let i = 0; i < OBJS.length; ++i) { + foo(OBJS[i]); + foo(OBJS[i]); + } + %OptimizeFunctionOnNextCall(foo); + for (let i = 0; i < OBJS.length; ++i) { + foo(OBJS[i]); + foo(OBJS[i]); + } + for (const o of OBJS) { + assertEquals(o, o[symbol]); + } +})(); diff --git a/deps/v8/test/mjsunit/compiler/regress-700883.js b/deps/v8/test/mjsunit/compiler/regress-700883.js index 0b148b5e08..41440f3a3f 100644 --- a/deps/v8/test/mjsunit/compiler/regress-700883.js +++ b/deps/v8/test/mjsunit/compiler/regress-700883.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --stress-inline function add(x) { return x + x; @@ -10,7 +10,6 @@ function add(x) { add(0); add(1); -%SetForceInlineFlag(add); var min = Math.min; function foo(x) { @@ -19,5 +18,6 @@ function foo(x) { return min(y, x); } +foo(); %OptimizeFunctionOnNextCall(foo); foo(); diff --git a/deps/v8/test/mjsunit/compiler/regress-758096.js b/deps/v8/test/mjsunit/compiler/regress-758096.js new file mode 100644 index 0000000000..1ed32c0263 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/regress-758096.js @@ -0,0 +1,54 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax + +(function() { + var x = 1; + x.__proto__.f = function() { return 1; } + + function g() {} + g.prototype.f = function() { return 3; }; + var y = new g(); + + function f(obj) { + return obj.f(); + } + + f(x); + f(y); + f(x); + f(y); + %OptimizeFunctionOnNextCall(f); + assertEquals(1, f(x)); + assertEquals(3, f(y)); +})(); + +(function() { + function f() { return 1; } + function g() { return 2; } + + var global; + + function h(s) { + var fg; + var a = 0; + if (s) { + global = 0; + a = 1; + fg = f; + } else { + global = 1 + fg = g; + } + return fg() + a; + } + + h(0); + h(0); + h(1); + h(1); + %OptimizeFunctionOnNextCall(h); + assertEquals(2, h(0)); +})(); diff --git a/deps/v8/test/mjsunit/compiler/regress-761892.js b/deps/v8/test/mjsunit/compiler/regress-761892.js new file mode 100644 index 0000000000..5423c59c04 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/regress-761892.js @@ -0,0 +1,15 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax + +function f(x) { + var x0 = (0 != Math.min(1, 1)) && 1; + 1.1!=(x||x0) +} + +f(1.1); +f(1.1); +%OptimizeFunctionOnNextCall(f); +f(1); diff --git a/deps/v8/test/mjsunit/compiler/regress-762057.js b/deps/v8/test/mjsunit/compiler/regress-762057.js new file mode 100644 index 0000000000..4b5cab6ef5 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/regress-762057.js @@ -0,0 +1,20 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax + +function* foo() { + yield; + new Set(); + for (let x of []) { + for (let y of []) { + yield; + } + } +} + +let gaga = foo(); +gaga.next(); +%OptimizeFunctionOnNextCall(foo); +gaga.next(); diff --git a/deps/v8/test/mjsunit/compiler/regress-780658.js b/deps/v8/test/mjsunit/compiler/regress-780658.js new file mode 100644 index 0000000000..57fdbbabed --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/regress-780658.js @@ -0,0 +1,29 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax --turbo-escape + +function get1(l, b) { + return l[1]; +} + +function with_double(x) { + var o = {a: [x,x,x]}; + o.a.some_property = 1; + return get1(o.a); +} + +function with_tagged(x) { + var l = [{}, x,x]; + return get1(l); +} + +with_double(.5); +with_tagged({}); +with_double(.6); +with_tagged(null); +with_double(.5); +with_tagged({}); +%OptimizeFunctionOnNextCall(with_double); +with_double(.7); diff --git a/deps/v8/test/mjsunit/compiler/stress-deopt-count-1.js b/deps/v8/test/mjsunit/compiler/stress-deopt-count-1.js new file mode 100644 index 0000000000..834a873e75 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/stress-deopt-count-1.js @@ -0,0 +1,20 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax --deopt-every-n-times=0 --opt --no-always-opt + +// Check that --deopt-every-n-times 0 doesn't deopt + +function f(x) { + return x + 1; +} + +f(0); +%OptimizeFunctionOnNextCall(f); + +f(1); +assertOptimized(f, undefined, undefined, false); + +f(1); +assertOptimized(f, undefined, undefined, false); diff --git a/deps/v8/test/mjsunit/compiler/stress-deopt-count-2.js b/deps/v8/test/mjsunit/compiler/stress-deopt-count-2.js new file mode 100644 index 0000000000..641a9e8180 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/stress-deopt-count-2.js @@ -0,0 +1,48 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax --opt --no-always-opt --deopt-every-n-times=6 + +// Check that stress deopt count resets correctly + +// Function with two deopt points +function f(x) { + return x + 1; +} + +f(1); +%OptimizeFunctionOnNextCall(f); + +// stress_deopt_count == 6 + +f(1); +assertOptimized(f, undefined, undefined, false); + +// stress_deopt_count == 4 + +f(1); +assertOptimized(f, undefined, undefined, false); + +// stress_deopt_count == 2 + +f(1); +// deopt & counter reset +assertUnoptimized(f, undefined, undefined, false); + +// stress_deopt_count == 6 + +%OptimizeFunctionOnNextCall(f); +f(1); +assertOptimized(f, undefined, undefined, false); + +// stress_deopt_count == 4 + +f(1); +assertOptimized(f, undefined, undefined, false); + +// stress_deopt_count == 2 + +f(1); +// deopt & counter reset +assertUnoptimized(f, undefined, undefined, false); diff --git a/deps/v8/test/mjsunit/compiler/typedarray-prototype-tostringtag.js b/deps/v8/test/mjsunit/compiler/typedarray-prototype-tostringtag.js new file mode 100644 index 0000000000..de4b302017 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/typedarray-prototype-tostringtag.js @@ -0,0 +1,84 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax + +const Classes = [ + Uint8Array, + Int8Array, + Uint16Array, + Int16Array, + Uint32Array, + Int32Array, + Uint8ClampedArray, + Float32Array, + Float64Array +]; +const TypedArrayPrototype_toStringTag = + Object.getOwnPropertyDescriptor( + Object.getPrototypeOf(Uint8Array.prototype), + Symbol.toStringTag).get; + +(function() { + function foo(o) { + return TypedArrayPrototype_toStringTag.call(o); + } + assertEquals(undefined, foo(1)); + assertEquals(undefined, foo({})); + assertEquals(undefined, foo([])); + Classes.forEach(C => assertEquals(C.name, foo(new C(1)))); + %OptimizeFunctionOnNextCall(foo); + assertEquals(undefined, foo(1)); + assertEquals(undefined, foo({})); + assertEquals(undefined, foo([])); + Classes.forEach(C => assertEquals(C.name, foo(new C(1)))); +})(); + +(function() { + const ReflectApply = Reflect.apply; + const uncurryThis = func => (thisArg, ...args) => + ReflectApply(func, thisArg, args); + const TypedArrayProto_toStringTag = + uncurryThis(TypedArrayPrototype_toStringTag); + + function isTypedArray(value) { + return TypedArrayProto_toStringTag(value) !== undefined; + } + + assertFalse(isTypedArray(1)); + assertFalse(isTypedArray({})); + assertFalse(isTypedArray([])); + assertFalse(isTypedArray('Lorem ipsum')); + Classes.forEach(C => assertTrue(isTypedArray(new C(1)))); + %OptimizeFunctionOnNextCall(isTypedArray); + assertFalse(isTypedArray(1)); + assertFalse(isTypedArray({})); + assertFalse(isTypedArray([])); + assertFalse(isTypedArray('Lorem ipsum')); + Classes.forEach(C => assertTrue(isTypedArray(new C(1)))); +})(); + +(function() { + const ReflectApply = Reflect.apply; + const uncurryThis = func => (thisArg, ...args) => + ReflectApply(func, thisArg, args); + const TypedArrayProto_toStringTag = + uncurryThis(TypedArrayPrototype_toStringTag); + + function isUint8Array(value) { + return TypedArrayProto_toStringTag(value) === 'Uint8Array'; + } + + assertFalse(isUint8Array(1)); + assertFalse(isUint8Array({})); + assertFalse(isUint8Array([])); + assertFalse(isUint8Array('Lorem ipsum')); + Classes.forEach(C => assertEquals(C === Uint8Array, isUint8Array(new C(1)))); + %OptimizeFunctionOnNextCall(isUint8Array); + assertFalse(isUint8Array(1)); + assertFalse(isUint8Array({})); + assertFalse(isUint8Array([])); + assertFalse(isUint8Array('Lorem ipsum')); + Classes.forEach(C => assertEquals(C === Uint8Array, isUint8Array(new C(1)))); +})(); diff --git a/deps/v8/test/mjsunit/es6/new-target.js b/deps/v8/test/mjsunit/es6/new-target.js index 14446fc40f..c77c153cc0 100644 --- a/deps/v8/test/mjsunit/es6/new-target.js +++ b/deps/v8/test/mjsunit/es6/new-target.js @@ -472,3 +472,12 @@ function get_new_target() { return new.target; } tagNewTargetProp.Prop = C; assertEquals(new tagNewTargetProp, ["tagNewTargetProp"]); })(); + +(function testDeleteSloppy() { + assertTrue(delete new.target); +})(); + +(function testDeleteStrict() { + "use strict"; + assertTrue(delete new.target); +})(); diff --git a/deps/v8/test/mjsunit/es6/proxies-get.js b/deps/v8/test/mjsunit/es6/proxies-get.js index 4f7b2d0be4..f52ae1aa7e 100644 --- a/deps/v8/test/mjsunit/es6/proxies-get.js +++ b/deps/v8/test/mjsunit/es6/proxies-get.js @@ -193,7 +193,6 @@ 'Error from proxy getOwnPropertyDescriptor trap'); })(); - (function testGetPropertyDetailsBailout2() { var obj = {}; Object.defineProperty(obj, 'prop', { @@ -211,3 +210,13 @@ " property on the proxy target but the proxy did not return its actual" + " value (expected '53' but got '42')"); })(); + +(function test32BitIndex() { + var index = (1 << 31) + 1; + var obj = {}; + obj[index] = 42; + var p = new Proxy(obj, {}); + for (var i = 0; i < 3; ++i) { + assertEquals(42, p[index]); + } +})(); diff --git a/deps/v8/test/mjsunit/es6/proxies-set.js b/deps/v8/test/mjsunit/es6/proxies-set.js index 19f39f9a65..d56cec52f9 100644 --- a/deps/v8/test/mjsunit/es6/proxies-set.js +++ b/deps/v8/test/mjsunit/es6/proxies-set.js @@ -308,3 +308,101 @@ TestTrapReceiverArgument(strictReflectSet); } } })(); + + +function TestTargetProxy(mySet) { + var q = new Proxy({}, {}); + var proxy = new Proxy(q, { + set: function(t, k, v) { + return Reflect.set(t, k, v); + } + }); + + for (var p of properties) { + assertTrueIf(mySet.returnsBool, mySet(proxy, p, 42)); + assertSame(42, q[p]); + } +}; + +TestTargetProxy(sloppyDefaultSet); +TestTargetProxy(sloppyReflectSet); +TestTargetProxy(strictDefaultSet); +TestTargetProxy(strictReflectSet); + + +(function TestAccessorNoSet() { + var target = { + }; + Object.defineProperty(target, 'prop', { + get: function() { + return 42; + }, + configurable: false + }) + var handler = { + set: function() { return true; } + } + var proxy = new Proxy(target, handler); + assertThrows(function() { proxy.prop = 0; }, TypeError); +})(); + +(function TestProxyInPrototype() { + var handler = { + set: function(t, k, v) { + Reflect.set(t, k, v); + } + }; + var obj = {}; + var proxy = new Proxy(obj, handler); + var o = Object.create(proxy); + + for (var i = 0; i < 3; ++i) { + o.prop = 42 + i; + assertEquals(42 + i, obj.prop); + } +})(); + +(function TestProxyInPrototypeNoTrap() { + var handler = { + }; + var obj = {}; + var proxy = new Proxy(obj, handler); + var o = Object.create(proxy); + + for (var i = 0; i < 3; ++i) { + o.prop = 42 + i; + assertEquals(42 + i, o.prop); + assertEquals(undefined, obj.prop); + } +})(); + +// Note: this case is currently handled by runtime. +(function TestDifferentHolder() { + var obj = { + '1337': 100 + }; + var handler = { + set(target, name, value, receiver) { + if (name != '1337') return Reflect.set(target, name, value, receiver); + + assertSame(target, obj); + assertSame(receiver, p); + return target[name] = value; + } + }; + var p = new Proxy(obj, handler); + for (var i = 0; i < 3; ++i) { + assertEquals(42, p[1337] = 42); + } +})(); + +(function test32BitIndex() { + var index = (1 << 31) + 1; + var obj = {}; + obj[index] = 42; + var p = new Proxy(obj, {}); + for (var i = 0; i < 3; ++i) { + p[index] = 100; + assertEquals(100, obj[index]); + } +})(); diff --git a/deps/v8/test/mjsunit/es6/proxies.js b/deps/v8/test/mjsunit/es6/proxies.js index 3b9a4c5119..75a80a15bd 100644 --- a/deps/v8/test/mjsunit/es6/proxies.js +++ b/deps/v8/test/mjsunit/es6/proxies.js @@ -50,6 +50,19 @@ function TestWithFunctionProxy(test, x, y, z) { } // --------------------------------------------------------------------------- +// Test Proxy constructor properties + +(function TestProxyProperties() { + assertEquals(2, Proxy.length); + assertEquals(Function.__proto__, Proxy.__proto__); + assertEquals(null, Proxy.prototype); + assertEquals(undefined, Object.getOwnPropertyDescriptor(Proxy, "arguments")); + assertThrows(() => Proxy.arguments, TypeError); + assertEquals(undefined, Object.getOwnPropertyDescriptor(Proxy, "caller")); + assertThrows(() => Proxy.caller, TypeError); +})(); + +// --------------------------------------------------------------------------- // Getting property descriptors (Object.getOwnPropertyDescriptor). var key diff --git a/deps/v8/test/mjsunit/es6/regress/regress-777182.js b/deps/v8/test/mjsunit/es6/regress/regress-777182.js new file mode 100644 index 0000000000..6d6eb55c82 --- /dev/null +++ b/deps/v8/test/mjsunit/es6/regress/regress-777182.js @@ -0,0 +1,9 @@ +// Copyright 2017 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. + +// Flags: --enable-slow-asserts + +var __v_65159 = [1.3]; +__v_65159.length = 0; +new Int8Array(10).set(__v_65159); diff --git a/deps/v8/test/mjsunit/es6/string-html.js b/deps/v8/test/mjsunit/es6/string-html.js index 690830ba84..1eaa7b1eb1 100644 --- a/deps/v8/test/mjsunit/es6/string-html.js +++ b/deps/v8/test/mjsunit/es6/string-html.js @@ -8,7 +8,8 @@ assertEquals('_'.anchor('b'), '<a name="b">_</a>'); assertEquals('<'.anchor('<'), '<a name="<"><</a>'); assertEquals('_'.anchor(0x2A), '<a name="42">_</a>'); -assertEquals('_'.anchor('\x22'), '<a name=""">_</a>'); +assertEquals('_'.anchor('\x22\x22'), '<a name="""">_</a>'); +assertEquals('_'.anchor(), '<a name="undefined">_</a>'); assertEquals(String.prototype.anchor.call(0x2A, 0x2A), '<a name="42">42</a>'); assertThrows(function() { String.prototype.anchor.call(undefined); diff --git a/deps/v8/test/mjsunit/es6/string-repeat.js b/deps/v8/test/mjsunit/es6/string-repeat.js index d61aec066c..3649c5b09b 100644 --- a/deps/v8/test/mjsunit/es6/string-repeat.js +++ b/deps/v8/test/mjsunit/es6/string-repeat.js @@ -60,14 +60,19 @@ assertEquals("", "abc".repeat(0)); assertEquals("abcabc", "abc".repeat(2.0)); assertEquals("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "a".repeat(37)); +assertEquals("", "a".repeat(NaN)); assertThrows('"a".repeat(-1)', RangeError); assertThrows('"a".repeat(Number.POSITIVE_INFINITY)', RangeError); +assertThrows('"a".repeat(Number.NEGATIVE_INFINITY)', RangeError); assertThrows('"a".repeat(Math.pow(2, 30))', RangeError); assertThrows('"a".repeat(Math.pow(2, 40))', RangeError); +assertThrows('"a".repeat(-Math.pow(2, 40))', RangeError); // Handling empty strings assertThrows('"".repeat(-1)', RangeError); assertThrows('"".repeat(Number.POSITIVE_INFINITY)', RangeError); +assertThrows('"".repeat(Number.NEGATIVE_INFINITY)', RangeError); +assertThrows('"a".repeat(-Math.pow(2, 40))', RangeError); assertEquals("", "".repeat(Math.pow(2, 30))); assertEquals("", "".repeat(Math.pow(2, 40))); diff --git a/deps/v8/test/mjsunit/es6/typedarray-set-bytelength-not-smi.js b/deps/v8/test/mjsunit/es6/typedarray-set-bytelength-not-smi.js new file mode 100644 index 0000000000..1f842878dc --- /dev/null +++ b/deps/v8/test/mjsunit/es6/typedarray-set-bytelength-not-smi.js @@ -0,0 +1,21 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax --mock-arraybuffer-allocator + +(function TestBufferByteLengthNonSmi() { + const source_buffer_length = %_MaxSmi() + 1; + const source_buffer = new ArrayBuffer(source_buffer_length); + const source = new Uint16Array(source_buffer); + assertEquals(source_buffer_length, source_buffer.byteLength); + assertEquals(source_buffer_length / 2, source.length); + + const target_buffer_length = %_MaxSmi() - 1; + const target_buffer = new ArrayBuffer(target_buffer_length); + const target = new Uint16Array(target_buffer); + assertEquals(target_buffer_length, target_buffer.byteLength); + assertEquals(target_buffer_length / 2, target.length); + + assertThrows(() => target.set(source), RangeError); +})(); diff --git a/deps/v8/test/mjsunit/es6/typedarray.js b/deps/v8/test/mjsunit/es6/typedarray.js index 2f4c1b639d..5f4d3f0747 100644 --- a/deps/v8/test/mjsunit/es6/typedarray.js +++ b/deps/v8/test/mjsunit/es6/typedarray.js @@ -25,6 +25,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// Flags: --allow-natives-syntax + // ArrayBuffer function TestByteLength(param, expectedByteLength) { @@ -609,6 +611,103 @@ function TestTypedArraySet() { a101[0] = 42; b101.set(a101); assertArrayPrefix([42], b101); + + // Detached array buffer when accessing a source element + var a111 = new Int8Array(100); + var evilarr = new Array(100); + var detached = false; + evilarr[1] = { + [Symbol.toPrimitive]() { + %ArrayBufferNeuter(a111.buffer); + detached = true; + return 1; + } + }; + assertThrows(() => a111.set(evilarr), TypeError); + assertEquals(true, detached); + + // Detached array buffer when converting offset. + { + for (const klass of typedArrayConstructors) { + const xs = new klass(10); + let detached = false; + const offset = { + [Symbol.toPrimitive]() { + %ArrayBufferNeuter(xs.buffer); + detached = true; + return 0; + } + }; + assertThrows(() => xs.set(xs, offset), TypeError); + assertEquals(true, detached); + } + } + + // Detached JSTypedArray source argument. + { + for (const klass of typedArrayConstructors) { + const a = new klass(2); + for (let i = 0; i < a.length; i++) a[i] = i; + %ArrayBufferNeuter(a.buffer); + + const b = new klass(2); + assertThrows(() => b.set(a), TypeError); + } + } + + // Various offset edge cases. + { + for (const klass of typedArrayConstructors) { + const xs = new klass(10); + assertThrows(() => xs.set(xs, -1), RangeError); + assertThrows(() => xs.set(xs, -1 * 2**64), RangeError); + xs.set(xs, -0.0); + xs.set(xs, 0.0); + xs.set(xs, 0.5); + assertThrows(() => xs.set(xs, 2**64), RangeError); + } + } + + // Exhaustively test elements kind combinations with JSArray source arg. + { + const kSize = 3; + const targets = typedArrayConstructors.map(klass => new klass(kSize)); + const sources = [ [0,1,2] // PACKED_SMI + , [0,,2] // HOLEY_SMI + , [0.1,0.2,0.3] // PACKED_DOUBLE + , [0.1,,0.3] // HOLEY_DOUBLE + , [{},{},{}] // PACKED + , [{},,{}] // HOLEY + , [] // DICTIONARY (patched later) + ]; + + // Migrate to DICTIONARY_ELEMENTS. + Object.defineProperty(sources[6], 0, {}); + + assertTrue(%HasSmiElements(sources[0])); + assertTrue(%HasFastElements(sources[0]) && !%HasHoleyElements(sources[0])); + assertTrue(%HasSmiElements(sources[1])); + assertTrue(%HasFastElements(sources[1]) && %HasHoleyElements(sources[1])); + assertTrue(%HasDoubleElements(sources[2])); + assertTrue(%HasFastElements(sources[2]) && !%HasHoleyElements(sources[2])); + assertTrue(%HasDoubleElements(sources[3])); + assertTrue(%HasFastElements(sources[3]) && %HasHoleyElements(sources[3])); + assertTrue(%HasObjectElements(sources[4])); + assertTrue(%HasFastElements(sources[4]) && !%HasHoleyElements(sources[4])); + assertTrue(%HasObjectElements(sources[4])); + assertTrue(%HasFastElements(sources[4]) && !%HasHoleyElements(sources[4])); + assertTrue(%HasObjectElements(sources[5])); + assertTrue(%HasFastElements(sources[5]) && %HasHoleyElements(sources[5])); + assertTrue(%HasDictionaryElements(sources[6])); + + for (const target of targets) { + for (const source of sources) { + target.set(source); + %HeapObjectVerify(target); + %HeapObjectVerify(source); + } + } + } } TestTypedArraySet(); @@ -885,3 +984,12 @@ for(i = 0; i < typedArrayConstructors.length; i++) { e.message); } })(); + +// Regression test 761654 +assertThrows(function LargeSourceArray() { + let v0 = {}; + v0.length = 2 ** 32; // too large for uint32 + let a = new Int8Array(); + + a.set(v0); +}); diff --git a/deps/v8/test/mjsunit/function-bind.js b/deps/v8/test/mjsunit/function-bind.js index 826986943b..7d37da57d2 100644 --- a/deps/v8/test/mjsunit/function-bind.js +++ b/deps/v8/test/mjsunit/function-bind.js @@ -41,21 +41,25 @@ var f = foo.bind(foo); assertEquals([foo, 3, 1], f(1, 2, 3)); assertEquals(3, f.length); assertEquals("function () { [native code] }", f.toString()); +%HeapObjectVerify(f); f = foo.bind(foo, 1); assertEquals([foo, 3, 1], f(2, 3)); assertEquals(2, f.length); assertEquals("function () { [native code] }", f.toString()); +%HeapObjectVerify(f); f = foo.bind(foo, 1, 2); assertEquals([foo, 3, 1], f(3)); assertEquals(1, f.length); assertEquals("function () { [native code] }", f.toString()); +%HeapObjectVerify(f); f = foo.bind(foo, 1, 2, 3); assertEquals([foo, 3, 1], f()); assertEquals(0, f.length); assertEquals("function () { [native code] }", f.toString()); +%HeapObjectVerify(f); // Test that length works correctly even if more than the actual number // of arguments are given when binding. @@ -63,6 +67,7 @@ f = foo.bind(foo, 1, 2, 3, 4, 5, 6, 7, 8, 9); assertEquals([foo, 9, 1], f()); assertEquals(0, f.length); assertEquals("function () { [native code] }", f.toString()); +%HeapObjectVerify(f); // Use a different bound object. var obj = {x: 42, y: 43}; @@ -78,11 +83,13 @@ assertEquals(3, f_bound_this(1)) f = f_bound_this.bind(obj); assertEquals(2, f(1)); assertEquals(1, f.length); +%HeapObjectVerify(f); f = f_bound_this.bind(obj, 2); assertEquals(3, f()); assertEquals(0, f.length); assertEquals('[object Function]', Object.prototype.toString.call(f)); +%HeapObjectVerify(f); // Test chained binds. @@ -90,65 +97,80 @@ assertEquals('[object Function]', Object.prototype.toString.call(f)); // the same effect. f = foo.bind(foo); assertEquals([foo, 3, 1], f(1, 2, 3)); +%HeapObjectVerify(f); var not_foo = {}; f = foo.bind(foo).bind(not_foo).bind(not_foo).bind(not_foo); assertEquals([foo, 3, 1], f(1, 2, 3)); assertEquals(3, f.length); +%HeapObjectVerify(f); // Giving bound parameters should work at any place in the chain. f = foo.bind(foo, 1).bind(not_foo).bind(not_foo).bind(not_foo); assertEquals([foo, 3, 1], f(2, 3)); assertEquals(2, f.length); +%HeapObjectVerify(f); f = foo.bind(foo).bind(not_foo, 1).bind(not_foo).bind(not_foo); assertEquals([foo, 3, 1], f(2, 3)); assertEquals(2, f.length); +%HeapObjectVerify(f); f = foo.bind(foo).bind(not_foo).bind(not_foo,1 ).bind(not_foo); assertEquals([foo, 3, 1], f(2, 3)); assertEquals(2, f.length); +%HeapObjectVerify(f); f = foo.bind(foo).bind(not_foo).bind(not_foo).bind(not_foo, 1); assertEquals([foo, 3, 1], f(2, 3)); assertEquals(2, f.length); +%HeapObjectVerify(f); // Several parameters can be given, and given in different bind invocations. f = foo.bind(foo, 1, 2).bind(not_foo).bind(not_foo).bind(not_foo); assertEquals([foo, 3, 1], f(3)); assertEquals(1, f.length); +%HeapObjectVerify(f); f = foo.bind(foo).bind(not_foo, 1, 2).bind(not_foo).bind(not_foo); assertEquals([foo, 3, 1], f(1)); assertEquals(1, f.length); +%HeapObjectVerify(f); f = foo.bind(foo).bind(not_foo, 1, 2).bind(not_foo).bind(not_foo); assertEquals([foo, 3, 1], f(3)); assertEquals(1, f.length); +%HeapObjectVerify(f); f = foo.bind(foo).bind(not_foo).bind(not_foo, 1, 2).bind(not_foo); assertEquals([foo, 3, 1], f(1)); assertEquals(1, f.length); +%HeapObjectVerify(f); f = foo.bind(foo).bind(not_foo).bind(not_foo).bind(not_foo, 1, 2); assertEquals([foo, 3, 1], f(3)); assertEquals(1, f.length); +%HeapObjectVerify(f); f = foo.bind(foo, 1).bind(not_foo, 2).bind(not_foo).bind(not_foo); assertEquals([foo, 3, 1], f(3)); assertEquals(1, f.length); +%HeapObjectVerify(f); f = foo.bind(foo, 1).bind(not_foo).bind(not_foo, 2).bind(not_foo); assertEquals([foo, 3, 1], f(3)); assertEquals(1, f.length); +%HeapObjectVerify(f); f = foo.bind(foo, 1).bind(not_foo).bind(not_foo).bind(not_foo, 2); assertEquals([foo, 3, 1], f(3)); assertEquals(1, f.length); +%HeapObjectVerify(f); f = foo.bind(foo).bind(not_foo, 1).bind(not_foo).bind(not_foo, 2); assertEquals([foo, 3, 1], f(3)); assertEquals(1, f.length); +%HeapObjectVerify(f); // The wrong number of arguments can be given to bound functions too. f = foo.bind(foo); @@ -158,6 +180,7 @@ assertEquals([foo, 1, 1], f(1)); assertEquals([foo, 2, 1], f(1, 2)); assertEquals([foo, 3, 1], f(1, 2, 3)); assertEquals([foo, 4, 1], f(1, 2, 3, 4)); +%HeapObjectVerify(f); f = foo.bind(foo, 1); assertEquals(2, f.length); @@ -165,21 +188,25 @@ assertEquals([foo, 1, 1], f()); assertEquals([foo, 2, 1], f(2)); assertEquals([foo, 3, 1], f(2, 3)); assertEquals([foo, 4, 1], f(2, 3, 4)); +%HeapObjectVerify(f); f = foo.bind(foo, 1, 2); assertEquals(1, f.length); assertEquals([foo, 2, 1], f()); assertEquals([foo, 3, 1], f(3)); assertEquals([foo, 4, 1], f(3, 4)); +%HeapObjectVerify(f); f = foo.bind(foo, 1, 2, 3); assertEquals(0, f.length); assertEquals([foo, 3, 1], f()); assertEquals([foo, 4, 1], f(4)); +%HeapObjectVerify(f); f = foo.bind(foo, 1, 2, 3, 4); assertEquals(0, f.length); assertEquals([foo, 4, 1], f()); +%HeapObjectVerify(f); // Test constructor calls. @@ -194,24 +221,32 @@ var obj2 = new f(1,2,3); assertEquals(1, obj2.x); assertEquals(2, obj2.y); assertEquals(3, obj2.z); +%HeapObjectVerify(f); +%HeapObjectVerify(obj2); f = bar.bind(bar, 1); obj2 = new f(2,3); assertEquals(1, obj2.x); assertEquals(2, obj2.y); assertEquals(3, obj2.z); +%HeapObjectVerify(f); +%HeapObjectVerify(obj2); f = bar.bind(bar, 1, 2); obj2 = new f(3); assertEquals(1, obj2.x); assertEquals(2, obj2.y); assertEquals(3, obj2.z); +%HeapObjectVerify(f); +%HeapObjectVerify(obj2); f = bar.bind(bar, 1, 2, 3); obj2 = new f(); assertEquals(1, obj2.x); assertEquals(2, obj2.y); assertEquals(3, obj2.z); +%HeapObjectVerify(f); +%HeapObjectVerify(obj2); // Test bind chains when used as a constructor. @@ -220,6 +255,8 @@ obj2 = new f(); assertEquals(1, obj2.x); assertEquals(2, obj2.y); assertEquals(3, obj2.z); +%HeapObjectVerify(f); +%HeapObjectVerify(obj2); // Test obj2 is instanceof both bar and f. assertTrue(obj2 instanceof bar); @@ -235,22 +272,29 @@ assertTrue(obj3 instanceof f); assertFalse(obj3 instanceof foo); assertFalse(obj3 instanceof Function); assertFalse(obj3 instanceof String); +%HeapObjectVerify(f); +%HeapObjectVerify(obj3); // thisArg is converted to object. f = foo.bind(undefined); assertEquals([this, 0, undefined], f()); +%HeapObjectVerify(f); f = foo.bind(null); assertEquals([this, 0, undefined], f()); +%HeapObjectVerify(f); f = foo.bind(42); assertEquals([Object(42), 0, undefined], f()); +%HeapObjectVerify(f); f = foo.bind("foo"); assertEquals([Object("foo"), 0, undefined], f()); +%HeapObjectVerify(f); f = foo.bind(true); assertEquals([Object(true), 0, undefined], f()); +%HeapObjectVerify(f); // Strict functions don't convert thisArg. function soo(x, y, z) { @@ -260,18 +304,23 @@ function soo(x, y, z) { var s = soo.bind(undefined); assertEquals([undefined, 0, undefined], s()); +%HeapObjectVerify(s); s = soo.bind(null); assertEquals([null, 0, undefined], s()); +%HeapObjectVerify(s); s = soo.bind(42); assertEquals([42, 0, undefined], s()); +%HeapObjectVerify(s); s = soo.bind("foo"); assertEquals(["foo", 0, undefined], s()); +%HeapObjectVerify(s); s = soo.bind(true); assertEquals([true, 0, undefined], s()); +%HeapObjectVerify(s); // Test that .arguments and .caller are poisoned according to the ES5 spec. @@ -316,11 +365,14 @@ assertThrows(function() { f.arguments = 42; }, TypeError); Object.setPrototypeOf(fun, proto); var bound = fun.bind({}); assertEquals(proto, Object.getPrototypeOf(bound)); + %HeapObjectVerify(bound); var bound2 = fun.bind({}); assertTrue(%HaveSameMap(new bound, new bound2)); + %HeapObjectVerify(bound2); Object.setPrototypeOf(fun, null); bound = Function.prototype.bind.call(fun, {}); assertEquals(null, Object.getPrototypeOf(bound)); + %HeapObjectVerify(bound); })(); diff --git a/deps/v8/test/mjsunit/harmony/array-sort-comparefn.js b/deps/v8/test/mjsunit/harmony/array-sort-comparefn.js new file mode 100644 index 0000000000..1ae470a351 --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/array-sort-comparefn.js @@ -0,0 +1,38 @@ +// Copyright 2017 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. + +// Array.prototype.sort + TypedArray.prototype.sort: comparefn must be either a +// function or undefined. +// https://github.com/tc39/ecma262/pull/785 + +const types = [ + Array, + Int8Array, Uint8Array, + Int16Array, Uint16Array, + Int32Array, Uint32Array, + Uint8ClampedArray, + Float32Array, Float64Array, +]; + +for (const type of types) { + const array = new type(); + array[0] = 1; + array[1] = 2; + array[2] = 3; + + array.sort(); + array.sort(undefined); + array.sort(() => {}); + + assertThrows(() => { array.sort(null); }, TypeError); + assertThrows(() => { array.sort(true); }, TypeError); + assertThrows(() => { array.sort(false); }, TypeError); + assertThrows(() => { array.sort(''); }, TypeError); + assertThrows(() => { array.sort(0); }, TypeError); + assertThrows(() => { array.sort(42); }, TypeError); + assertThrows(() => { array.sort([]); }, TypeError); + assertThrows(() => { array.sort(/./); }, TypeError); + assertThrows(() => { array.sort({}); }, TypeError); + assertThrows(() => { array.sort(Symbol()); }, TypeError); +} diff --git a/deps/v8/test/mjsunit/harmony/bigint.js b/deps/v8/test/mjsunit/harmony/bigint.js new file mode 100644 index 0000000000..4406f12b11 --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/bigint.js @@ -0,0 +1,355 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax --harmony-bigint --no-opt + +'use strict' + +const zero = BigInt(0); +const another_zero = BigInt(0); +const one = BigInt(1); +const another_one = BigInt(1); +const two = BigInt(2); +const three = BigInt(3); +const six = BigInt(6); + +// BigInt +{ + assertSame(BigInt, BigInt.prototype.constructor) +} + +// typeof +{ + assertEquals(typeof zero, "bigint"); + assertEquals(typeof one, "bigint"); +} +{ + // TODO(neis): Enable once --no-opt can be removed. + // + // function Typeof(x) { return typeof x } + // assertEquals(Typeof(zero), "bigint"); + // assertEquals(Typeof(zero), "bigint"); + // %OptimizeFunctionOnNextCall(Typeof); + // assertEquals(Typeof(zero), "bigint"); +} + +// ToString +{ + assertEquals(String(zero), "0"); + assertEquals(String(one), "1"); +} + +// .toString(radix) +{ + // Single-digit BigInts: random-generated inputs close to kMaxInt. + // Expectations computed with the following Python program: + // def Format(x, base): + // s = "" + // while x > 0: + // s = "0123456789abcdefghijklmnopqrstuvwxyz"[x % base] + s + // x = x / base + // return s + assertEquals("10100110000100101000011100101", BigInt(0x14c250e5).toString(2)); + assertEquals("-110110100010011111001011111", BigInt(-0x6d13e5f).toString(2)); + assertEquals("1001222020000100000", BigInt(0x18c72873).toString(3)); + assertEquals("-1212101122110102020", BigInt(-0x2b19aebe).toString(3)); + assertEquals("120303133110120", BigInt(0x18cdf518).toString(4)); + assertEquals("-113203101020122", BigInt(-0x178d121a).toString(4)); + assertEquals("1323302233400", BigInt(0x18de6256).toString(5)); + assertEquals("-2301033210212", BigInt(-0x25f7f454).toString(5)); + assertEquals("131050115130", BigInt(0x211f0d5e).toString(6)); + assertEquals("-104353333321", BigInt(-0x186bbe91).toString(6)); + assertEquals("25466260221", BigInt(0x2f69f47e).toString(7)); + assertEquals("-31051540346", BigInt(-0x352c7efa).toString(7)); + assertEquals("5004630525", BigInt(0x28133155).toString(8)); + assertEquals("-7633240703", BigInt(-0x3e6d41c3).toString(8)); + assertEquals("705082365", BigInt(0x121f4264).toString(9)); + assertEquals("-780654431", BigInt(-0x1443b36e).toString(9)); + assertEquals("297019028", BigInt(0x11b42694).toString(10)); + assertEquals("-721151126", BigInt(-0x2afbe496).toString(10)); + assertEquals("312914074", BigInt(0x27ca6879).toString(11)); + assertEquals("-198025592", BigInt(-0x1813d3a7).toString(11)); + assertEquals("191370997", BigInt(0x2d14f083).toString(12)); + assertEquals("-1b8aab4a2", BigInt(-0x32b52efa).toString(12)); + assertEquals("7818062c", BigInt(0x1c84a48c).toString(13)); + assertEquals("-7529695b", BigInt(-0x1badffee).toString(13)); + assertEquals("6bc929c4", BigInt(0x2b0a91d0).toString(14)); + assertEquals("-63042008", BigInt(-0x270dff78).toString(14)); + assertEquals("5e8b8dec", BigInt(0x3cd27d7f).toString(15)); + assertEquals("-4005433d", BigInt(-0x28c0821a).toString(15)); + assertEquals("10b35ca3", BigInt(0x10b35ca3).toString(16)); + assertEquals("-23d4d9d6", BigInt(-0x23d4d9d6).toString(16)); + assertEquals("28c3d5e3", BigInt(0x3d75d48c).toString(17)); + assertEquals("-10c06328", BigInt(-0x1979b7f0).toString(17)); + assertEquals("eb8d349", BigInt(0x1dacf0a5).toString(18)); + assertEquals("-1217015h", BigInt(-0x28b3c23f).toString(18)); + assertEquals("1018520b", BigInt(0x357da01a).toString(19)); + assertEquals("-9c64e33", BigInt(-0x1b0e9571).toString(19)); + assertEquals("d7bf9ab", BigInt(0x3309daa3).toString(20)); + assertEquals("-58h0h9h", BigInt(-0x14c30c55).toString(20)); + assertEquals("64igi9h", BigInt(0x1fdd329c).toString(21)); + assertEquals("-45cbc4a", BigInt(-0x15cf9682).toString(21)); + assertEquals("7bi7d1h", BigInt(0x32f0dfe3).toString(22)); + assertEquals("-61j743l", BigInt(-0x291ff61f).toString(22)); + assertEquals("5g5gg25", BigInt(0x325a10bd).toString(23)); + assertEquals("-3359flb", BigInt(-0x1bb653c9).toString(23)); + assertEquals("392f5ec", BigInt(0x267ed69c).toString(24)); + assertEquals("-2ab3icb", BigInt(-0x1bbf7bab).toString(24)); + assertEquals("3jb2afo", BigInt(0x36f93c24).toString(25)); + assertEquals("-30bcheh", BigInt(-0x2bec76fa).toString(25)); + assertEquals("3845agk", BigInt(0x3d04bf64).toString(26)); + assertEquals("-1gpjl3g", BigInt(-0x1e720b1a).toString(26)); + assertEquals("20bpaf0", BigInt(0x2e8ff627).toString(27)); + assertEquals("-292i3c2", BigInt(-0x35f751fe).toString(27)); + assertEquals("266113k", BigInt(0x3fd26738).toString(28)); + assertEquals("-1eh16bo", BigInt(-0x2bb5726c).toString(28)); + assertEquals("19gj7qa", BigInt(0x2f28e8d8).toString(29)); + assertEquals("-13a0apf", BigInt(-0x278b4588).toString(29)); + assertEquals("iasrb8", BigInt(0x1a99b3be).toString(30)); + assertEquals("-frlhoc", BigInt(-0x17106f48).toString(30)); + assertEquals("bfe4p2", BigInt(0x139f1ea3).toString(31)); + assertEquals("-ioal1a", BigInt(-0x200e49fa).toString(31)); + assertEquals("m0v0kf", BigInt(0x2c0f828f).toString(32)); + assertEquals("-g4bab5", BigInt(-0x2045a965).toString(32)); + assertEquals("9i1kit", BigInt(0x16450a9f).toString(33)); + assertEquals("-fqb0e7", BigInt(-0x24d9e889).toString(33)); + assertEquals("gb9r6m", BigInt(0x2c3acf46).toString(34)); + assertEquals("-jcaemv", BigInt(-0x346f72b3).toString(34)); + assertEquals("cw4mbk", BigInt(0x2870cdcb).toString(35)); + assertEquals("-hw4eki", BigInt(-0x3817c29b).toString(35)); + assertEquals("alzwgj", BigInt(0x263e2c13).toString(36)); + assertEquals("-bo4ukz", BigInt(-0x2a0f97d3).toString(36)); + + // Multi-digit BigInts. + // Test parseInt/toString round trip on a list of randomly generated + // string representations of numbers in various bases. + var positive = [0, 0, // Skip base 0 and 1. + "1100110001100010110011110110010010001011100111100101111000111101100001000", + "1001200022210010220101120212021002011002201122200002211102120120021011020", + "1111113020012203332320220022231110130001001320122012131311333110012023232", + "4214313040222110434114402342013144321401424143322013320403411012033300312", + "5025302003542512450341430541203424555035430434034243510233043041501130015", + "6231052230016515343200525230300322104013130605414211331345043144525012021", + "1146340505617030644211355340006353546230356336306352536433054143503442135", + "7262360724624787621528668212168232276348417717770383567066203032200270570", + "7573792356581293501680046955899735043496925151216904903504319328753434194", + "4a627927557579898720a42647639128174a8689889766a219342133671449069a2235011", + "1a574a5848289924996342a32893380690322330393633b587ba5a15b7b82080222400464", + "5163304c74c387b7a443c92466688595b671a3329b42083b1499b0c10a74a9298a06c3a5a", + "4b63c834356a03c80946133284a709cbbc2a75022757207dc31c14abd4c160dc122327c17", + "d8d59cbb4ca2860de7c002eee4ab3c215b90069200d20dbdc0111cb1e1bab97e8c7609670", + "22d4b69398a7f848e6ae36798811cd1a63d90f340d8607f3ce5566c97c18468787eb2b9fd", + "1176gf69afd32cc105fa70c705927a384dbdb1g8d952f28028g31ebdc9e32a89f16e825ee", + "5d64b74f4d70632h4ee07h7c1e2da9125c42g2727f4b6d95e5cec6ga49566hh731ab5f544", + "7ff8cg7f05dd72916a09a4761ii7b0ibcg68ba39b10436f14efg76ge817317badcbi4gffc", + "6d7c4hci6cd72e4ja26j354i12i71gb0cbj12gi145j91h02hde3b72c65geb7ff9bi9d0c2b", + "c96997f50abe425d13a53kk4af631kg7db208ka5j5bfg8ca5f9c0bjf69j5kgg4jb5h7hi86", + "3g5fd800d9ib9j0i8all5jgb23dh9483ab6le5ad9g4kja8a0b3j5jbjfge7k5fffg2kbheee", + "9j1119d1cd61kmdm7kma105cki313f678fc3h25f4664281bbmg3fk97kfbh7d48j89j178ch", + "d2933cdc9jfe4hl3794kb3e13dg2lihad968ib9jg19dgf1fi482b27ji0d10c6kfkdge5764", + "bf6o0njkm1ij5in5nh7h94584bd80el02b07el5ojk9k9g0gn906do70gbbnckl048c0kdmao", + "8gb7jnge9p9cdgigo394oa33gfaenc3gnb53eceg4b8511gkkm88b0dod85e5bggpc861d7d5", + "qbbnqhkpleb4o8ndaddpc34h5b2iljn3jgnjdn5k57bi3n9i09hjle9hqgqdpgbnk499mak56", + "akg7e2976arn8i2m53gif0dp59bmfd7mk9erlg2qm3fc76da9glf397eh4ooij9il0nfl9gac", + "mehpbfrj5ah2ef3p2hl637gjp1pm5grqn4037pm1qfgfpr9cfljfc145hljehjjb48bb1n6en", + "rg6ik3agnb3p6t2rtja9h4il76i8fkqlt6gplap3fq6pfr7bbcfcp5ffncf3nm4kamap39hse", + "bk8rp9r9r8pltdqpb7euc6s9rcm33969pcq6uk3mtfoktt86di8589oacbam5tn29b9b6dq3j", + "npth8juld44rss3e57iigjg65po3d1h02heo4r103jmg3ocv89buqtgiov35k39rdf8j9t4ca", + "vrmqlwrrrd0uml1womae49jpa9tadh44fw7mucgk06l0uk4uqwuo37t6kwn7wwrm3a6oq081s", + "n5cft6gvufqd8iksquu2amghokk17gbtpguidc290af634p7k7rhmfu7bf1s62ej4megoa1j4", + "3v3gcrmlfc2tl0tefgkiogj41f6y2tmj9w5bxke8y03xqf49ox8gh9wbrhycrkluicqajtnur", + "z2m7b0sy2tzergtkqts5yj0dkrlfkxls81ijgxgfequizpntcwggv2d4rdzcncd0kj9mrmnrb", + ]; + var negative = [0, 0, // Skip base 0 and 1. + "-100010011110111010111111110001100100111010101000001011010010101100101000", + "-110012122000122102021210112200001000122011010120101201001122000002022102", + "-203210320111001002200122200001312300221100221321010300023323201113122333", + "-133042441230110320040323303341320302144241224443231311022240124413104131", + "-311325230504055004330150145105331121322231155401110315251422505233103112", + "-643153641664240231336166403516403454646560261062114326443664602606315326", + "-200057252627665476551635525303641543165622340301637556323453513664337277", + "-826688166214270516331644053744613530235020517172322840763172114078364165", + "-743042397390679269240157150971957535458122650450558451124173993544604852", + "-73528688500003573942a56a504a2996a1384129563098512a63196697975038692aaa63", + "-616576a2948a9029316290168b71137b027851639a0283150b125b664b74b767a3597805", + "-b875467540719b371b7a36047a7886872a5399c4c630c37149bc3182917a7a7c124475bb", + "-3860411b61d35977721bc81bd715c386c9b70a752940913d265505d8c7c5dd2624b591d7", + "-bad5dd79b083ee0da9a6296664e72c246d827762357116ae7076a22bb369acbc3a201d03", + "-f9b37352aff265124303942a463917a252ff1a2ff4a33777f490b4c103bdcd1a655dbe2c", + "-805fg8c74125214g383a8d8g573c49fa7c4035fbc6db61g5gb5g6beb8f90dae4a9a5g7cc", + "-70aae113459d3h5084b1gg209g3695d20e78d01gcbb71bh1bd4gdge31haf5hc02dghf14e", + "-c55a57haf47b7ih2gh6ea93098ig02b42icga6ead254e0aeeic7g53h5fd6637ge03b2e20", + "-e32f7204624ie596j731g72136cejc25ebbgb0140i4997fcdf477f021d86ci4e10db543a", + "-i7f32c817i3cac1c24c7786k6ig185f47cj1471ki6bb7agiae838027gjge9g59if9f88g6", + "-i30aha2030a9605c270h92e1ca3i02j996hl918gh52fbhb7i16ik1i919ieak3cj384kb61", + "-58jmem8e59li67aellid2083dabh4kh51ci1jg7c6a3k4l1hdgfkdha0fglfm4805kida5b9", + "-cl9iecjg9ak087cad4151lll44296heae2349g70fbjj37998m2ddn6427fgcl2aknhgn1a1", + "-alfjfhho4gf8bi4j2bi3743mhg2aache4c6jcinkmf5ddm7kf9gg350hlja16ealbdlk201j", + "-bhh1146ho3o2m3b839c565hbgjnhjh96oofbmdl7gn8h4f94kli94hkk180o79pc4d2l0721", + "-p00gknh7e05k6a3apg6i9lb46f4a9qeeiq1778ak8il5dcponk5gl2fiednb4pmo1agmoqph", + "-4j8lo4d4p508fnd2hkfb76e8ri81k6hq0op3pr14ca0cn96pccplk7rbahc9cdkdce1q16dn", + "-ednlo3ogf2i8annrel9rm323bpf00meed3oi47n0qrdgnd2n3il4bnsc9s2jd7loh44im8ra", + "-bjjg6fsbpcc2tc1o09m9r6fd6eoq5480har62a5offn9thcfahbno9kf9magl2akl0jgncj9", + "-sonuhat2h60glpbpej9jjado2s5l86122d26tudoc1d6aic2oitu793gk0mlac3dk1dufp1q", + "-i9pbvm53ubh8jqifuarauch8cbgk9cjsl6rlioka1phs1lskg1oosll23hjoli2subgr1rto", + "-w1ncn5t60b5dv669ekwnvk8n2g7djrsl8cdkwun8o3m5divc3jhnkp2381rhj70gc71a6wff", + "-buiq8v33p5ex44ps4s45enj6lrluivm19lcowkvntu72u0xguw13bxgxxe7mdlwt1a4qksae", + "-woiycfmea6i12r2yai49mf4lbd7w2jdoebiogfhnh1i4rwgox57obci8qbsfpb4w07nu19m5", + "-tbttuip1r6ioca6g6dw354o4m78qep9yh03nojx47yq29fqime6zstwllb74501qct8eskxn", + ]; + for (var base = 2; base <= 36; base++) { + var input = positive[base]; + assertEquals(input, BigInt.parseInt(input, base).toString(base)); + input = negative[base]; + assertEquals(input, BigInt.parseInt(input, base).toString(base)); + } +} + +// .parseInt +{ + assertEquals("hellobigint", BigInt.parseInt("hellobigint", 32).toString(32)); + assertEquals("abc", BigInt.parseInt("101010111100", 2).toString(16)); + // Detect "0x" prefix. + assertEquals("f00dcafe", BigInt.parseInt("0xf00dcafe").toString(16)); + // Default base is 10, trailing junk is skipped. + assertEquals("abc", BigInt.parseInt("2748junk").toString(16)); + // Objects are converted to string. + let obj = {toString: () => "0x12345"}; + assertEquals("12345", BigInt.parseInt(obj).toString(16)); + // Empty and invalid strings throw. + assertThrows("BigInt.parseInt('')", SyntaxError); + assertThrows("BigInt.parseInt('nope', 2)", SyntaxError); +} + +// .valueOf +{ + assertEquals(Object(zero).valueOf(), another_zero); + assertThrows(() => { return BigInt.prototype.valueOf.call("string"); }, + TypeError); + // TODO(jkummerow): Add tests for (new BigInt(...)).valueOf() when we + // can construct BigInt wrappers. +} + +// ToBoolean +{ + assertTrue(!zero); + assertFalse(!!zero); + assertTrue(!!!zero); + + assertFalse(!one); + assertTrue(!!one); + assertFalse(!!!one); +} + +// Strict equality +{ + assertTrue(zero === zero); + assertFalse(zero !== zero); + + assertTrue(zero === another_zero); + assertFalse(zero !== another_zero); + + assertFalse(zero === one); + assertTrue(zero !== one); + assertTrue(one !== zero); + assertFalse(one === zero); + + assertFalse(zero === 0); + assertTrue(zero !== 0); + assertFalse(0 === zero); + assertTrue(0 !== zero); +} + +// SameValue +{ + const obj = Object.defineProperty({}, 'foo', + {value: zero, writable: false, configurable: false}); + + assertTrue(Reflect.defineProperty(obj, 'foo', {value: zero})); + assertTrue(Reflect.defineProperty(obj, 'foo', {value: another_zero})); + assertFalse(Reflect.defineProperty(obj, 'foo', {value: one})); +} + +// SameValueZero +{ + assertTrue([zero].includes(zero)); + assertTrue([zero].includes(another_zero)); + + assertFalse([zero].includes(+0)); + assertFalse([zero].includes(-0)); + + assertFalse([+0].includes(zero)); + assertFalse([-0].includes(zero)); + + assertTrue([one].includes(one)); + assertTrue([one].includes(another_one)); + + assertFalse([one].includes(1)); + assertFalse([1].includes(one)); +}{ + assertTrue(new Set([zero]).has(zero)); + assertTrue(new Set([zero]).has(another_zero)); + + assertFalse(new Set([zero]).has(+0)); + assertFalse(new Set([zero]).has(-0)); + + assertFalse(new Set([+0]).has(zero)); + assertFalse(new Set([-0]).has(zero)); + + assertTrue(new Set([one]).has(one)); + assertTrue(new Set([one]).has(another_one)); +}{ + assertTrue(new Map([[zero, 42]]).has(zero)); + assertTrue(new Map([[zero, 42]]).has(another_zero)); + + assertFalse(new Map([[zero, 42]]).has(+0)); + assertFalse(new Map([[zero, 42]]).has(-0)); + + assertFalse(new Map([[+0, 42]]).has(zero)); + assertFalse(new Map([[-0, 42]]).has(zero)); + + assertTrue(new Map([[one, 42]]).has(one)); + assertTrue(new Map([[one, 42]]).has(another_one)); +} + +// Binary ops. +{ + assertTrue(one + two === three); + assertEquals("hello1", "hello" + one); + assertEquals("2hello", two + "hello"); + assertThrows("one + 2", TypeError); + assertThrows("2 + one", TypeError); + assertThrows("one + 0.5", TypeError); + assertThrows("0.5 + one", TypeError); + assertThrows("one + null", TypeError); + assertThrows("null + one", TypeError); + + assertTrue(three - two === one); + assertThrows("two - 1", TypeError); + assertThrows("2 - one", TypeError); + assertThrows("two - 0.5", TypeError); + assertThrows("2.5 - one", TypeError); + + assertTrue(two * three === six); + assertThrows("two * 1", TypeError); + assertThrows("1 * two", TypeError); + assertThrows("two * 1.5", TypeError); + assertThrows("1.5 * two", TypeError); + + assertTrue(six / three === two); + assertThrows("six / 3", TypeError); + assertThrows("3 / three", TypeError); + assertThrows("six / 0.5", TypeError); + assertThrows("0.5 / six", TypeError); + assertThrows("zero / zero", RangeError); + assertThrows("zero / 0", TypeError); + + assertTrue(three % two === one); + assertThrows("three % 2", TypeError); + assertThrows("3 % two", TypeError); + assertThrows("three % 2.5", TypeError); + assertThrows("3.5 % two", TypeError); + assertThrows("three % zero", RangeError); + assertThrows("three % 0", TypeError); +} diff --git a/deps/v8/test/mjsunit/harmony/modules-import-large.js b/deps/v8/test/mjsunit/harmony/modules-import-large.js new file mode 100644 index 0000000000..250a41bd82 --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/modules-import-large.js @@ -0,0 +1,1120 @@ +// Copyright 2017 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. +// +// MODULE + +// Flags: --allow-natives-syntax + +import * as m1 from "modules-skip-large1.js"; +import * as m2 from "modules-skip-large2.js"; + +assertFalse(%HasFastProperties(m1)); +assertFalse(%HasFastProperties(m2)); +assertFalse(%HaveSameMap(m1, m2)); + +function verify(m) { + assertEquals(m.a0, 0); + assertEquals(m.a1, 1); + assertEquals(m.a2, 2); + assertEquals(m.a3, 3); + assertEquals(m.a4, 4); + assertEquals(m.a5, 5); + assertEquals(m.a6, 6); + assertEquals(m.a7, 7); + assertEquals(m.a8, 8); + assertEquals(m.a9, 9); + assertEquals(m.a10, 10); + assertEquals(m.a11, 11); + assertEquals(m.a12, 12); + assertEquals(m.a13, 13); + assertEquals(m.a14, 14); + assertEquals(m.a15, 15); + assertEquals(m.a16, 16); + assertEquals(m.a17, 17); + assertEquals(m.a18, 18); + assertEquals(m.a19, 19); + assertEquals(m.a20, 20); + assertEquals(m.a21, 21); + assertEquals(m.a22, 22); + assertEquals(m.a23, 23); + assertEquals(m.a24, 24); + assertEquals(m.a25, 25); + assertEquals(m.a26, 26); + assertEquals(m.a27, 27); + assertEquals(m.a28, 28); + assertEquals(m.a29, 29); + assertEquals(m.a30, 30); + assertEquals(m.a31, 31); + assertEquals(m.a32, 32); + assertEquals(m.a33, 33); + assertEquals(m.a34, 34); + assertEquals(m.a35, 35); + assertEquals(m.a36, 36); + assertEquals(m.a37, 37); + assertEquals(m.a38, 38); + assertEquals(m.a39, 39); + assertEquals(m.a40, 40); + assertEquals(m.a41, 41); + assertEquals(m.a42, 42); + assertEquals(m.a43, 43); + assertEquals(m.a44, 44); + assertEquals(m.a45, 45); + assertEquals(m.a46, 46); + assertEquals(m.a47, 47); + assertEquals(m.a48, 48); + assertEquals(m.a49, 49); + assertEquals(m.a50, 50); + assertEquals(m.a51, 51); + assertEquals(m.a52, 52); + assertEquals(m.a53, 53); + assertEquals(m.a54, 54); + assertEquals(m.a55, 55); + assertEquals(m.a56, 56); + assertEquals(m.a57, 57); + assertEquals(m.a58, 58); + assertEquals(m.a59, 59); + assertEquals(m.a60, 60); + assertEquals(m.a61, 61); + assertEquals(m.a62, 62); + assertEquals(m.a63, 63); + assertEquals(m.a64, 64); + assertEquals(m.a65, 65); + assertEquals(m.a66, 66); + assertEquals(m.a67, 67); + assertEquals(m.a68, 68); + assertEquals(m.a69, 69); + assertEquals(m.a70, 70); + assertEquals(m.a71, 71); + assertEquals(m.a72, 72); + assertEquals(m.a73, 73); + assertEquals(m.a74, 74); + assertEquals(m.a75, 75); + assertEquals(m.a76, 76); + assertEquals(m.a77, 77); + assertEquals(m.a78, 78); + assertEquals(m.a79, 79); + assertEquals(m.a80, 80); + assertEquals(m.a81, 81); + assertEquals(m.a82, 82); + assertEquals(m.a83, 83); + assertEquals(m.a84, 84); + assertEquals(m.a85, 85); + assertEquals(m.a86, 86); + assertEquals(m.a87, 87); + assertEquals(m.a88, 88); + assertEquals(m.a89, 89); + assertEquals(m.a90, 90); + assertEquals(m.a91, 91); + assertEquals(m.a92, 92); + assertEquals(m.a93, 93); + assertEquals(m.a94, 94); + assertEquals(m.a95, 95); + assertEquals(m.a96, 96); + assertEquals(m.a97, 97); + assertEquals(m.a98, 98); + assertEquals(m.a99, 99); + assertEquals(m.a100, 100); + assertEquals(m.a101, 101); + assertEquals(m.a102, 102); + assertEquals(m.a103, 103); + assertEquals(m.a104, 104); + assertEquals(m.a105, 105); + assertEquals(m.a106, 106); + assertEquals(m.a107, 107); + assertEquals(m.a108, 108); + assertEquals(m.a109, 109); + assertEquals(m.a110, 110); + assertEquals(m.a111, 111); + assertEquals(m.a112, 112); + assertEquals(m.a113, 113); + assertEquals(m.a114, 114); + assertEquals(m.a115, 115); + assertEquals(m.a116, 116); + assertEquals(m.a117, 117); + assertEquals(m.a118, 118); + assertEquals(m.a119, 119); + assertEquals(m.a120, 120); + assertEquals(m.a121, 121); + assertEquals(m.a122, 122); + assertEquals(m.a123, 123); + assertEquals(m.a124, 124); + assertEquals(m.a125, 125); + assertEquals(m.a126, 126); + assertEquals(m.a127, 127); + assertEquals(m.a128, 128); + assertEquals(m.a129, 129); + assertEquals(m.a130, 130); + assertEquals(m.a131, 131); + assertEquals(m.a132, 132); + assertEquals(m.a133, 133); + assertEquals(m.a134, 134); + assertEquals(m.a135, 135); + assertEquals(m.a136, 136); + assertEquals(m.a137, 137); + assertEquals(m.a138, 138); + assertEquals(m.a139, 139); + assertEquals(m.a140, 140); + assertEquals(m.a141, 141); + assertEquals(m.a142, 142); + assertEquals(m.a143, 143); + assertEquals(m.a144, 144); + assertEquals(m.a145, 145); + assertEquals(m.a146, 146); + assertEquals(m.a147, 147); + assertEquals(m.a148, 148); + assertEquals(m.a149, 149); + assertEquals(m.a150, 150); + assertEquals(m.a151, 151); + assertEquals(m.a152, 152); + assertEquals(m.a153, 153); + assertEquals(m.a154, 154); + assertEquals(m.a155, 155); + assertEquals(m.a156, 156); + assertEquals(m.a157, 157); + assertEquals(m.a158, 158); + assertEquals(m.a159, 159); + assertEquals(m.a160, 160); + assertEquals(m.a161, 161); + assertEquals(m.a162, 162); + assertEquals(m.a163, 163); + assertEquals(m.a164, 164); + assertEquals(m.a165, 165); + assertEquals(m.a166, 166); + assertEquals(m.a167, 167); + assertEquals(m.a168, 168); + assertEquals(m.a169, 169); + assertEquals(m.a170, 170); + assertEquals(m.a171, 171); + assertEquals(m.a172, 172); + assertEquals(m.a173, 173); + assertEquals(m.a174, 174); + assertEquals(m.a175, 175); + assertEquals(m.a176, 176); + assertEquals(m.a177, 177); + assertEquals(m.a178, 178); + assertEquals(m.a179, 179); + assertEquals(m.a180, 180); + assertEquals(m.a181, 181); + assertEquals(m.a182, 182); + assertEquals(m.a183, 183); + assertEquals(m.a184, 184); + assertEquals(m.a185, 185); + assertEquals(m.a186, 186); + assertEquals(m.a187, 187); + assertEquals(m.a188, 188); + assertEquals(m.a189, 189); + assertEquals(m.a190, 190); + assertEquals(m.a191, 191); + assertEquals(m.a192, 192); + assertEquals(m.a193, 193); + assertEquals(m.a194, 194); + assertEquals(m.a195, 195); + assertEquals(m.a196, 196); + assertEquals(m.a197, 197); + assertEquals(m.a198, 198); + assertEquals(m.a199, 199); + assertEquals(m.a200, 200); + assertEquals(m.a201, 201); + assertEquals(m.a202, 202); + assertEquals(m.a203, 203); + assertEquals(m.a204, 204); + assertEquals(m.a205, 205); + assertEquals(m.a206, 206); + assertEquals(m.a207, 207); + assertEquals(m.a208, 208); + assertEquals(m.a209, 209); + assertEquals(m.a210, 210); + assertEquals(m.a211, 211); + assertEquals(m.a212, 212); + assertEquals(m.a213, 213); + assertEquals(m.a214, 214); + assertEquals(m.a215, 215); + assertEquals(m.a216, 216); + assertEquals(m.a217, 217); + assertEquals(m.a218, 218); + assertEquals(m.a219, 219); + assertEquals(m.a220, 220); + assertEquals(m.a221, 221); + assertEquals(m.a222, 222); + assertEquals(m.a223, 223); + assertEquals(m.a224, 224); + assertEquals(m.a225, 225); + assertEquals(m.a226, 226); + assertEquals(m.a227, 227); + assertEquals(m.a228, 228); + assertEquals(m.a229, 229); + assertEquals(m.a230, 230); + assertEquals(m.a231, 231); + assertEquals(m.a232, 232); + assertEquals(m.a233, 233); + assertEquals(m.a234, 234); + assertEquals(m.a235, 235); + assertEquals(m.a236, 236); + assertEquals(m.a237, 237); + assertEquals(m.a238, 238); + assertEquals(m.a239, 239); + assertEquals(m.a240, 240); + assertEquals(m.a241, 241); + assertEquals(m.a242, 242); + assertEquals(m.a243, 243); + assertEquals(m.a244, 244); + assertEquals(m.a245, 245); + assertEquals(m.a246, 246); + assertEquals(m.a247, 247); + assertEquals(m.a248, 248); + assertEquals(m.a249, 249); + assertEquals(m.a250, 250); + assertEquals(m.a251, 251); + assertEquals(m.a252, 252); + assertEquals(m.a253, 253); + assertEquals(m.a254, 254); + assertEquals(m.a255, 255); + assertEquals(m.a256, 256); + assertEquals(m.a257, 257); + assertEquals(m.a258, 258); + assertEquals(m.a259, 259); + assertEquals(m.a260, 260); + assertEquals(m.a261, 261); + assertEquals(m.a262, 262); + assertEquals(m.a263, 263); + assertEquals(m.a264, 264); + assertEquals(m.a265, 265); + assertEquals(m.a266, 266); + assertEquals(m.a267, 267); + assertEquals(m.a268, 268); + assertEquals(m.a269, 269); + assertEquals(m.a270, 270); + assertEquals(m.a271, 271); + assertEquals(m.a272, 272); + assertEquals(m.a273, 273); + assertEquals(m.a274, 274); + assertEquals(m.a275, 275); + assertEquals(m.a276, 276); + assertEquals(m.a277, 277); + assertEquals(m.a278, 278); + assertEquals(m.a279, 279); + assertEquals(m.a280, 280); + assertEquals(m.a281, 281); + assertEquals(m.a282, 282); + assertEquals(m.a283, 283); + assertEquals(m.a284, 284); + assertEquals(m.a285, 285); + assertEquals(m.a286, 286); + assertEquals(m.a287, 287); + assertEquals(m.a288, 288); + assertEquals(m.a289, 289); + assertEquals(m.a290, 290); + assertEquals(m.a291, 291); + assertEquals(m.a292, 292); + assertEquals(m.a293, 293); + assertEquals(m.a294, 294); + assertEquals(m.a295, 295); + assertEquals(m.a296, 296); + assertEquals(m.a297, 297); + assertEquals(m.a298, 298); + assertEquals(m.a299, 299); + assertEquals(m.a300, 300); + assertEquals(m.a301, 301); + assertEquals(m.a302, 302); + assertEquals(m.a303, 303); + assertEquals(m.a304, 304); + assertEquals(m.a305, 305); + assertEquals(m.a306, 306); + assertEquals(m.a307, 307); + assertEquals(m.a308, 308); + assertEquals(m.a309, 309); + assertEquals(m.a310, 310); + assertEquals(m.a311, 311); + assertEquals(m.a312, 312); + assertEquals(m.a313, 313); + assertEquals(m.a314, 314); + assertEquals(m.a315, 315); + assertEquals(m.a316, 316); + assertEquals(m.a317, 317); + assertEquals(m.a318, 318); + assertEquals(m.a319, 319); + assertEquals(m.a320, 320); + assertEquals(m.a321, 321); + assertEquals(m.a322, 322); + assertEquals(m.a323, 323); + assertEquals(m.a324, 324); + assertEquals(m.a325, 325); + assertEquals(m.a326, 326); + assertEquals(m.a327, 327); + assertEquals(m.a328, 328); + assertEquals(m.a329, 329); + assertEquals(m.a330, 330); + assertEquals(m.a331, 331); + assertEquals(m.a332, 332); + assertEquals(m.a333, 333); + assertEquals(m.a334, 334); + assertEquals(m.a335, 335); + assertEquals(m.a336, 336); + assertEquals(m.a337, 337); + assertEquals(m.a338, 338); + assertEquals(m.a339, 339); + assertEquals(m.a340, 340); + assertEquals(m.a341, 341); + assertEquals(m.a342, 342); + assertEquals(m.a343, 343); + assertEquals(m.a344, 344); + assertEquals(m.a345, 345); + assertEquals(m.a346, 346); + assertEquals(m.a347, 347); + assertEquals(m.a348, 348); + assertEquals(m.a349, 349); + assertEquals(m.a350, 350); + assertEquals(m.a351, 351); + assertEquals(m.a352, 352); + assertEquals(m.a353, 353); + assertEquals(m.a354, 354); + assertEquals(m.a355, 355); + assertEquals(m.a356, 356); + assertEquals(m.a357, 357); + assertEquals(m.a358, 358); + assertEquals(m.a359, 359); + assertEquals(m.a360, 360); + assertEquals(m.a361, 361); + assertEquals(m.a362, 362); + assertEquals(m.a363, 363); + assertEquals(m.a364, 364); + assertEquals(m.a365, 365); + assertEquals(m.a366, 366); + assertEquals(m.a367, 367); + assertEquals(m.a368, 368); + assertEquals(m.a369, 369); + assertEquals(m.a370, 370); + assertEquals(m.a371, 371); + assertEquals(m.a372, 372); + assertEquals(m.a373, 373); + assertEquals(m.a374, 374); + assertEquals(m.a375, 375); + assertEquals(m.a376, 376); + assertEquals(m.a377, 377); + assertEquals(m.a378, 378); + assertEquals(m.a379, 379); + assertEquals(m.a380, 380); + assertEquals(m.a381, 381); + assertEquals(m.a382, 382); + assertEquals(m.a383, 383); + assertEquals(m.a384, 384); + assertEquals(m.a385, 385); + assertEquals(m.a386, 386); + assertEquals(m.a387, 387); + assertEquals(m.a388, 388); + assertEquals(m.a389, 389); + assertEquals(m.a390, 390); + assertEquals(m.a391, 391); + assertEquals(m.a392, 392); + assertEquals(m.a393, 393); + assertEquals(m.a394, 394); + assertEquals(m.a395, 395); + assertEquals(m.a396, 396); + assertEquals(m.a397, 397); + assertEquals(m.a398, 398); + assertEquals(m.a399, 399); + assertEquals(m.a400, 400); + assertEquals(m.a401, 401); + assertEquals(m.a402, 402); + assertEquals(m.a403, 403); + assertEquals(m.a404, 404); + assertEquals(m.a405, 405); + assertEquals(m.a406, 406); + assertEquals(m.a407, 407); + assertEquals(m.a408, 408); + assertEquals(m.a409, 409); + assertEquals(m.a410, 410); + assertEquals(m.a411, 411); + assertEquals(m.a412, 412); + assertEquals(m.a413, 413); + assertEquals(m.a414, 414); + assertEquals(m.a415, 415); + assertEquals(m.a416, 416); + assertEquals(m.a417, 417); + assertEquals(m.a418, 418); + assertEquals(m.a419, 419); + assertEquals(m.a420, 420); + assertEquals(m.a421, 421); + assertEquals(m.a422, 422); + assertEquals(m.a423, 423); + assertEquals(m.a424, 424); + assertEquals(m.a425, 425); + assertEquals(m.a426, 426); + assertEquals(m.a427, 427); + assertEquals(m.a428, 428); + assertEquals(m.a429, 429); + assertEquals(m.a430, 430); + assertEquals(m.a431, 431); + assertEquals(m.a432, 432); + assertEquals(m.a433, 433); + assertEquals(m.a434, 434); + assertEquals(m.a435, 435); + assertEquals(m.a436, 436); + assertEquals(m.a437, 437); + assertEquals(m.a438, 438); + assertEquals(m.a439, 439); + assertEquals(m.a440, 440); + assertEquals(m.a441, 441); + assertEquals(m.a442, 442); + assertEquals(m.a443, 443); + assertEquals(m.a444, 444); + assertEquals(m.a445, 445); + assertEquals(m.a446, 446); + assertEquals(m.a447, 447); + assertEquals(m.a448, 448); + assertEquals(m.a449, 449); + assertEquals(m.a450, 450); + assertEquals(m.a451, 451); + assertEquals(m.a452, 452); + assertEquals(m.a453, 453); + assertEquals(m.a454, 454); + assertEquals(m.a455, 455); + assertEquals(m.a456, 456); + assertEquals(m.a457, 457); + assertEquals(m.a458, 458); + assertEquals(m.a459, 459); + assertEquals(m.a460, 460); + assertEquals(m.a461, 461); + assertEquals(m.a462, 462); + assertEquals(m.a463, 463); + assertEquals(m.a464, 464); + assertEquals(m.a465, 465); + assertEquals(m.a466, 466); + assertEquals(m.a467, 467); + assertEquals(m.a468, 468); + assertEquals(m.a469, 469); + assertEquals(m.a470, 470); + assertEquals(m.a471, 471); + assertEquals(m.a472, 472); + assertEquals(m.a473, 473); + assertEquals(m.a474, 474); + assertEquals(m.a475, 475); + assertEquals(m.a476, 476); + assertEquals(m.a477, 477); + assertEquals(m.a478, 478); + assertEquals(m.a479, 479); + assertEquals(m.a480, 480); + assertEquals(m.a481, 481); + assertEquals(m.a482, 482); + assertEquals(m.a483, 483); + assertEquals(m.a484, 484); + assertEquals(m.a485, 485); + assertEquals(m.a486, 486); + assertEquals(m.a487, 487); + assertEquals(m.a488, 488); + assertEquals(m.a489, 489); + assertEquals(m.a490, 490); + assertEquals(m.a491, 491); + assertEquals(m.a492, 492); + assertEquals(m.a493, 493); + assertEquals(m.a494, 494); + assertEquals(m.a495, 495); + assertEquals(m.a496, 496); + assertEquals(m.a497, 497); + assertEquals(m.a498, 498); + assertEquals(m.a499, 499); + assertEquals(m.a500, 500); + assertEquals(m.a501, 501); + assertEquals(m.a502, 502); + assertEquals(m.a503, 503); + assertEquals(m.a504, 504); + assertEquals(m.a505, 505); + assertEquals(m.a506, 506); + assertEquals(m.a507, 507); + assertEquals(m.a508, 508); + assertEquals(m.a509, 509); + assertEquals(m.a510, 510); + assertEquals(m.a511, 511); + assertEquals(m.a512, 512); + assertEquals(m.a513, 513); + assertEquals(m.a514, 514); + assertEquals(m.a515, 515); + assertEquals(m.a516, 516); + assertEquals(m.a517, 517); + assertEquals(m.a518, 518); + assertEquals(m.a519, 519); + assertEquals(m.a520, 520); + assertEquals(m.a521, 521); + assertEquals(m.a522, 522); + assertEquals(m.a523, 523); + assertEquals(m.a524, 524); + assertEquals(m.a525, 525); + assertEquals(m.a526, 526); + assertEquals(m.a527, 527); + assertEquals(m.a528, 528); + assertEquals(m.a529, 529); + assertEquals(m.a530, 530); + assertEquals(m.a531, 531); + assertEquals(m.a532, 532); + assertEquals(m.a533, 533); + assertEquals(m.a534, 534); + assertEquals(m.a535, 535); + assertEquals(m.a536, 536); + assertEquals(m.a537, 537); + assertEquals(m.a538, 538); + assertEquals(m.a539, 539); + assertEquals(m.a540, 540); + assertEquals(m.a541, 541); + assertEquals(m.a542, 542); + assertEquals(m.a543, 543); + assertEquals(m.a544, 544); + assertEquals(m.a545, 545); + assertEquals(m.a546, 546); + assertEquals(m.a547, 547); + assertEquals(m.a548, 548); + assertEquals(m.a549, 549); + assertEquals(m.a550, 550); + assertEquals(m.a551, 551); + assertEquals(m.a552, 552); + assertEquals(m.a553, 553); + assertEquals(m.a554, 554); + assertEquals(m.a555, 555); + assertEquals(m.a556, 556); + assertEquals(m.a557, 557); + assertEquals(m.a558, 558); + assertEquals(m.a559, 559); + assertEquals(m.a560, 560); + assertEquals(m.a561, 561); + assertEquals(m.a562, 562); + assertEquals(m.a563, 563); + assertEquals(m.a564, 564); + assertEquals(m.a565, 565); + assertEquals(m.a566, 566); + assertEquals(m.a567, 567); + assertEquals(m.a568, 568); + assertEquals(m.a569, 569); + assertEquals(m.a570, 570); + assertEquals(m.a571, 571); + assertEquals(m.a572, 572); + assertEquals(m.a573, 573); + assertEquals(m.a574, 574); + assertEquals(m.a575, 575); + assertEquals(m.a576, 576); + assertEquals(m.a577, 577); + assertEquals(m.a578, 578); + assertEquals(m.a579, 579); + assertEquals(m.a580, 580); + assertEquals(m.a581, 581); + assertEquals(m.a582, 582); + assertEquals(m.a583, 583); + assertEquals(m.a584, 584); + assertEquals(m.a585, 585); + assertEquals(m.a586, 586); + assertEquals(m.a587, 587); + assertEquals(m.a588, 588); + assertEquals(m.a589, 589); + assertEquals(m.a590, 590); + assertEquals(m.a591, 591); + assertEquals(m.a592, 592); + assertEquals(m.a593, 593); + assertEquals(m.a594, 594); + assertEquals(m.a595, 595); + assertEquals(m.a596, 596); + assertEquals(m.a597, 597); + assertEquals(m.a598, 598); + assertEquals(m.a599, 599); + assertEquals(m.a600, 600); + assertEquals(m.a601, 601); + assertEquals(m.a602, 602); + assertEquals(m.a603, 603); + assertEquals(m.a604, 604); + assertEquals(m.a605, 605); + assertEquals(m.a606, 606); + assertEquals(m.a607, 607); + assertEquals(m.a608, 608); + assertEquals(m.a609, 609); + assertEquals(m.a610, 610); + assertEquals(m.a611, 611); + assertEquals(m.a612, 612); + assertEquals(m.a613, 613); + assertEquals(m.a614, 614); + assertEquals(m.a615, 615); + assertEquals(m.a616, 616); + assertEquals(m.a617, 617); + assertEquals(m.a618, 618); + assertEquals(m.a619, 619); + assertEquals(m.a620, 620); + assertEquals(m.a621, 621); + assertEquals(m.a622, 622); + assertEquals(m.a623, 623); + assertEquals(m.a624, 624); + assertEquals(m.a625, 625); + assertEquals(m.a626, 626); + assertEquals(m.a627, 627); + assertEquals(m.a628, 628); + assertEquals(m.a629, 629); + assertEquals(m.a630, 630); + assertEquals(m.a631, 631); + assertEquals(m.a632, 632); + assertEquals(m.a633, 633); + assertEquals(m.a634, 634); + assertEquals(m.a635, 635); + assertEquals(m.a636, 636); + assertEquals(m.a637, 637); + assertEquals(m.a638, 638); + assertEquals(m.a639, 639); + assertEquals(m.a640, 640); + assertEquals(m.a641, 641); + assertEquals(m.a642, 642); + assertEquals(m.a643, 643); + assertEquals(m.a644, 644); + assertEquals(m.a645, 645); + assertEquals(m.a646, 646); + assertEquals(m.a647, 647); + assertEquals(m.a648, 648); + assertEquals(m.a649, 649); + assertEquals(m.a650, 650); + assertEquals(m.a651, 651); + assertEquals(m.a652, 652); + assertEquals(m.a653, 653); + assertEquals(m.a654, 654); + assertEquals(m.a655, 655); + assertEquals(m.a656, 656); + assertEquals(m.a657, 657); + assertEquals(m.a658, 658); + assertEquals(m.a659, 659); + assertEquals(m.a660, 660); + assertEquals(m.a661, 661); + assertEquals(m.a662, 662); + assertEquals(m.a663, 663); + assertEquals(m.a664, 664); + assertEquals(m.a665, 665); + assertEquals(m.a666, 666); + assertEquals(m.a667, 667); + assertEquals(m.a668, 668); + assertEquals(m.a669, 669); + assertEquals(m.a670, 670); + assertEquals(m.a671, 671); + assertEquals(m.a672, 672); + assertEquals(m.a673, 673); + assertEquals(m.a674, 674); + assertEquals(m.a675, 675); + assertEquals(m.a676, 676); + assertEquals(m.a677, 677); + assertEquals(m.a678, 678); + assertEquals(m.a679, 679); + assertEquals(m.a680, 680); + assertEquals(m.a681, 681); + assertEquals(m.a682, 682); + assertEquals(m.a683, 683); + assertEquals(m.a684, 684); + assertEquals(m.a685, 685); + assertEquals(m.a686, 686); + assertEquals(m.a687, 687); + assertEquals(m.a688, 688); + assertEquals(m.a689, 689); + assertEquals(m.a690, 690); + assertEquals(m.a691, 691); + assertEquals(m.a692, 692); + assertEquals(m.a693, 693); + assertEquals(m.a694, 694); + assertEquals(m.a695, 695); + assertEquals(m.a696, 696); + assertEquals(m.a697, 697); + assertEquals(m.a698, 698); + assertEquals(m.a699, 699); + assertEquals(m.a700, 700); + assertEquals(m.a701, 701); + assertEquals(m.a702, 702); + assertEquals(m.a703, 703); + assertEquals(m.a704, 704); + assertEquals(m.a705, 705); + assertEquals(m.a706, 706); + assertEquals(m.a707, 707); + assertEquals(m.a708, 708); + assertEquals(m.a709, 709); + assertEquals(m.a710, 710); + assertEquals(m.a711, 711); + assertEquals(m.a712, 712); + assertEquals(m.a713, 713); + assertEquals(m.a714, 714); + assertEquals(m.a715, 715); + assertEquals(m.a716, 716); + assertEquals(m.a717, 717); + assertEquals(m.a718, 718); + assertEquals(m.a719, 719); + assertEquals(m.a720, 720); + assertEquals(m.a721, 721); + assertEquals(m.a722, 722); + assertEquals(m.a723, 723); + assertEquals(m.a724, 724); + assertEquals(m.a725, 725); + assertEquals(m.a726, 726); + assertEquals(m.a727, 727); + assertEquals(m.a728, 728); + assertEquals(m.a729, 729); + assertEquals(m.a730, 730); + assertEquals(m.a731, 731); + assertEquals(m.a732, 732); + assertEquals(m.a733, 733); + assertEquals(m.a734, 734); + assertEquals(m.a735, 735); + assertEquals(m.a736, 736); + assertEquals(m.a737, 737); + assertEquals(m.a738, 738); + assertEquals(m.a739, 739); + assertEquals(m.a740, 740); + assertEquals(m.a741, 741); + assertEquals(m.a742, 742); + assertEquals(m.a743, 743); + assertEquals(m.a744, 744); + assertEquals(m.a745, 745); + assertEquals(m.a746, 746); + assertEquals(m.a747, 747); + assertEquals(m.a748, 748); + assertEquals(m.a749, 749); + assertEquals(m.a750, 750); + assertEquals(m.a751, 751); + assertEquals(m.a752, 752); + assertEquals(m.a753, 753); + assertEquals(m.a754, 754); + assertEquals(m.a755, 755); + assertEquals(m.a756, 756); + assertEquals(m.a757, 757); + assertEquals(m.a758, 758); + assertEquals(m.a759, 759); + assertEquals(m.a760, 760); + assertEquals(m.a761, 761); + assertEquals(m.a762, 762); + assertEquals(m.a763, 763); + assertEquals(m.a764, 764); + assertEquals(m.a765, 765); + assertEquals(m.a766, 766); + assertEquals(m.a767, 767); + assertEquals(m.a768, 768); + assertEquals(m.a769, 769); + assertEquals(m.a770, 770); + assertEquals(m.a771, 771); + assertEquals(m.a772, 772); + assertEquals(m.a773, 773); + assertEquals(m.a774, 774); + assertEquals(m.a775, 775); + assertEquals(m.a776, 776); + assertEquals(m.a777, 777); + assertEquals(m.a778, 778); + assertEquals(m.a779, 779); + assertEquals(m.a780, 780); + assertEquals(m.a781, 781); + assertEquals(m.a782, 782); + assertEquals(m.a783, 783); + assertEquals(m.a784, 784); + assertEquals(m.a785, 785); + assertEquals(m.a786, 786); + assertEquals(m.a787, 787); + assertEquals(m.a788, 788); + assertEquals(m.a789, 789); + assertEquals(m.a790, 790); + assertEquals(m.a791, 791); + assertEquals(m.a792, 792); + assertEquals(m.a793, 793); + assertEquals(m.a794, 794); + assertEquals(m.a795, 795); + assertEquals(m.a796, 796); + assertEquals(m.a797, 797); + assertEquals(m.a798, 798); + assertEquals(m.a799, 799); + assertEquals(m.a800, 800); + assertEquals(m.a801, 801); + assertEquals(m.a802, 802); + assertEquals(m.a803, 803); + assertEquals(m.a804, 804); + assertEquals(m.a805, 805); + assertEquals(m.a806, 806); + assertEquals(m.a807, 807); + assertEquals(m.a808, 808); + assertEquals(m.a809, 809); + assertEquals(m.a810, 810); + assertEquals(m.a811, 811); + assertEquals(m.a812, 812); + assertEquals(m.a813, 813); + assertEquals(m.a814, 814); + assertEquals(m.a815, 815); + assertEquals(m.a816, 816); + assertEquals(m.a817, 817); + assertEquals(m.a818, 818); + assertEquals(m.a819, 819); + assertEquals(m.a820, 820); + assertEquals(m.a821, 821); + assertEquals(m.a822, 822); + assertEquals(m.a823, 823); + assertEquals(m.a824, 824); + assertEquals(m.a825, 825); + assertEquals(m.a826, 826); + assertEquals(m.a827, 827); + assertEquals(m.a828, 828); + assertEquals(m.a829, 829); + assertEquals(m.a830, 830); + assertEquals(m.a831, 831); + assertEquals(m.a832, 832); + assertEquals(m.a833, 833); + assertEquals(m.a834, 834); + assertEquals(m.a835, 835); + assertEquals(m.a836, 836); + assertEquals(m.a837, 837); + assertEquals(m.a838, 838); + assertEquals(m.a839, 839); + assertEquals(m.a840, 840); + assertEquals(m.a841, 841); + assertEquals(m.a842, 842); + assertEquals(m.a843, 843); + assertEquals(m.a844, 844); + assertEquals(m.a845, 845); + assertEquals(m.a846, 846); + assertEquals(m.a847, 847); + assertEquals(m.a848, 848); + assertEquals(m.a849, 849); + assertEquals(m.a850, 850); + assertEquals(m.a851, 851); + assertEquals(m.a852, 852); + assertEquals(m.a853, 853); + assertEquals(m.a854, 854); + assertEquals(m.a855, 855); + assertEquals(m.a856, 856); + assertEquals(m.a857, 857); + assertEquals(m.a858, 858); + assertEquals(m.a859, 859); + assertEquals(m.a860, 860); + assertEquals(m.a861, 861); + assertEquals(m.a862, 862); + assertEquals(m.a863, 863); + assertEquals(m.a864, 864); + assertEquals(m.a865, 865); + assertEquals(m.a866, 866); + assertEquals(m.a867, 867); + assertEquals(m.a868, 868); + assertEquals(m.a869, 869); + assertEquals(m.a870, 870); + assertEquals(m.a871, 871); + assertEquals(m.a872, 872); + assertEquals(m.a873, 873); + assertEquals(m.a874, 874); + assertEquals(m.a875, 875); + assertEquals(m.a876, 876); + assertEquals(m.a877, 877); + assertEquals(m.a878, 878); + assertEquals(m.a879, 879); + assertEquals(m.a880, 880); + assertEquals(m.a881, 881); + assertEquals(m.a882, 882); + assertEquals(m.a883, 883); + assertEquals(m.a884, 884); + assertEquals(m.a885, 885); + assertEquals(m.a886, 886); + assertEquals(m.a887, 887); + assertEquals(m.a888, 888); + assertEquals(m.a889, 889); + assertEquals(m.a890, 890); + assertEquals(m.a891, 891); + assertEquals(m.a892, 892); + assertEquals(m.a893, 893); + assertEquals(m.a894, 894); + assertEquals(m.a895, 895); + assertEquals(m.a896, 896); + assertEquals(m.a897, 897); + assertEquals(m.a898, 898); + assertEquals(m.a899, 899); + assertEquals(m.a900, 900); + assertEquals(m.a901, 901); + assertEquals(m.a902, 902); + assertEquals(m.a903, 903); + assertEquals(m.a904, 904); + assertEquals(m.a905, 905); + assertEquals(m.a906, 906); + assertEquals(m.a907, 907); + assertEquals(m.a908, 908); + assertEquals(m.a909, 909); + assertEquals(m.a910, 910); + assertEquals(m.a911, 911); + assertEquals(m.a912, 912); + assertEquals(m.a913, 913); + assertEquals(m.a914, 914); + assertEquals(m.a915, 915); + assertEquals(m.a916, 916); + assertEquals(m.a917, 917); + assertEquals(m.a918, 918); + assertEquals(m.a919, 919); + assertEquals(m.a920, 920); + assertEquals(m.a921, 921); + assertEquals(m.a922, 922); + assertEquals(m.a923, 923); + assertEquals(m.a924, 924); + assertEquals(m.a925, 925); + assertEquals(m.a926, 926); + assertEquals(m.a927, 927); + assertEquals(m.a928, 928); + assertEquals(m.a929, 929); + assertEquals(m.a930, 930); + assertEquals(m.a931, 931); + assertEquals(m.a932, 932); + assertEquals(m.a933, 933); + assertEquals(m.a934, 934); + assertEquals(m.a935, 935); + assertEquals(m.a936, 936); + assertEquals(m.a937, 937); + assertEquals(m.a938, 938); + assertEquals(m.a939, 939); + assertEquals(m.a940, 940); + assertEquals(m.a941, 941); + assertEquals(m.a942, 942); + assertEquals(m.a943, 943); + assertEquals(m.a944, 944); + assertEquals(m.a945, 945); + assertEquals(m.a946, 946); + assertEquals(m.a947, 947); + assertEquals(m.a948, 948); + assertEquals(m.a949, 949); + assertEquals(m.a950, 950); + assertEquals(m.a951, 951); + assertEquals(m.a952, 952); + assertEquals(m.a953, 953); + assertEquals(m.a954, 954); + assertEquals(m.a955, 955); + assertEquals(m.a956, 956); + assertEquals(m.a957, 957); + assertEquals(m.a958, 958); + assertEquals(m.a959, 959); + assertEquals(m.a960, 960); + assertEquals(m.a961, 961); + assertEquals(m.a962, 962); + assertEquals(m.a963, 963); + assertEquals(m.a964, 964); + assertEquals(m.a965, 965); + assertEquals(m.a966, 966); + assertEquals(m.a967, 967); + assertEquals(m.a968, 968); + assertEquals(m.a969, 969); + assertEquals(m.a970, 970); + assertEquals(m.a971, 971); + assertEquals(m.a972, 972); + assertEquals(m.a973, 973); + assertEquals(m.a974, 974); + assertEquals(m.a975, 975); + assertEquals(m.a976, 976); + assertEquals(m.a977, 977); + assertEquals(m.a978, 978); + assertEquals(m.a979, 979); + assertEquals(m.a980, 980); + assertEquals(m.a981, 981); + assertEquals(m.a982, 982); + assertEquals(m.a983, 983); + assertEquals(m.a984, 984); + assertEquals(m.a985, 985); + assertEquals(m.a986, 986); + assertEquals(m.a987, 987); + assertEquals(m.a988, 988); + assertEquals(m.a989, 989); + assertEquals(m.a990, 990); + assertEquals(m.a991, 991); + assertEquals(m.a992, 992); + assertEquals(m.a993, 993); + assertEquals(m.a994, 994); + assertEquals(m.a995, 995); + assertEquals(m.a996, 996); + assertEquals(m.a997, 997); + assertEquals(m.a998, 998); + assertEquals(m.a999, 999); + assertEquals(m.a1000, 1000); + assertEquals(m.a1001, 1001); + assertEquals(m.a1002, 1002); + assertEquals(m.a1003, 1003); + assertEquals(m.a1004, 1004); + assertEquals(m.a1005, 1005); + assertEquals(m.a1006, 1006); + assertEquals(m.a1007, 1007); + assertEquals(m.a1008, 1008); + assertEquals(m.a1009, 1009); + assertEquals(m.a1010, 1010); + assertEquals(m.a1011, 1011); + assertEquals(m.a1012, 1012); + assertEquals(m.a1013, 1013); + assertEquals(m.a1014, 1014); + assertEquals(m.a1015, 1015); + assertEquals(m.a1016, 1016); + assertEquals(m.a1017, 1017); + assertEquals(m.a1018, 1018); + assertEquals(m.a1019, 1019); + assertEquals(m.a1020, 1020); + assertEquals(m.a1021, 1021); + assertEquals(m.a1022, 1022); + assertEquals(m.a1023, 1023); + assertEquals(m.a1024, 1024); + assertEquals(m.a1025, 1025); + assertEquals(m.a1026, 1026); + assertEquals(m.a1027, 1027); + assertEquals(m.a1028, 1028); + assertEquals(m.a1029, 1029); + assertEquals(m.a1030, 1030); + assertEquals(m.a1031, 1031); + assertEquals(m.a1032, 1032); + assertEquals(m.a1033, 1033); + assertEquals(m.a1034, 1034); + assertEquals(m.a1035, 1035); + assertEquals(m.a1036, 1036); + assertEquals(m.a1037, 1037); + assertEquals(m.a1038, 1038); + assertEquals(m.a1039, 1039); + assertEquals(m.a1040, 1040); + assertEquals(m.a1041, 1041); + assertEquals(m.a1042, 1042); + assertEquals(m.a1043, 1043); + assertEquals(m.a1044, 1044); + assertEquals(m.a1045, 1045); + assertEquals(m.a1046, 1046); + assertEquals(m.a1047, 1047); + assertEquals(m.a1048, 1048); + assertEquals(m.a1049, 1049); + assertEquals(m.a1050, 1050); + assertEquals(m.a1051, 1051); + assertEquals(m.a1052, 1052); + assertEquals(m.a1053, 1053); + assertEquals(m.a1054, 1054); + assertEquals(m.a1055, 1055); + assertEquals(m.a1056, 1056); + assertEquals(m.a1057, 1057); + assertEquals(m.a1058, 1058); + assertEquals(m.a1059, 1059); + assertEquals(m.a1060, 1060); + assertEquals(m.a1061, 1061); + assertEquals(m.a1062, 1062); + assertEquals(m.a1063, 1063); + assertEquals(m.a1064, 1064); + assertEquals(m.a1065, 1065); + assertEquals(m.a1066, 1066); + assertEquals(m.a1067, 1067); + assertEquals(m.a1068, 1068); + assertEquals(m.a1069, 1069); + assertEquals(m.a1070, 1070); + assertEquals(m.a1071, 1071); + assertEquals(m.a1072, 1072); + assertEquals(m.a1073, 1073); + assertEquals(m.a1074, 1074); + assertEquals(m.a1075, 1075); + assertEquals(m.a1076, 1076); + assertEquals(m.a1077, 1077); + assertEquals(m.a1078, 1078); + assertEquals(m.a1079, 1079); + assertEquals(m.a1080, 1080); + assertEquals(m.a1081, 1081); + assertEquals(m.a1082, 1082); + assertEquals(m.a1083, 1083); + assertEquals(m.a1084, 1084); + assertEquals(m.a1085, 1085); + assertEquals(m.a1086, 1086); + assertEquals(m.a1087, 1087); + assertEquals(m.a1088, 1088); + assertEquals(m.a1089, 1089); + assertEquals(m.a1090, 1090); + assertEquals(m.a1091, 1091); + assertEquals(m.a1092, 1092); + assertEquals(m.a1093, 1093); + assertEquals(m.a1094, 1094); + assertEquals(m.a1095, 1095); + assertEquals(m.a1096, 1096); + assertEquals(m.a1097, 1097); + assertEquals(m.a1098, 1098); + assertEquals(m.a1099, 1099); +} +verify(m1); // Uninitialized. +verify(m1); // Premonomorphic. +verify(m2); // Monomorphic. diff --git a/deps/v8/test/mjsunit/harmony/modules-skip-large1.js b/deps/v8/test/mjsunit/harmony/modules-skip-large1.js new file mode 100644 index 0000000000..e643df32a9 --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/modules-skip-large1.js @@ -0,0 +1,2204 @@ +// Copyright 2017 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. + +export let a0 = 0; +export let a1 = 1; +export let a2 = 2; +export let a3 = 3; +export let a4 = 4; +export let a5 = 5; +export let a6 = 6; +export let a7 = 7; +export let a8 = 8; +export let a9 = 9; +export let a10 = 10; +export let a11 = 11; +export let a12 = 12; +export let a13 = 13; +export let a14 = 14; +export let a15 = 15; +export let a16 = 16; +export let a17 = 17; +export let a18 = 18; +export let a19 = 19; +export let a20 = 20; +export let a21 = 21; +export let a22 = 22; +export let a23 = 23; +export let a24 = 24; +export let a25 = 25; +export let a26 = 26; +export let a27 = 27; +export let a28 = 28; +export let a29 = 29; +export let a30 = 30; +export let a31 = 31; +export let a32 = 32; +export let a33 = 33; +export let a34 = 34; +export let a35 = 35; +export let a36 = 36; +export let a37 = 37; +export let a38 = 38; +export let a39 = 39; +export let a40 = 40; +export let a41 = 41; +export let a42 = 42; +export let a43 = 43; +export let a44 = 44; +export let a45 = 45; +export let a46 = 46; +export let a47 = 47; +export let a48 = 48; +export let a49 = 49; +export let a50 = 50; +export let a51 = 51; +export let a52 = 52; +export let a53 = 53; +export let a54 = 54; +export let a55 = 55; +export let a56 = 56; +export let a57 = 57; +export let a58 = 58; +export let a59 = 59; +export let a60 = 60; +export let a61 = 61; +export let a62 = 62; +export let a63 = 63; +export let a64 = 64; +export let a65 = 65; +export let a66 = 66; +export let a67 = 67; +export let a68 = 68; +export let a69 = 69; +export let a70 = 70; +export let a71 = 71; +export let a72 = 72; +export let a73 = 73; +export let a74 = 74; +export let a75 = 75; +export let a76 = 76; +export let a77 = 77; +export let a78 = 78; +export let a79 = 79; +export let a80 = 80; +export let a81 = 81; +export let a82 = 82; +export let a83 = 83; +export let a84 = 84; +export let a85 = 85; +export let a86 = 86; +export let a87 = 87; +export let a88 = 88; +export let a89 = 89; +export let a90 = 90; +export let a91 = 91; +export let a92 = 92; +export let a93 = 93; +export let a94 = 94; +export let a95 = 95; +export let a96 = 96; +export let a97 = 97; +export let a98 = 98; +export let a99 = 99; +export let a100 = 100; +export let a101 = 101; +export let a102 = 102; +export let a103 = 103; +export let a104 = 104; +export let a105 = 105; +export let a106 = 106; +export let a107 = 107; +export let a108 = 108; +export let a109 = 109; +export let a110 = 110; +export let a111 = 111; +export let a112 = 112; +export let a113 = 113; +export let a114 = 114; +export let a115 = 115; +export let a116 = 116; +export let a117 = 117; +export let a118 = 118; +export let a119 = 119; +export let a120 = 120; +export let a121 = 121; +export let a122 = 122; +export let a123 = 123; +export let a124 = 124; +export let a125 = 125; +export let a126 = 126; +export let a127 = 127; +export let a128 = 128; +export let a129 = 129; +export let a130 = 130; +export let a131 = 131; +export let a132 = 132; +export let a133 = 133; +export let a134 = 134; +export let a135 = 135; +export let a136 = 136; +export let a137 = 137; +export let a138 = 138; +export let a139 = 139; +export let a140 = 140; +export let a141 = 141; +export let a142 = 142; +export let a143 = 143; +export let a144 = 144; +export let a145 = 145; +export let a146 = 146; +export let a147 = 147; +export let a148 = 148; +export let a149 = 149; +export let a150 = 150; +export let a151 = 151; +export let a152 = 152; +export let a153 = 153; +export let a154 = 154; +export let a155 = 155; +export let a156 = 156; +export let a157 = 157; +export let a158 = 158; +export let a159 = 159; +export let a160 = 160; +export let a161 = 161; +export let a162 = 162; +export let a163 = 163; +export let a164 = 164; +export let a165 = 165; +export let a166 = 166; +export let a167 = 167; +export let a168 = 168; +export let a169 = 169; +export let a170 = 170; +export let a171 = 171; +export let a172 = 172; +export let a173 = 173; +export let a174 = 174; +export let a175 = 175; +export let a176 = 176; +export let a177 = 177; +export let a178 = 178; +export let a179 = 179; +export let a180 = 180; +export let a181 = 181; +export let a182 = 182; +export let a183 = 183; +export let a184 = 184; +export let a185 = 185; +export let a186 = 186; +export let a187 = 187; +export let a188 = 188; +export let a189 = 189; +export let a190 = 190; +export let a191 = 191; +export let a192 = 192; +export let a193 = 193; +export let a194 = 194; +export let a195 = 195; +export let a196 = 196; +export let a197 = 197; +export let a198 = 198; +export let a199 = 199; +export let a200 = 200; +export let a201 = 201; +export let a202 = 202; +export let a203 = 203; +export let a204 = 204; +export let a205 = 205; +export let a206 = 206; +export let a207 = 207; +export let a208 = 208; +export let a209 = 209; +export let a210 = 210; +export let a211 = 211; +export let a212 = 212; +export let a213 = 213; +export let a214 = 214; +export let a215 = 215; +export let a216 = 216; +export let a217 = 217; +export let a218 = 218; +export let a219 = 219; +export let a220 = 220; +export let a221 = 221; +export let a222 = 222; +export let a223 = 223; +export let a224 = 224; +export let a225 = 225; +export let a226 = 226; +export let a227 = 227; +export let a228 = 228; +export let a229 = 229; +export let a230 = 230; +export let a231 = 231; +export let a232 = 232; +export let a233 = 233; +export let a234 = 234; +export let a235 = 235; +export let a236 = 236; +export let a237 = 237; +export let a238 = 238; +export let a239 = 239; +export let a240 = 240; +export let a241 = 241; +export let a242 = 242; +export let a243 = 243; +export let a244 = 244; +export let a245 = 245; +export let a246 = 246; +export let a247 = 247; +export let a248 = 248; +export let a249 = 249; +export let a250 = 250; +export let a251 = 251; +export let a252 = 252; +export let a253 = 253; +export let a254 = 254; +export let a255 = 255; +export let a256 = 256; +export let a257 = 257; +export let a258 = 258; +export let a259 = 259; +export let a260 = 260; +export let a261 = 261; +export let a262 = 262; +export let a263 = 263; +export let a264 = 264; +export let a265 = 265; +export let a266 = 266; +export let a267 = 267; +export let a268 = 268; +export let a269 = 269; +export let a270 = 270; +export let a271 = 271; +export let a272 = 272; +export let a273 = 273; +export let a274 = 274; +export let a275 = 275; +export let a276 = 276; +export let a277 = 277; +export let a278 = 278; +export let a279 = 279; +export let a280 = 280; +export let a281 = 281; +export let a282 = 282; +export let a283 = 283; +export let a284 = 284; +export let a285 = 285; +export let a286 = 286; +export let a287 = 287; +export let a288 = 288; +export let a289 = 289; +export let a290 = 290; +export let a291 = 291; +export let a292 = 292; +export let a293 = 293; +export let a294 = 294; +export let a295 = 295; +export let a296 = 296; +export let a297 = 297; +export let a298 = 298; +export let a299 = 299; +export let a300 = 300; +export let a301 = 301; +export let a302 = 302; +export let a303 = 303; +export let a304 = 304; +export let a305 = 305; +export let a306 = 306; +export let a307 = 307; +export let a308 = 308; +export let a309 = 309; +export let a310 = 310; +export let a311 = 311; +export let a312 = 312; +export let a313 = 313; +export let a314 = 314; +export let a315 = 315; +export let a316 = 316; +export let a317 = 317; +export let a318 = 318; +export let a319 = 319; +export let a320 = 320; +export let a321 = 321; +export let a322 = 322; +export let a323 = 323; +export let a324 = 324; +export let a325 = 325; +export let a326 = 326; +export let a327 = 327; +export let a328 = 328; +export let a329 = 329; +export let a330 = 330; +export let a331 = 331; +export let a332 = 332; +export let a333 = 333; +export let a334 = 334; +export let a335 = 335; +export let a336 = 336; +export let a337 = 337; +export let a338 = 338; +export let a339 = 339; +export let a340 = 340; +export let a341 = 341; +export let a342 = 342; +export let a343 = 343; +export let a344 = 344; +export let a345 = 345; +export let a346 = 346; +export let a347 = 347; +export let a348 = 348; +export let a349 = 349; +export let a350 = 350; +export let a351 = 351; +export let a352 = 352; +export let a353 = 353; +export let a354 = 354; +export let a355 = 355; +export let a356 = 356; +export let a357 = 357; +export let a358 = 358; +export let a359 = 359; +export let a360 = 360; +export let a361 = 361; +export let a362 = 362; +export let a363 = 363; +export let a364 = 364; +export let a365 = 365; +export let a366 = 366; +export let a367 = 367; +export let a368 = 368; +export let a369 = 369; +export let a370 = 370; +export let a371 = 371; +export let a372 = 372; +export let a373 = 373; +export let a374 = 374; +export let a375 = 375; +export let a376 = 376; +export let a377 = 377; +export let a378 = 378; +export let a379 = 379; +export let a380 = 380; +export let a381 = 381; +export let a382 = 382; +export let a383 = 383; +export let a384 = 384; +export let a385 = 385; +export let a386 = 386; +export let a387 = 387; +export let a388 = 388; +export let a389 = 389; +export let a390 = 390; +export let a391 = 391; +export let a392 = 392; +export let a393 = 393; +export let a394 = 394; +export let a395 = 395; +export let a396 = 396; +export let a397 = 397; +export let a398 = 398; +export let a399 = 399; +export let a400 = 400; +export let a401 = 401; +export let a402 = 402; +export let a403 = 403; +export let a404 = 404; +export let a405 = 405; +export let a406 = 406; +export let a407 = 407; +export let a408 = 408; +export let a409 = 409; +export let a410 = 410; +export let a411 = 411; +export let a412 = 412; +export let a413 = 413; +export let a414 = 414; +export let a415 = 415; +export let a416 = 416; +export let a417 = 417; +export let a418 = 418; +export let a419 = 419; +export let a420 = 420; +export let a421 = 421; +export let a422 = 422; +export let a423 = 423; +export let a424 = 424; +export let a425 = 425; +export let a426 = 426; +export let a427 = 427; +export let a428 = 428; +export let a429 = 429; +export let a430 = 430; +export let a431 = 431; +export let a432 = 432; +export let a433 = 433; +export let a434 = 434; +export let a435 = 435; +export let a436 = 436; +export let a437 = 437; +export let a438 = 438; +export let a439 = 439; +export let a440 = 440; +export let a441 = 441; +export let a442 = 442; +export let a443 = 443; +export let a444 = 444; +export let a445 = 445; +export let a446 = 446; +export let a447 = 447; +export let a448 = 448; +export let a449 = 449; +export let a450 = 450; +export let a451 = 451; +export let a452 = 452; +export let a453 = 453; +export let a454 = 454; +export let a455 = 455; +export let a456 = 456; +export let a457 = 457; +export let a458 = 458; +export let a459 = 459; +export let a460 = 460; +export let a461 = 461; +export let a462 = 462; +export let a463 = 463; +export let a464 = 464; +export let a465 = 465; +export let a466 = 466; +export let a467 = 467; +export let a468 = 468; +export let a469 = 469; +export let a470 = 470; +export let a471 = 471; +export let a472 = 472; +export let a473 = 473; +export let a474 = 474; +export let a475 = 475; +export let a476 = 476; +export let a477 = 477; +export let a478 = 478; +export let a479 = 479; +export let a480 = 480; +export let a481 = 481; +export let a482 = 482; +export let a483 = 483; +export let a484 = 484; +export let a485 = 485; +export let a486 = 486; +export let a487 = 487; +export let a488 = 488; +export let a489 = 489; +export let a490 = 490; +export let a491 = 491; +export let a492 = 492; +export let a493 = 493; +export let a494 = 494; +export let a495 = 495; +export let a496 = 496; +export let a497 = 497; +export let a498 = 498; +export let a499 = 499; +export let a500 = 500; +export let a501 = 501; +export let a502 = 502; +export let a503 = 503; +export let a504 = 504; +export let a505 = 505; +export let a506 = 506; +export let a507 = 507; +export let a508 = 508; +export let a509 = 509; +export let a510 = 510; +export let a511 = 511; +export let a512 = 512; +export let a513 = 513; +export let a514 = 514; +export let a515 = 515; +export let a516 = 516; +export let a517 = 517; +export let a518 = 518; +export let a519 = 519; +export let a520 = 520; +export let a521 = 521; +export let a522 = 522; +export let a523 = 523; +export let a524 = 524; +export let a525 = 525; +export let a526 = 526; +export let a527 = 527; +export let a528 = 528; +export let a529 = 529; +export let a530 = 530; +export let a531 = 531; +export let a532 = 532; +export let a533 = 533; +export let a534 = 534; +export let a535 = 535; +export let a536 = 536; +export let a537 = 537; +export let a538 = 538; +export let a539 = 539; +export let a540 = 540; +export let a541 = 541; +export let a542 = 542; +export let a543 = 543; +export let a544 = 544; +export let a545 = 545; +export let a546 = 546; +export let a547 = 547; +export let a548 = 548; +export let a549 = 549; +export let a550 = 550; +export let a551 = 551; +export let a552 = 552; +export let a553 = 553; +export let a554 = 554; +export let a555 = 555; +export let a556 = 556; +export let a557 = 557; +export let a558 = 558; +export let a559 = 559; +export let a560 = 560; +export let a561 = 561; +export let a562 = 562; +export let a563 = 563; +export let a564 = 564; +export let a565 = 565; +export let a566 = 566; +export let a567 = 567; +export let a568 = 568; +export let a569 = 569; +export let a570 = 570; +export let a571 = 571; +export let a572 = 572; +export let a573 = 573; +export let a574 = 574; +export let a575 = 575; +export let a576 = 576; +export let a577 = 577; +export let a578 = 578; +export let a579 = 579; +export let a580 = 580; +export let a581 = 581; +export let a582 = 582; +export let a583 = 583; +export let a584 = 584; +export let a585 = 585; +export let a586 = 586; +export let a587 = 587; +export let a588 = 588; +export let a589 = 589; +export let a590 = 590; +export let a591 = 591; +export let a592 = 592; +export let a593 = 593; +export let a594 = 594; +export let a595 = 595; +export let a596 = 596; +export let a597 = 597; +export let a598 = 598; +export let a599 = 599; +export let a600 = 600; +export let a601 = 601; +export let a602 = 602; +export let a603 = 603; +export let a604 = 604; +export let a605 = 605; +export let a606 = 606; +export let a607 = 607; +export let a608 = 608; +export let a609 = 609; +export let a610 = 610; +export let a611 = 611; +export let a612 = 612; +export let a613 = 613; +export let a614 = 614; +export let a615 = 615; +export let a616 = 616; +export let a617 = 617; +export let a618 = 618; +export let a619 = 619; +export let a620 = 620; +export let a621 = 621; +export let a622 = 622; +export let a623 = 623; +export let a624 = 624; +export let a625 = 625; +export let a626 = 626; +export let a627 = 627; +export let a628 = 628; +export let a629 = 629; +export let a630 = 630; +export let a631 = 631; +export let a632 = 632; +export let a633 = 633; +export let a634 = 634; +export let a635 = 635; +export let a636 = 636; +export let a637 = 637; +export let a638 = 638; +export let a639 = 639; +export let a640 = 640; +export let a641 = 641; +export let a642 = 642; +export let a643 = 643; +export let a644 = 644; +export let a645 = 645; +export let a646 = 646; +export let a647 = 647; +export let a648 = 648; +export let a649 = 649; +export let a650 = 650; +export let a651 = 651; +export let a652 = 652; +export let a653 = 653; +export let a654 = 654; +export let a655 = 655; +export let a656 = 656; +export let a657 = 657; +export let a658 = 658; +export let a659 = 659; +export let a660 = 660; +export let a661 = 661; +export let a662 = 662; +export let a663 = 663; +export let a664 = 664; +export let a665 = 665; +export let a666 = 666; +export let a667 = 667; +export let a668 = 668; +export let a669 = 669; +export let a670 = 670; +export let a671 = 671; +export let a672 = 672; +export let a673 = 673; +export let a674 = 674; +export let a675 = 675; +export let a676 = 676; +export let a677 = 677; +export let a678 = 678; +export let a679 = 679; +export let a680 = 680; +export let a681 = 681; +export let a682 = 682; +export let a683 = 683; +export let a684 = 684; +export let a685 = 685; +export let a686 = 686; +export let a687 = 687; +export let a688 = 688; +export let a689 = 689; +export let a690 = 690; +export let a691 = 691; +export let a692 = 692; +export let a693 = 693; +export let a694 = 694; +export let a695 = 695; +export let a696 = 696; +export let a697 = 697; +export let a698 = 698; +export let a699 = 699; +export let a700 = 700; +export let a701 = 701; +export let a702 = 702; +export let a703 = 703; +export let a704 = 704; +export let a705 = 705; +export let a706 = 706; +export let a707 = 707; +export let a708 = 708; +export let a709 = 709; +export let a710 = 710; +export let a711 = 711; +export let a712 = 712; +export let a713 = 713; +export let a714 = 714; +export let a715 = 715; +export let a716 = 716; +export let a717 = 717; +export let a718 = 718; +export let a719 = 719; +export let a720 = 720; +export let a721 = 721; +export let a722 = 722; +export let a723 = 723; +export let a724 = 724; +export let a725 = 725; +export let a726 = 726; +export let a727 = 727; +export let a728 = 728; +export let a729 = 729; +export let a730 = 730; +export let a731 = 731; +export let a732 = 732; +export let a733 = 733; +export let a734 = 734; +export let a735 = 735; +export let a736 = 736; +export let a737 = 737; +export let a738 = 738; +export let a739 = 739; +export let a740 = 740; +export let a741 = 741; +export let a742 = 742; +export let a743 = 743; +export let a744 = 744; +export let a745 = 745; +export let a746 = 746; +export let a747 = 747; +export let a748 = 748; +export let a749 = 749; +export let a750 = 750; +export let a751 = 751; +export let a752 = 752; +export let a753 = 753; +export let a754 = 754; +export let a755 = 755; +export let a756 = 756; +export let a757 = 757; +export let a758 = 758; +export let a759 = 759; +export let a760 = 760; +export let a761 = 761; +export let a762 = 762; +export let a763 = 763; +export let a764 = 764; +export let a765 = 765; +export let a766 = 766; +export let a767 = 767; +export let a768 = 768; +export let a769 = 769; +export let a770 = 770; +export let a771 = 771; +export let a772 = 772; +export let a773 = 773; +export let a774 = 774; +export let a775 = 775; +export let a776 = 776; +export let a777 = 777; +export let a778 = 778; +export let a779 = 779; +export let a780 = 780; +export let a781 = 781; +export let a782 = 782; +export let a783 = 783; +export let a784 = 784; +export let a785 = 785; +export let a786 = 786; +export let a787 = 787; +export let a788 = 788; +export let a789 = 789; +export let a790 = 790; +export let a791 = 791; +export let a792 = 792; +export let a793 = 793; +export let a794 = 794; +export let a795 = 795; +export let a796 = 796; +export let a797 = 797; +export let a798 = 798; +export let a799 = 799; +export let a800 = 800; +export let a801 = 801; +export let a802 = 802; +export let a803 = 803; +export let a804 = 804; +export let a805 = 805; +export let a806 = 806; +export let a807 = 807; +export let a808 = 808; +export let a809 = 809; +export let a810 = 810; +export let a811 = 811; +export let a812 = 812; +export let a813 = 813; +export let a814 = 814; +export let a815 = 815; +export let a816 = 816; +export let a817 = 817; +export let a818 = 818; +export let a819 = 819; +export let a820 = 820; +export let a821 = 821; +export let a822 = 822; +export let a823 = 823; +export let a824 = 824; +export let a825 = 825; +export let a826 = 826; +export let a827 = 827; +export let a828 = 828; +export let a829 = 829; +export let a830 = 830; +export let a831 = 831; +export let a832 = 832; +export let a833 = 833; +export let a834 = 834; +export let a835 = 835; +export let a836 = 836; +export let a837 = 837; +export let a838 = 838; +export let a839 = 839; +export let a840 = 840; +export let a841 = 841; +export let a842 = 842; +export let a843 = 843; +export let a844 = 844; +export let a845 = 845; +export let a846 = 846; +export let a847 = 847; +export let a848 = 848; +export let a849 = 849; +export let a850 = 850; +export let a851 = 851; +export let a852 = 852; +export let a853 = 853; +export let a854 = 854; +export let a855 = 855; +export let a856 = 856; +export let a857 = 857; +export let a858 = 858; +export let a859 = 859; +export let a860 = 860; +export let a861 = 861; +export let a862 = 862; +export let a863 = 863; +export let a864 = 864; +export let a865 = 865; +export let a866 = 866; +export let a867 = 867; +export let a868 = 868; +export let a869 = 869; +export let a870 = 870; +export let a871 = 871; +export let a872 = 872; +export let a873 = 873; +export let a874 = 874; +export let a875 = 875; +export let a876 = 876; +export let a877 = 877; +export let a878 = 878; +export let a879 = 879; +export let a880 = 880; +export let a881 = 881; +export let a882 = 882; +export let a883 = 883; +export let a884 = 884; +export let a885 = 885; +export let a886 = 886; +export let a887 = 887; +export let a888 = 888; +export let a889 = 889; +export let a890 = 890; +export let a891 = 891; +export let a892 = 892; +export let a893 = 893; +export let a894 = 894; +export let a895 = 895; +export let a896 = 896; +export let a897 = 897; +export let a898 = 898; +export let a899 = 899; +export let a900 = 900; +export let a901 = 901; +export let a902 = 902; +export let a903 = 903; +export let a904 = 904; +export let a905 = 905; +export let a906 = 906; +export let a907 = 907; +export let a908 = 908; +export let a909 = 909; +export let a910 = 910; +export let a911 = 911; +export let a912 = 912; +export let a913 = 913; +export let a914 = 914; +export let a915 = 915; +export let a916 = 916; +export let a917 = 917; +export let a918 = 918; +export let a919 = 919; +export let a920 = 920; +export let a921 = 921; +export let a922 = 922; +export let a923 = 923; +export let a924 = 924; +export let a925 = 925; +export let a926 = 926; +export let a927 = 927; +export let a928 = 928; +export let a929 = 929; +export let a930 = 930; +export let a931 = 931; +export let a932 = 932; +export let a933 = 933; +export let a934 = 934; +export let a935 = 935; +export let a936 = 936; +export let a937 = 937; +export let a938 = 938; +export let a939 = 939; +export let a940 = 940; +export let a941 = 941; +export let a942 = 942; +export let a943 = 943; +export let a944 = 944; +export let a945 = 945; +export let a946 = 946; +export let a947 = 947; +export let a948 = 948; +export let a949 = 949; +export let a950 = 950; +export let a951 = 951; +export let a952 = 952; +export let a953 = 953; +export let a954 = 954; +export let a955 = 955; +export let a956 = 956; +export let a957 = 957; +export let a958 = 958; +export let a959 = 959; +export let a960 = 960; +export let a961 = 961; +export let a962 = 962; +export let a963 = 963; +export let a964 = 964; +export let a965 = 965; +export let a966 = 966; +export let a967 = 967; +export let a968 = 968; +export let a969 = 969; +export let a970 = 970; +export let a971 = 971; +export let a972 = 972; +export let a973 = 973; +export let a974 = 974; +export let a975 = 975; +export let a976 = 976; +export let a977 = 977; +export let a978 = 978; +export let a979 = 979; +export let a980 = 980; +export let a981 = 981; +export let a982 = 982; +export let a983 = 983; +export let a984 = 984; +export let a985 = 985; +export let a986 = 986; +export let a987 = 987; +export let a988 = 988; +export let a989 = 989; +export let a990 = 990; +export let a991 = 991; +export let a992 = 992; +export let a993 = 993; +export let a994 = 994; +export let a995 = 995; +export let a996 = 996; +export let a997 = 997; +export let a998 = 998; +export let a999 = 999; +export let a1000 = 1000; +export let a1001 = 1001; +export let a1002 = 1002; +export let a1003 = 1003; +export let a1004 = 1004; +export let a1005 = 1005; +export let a1006 = 1006; +export let a1007 = 1007; +export let a1008 = 1008; +export let a1009 = 1009; +export let a1010 = 1010; +export let a1011 = 1011; +export let a1012 = 1012; +export let a1013 = 1013; +export let a1014 = 1014; +export let a1015 = 1015; +export let a1016 = 1016; +export let a1017 = 1017; +export let a1018 = 1018; +export let a1019 = 1019; +export let a1020 = 1020; +export let a1021 = 1021; +export let a1022 = 1022; +export let a1023 = 1023; +export let a1024 = 1024; +export let a1025 = 1025; +export let a1026 = 1026; +export let a1027 = 1027; +export let a1028 = 1028; +export let a1029 = 1029; +export let a1030 = 1030; +export let a1031 = 1031; +export let a1032 = 1032; +export let a1033 = 1033; +export let a1034 = 1034; +export let a1035 = 1035; +export let a1036 = 1036; +export let a1037 = 1037; +export let a1038 = 1038; +export let a1039 = 1039; +export let a1040 = 1040; +export let a1041 = 1041; +export let a1042 = 1042; +export let a1043 = 1043; +export let a1044 = 1044; +export let a1045 = 1045; +export let a1046 = 1046; +export let a1047 = 1047; +export let a1048 = 1048; +export let a1049 = 1049; +export let a1050 = 1050; +export let a1051 = 1051; +export let a1052 = 1052; +export let a1053 = 1053; +export let a1054 = 1054; +export let a1055 = 1055; +export let a1056 = 1056; +export let a1057 = 1057; +export let a1058 = 1058; +export let a1059 = 1059; +export let a1060 = 1060; +export let a1061 = 1061; +export let a1062 = 1062; +export let a1063 = 1063; +export let a1064 = 1064; +export let a1065 = 1065; +export let a1066 = 1066; +export let a1067 = 1067; +export let a1068 = 1068; +export let a1069 = 1069; +export let a1070 = 1070; +export let a1071 = 1071; +export let a1072 = 1072; +export let a1073 = 1073; +export let a1074 = 1074; +export let a1075 = 1075; +export let a1076 = 1076; +export let a1077 = 1077; +export let a1078 = 1078; +export let a1079 = 1079; +export let a1080 = 1080; +export let a1081 = 1081; +export let a1082 = 1082; +export let a1083 = 1083; +export let a1084 = 1084; +export let a1085 = 1085; +export let a1086 = 1086; +export let a1087 = 1087; +export let a1088 = 1088; +export let a1089 = 1089; +export let a1090 = 1090; +export let a1091 = 1091; +export let a1092 = 1092; +export let a1093 = 1093; +export let a1094 = 1094; +export let a1095 = 1095; +export let a1096 = 1096; +export let a1097 = 1097; +export let a1098 = 1098; +export let a1099 = 1099; +export let a1100 = 1100; +export let a1101 = 1101; +export let a1102 = 1102; +export let a1103 = 1103; +export let a1104 = 1104; +export let a1105 = 1105; +export let a1106 = 1106; +export let a1107 = 1107; +export let a1108 = 1108; +export let a1109 = 1109; +export let a1110 = 1110; +export let a1111 = 1111; +export let a1112 = 1112; +export let a1113 = 1113; +export let a1114 = 1114; +export let a1115 = 1115; +export let a1116 = 1116; +export let a1117 = 1117; +export let a1118 = 1118; +export let a1119 = 1119; +export let a1120 = 1120; +export let a1121 = 1121; +export let a1122 = 1122; +export let a1123 = 1123; +export let a1124 = 1124; +export let a1125 = 1125; +export let a1126 = 1126; +export let a1127 = 1127; +export let a1128 = 1128; +export let a1129 = 1129; +export let a1130 = 1130; +export let a1131 = 1131; +export let a1132 = 1132; +export let a1133 = 1133; +export let a1134 = 1134; +export let a1135 = 1135; +export let a1136 = 1136; +export let a1137 = 1137; +export let a1138 = 1138; +export let a1139 = 1139; +export let a1140 = 1140; +export let a1141 = 1141; +export let a1142 = 1142; +export let a1143 = 1143; +export let a1144 = 1144; +export let a1145 = 1145; +export let a1146 = 1146; +export let a1147 = 1147; +export let a1148 = 1148; +export let a1149 = 1149; +export let a1150 = 1150; +export let a1151 = 1151; +export let a1152 = 1152; +export let a1153 = 1153; +export let a1154 = 1154; +export let a1155 = 1155; +export let a1156 = 1156; +export let a1157 = 1157; +export let a1158 = 1158; +export let a1159 = 1159; +export let a1160 = 1160; +export let a1161 = 1161; +export let a1162 = 1162; +export let a1163 = 1163; +export let a1164 = 1164; +export let a1165 = 1165; +export let a1166 = 1166; +export let a1167 = 1167; +export let a1168 = 1168; +export let a1169 = 1169; +export let a1170 = 1170; +export let a1171 = 1171; +export let a1172 = 1172; +export let a1173 = 1173; +export let a1174 = 1174; +export let a1175 = 1175; +export let a1176 = 1176; +export let a1177 = 1177; +export let a1178 = 1178; +export let a1179 = 1179; +export let a1180 = 1180; +export let a1181 = 1181; +export let a1182 = 1182; +export let a1183 = 1183; +export let a1184 = 1184; +export let a1185 = 1185; +export let a1186 = 1186; +export let a1187 = 1187; +export let a1188 = 1188; +export let a1189 = 1189; +export let a1190 = 1190; +export let a1191 = 1191; +export let a1192 = 1192; +export let a1193 = 1193; +export let a1194 = 1194; +export let a1195 = 1195; +export let a1196 = 1196; +export let a1197 = 1197; +export let a1198 = 1198; +export let a1199 = 1199; +export let a1200 = 1200; +export let a1201 = 1201; +export let a1202 = 1202; +export let a1203 = 1203; +export let a1204 = 1204; +export let a1205 = 1205; +export let a1206 = 1206; +export let a1207 = 1207; +export let a1208 = 1208; +export let a1209 = 1209; +export let a1210 = 1210; +export let a1211 = 1211; +export let a1212 = 1212; +export let a1213 = 1213; +export let a1214 = 1214; +export let a1215 = 1215; +export let a1216 = 1216; +export let a1217 = 1217; +export let a1218 = 1218; +export let a1219 = 1219; +export let a1220 = 1220; +export let a1221 = 1221; +export let a1222 = 1222; +export let a1223 = 1223; +export let a1224 = 1224; +export let a1225 = 1225; +export let a1226 = 1226; +export let a1227 = 1227; +export let a1228 = 1228; +export let a1229 = 1229; +export let a1230 = 1230; +export let a1231 = 1231; +export let a1232 = 1232; +export let a1233 = 1233; +export let a1234 = 1234; +export let a1235 = 1235; +export let a1236 = 1236; +export let a1237 = 1237; +export let a1238 = 1238; +export let a1239 = 1239; +export let a1240 = 1240; +export let a1241 = 1241; +export let a1242 = 1242; +export let a1243 = 1243; +export let a1244 = 1244; +export let a1245 = 1245; +export let a1246 = 1246; +export let a1247 = 1247; +export let a1248 = 1248; +export let a1249 = 1249; +export let a1250 = 1250; +export let a1251 = 1251; +export let a1252 = 1252; +export let a1253 = 1253; +export let a1254 = 1254; +export let a1255 = 1255; +export let a1256 = 1256; +export let a1257 = 1257; +export let a1258 = 1258; +export let a1259 = 1259; +export let a1260 = 1260; +export let a1261 = 1261; +export let a1262 = 1262; +export let a1263 = 1263; +export let a1264 = 1264; +export let a1265 = 1265; +export let a1266 = 1266; +export let a1267 = 1267; +export let a1268 = 1268; +export let a1269 = 1269; +export let a1270 = 1270; +export let a1271 = 1271; +export let a1272 = 1272; +export let a1273 = 1273; +export let a1274 = 1274; +export let a1275 = 1275; +export let a1276 = 1276; +export let a1277 = 1277; +export let a1278 = 1278; +export let a1279 = 1279; +export let a1280 = 1280; +export let a1281 = 1281; +export let a1282 = 1282; +export let a1283 = 1283; +export let a1284 = 1284; +export let a1285 = 1285; +export let a1286 = 1286; +export let a1287 = 1287; +export let a1288 = 1288; +export let a1289 = 1289; +export let a1290 = 1290; +export let a1291 = 1291; +export let a1292 = 1292; +export let a1293 = 1293; +export let a1294 = 1294; +export let a1295 = 1295; +export let a1296 = 1296; +export let a1297 = 1297; +export let a1298 = 1298; +export let a1299 = 1299; +export let a1300 = 1300; +export let a1301 = 1301; +export let a1302 = 1302; +export let a1303 = 1303; +export let a1304 = 1304; +export let a1305 = 1305; +export let a1306 = 1306; +export let a1307 = 1307; +export let a1308 = 1308; +export let a1309 = 1309; +export let a1310 = 1310; +export let a1311 = 1311; +export let a1312 = 1312; +export let a1313 = 1313; +export let a1314 = 1314; +export let a1315 = 1315; +export let a1316 = 1316; +export let a1317 = 1317; +export let a1318 = 1318; +export let a1319 = 1319; +export let a1320 = 1320; +export let a1321 = 1321; +export let a1322 = 1322; +export let a1323 = 1323; +export let a1324 = 1324; +export let a1325 = 1325; +export let a1326 = 1326; +export let a1327 = 1327; +export let a1328 = 1328; +export let a1329 = 1329; +export let a1330 = 1330; +export let a1331 = 1331; +export let a1332 = 1332; +export let a1333 = 1333; +export let a1334 = 1334; +export let a1335 = 1335; +export let a1336 = 1336; +export let a1337 = 1337; +export let a1338 = 1338; +export let a1339 = 1339; +export let a1340 = 1340; +export let a1341 = 1341; +export let a1342 = 1342; +export let a1343 = 1343; +export let a1344 = 1344; +export let a1345 = 1345; +export let a1346 = 1346; +export let a1347 = 1347; +export let a1348 = 1348; +export let a1349 = 1349; +export let a1350 = 1350; +export let a1351 = 1351; +export let a1352 = 1352; +export let a1353 = 1353; +export let a1354 = 1354; +export let a1355 = 1355; +export let a1356 = 1356; +export let a1357 = 1357; +export let a1358 = 1358; +export let a1359 = 1359; +export let a1360 = 1360; +export let a1361 = 1361; +export let a1362 = 1362; +export let a1363 = 1363; +export let a1364 = 1364; +export let a1365 = 1365; +export let a1366 = 1366; +export let a1367 = 1367; +export let a1368 = 1368; +export let a1369 = 1369; +export let a1370 = 1370; +export let a1371 = 1371; +export let a1372 = 1372; +export let a1373 = 1373; +export let a1374 = 1374; +export let a1375 = 1375; +export let a1376 = 1376; +export let a1377 = 1377; +export let a1378 = 1378; +export let a1379 = 1379; +export let a1380 = 1380; +export let a1381 = 1381; +export let a1382 = 1382; +export let a1383 = 1383; +export let a1384 = 1384; +export let a1385 = 1385; +export let a1386 = 1386; +export let a1387 = 1387; +export let a1388 = 1388; +export let a1389 = 1389; +export let a1390 = 1390; +export let a1391 = 1391; +export let a1392 = 1392; +export let a1393 = 1393; +export let a1394 = 1394; +export let a1395 = 1395; +export let a1396 = 1396; +export let a1397 = 1397; +export let a1398 = 1398; +export let a1399 = 1399; +export let a1400 = 1400; +export let a1401 = 1401; +export let a1402 = 1402; +export let a1403 = 1403; +export let a1404 = 1404; +export let a1405 = 1405; +export let a1406 = 1406; +export let a1407 = 1407; +export let a1408 = 1408; +export let a1409 = 1409; +export let a1410 = 1410; +export let a1411 = 1411; +export let a1412 = 1412; +export let a1413 = 1413; +export let a1414 = 1414; +export let a1415 = 1415; +export let a1416 = 1416; +export let a1417 = 1417; +export let a1418 = 1418; +export let a1419 = 1419; +export let a1420 = 1420; +export let a1421 = 1421; +export let a1422 = 1422; +export let a1423 = 1423; +export let a1424 = 1424; +export let a1425 = 1425; +export let a1426 = 1426; +export let a1427 = 1427; +export let a1428 = 1428; +export let a1429 = 1429; +export let a1430 = 1430; +export let a1431 = 1431; +export let a1432 = 1432; +export let a1433 = 1433; +export let a1434 = 1434; +export let a1435 = 1435; +export let a1436 = 1436; +export let a1437 = 1437; +export let a1438 = 1438; +export let a1439 = 1439; +export let a1440 = 1440; +export let a1441 = 1441; +export let a1442 = 1442; +export let a1443 = 1443; +export let a1444 = 1444; +export let a1445 = 1445; +export let a1446 = 1446; +export let a1447 = 1447; +export let a1448 = 1448; +export let a1449 = 1449; +export let a1450 = 1450; +export let a1451 = 1451; +export let a1452 = 1452; +export let a1453 = 1453; +export let a1454 = 1454; +export let a1455 = 1455; +export let a1456 = 1456; +export let a1457 = 1457; +export let a1458 = 1458; +export let a1459 = 1459; +export let a1460 = 1460; +export let a1461 = 1461; +export let a1462 = 1462; +export let a1463 = 1463; +export let a1464 = 1464; +export let a1465 = 1465; +export let a1466 = 1466; +export let a1467 = 1467; +export let a1468 = 1468; +export let a1469 = 1469; +export let a1470 = 1470; +export let a1471 = 1471; +export let a1472 = 1472; +export let a1473 = 1473; +export let a1474 = 1474; +export let a1475 = 1475; +export let a1476 = 1476; +export let a1477 = 1477; +export let a1478 = 1478; +export let a1479 = 1479; +export let a1480 = 1480; +export let a1481 = 1481; +export let a1482 = 1482; +export let a1483 = 1483; +export let a1484 = 1484; +export let a1485 = 1485; +export let a1486 = 1486; +export let a1487 = 1487; +export let a1488 = 1488; +export let a1489 = 1489; +export let a1490 = 1490; +export let a1491 = 1491; +export let a1492 = 1492; +export let a1493 = 1493; +export let a1494 = 1494; +export let a1495 = 1495; +export let a1496 = 1496; +export let a1497 = 1497; +export let a1498 = 1498; +export let a1499 = 1499; +export let a1500 = 1500; +export let a1501 = 1501; +export let a1502 = 1502; +export let a1503 = 1503; +export let a1504 = 1504; +export let a1505 = 1505; +export let a1506 = 1506; +export let a1507 = 1507; +export let a1508 = 1508; +export let a1509 = 1509; +export let a1510 = 1510; +export let a1511 = 1511; +export let a1512 = 1512; +export let a1513 = 1513; +export let a1514 = 1514; +export let a1515 = 1515; +export let a1516 = 1516; +export let a1517 = 1517; +export let a1518 = 1518; +export let a1519 = 1519; +export let a1520 = 1520; +export let a1521 = 1521; +export let a1522 = 1522; +export let a1523 = 1523; +export let a1524 = 1524; +export let a1525 = 1525; +export let a1526 = 1526; +export let a1527 = 1527; +export let a1528 = 1528; +export let a1529 = 1529; +export let a1530 = 1530; +export let a1531 = 1531; +export let a1532 = 1532; +export let a1533 = 1533; +export let a1534 = 1534; +export let a1535 = 1535; +export let a1536 = 1536; +export let a1537 = 1537; +export let a1538 = 1538; +export let a1539 = 1539; +export let a1540 = 1540; +export let a1541 = 1541; +export let a1542 = 1542; +export let a1543 = 1543; +export let a1544 = 1544; +export let a1545 = 1545; +export let a1546 = 1546; +export let a1547 = 1547; +export let a1548 = 1548; +export let a1549 = 1549; +export let a1550 = 1550; +export let a1551 = 1551; +export let a1552 = 1552; +export let a1553 = 1553; +export let a1554 = 1554; +export let a1555 = 1555; +export let a1556 = 1556; +export let a1557 = 1557; +export let a1558 = 1558; +export let a1559 = 1559; +export let a1560 = 1560; +export let a1561 = 1561; +export let a1562 = 1562; +export let a1563 = 1563; +export let a1564 = 1564; +export let a1565 = 1565; +export let a1566 = 1566; +export let a1567 = 1567; +export let a1568 = 1568; +export let a1569 = 1569; +export let a1570 = 1570; +export let a1571 = 1571; +export let a1572 = 1572; +export let a1573 = 1573; +export let a1574 = 1574; +export let a1575 = 1575; +export let a1576 = 1576; +export let a1577 = 1577; +export let a1578 = 1578; +export let a1579 = 1579; +export let a1580 = 1580; +export let a1581 = 1581; +export let a1582 = 1582; +export let a1583 = 1583; +export let a1584 = 1584; +export let a1585 = 1585; +export let a1586 = 1586; +export let a1587 = 1587; +export let a1588 = 1588; +export let a1589 = 1589; +export let a1590 = 1590; +export let a1591 = 1591; +export let a1592 = 1592; +export let a1593 = 1593; +export let a1594 = 1594; +export let a1595 = 1595; +export let a1596 = 1596; +export let a1597 = 1597; +export let a1598 = 1598; +export let a1599 = 1599; +export let a1600 = 1600; +export let a1601 = 1601; +export let a1602 = 1602; +export let a1603 = 1603; +export let a1604 = 1604; +export let a1605 = 1605; +export let a1606 = 1606; +export let a1607 = 1607; +export let a1608 = 1608; +export let a1609 = 1609; +export let a1610 = 1610; +export let a1611 = 1611; +export let a1612 = 1612; +export let a1613 = 1613; +export let a1614 = 1614; +export let a1615 = 1615; +export let a1616 = 1616; +export let a1617 = 1617; +export let a1618 = 1618; +export let a1619 = 1619; +export let a1620 = 1620; +export let a1621 = 1621; +export let a1622 = 1622; +export let a1623 = 1623; +export let a1624 = 1624; +export let a1625 = 1625; +export let a1626 = 1626; +export let a1627 = 1627; +export let a1628 = 1628; +export let a1629 = 1629; +export let a1630 = 1630; +export let a1631 = 1631; +export let a1632 = 1632; +export let a1633 = 1633; +export let a1634 = 1634; +export let a1635 = 1635; +export let a1636 = 1636; +export let a1637 = 1637; +export let a1638 = 1638; +export let a1639 = 1639; +export let a1640 = 1640; +export let a1641 = 1641; +export let a1642 = 1642; +export let a1643 = 1643; +export let a1644 = 1644; +export let a1645 = 1645; +export let a1646 = 1646; +export let a1647 = 1647; +export let a1648 = 1648; +export let a1649 = 1649; +export let a1650 = 1650; +export let a1651 = 1651; +export let a1652 = 1652; +export let a1653 = 1653; +export let a1654 = 1654; +export let a1655 = 1655; +export let a1656 = 1656; +export let a1657 = 1657; +export let a1658 = 1658; +export let a1659 = 1659; +export let a1660 = 1660; +export let a1661 = 1661; +export let a1662 = 1662; +export let a1663 = 1663; +export let a1664 = 1664; +export let a1665 = 1665; +export let a1666 = 1666; +export let a1667 = 1667; +export let a1668 = 1668; +export let a1669 = 1669; +export let a1670 = 1670; +export let a1671 = 1671; +export let a1672 = 1672; +export let a1673 = 1673; +export let a1674 = 1674; +export let a1675 = 1675; +export let a1676 = 1676; +export let a1677 = 1677; +export let a1678 = 1678; +export let a1679 = 1679; +export let a1680 = 1680; +export let a1681 = 1681; +export let a1682 = 1682; +export let a1683 = 1683; +export let a1684 = 1684; +export let a1685 = 1685; +export let a1686 = 1686; +export let a1687 = 1687; +export let a1688 = 1688; +export let a1689 = 1689; +export let a1690 = 1690; +export let a1691 = 1691; +export let a1692 = 1692; +export let a1693 = 1693; +export let a1694 = 1694; +export let a1695 = 1695; +export let a1696 = 1696; +export let a1697 = 1697; +export let a1698 = 1698; +export let a1699 = 1699; +export let a1700 = 1700; +export let a1701 = 1701; +export let a1702 = 1702; +export let a1703 = 1703; +export let a1704 = 1704; +export let a1705 = 1705; +export let a1706 = 1706; +export let a1707 = 1707; +export let a1708 = 1708; +export let a1709 = 1709; +export let a1710 = 1710; +export let a1711 = 1711; +export let a1712 = 1712; +export let a1713 = 1713; +export let a1714 = 1714; +export let a1715 = 1715; +export let a1716 = 1716; +export let a1717 = 1717; +export let a1718 = 1718; +export let a1719 = 1719; +export let a1720 = 1720; +export let a1721 = 1721; +export let a1722 = 1722; +export let a1723 = 1723; +export let a1724 = 1724; +export let a1725 = 1725; +export let a1726 = 1726; +export let a1727 = 1727; +export let a1728 = 1728; +export let a1729 = 1729; +export let a1730 = 1730; +export let a1731 = 1731; +export let a1732 = 1732; +export let a1733 = 1733; +export let a1734 = 1734; +export let a1735 = 1735; +export let a1736 = 1736; +export let a1737 = 1737; +export let a1738 = 1738; +export let a1739 = 1739; +export let a1740 = 1740; +export let a1741 = 1741; +export let a1742 = 1742; +export let a1743 = 1743; +export let a1744 = 1744; +export let a1745 = 1745; +export let a1746 = 1746; +export let a1747 = 1747; +export let a1748 = 1748; +export let a1749 = 1749; +export let a1750 = 1750; +export let a1751 = 1751; +export let a1752 = 1752; +export let a1753 = 1753; +export let a1754 = 1754; +export let a1755 = 1755; +export let a1756 = 1756; +export let a1757 = 1757; +export let a1758 = 1758; +export let a1759 = 1759; +export let a1760 = 1760; +export let a1761 = 1761; +export let a1762 = 1762; +export let a1763 = 1763; +export let a1764 = 1764; +export let a1765 = 1765; +export let a1766 = 1766; +export let a1767 = 1767; +export let a1768 = 1768; +export let a1769 = 1769; +export let a1770 = 1770; +export let a1771 = 1771; +export let a1772 = 1772; +export let a1773 = 1773; +export let a1774 = 1774; +export let a1775 = 1775; +export let a1776 = 1776; +export let a1777 = 1777; +export let a1778 = 1778; +export let a1779 = 1779; +export let a1780 = 1780; +export let a1781 = 1781; +export let a1782 = 1782; +export let a1783 = 1783; +export let a1784 = 1784; +export let a1785 = 1785; +export let a1786 = 1786; +export let a1787 = 1787; +export let a1788 = 1788; +export let a1789 = 1789; +export let a1790 = 1790; +export let a1791 = 1791; +export let a1792 = 1792; +export let a1793 = 1793; +export let a1794 = 1794; +export let a1795 = 1795; +export let a1796 = 1796; +export let a1797 = 1797; +export let a1798 = 1798; +export let a1799 = 1799; +export let a1800 = 1800; +export let a1801 = 1801; +export let a1802 = 1802; +export let a1803 = 1803; +export let a1804 = 1804; +export let a1805 = 1805; +export let a1806 = 1806; +export let a1807 = 1807; +export let a1808 = 1808; +export let a1809 = 1809; +export let a1810 = 1810; +export let a1811 = 1811; +export let a1812 = 1812; +export let a1813 = 1813; +export let a1814 = 1814; +export let a1815 = 1815; +export let a1816 = 1816; +export let a1817 = 1817; +export let a1818 = 1818; +export let a1819 = 1819; +export let a1820 = 1820; +export let a1821 = 1821; +export let a1822 = 1822; +export let a1823 = 1823; +export let a1824 = 1824; +export let a1825 = 1825; +export let a1826 = 1826; +export let a1827 = 1827; +export let a1828 = 1828; +export let a1829 = 1829; +export let a1830 = 1830; +export let a1831 = 1831; +export let a1832 = 1832; +export let a1833 = 1833; +export let a1834 = 1834; +export let a1835 = 1835; +export let a1836 = 1836; +export let a1837 = 1837; +export let a1838 = 1838; +export let a1839 = 1839; +export let a1840 = 1840; +export let a1841 = 1841; +export let a1842 = 1842; +export let a1843 = 1843; +export let a1844 = 1844; +export let a1845 = 1845; +export let a1846 = 1846; +export let a1847 = 1847; +export let a1848 = 1848; +export let a1849 = 1849; +export let a1850 = 1850; +export let a1851 = 1851; +export let a1852 = 1852; +export let a1853 = 1853; +export let a1854 = 1854; +export let a1855 = 1855; +export let a1856 = 1856; +export let a1857 = 1857; +export let a1858 = 1858; +export let a1859 = 1859; +export let a1860 = 1860; +export let a1861 = 1861; +export let a1862 = 1862; +export let a1863 = 1863; +export let a1864 = 1864; +export let a1865 = 1865; +export let a1866 = 1866; +export let a1867 = 1867; +export let a1868 = 1868; +export let a1869 = 1869; +export let a1870 = 1870; +export let a1871 = 1871; +export let a1872 = 1872; +export let a1873 = 1873; +export let a1874 = 1874; +export let a1875 = 1875; +export let a1876 = 1876; +export let a1877 = 1877; +export let a1878 = 1878; +export let a1879 = 1879; +export let a1880 = 1880; +export let a1881 = 1881; +export let a1882 = 1882; +export let a1883 = 1883; +export let a1884 = 1884; +export let a1885 = 1885; +export let a1886 = 1886; +export let a1887 = 1887; +export let a1888 = 1888; +export let a1889 = 1889; +export let a1890 = 1890; +export let a1891 = 1891; +export let a1892 = 1892; +export let a1893 = 1893; +export let a1894 = 1894; +export let a1895 = 1895; +export let a1896 = 1896; +export let a1897 = 1897; +export let a1898 = 1898; +export let a1899 = 1899; +export let a1900 = 1900; +export let a1901 = 1901; +export let a1902 = 1902; +export let a1903 = 1903; +export let a1904 = 1904; +export let a1905 = 1905; +export let a1906 = 1906; +export let a1907 = 1907; +export let a1908 = 1908; +export let a1909 = 1909; +export let a1910 = 1910; +export let a1911 = 1911; +export let a1912 = 1912; +export let a1913 = 1913; +export let a1914 = 1914; +export let a1915 = 1915; +export let a1916 = 1916; +export let a1917 = 1917; +export let a1918 = 1918; +export let a1919 = 1919; +export let a1920 = 1920; +export let a1921 = 1921; +export let a1922 = 1922; +export let a1923 = 1923; +export let a1924 = 1924; +export let a1925 = 1925; +export let a1926 = 1926; +export let a1927 = 1927; +export let a1928 = 1928; +export let a1929 = 1929; +export let a1930 = 1930; +export let a1931 = 1931; +export let a1932 = 1932; +export let a1933 = 1933; +export let a1934 = 1934; +export let a1935 = 1935; +export let a1936 = 1936; +export let a1937 = 1937; +export let a1938 = 1938; +export let a1939 = 1939; +export let a1940 = 1940; +export let a1941 = 1941; +export let a1942 = 1942; +export let a1943 = 1943; +export let a1944 = 1944; +export let a1945 = 1945; +export let a1946 = 1946; +export let a1947 = 1947; +export let a1948 = 1948; +export let a1949 = 1949; +export let a1950 = 1950; +export let a1951 = 1951; +export let a1952 = 1952; +export let a1953 = 1953; +export let a1954 = 1954; +export let a1955 = 1955; +export let a1956 = 1956; +export let a1957 = 1957; +export let a1958 = 1958; +export let a1959 = 1959; +export let a1960 = 1960; +export let a1961 = 1961; +export let a1962 = 1962; +export let a1963 = 1963; +export let a1964 = 1964; +export let a1965 = 1965; +export let a1966 = 1966; +export let a1967 = 1967; +export let a1968 = 1968; +export let a1969 = 1969; +export let a1970 = 1970; +export let a1971 = 1971; +export let a1972 = 1972; +export let a1973 = 1973; +export let a1974 = 1974; +export let a1975 = 1975; +export let a1976 = 1976; +export let a1977 = 1977; +export let a1978 = 1978; +export let a1979 = 1979; +export let a1980 = 1980; +export let a1981 = 1981; +export let a1982 = 1982; +export let a1983 = 1983; +export let a1984 = 1984; +export let a1985 = 1985; +export let a1986 = 1986; +export let a1987 = 1987; +export let a1988 = 1988; +export let a1989 = 1989; +export let a1990 = 1990; +export let a1991 = 1991; +export let a1992 = 1992; +export let a1993 = 1993; +export let a1994 = 1994; +export let a1995 = 1995; +export let a1996 = 1996; +export let a1997 = 1997; +export let a1998 = 1998; +export let a1999 = 1999; +export let a2000 = 2000; +export let a2001 = 2001; +export let a2002 = 2002; +export let a2003 = 2003; +export let a2004 = 2004; +export let a2005 = 2005; +export let a2006 = 2006; +export let a2007 = 2007; +export let a2008 = 2008; +export let a2009 = 2009; +export let a2010 = 2010; +export let a2011 = 2011; +export let a2012 = 2012; +export let a2013 = 2013; +export let a2014 = 2014; +export let a2015 = 2015; +export let a2016 = 2016; +export let a2017 = 2017; +export let a2018 = 2018; +export let a2019 = 2019; +export let a2020 = 2020; +export let a2021 = 2021; +export let a2022 = 2022; +export let a2023 = 2023; +export let a2024 = 2024; +export let a2025 = 2025; +export let a2026 = 2026; +export let a2027 = 2027; +export let a2028 = 2028; +export let a2029 = 2029; +export let a2030 = 2030; +export let a2031 = 2031; +export let a2032 = 2032; +export let a2033 = 2033; +export let a2034 = 2034; +export let a2035 = 2035; +export let a2036 = 2036; +export let a2037 = 2037; +export let a2038 = 2038; +export let a2039 = 2039; +export let a2040 = 2040; +export let a2041 = 2041; +export let a2042 = 2042; +export let a2043 = 2043; +export let a2044 = 2044; +export let a2045 = 2045; +export let a2046 = 2046; +export let a2047 = 2047; +export let a2048 = 2048; +export let a2049 = 2049; +export let a2050 = 2050; +export let a2051 = 2051; +export let a2052 = 2052; +export let a2053 = 2053; +export let a2054 = 2054; +export let a2055 = 2055; +export let a2056 = 2056; +export let a2057 = 2057; +export let a2058 = 2058; +export let a2059 = 2059; +export let a2060 = 2060; +export let a2061 = 2061; +export let a2062 = 2062; +export let a2063 = 2063; +export let a2064 = 2064; +export let a2065 = 2065; +export let a2066 = 2066; +export let a2067 = 2067; +export let a2068 = 2068; +export let a2069 = 2069; +export let a2070 = 2070; +export let a2071 = 2071; +export let a2072 = 2072; +export let a2073 = 2073; +export let a2074 = 2074; +export let a2075 = 2075; +export let a2076 = 2076; +export let a2077 = 2077; +export let a2078 = 2078; +export let a2079 = 2079; +export let a2080 = 2080; +export let a2081 = 2081; +export let a2082 = 2082; +export let a2083 = 2083; +export let a2084 = 2084; +export let a2085 = 2085; +export let a2086 = 2086; +export let a2087 = 2087; +export let a2088 = 2088; +export let a2089 = 2089; +export let a2090 = 2090; +export let a2091 = 2091; +export let a2092 = 2092; +export let a2093 = 2093; +export let a2094 = 2094; +export let a2095 = 2095; +export let a2096 = 2096; +export let a2097 = 2097; +export let a2098 = 2098; +export let a2099 = 2099; +export let a2100 = 2100; +export let a2101 = 2101; +export let a2102 = 2102; +export let a2103 = 2103; +export let a2104 = 2104; +export let a2105 = 2105; +export let a2106 = 2106; +export let a2107 = 2107; +export let a2108 = 2108; +export let a2109 = 2109; +export let a2110 = 2110; +export let a2111 = 2111; +export let a2112 = 2112; +export let a2113 = 2113; +export let a2114 = 2114; +export let a2115 = 2115; +export let a2116 = 2116; +export let a2117 = 2117; +export let a2118 = 2118; +export let a2119 = 2119; +export let a2120 = 2120; +export let a2121 = 2121; +export let a2122 = 2122; +export let a2123 = 2123; +export let a2124 = 2124; +export let a2125 = 2125; +export let a2126 = 2126; +export let a2127 = 2127; +export let a2128 = 2128; +export let a2129 = 2129; +export let a2130 = 2130; +export let a2131 = 2131; +export let a2132 = 2132; +export let a2133 = 2133; +export let a2134 = 2134; +export let a2135 = 2135; +export let a2136 = 2136; +export let a2137 = 2137; +export let a2138 = 2138; +export let a2139 = 2139; +export let a2140 = 2140; +export let a2141 = 2141; +export let a2142 = 2142; +export let a2143 = 2143; +export let a2144 = 2144; +export let a2145 = 2145; +export let a2146 = 2146; +export let a2147 = 2147; +export let a2148 = 2148; +export let a2149 = 2149; +export let a2150 = 2150; +export let a2151 = 2151; +export let a2152 = 2152; +export let a2153 = 2153; +export let a2154 = 2154; +export let a2155 = 2155; +export let a2156 = 2156; +export let a2157 = 2157; +export let a2158 = 2158; +export let a2159 = 2159; +export let a2160 = 2160; +export let a2161 = 2161; +export let a2162 = 2162; +export let a2163 = 2163; +export let a2164 = 2164; +export let a2165 = 2165; +export let a2166 = 2166; +export let a2167 = 2167; +export let a2168 = 2168; +export let a2169 = 2169; +export let a2170 = 2170; +export let a2171 = 2171; +export let a2172 = 2172; +export let a2173 = 2173; +export let a2174 = 2174; +export let a2175 = 2175; +export let a2176 = 2176; +export let a2177 = 2177; +export let a2178 = 2178; +export let a2179 = 2179; +export let a2180 = 2180; +export let a2181 = 2181; +export let a2182 = 2182; +export let a2183 = 2183; +export let a2184 = 2184; +export let a2185 = 2185; +export let a2186 = 2186; +export let a2187 = 2187; +export let a2188 = 2188; +export let a2189 = 2189; +export let a2190 = 2190; +export let a2191 = 2191; +export let a2192 = 2192; +export let a2193 = 2193; +export let a2194 = 2194; +export let a2195 = 2195; +export let a2196 = 2196; +export let a2197 = 2197; +export let a2198 = 2198; +export let a2199 = 2199; diff --git a/deps/v8/test/mjsunit/harmony/modules-skip-large2.js b/deps/v8/test/mjsunit/harmony/modules-skip-large2.js new file mode 100644 index 0000000000..2c03557197 --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/modules-skip-large2.js @@ -0,0 +1,1104 @@ +// Copyright 2017 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. + +export let a0 = 0; +export let a1 = 1; +export let a2 = 2; +export let a3 = 3; +export let a4 = 4; +export let a5 = 5; +export let a6 = 6; +export let a7 = 7; +export let a8 = 8; +export let a9 = 9; +export let a10 = 10; +export let a11 = 11; +export let a12 = 12; +export let a13 = 13; +export let a14 = 14; +export let a15 = 15; +export let a16 = 16; +export let a17 = 17; +export let a18 = 18; +export let a19 = 19; +export let a20 = 20; +export let a21 = 21; +export let a22 = 22; +export let a23 = 23; +export let a24 = 24; +export let a25 = 25; +export let a26 = 26; +export let a27 = 27; +export let a28 = 28; +export let a29 = 29; +export let a30 = 30; +export let a31 = 31; +export let a32 = 32; +export let a33 = 33; +export let a34 = 34; +export let a35 = 35; +export let a36 = 36; +export let a37 = 37; +export let a38 = 38; +export let a39 = 39; +export let a40 = 40; +export let a41 = 41; +export let a42 = 42; +export let a43 = 43; +export let a44 = 44; +export let a45 = 45; +export let a46 = 46; +export let a47 = 47; +export let a48 = 48; +export let a49 = 49; +export let a50 = 50; +export let a51 = 51; +export let a52 = 52; +export let a53 = 53; +export let a54 = 54; +export let a55 = 55; +export let a56 = 56; +export let a57 = 57; +export let a58 = 58; +export let a59 = 59; +export let a60 = 60; +export let a61 = 61; +export let a62 = 62; +export let a63 = 63; +export let a64 = 64; +export let a65 = 65; +export let a66 = 66; +export let a67 = 67; +export let a68 = 68; +export let a69 = 69; +export let a70 = 70; +export let a71 = 71; +export let a72 = 72; +export let a73 = 73; +export let a74 = 74; +export let a75 = 75; +export let a76 = 76; +export let a77 = 77; +export let a78 = 78; +export let a79 = 79; +export let a80 = 80; +export let a81 = 81; +export let a82 = 82; +export let a83 = 83; +export let a84 = 84; +export let a85 = 85; +export let a86 = 86; +export let a87 = 87; +export let a88 = 88; +export let a89 = 89; +export let a90 = 90; +export let a91 = 91; +export let a92 = 92; +export let a93 = 93; +export let a94 = 94; +export let a95 = 95; +export let a96 = 96; +export let a97 = 97; +export let a98 = 98; +export let a99 = 99; +export let a100 = 100; +export let a101 = 101; +export let a102 = 102; +export let a103 = 103; +export let a104 = 104; +export let a105 = 105; +export let a106 = 106; +export let a107 = 107; +export let a108 = 108; +export let a109 = 109; +export let a110 = 110; +export let a111 = 111; +export let a112 = 112; +export let a113 = 113; +export let a114 = 114; +export let a115 = 115; +export let a116 = 116; +export let a117 = 117; +export let a118 = 118; +export let a119 = 119; +export let a120 = 120; +export let a121 = 121; +export let a122 = 122; +export let a123 = 123; +export let a124 = 124; +export let a125 = 125; +export let a126 = 126; +export let a127 = 127; +export let a128 = 128; +export let a129 = 129; +export let a130 = 130; +export let a131 = 131; +export let a132 = 132; +export let a133 = 133; +export let a134 = 134; +export let a135 = 135; +export let a136 = 136; +export let a137 = 137; +export let a138 = 138; +export let a139 = 139; +export let a140 = 140; +export let a141 = 141; +export let a142 = 142; +export let a143 = 143; +export let a144 = 144; +export let a145 = 145; +export let a146 = 146; +export let a147 = 147; +export let a148 = 148; +export let a149 = 149; +export let a150 = 150; +export let a151 = 151; +export let a152 = 152; +export let a153 = 153; +export let a154 = 154; +export let a155 = 155; +export let a156 = 156; +export let a157 = 157; +export let a158 = 158; +export let a159 = 159; +export let a160 = 160; +export let a161 = 161; +export let a162 = 162; +export let a163 = 163; +export let a164 = 164; +export let a165 = 165; +export let a166 = 166; +export let a167 = 167; +export let a168 = 168; +export let a169 = 169; +export let a170 = 170; +export let a171 = 171; +export let a172 = 172; +export let a173 = 173; +export let a174 = 174; +export let a175 = 175; +export let a176 = 176; +export let a177 = 177; +export let a178 = 178; +export let a179 = 179; +export let a180 = 180; +export let a181 = 181; +export let a182 = 182; +export let a183 = 183; +export let a184 = 184; +export let a185 = 185; +export let a186 = 186; +export let a187 = 187; +export let a188 = 188; +export let a189 = 189; +export let a190 = 190; +export let a191 = 191; +export let a192 = 192; +export let a193 = 193; +export let a194 = 194; +export let a195 = 195; +export let a196 = 196; +export let a197 = 197; +export let a198 = 198; +export let a199 = 199; +export let a200 = 200; +export let a201 = 201; +export let a202 = 202; +export let a203 = 203; +export let a204 = 204; +export let a205 = 205; +export let a206 = 206; +export let a207 = 207; +export let a208 = 208; +export let a209 = 209; +export let a210 = 210; +export let a211 = 211; +export let a212 = 212; +export let a213 = 213; +export let a214 = 214; +export let a215 = 215; +export let a216 = 216; +export let a217 = 217; +export let a218 = 218; +export let a219 = 219; +export let a220 = 220; +export let a221 = 221; +export let a222 = 222; +export let a223 = 223; +export let a224 = 224; +export let a225 = 225; +export let a226 = 226; +export let a227 = 227; +export let a228 = 228; +export let a229 = 229; +export let a230 = 230; +export let a231 = 231; +export let a232 = 232; +export let a233 = 233; +export let a234 = 234; +export let a235 = 235; +export let a236 = 236; +export let a237 = 237; +export let a238 = 238; +export let a239 = 239; +export let a240 = 240; +export let a241 = 241; +export let a242 = 242; +export let a243 = 243; +export let a244 = 244; +export let a245 = 245; +export let a246 = 246; +export let a247 = 247; +export let a248 = 248; +export let a249 = 249; +export let a250 = 250; +export let a251 = 251; +export let a252 = 252; +export let a253 = 253; +export let a254 = 254; +export let a255 = 255; +export let a256 = 256; +export let a257 = 257; +export let a258 = 258; +export let a259 = 259; +export let a260 = 260; +export let a261 = 261; +export let a262 = 262; +export let a263 = 263; +export let a264 = 264; +export let a265 = 265; +export let a266 = 266; +export let a267 = 267; +export let a268 = 268; +export let a269 = 269; +export let a270 = 270; +export let a271 = 271; +export let a272 = 272; +export let a273 = 273; +export let a274 = 274; +export let a275 = 275; +export let a276 = 276; +export let a277 = 277; +export let a278 = 278; +export let a279 = 279; +export let a280 = 280; +export let a281 = 281; +export let a282 = 282; +export let a283 = 283; +export let a284 = 284; +export let a285 = 285; +export let a286 = 286; +export let a287 = 287; +export let a288 = 288; +export let a289 = 289; +export let a290 = 290; +export let a291 = 291; +export let a292 = 292; +export let a293 = 293; +export let a294 = 294; +export let a295 = 295; +export let a296 = 296; +export let a297 = 297; +export let a298 = 298; +export let a299 = 299; +export let a300 = 300; +export let a301 = 301; +export let a302 = 302; +export let a303 = 303; +export let a304 = 304; +export let a305 = 305; +export let a306 = 306; +export let a307 = 307; +export let a308 = 308; +export let a309 = 309; +export let a310 = 310; +export let a311 = 311; +export let a312 = 312; +export let a313 = 313; +export let a314 = 314; +export let a315 = 315; +export let a316 = 316; +export let a317 = 317; +export let a318 = 318; +export let a319 = 319; +export let a320 = 320; +export let a321 = 321; +export let a322 = 322; +export let a323 = 323; +export let a324 = 324; +export let a325 = 325; +export let a326 = 326; +export let a327 = 327; +export let a328 = 328; +export let a329 = 329; +export let a330 = 330; +export let a331 = 331; +export let a332 = 332; +export let a333 = 333; +export let a334 = 334; +export let a335 = 335; +export let a336 = 336; +export let a337 = 337; +export let a338 = 338; +export let a339 = 339; +export let a340 = 340; +export let a341 = 341; +export let a342 = 342; +export let a343 = 343; +export let a344 = 344; +export let a345 = 345; +export let a346 = 346; +export let a347 = 347; +export let a348 = 348; +export let a349 = 349; +export let a350 = 350; +export let a351 = 351; +export let a352 = 352; +export let a353 = 353; +export let a354 = 354; +export let a355 = 355; +export let a356 = 356; +export let a357 = 357; +export let a358 = 358; +export let a359 = 359; +export let a360 = 360; +export let a361 = 361; +export let a362 = 362; +export let a363 = 363; +export let a364 = 364; +export let a365 = 365; +export let a366 = 366; +export let a367 = 367; +export let a368 = 368; +export let a369 = 369; +export let a370 = 370; +export let a371 = 371; +export let a372 = 372; +export let a373 = 373; +export let a374 = 374; +export let a375 = 375; +export let a376 = 376; +export let a377 = 377; +export let a378 = 378; +export let a379 = 379; +export let a380 = 380; +export let a381 = 381; +export let a382 = 382; +export let a383 = 383; +export let a384 = 384; +export let a385 = 385; +export let a386 = 386; +export let a387 = 387; +export let a388 = 388; +export let a389 = 389; +export let a390 = 390; +export let a391 = 391; +export let a392 = 392; +export let a393 = 393; +export let a394 = 394; +export let a395 = 395; +export let a396 = 396; +export let a397 = 397; +export let a398 = 398; +export let a399 = 399; +export let a400 = 400; +export let a401 = 401; +export let a402 = 402; +export let a403 = 403; +export let a404 = 404; +export let a405 = 405; +export let a406 = 406; +export let a407 = 407; +export let a408 = 408; +export let a409 = 409; +export let a410 = 410; +export let a411 = 411; +export let a412 = 412; +export let a413 = 413; +export let a414 = 414; +export let a415 = 415; +export let a416 = 416; +export let a417 = 417; +export let a418 = 418; +export let a419 = 419; +export let a420 = 420; +export let a421 = 421; +export let a422 = 422; +export let a423 = 423; +export let a424 = 424; +export let a425 = 425; +export let a426 = 426; +export let a427 = 427; +export let a428 = 428; +export let a429 = 429; +export let a430 = 430; +export let a431 = 431; +export let a432 = 432; +export let a433 = 433; +export let a434 = 434; +export let a435 = 435; +export let a436 = 436; +export let a437 = 437; +export let a438 = 438; +export let a439 = 439; +export let a440 = 440; +export let a441 = 441; +export let a442 = 442; +export let a443 = 443; +export let a444 = 444; +export let a445 = 445; +export let a446 = 446; +export let a447 = 447; +export let a448 = 448; +export let a449 = 449; +export let a450 = 450; +export let a451 = 451; +export let a452 = 452; +export let a453 = 453; +export let a454 = 454; +export let a455 = 455; +export let a456 = 456; +export let a457 = 457; +export let a458 = 458; +export let a459 = 459; +export let a460 = 460; +export let a461 = 461; +export let a462 = 462; +export let a463 = 463; +export let a464 = 464; +export let a465 = 465; +export let a466 = 466; +export let a467 = 467; +export let a468 = 468; +export let a469 = 469; +export let a470 = 470; +export let a471 = 471; +export let a472 = 472; +export let a473 = 473; +export let a474 = 474; +export let a475 = 475; +export let a476 = 476; +export let a477 = 477; +export let a478 = 478; +export let a479 = 479; +export let a480 = 480; +export let a481 = 481; +export let a482 = 482; +export let a483 = 483; +export let a484 = 484; +export let a485 = 485; +export let a486 = 486; +export let a487 = 487; +export let a488 = 488; +export let a489 = 489; +export let a490 = 490; +export let a491 = 491; +export let a492 = 492; +export let a493 = 493; +export let a494 = 494; +export let a495 = 495; +export let a496 = 496; +export let a497 = 497; +export let a498 = 498; +export let a499 = 499; +export let a500 = 500; +export let a501 = 501; +export let a502 = 502; +export let a503 = 503; +export let a504 = 504; +export let a505 = 505; +export let a506 = 506; +export let a507 = 507; +export let a508 = 508; +export let a509 = 509; +export let a510 = 510; +export let a511 = 511; +export let a512 = 512; +export let a513 = 513; +export let a514 = 514; +export let a515 = 515; +export let a516 = 516; +export let a517 = 517; +export let a518 = 518; +export let a519 = 519; +export let a520 = 520; +export let a521 = 521; +export let a522 = 522; +export let a523 = 523; +export let a524 = 524; +export let a525 = 525; +export let a526 = 526; +export let a527 = 527; +export let a528 = 528; +export let a529 = 529; +export let a530 = 530; +export let a531 = 531; +export let a532 = 532; +export let a533 = 533; +export let a534 = 534; +export let a535 = 535; +export let a536 = 536; +export let a537 = 537; +export let a538 = 538; +export let a539 = 539; +export let a540 = 540; +export let a541 = 541; +export let a542 = 542; +export let a543 = 543; +export let a544 = 544; +export let a545 = 545; +export let a546 = 546; +export let a547 = 547; +export let a548 = 548; +export let a549 = 549; +export let a550 = 550; +export let a551 = 551; +export let a552 = 552; +export let a553 = 553; +export let a554 = 554; +export let a555 = 555; +export let a556 = 556; +export let a557 = 557; +export let a558 = 558; +export let a559 = 559; +export let a560 = 560; +export let a561 = 561; +export let a562 = 562; +export let a563 = 563; +export let a564 = 564; +export let a565 = 565; +export let a566 = 566; +export let a567 = 567; +export let a568 = 568; +export let a569 = 569; +export let a570 = 570; +export let a571 = 571; +export let a572 = 572; +export let a573 = 573; +export let a574 = 574; +export let a575 = 575; +export let a576 = 576; +export let a577 = 577; +export let a578 = 578; +export let a579 = 579; +export let a580 = 580; +export let a581 = 581; +export let a582 = 582; +export let a583 = 583; +export let a584 = 584; +export let a585 = 585; +export let a586 = 586; +export let a587 = 587; +export let a588 = 588; +export let a589 = 589; +export let a590 = 590; +export let a591 = 591; +export let a592 = 592; +export let a593 = 593; +export let a594 = 594; +export let a595 = 595; +export let a596 = 596; +export let a597 = 597; +export let a598 = 598; +export let a599 = 599; +export let a600 = 600; +export let a601 = 601; +export let a602 = 602; +export let a603 = 603; +export let a604 = 604; +export let a605 = 605; +export let a606 = 606; +export let a607 = 607; +export let a608 = 608; +export let a609 = 609; +export let a610 = 610; +export let a611 = 611; +export let a612 = 612; +export let a613 = 613; +export let a614 = 614; +export let a615 = 615; +export let a616 = 616; +export let a617 = 617; +export let a618 = 618; +export let a619 = 619; +export let a620 = 620; +export let a621 = 621; +export let a622 = 622; +export let a623 = 623; +export let a624 = 624; +export let a625 = 625; +export let a626 = 626; +export let a627 = 627; +export let a628 = 628; +export let a629 = 629; +export let a630 = 630; +export let a631 = 631; +export let a632 = 632; +export let a633 = 633; +export let a634 = 634; +export let a635 = 635; +export let a636 = 636; +export let a637 = 637; +export let a638 = 638; +export let a639 = 639; +export let a640 = 640; +export let a641 = 641; +export let a642 = 642; +export let a643 = 643; +export let a644 = 644; +export let a645 = 645; +export let a646 = 646; +export let a647 = 647; +export let a648 = 648; +export let a649 = 649; +export let a650 = 650; +export let a651 = 651; +export let a652 = 652; +export let a653 = 653; +export let a654 = 654; +export let a655 = 655; +export let a656 = 656; +export let a657 = 657; +export let a658 = 658; +export let a659 = 659; +export let a660 = 660; +export let a661 = 661; +export let a662 = 662; +export let a663 = 663; +export let a664 = 664; +export let a665 = 665; +export let a666 = 666; +export let a667 = 667; +export let a668 = 668; +export let a669 = 669; +export let a670 = 670; +export let a671 = 671; +export let a672 = 672; +export let a673 = 673; +export let a674 = 674; +export let a675 = 675; +export let a676 = 676; +export let a677 = 677; +export let a678 = 678; +export let a679 = 679; +export let a680 = 680; +export let a681 = 681; +export let a682 = 682; +export let a683 = 683; +export let a684 = 684; +export let a685 = 685; +export let a686 = 686; +export let a687 = 687; +export let a688 = 688; +export let a689 = 689; +export let a690 = 690; +export let a691 = 691; +export let a692 = 692; +export let a693 = 693; +export let a694 = 694; +export let a695 = 695; +export let a696 = 696; +export let a697 = 697; +export let a698 = 698; +export let a699 = 699; +export let a700 = 700; +export let a701 = 701; +export let a702 = 702; +export let a703 = 703; +export let a704 = 704; +export let a705 = 705; +export let a706 = 706; +export let a707 = 707; +export let a708 = 708; +export let a709 = 709; +export let a710 = 710; +export let a711 = 711; +export let a712 = 712; +export let a713 = 713; +export let a714 = 714; +export let a715 = 715; +export let a716 = 716; +export let a717 = 717; +export let a718 = 718; +export let a719 = 719; +export let a720 = 720; +export let a721 = 721; +export let a722 = 722; +export let a723 = 723; +export let a724 = 724; +export let a725 = 725; +export let a726 = 726; +export let a727 = 727; +export let a728 = 728; +export let a729 = 729; +export let a730 = 730; +export let a731 = 731; +export let a732 = 732; +export let a733 = 733; +export let a734 = 734; +export let a735 = 735; +export let a736 = 736; +export let a737 = 737; +export let a738 = 738; +export let a739 = 739; +export let a740 = 740; +export let a741 = 741; +export let a742 = 742; +export let a743 = 743; +export let a744 = 744; +export let a745 = 745; +export let a746 = 746; +export let a747 = 747; +export let a748 = 748; +export let a749 = 749; +export let a750 = 750; +export let a751 = 751; +export let a752 = 752; +export let a753 = 753; +export let a754 = 754; +export let a755 = 755; +export let a756 = 756; +export let a757 = 757; +export let a758 = 758; +export let a759 = 759; +export let a760 = 760; +export let a761 = 761; +export let a762 = 762; +export let a763 = 763; +export let a764 = 764; +export let a765 = 765; +export let a766 = 766; +export let a767 = 767; +export let a768 = 768; +export let a769 = 769; +export let a770 = 770; +export let a771 = 771; +export let a772 = 772; +export let a773 = 773; +export let a774 = 774; +export let a775 = 775; +export let a776 = 776; +export let a777 = 777; +export let a778 = 778; +export let a779 = 779; +export let a780 = 780; +export let a781 = 781; +export let a782 = 782; +export let a783 = 783; +export let a784 = 784; +export let a785 = 785; +export let a786 = 786; +export let a787 = 787; +export let a788 = 788; +export let a789 = 789; +export let a790 = 790; +export let a791 = 791; +export let a792 = 792; +export let a793 = 793; +export let a794 = 794; +export let a795 = 795; +export let a796 = 796; +export let a797 = 797; +export let a798 = 798; +export let a799 = 799; +export let a800 = 800; +export let a801 = 801; +export let a802 = 802; +export let a803 = 803; +export let a804 = 804; +export let a805 = 805; +export let a806 = 806; +export let a807 = 807; +export let a808 = 808; +export let a809 = 809; +export let a810 = 810; +export let a811 = 811; +export let a812 = 812; +export let a813 = 813; +export let a814 = 814; +export let a815 = 815; +export let a816 = 816; +export let a817 = 817; +export let a818 = 818; +export let a819 = 819; +export let a820 = 820; +export let a821 = 821; +export let a822 = 822; +export let a823 = 823; +export let a824 = 824; +export let a825 = 825; +export let a826 = 826; +export let a827 = 827; +export let a828 = 828; +export let a829 = 829; +export let a830 = 830; +export let a831 = 831; +export let a832 = 832; +export let a833 = 833; +export let a834 = 834; +export let a835 = 835; +export let a836 = 836; +export let a837 = 837; +export let a838 = 838; +export let a839 = 839; +export let a840 = 840; +export let a841 = 841; +export let a842 = 842; +export let a843 = 843; +export let a844 = 844; +export let a845 = 845; +export let a846 = 846; +export let a847 = 847; +export let a848 = 848; +export let a849 = 849; +export let a850 = 850; +export let a851 = 851; +export let a852 = 852; +export let a853 = 853; +export let a854 = 854; +export let a855 = 855; +export let a856 = 856; +export let a857 = 857; +export let a858 = 858; +export let a859 = 859; +export let a860 = 860; +export let a861 = 861; +export let a862 = 862; +export let a863 = 863; +export let a864 = 864; +export let a865 = 865; +export let a866 = 866; +export let a867 = 867; +export let a868 = 868; +export let a869 = 869; +export let a870 = 870; +export let a871 = 871; +export let a872 = 872; +export let a873 = 873; +export let a874 = 874; +export let a875 = 875; +export let a876 = 876; +export let a877 = 877; +export let a878 = 878; +export let a879 = 879; +export let a880 = 880; +export let a881 = 881; +export let a882 = 882; +export let a883 = 883; +export let a884 = 884; +export let a885 = 885; +export let a886 = 886; +export let a887 = 887; +export let a888 = 888; +export let a889 = 889; +export let a890 = 890; +export let a891 = 891; +export let a892 = 892; +export let a893 = 893; +export let a894 = 894; +export let a895 = 895; +export let a896 = 896; +export let a897 = 897; +export let a898 = 898; +export let a899 = 899; +export let a900 = 900; +export let a901 = 901; +export let a902 = 902; +export let a903 = 903; +export let a904 = 904; +export let a905 = 905; +export let a906 = 906; +export let a907 = 907; +export let a908 = 908; +export let a909 = 909; +export let a910 = 910; +export let a911 = 911; +export let a912 = 912; +export let a913 = 913; +export let a914 = 914; +export let a915 = 915; +export let a916 = 916; +export let a917 = 917; +export let a918 = 918; +export let a919 = 919; +export let a920 = 920; +export let a921 = 921; +export let a922 = 922; +export let a923 = 923; +export let a924 = 924; +export let a925 = 925; +export let a926 = 926; +export let a927 = 927; +export let a928 = 928; +export let a929 = 929; +export let a930 = 930; +export let a931 = 931; +export let a932 = 932; +export let a933 = 933; +export let a934 = 934; +export let a935 = 935; +export let a936 = 936; +export let a937 = 937; +export let a938 = 938; +export let a939 = 939; +export let a940 = 940; +export let a941 = 941; +export let a942 = 942; +export let a943 = 943; +export let a944 = 944; +export let a945 = 945; +export let a946 = 946; +export let a947 = 947; +export let a948 = 948; +export let a949 = 949; +export let a950 = 950; +export let a951 = 951; +export let a952 = 952; +export let a953 = 953; +export let a954 = 954; +export let a955 = 955; +export let a956 = 956; +export let a957 = 957; +export let a958 = 958; +export let a959 = 959; +export let a960 = 960; +export let a961 = 961; +export let a962 = 962; +export let a963 = 963; +export let a964 = 964; +export let a965 = 965; +export let a966 = 966; +export let a967 = 967; +export let a968 = 968; +export let a969 = 969; +export let a970 = 970; +export let a971 = 971; +export let a972 = 972; +export let a973 = 973; +export let a974 = 974; +export let a975 = 975; +export let a976 = 976; +export let a977 = 977; +export let a978 = 978; +export let a979 = 979; +export let a980 = 980; +export let a981 = 981; +export let a982 = 982; +export let a983 = 983; +export let a984 = 984; +export let a985 = 985; +export let a986 = 986; +export let a987 = 987; +export let a988 = 988; +export let a989 = 989; +export let a990 = 990; +export let a991 = 991; +export let a992 = 992; +export let a993 = 993; +export let a994 = 994; +export let a995 = 995; +export let a996 = 996; +export let a997 = 997; +export let a998 = 998; +export let a999 = 999; +export let a1000 = 1000; +export let a1001 = 1001; +export let a1002 = 1002; +export let a1003 = 1003; +export let a1004 = 1004; +export let a1005 = 1005; +export let a1006 = 1006; +export let a1007 = 1007; +export let a1008 = 1008; +export let a1009 = 1009; +export let a1010 = 1010; +export let a1011 = 1011; +export let a1012 = 1012; +export let a1013 = 1013; +export let a1014 = 1014; +export let a1015 = 1015; +export let a1016 = 1016; +export let a1017 = 1017; +export let a1018 = 1018; +export let a1019 = 1019; +export let a1020 = 1020; +export let a1021 = 1021; +export let a1022 = 1022; +export let a1023 = 1023; +export let a1024 = 1024; +export let a1025 = 1025; +export let a1026 = 1026; +export let a1027 = 1027; +export let a1028 = 1028; +export let a1029 = 1029; +export let a1030 = 1030; +export let a1031 = 1031; +export let a1032 = 1032; +export let a1033 = 1033; +export let a1034 = 1034; +export let a1035 = 1035; +export let a1036 = 1036; +export let a1037 = 1037; +export let a1038 = 1038; +export let a1039 = 1039; +export let a1040 = 1040; +export let a1041 = 1041; +export let a1042 = 1042; +export let a1043 = 1043; +export let a1044 = 1044; +export let a1045 = 1045; +export let a1046 = 1046; +export let a1047 = 1047; +export let a1048 = 1048; +export let a1049 = 1049; +export let a1050 = 1050; +export let a1051 = 1051; +export let a1052 = 1052; +export let a1053 = 1053; +export let a1054 = 1054; +export let a1055 = 1055; +export let a1056 = 1056; +export let a1057 = 1057; +export let a1058 = 1058; +export let a1059 = 1059; +export let a1060 = 1060; +export let a1061 = 1061; +export let a1062 = 1062; +export let a1063 = 1063; +export let a1064 = 1064; +export let a1065 = 1065; +export let a1066 = 1066; +export let a1067 = 1067; +export let a1068 = 1068; +export let a1069 = 1069; +export let a1070 = 1070; +export let a1071 = 1071; +export let a1072 = 1072; +export let a1073 = 1073; +export let a1074 = 1074; +export let a1075 = 1075; +export let a1076 = 1076; +export let a1077 = 1077; +export let a1078 = 1078; +export let a1079 = 1079; +export let a1080 = 1080; +export let a1081 = 1081; +export let a1082 = 1082; +export let a1083 = 1083; +export let a1084 = 1084; +export let a1085 = 1085; +export let a1086 = 1086; +export let a1087 = 1087; +export let a1088 = 1088; +export let a1089 = 1089; +export let a1090 = 1090; +export let a1091 = 1091; +export let a1092 = 1092; +export let a1093 = 1093; +export let a1094 = 1094; +export let a1095 = 1095; +export let a1096 = 1096; +export let a1097 = 1097; +export let a1098 = 1098; +export let a1099 = 1099; diff --git a/deps/v8/test/mjsunit/harmony/promise-prototype-finally.js b/deps/v8/test/mjsunit/harmony/promise-prototype-finally.js index d80065f10d..3668ab5538 100644 --- a/deps/v8/test/mjsunit/harmony/promise-prototype-finally.js +++ b/deps/v8/test/mjsunit/harmony/promise-prototype-finally.js @@ -524,3 +524,84 @@ assertTrue(descriptor.configurable); assertFalse(descriptor.enumerable); assertEquals("finally", Promise.prototype.finally.name); assertEquals(1, Promise.prototype.finally.length); + +var count = 0; +class FooPromise extends Promise { + constructor(resolve, reject) { + count++; + return super(resolve, reject); + } +} + +testAsync(assert => { + assert.plan(1); + count = 0; + + new FooPromise(r => r()).finally(() => {}).then(() => { + assert.equals(6, count); + }); +}, "finally/speciesconstructor"); + +testAsync(assert => { + assert.plan(1); + count = 0; + + FooPromise.resolve().finally(() => {}).then(() => { + assert.equals(6, count); + }) +}, "resolve/finally/speciesconstructor"); + +testAsync(assert => { + assert.plan(1); + count = 0; + + FooPromise.reject().finally(() => {}).catch(() => { + assert.equals(6, count); + }) +}, "reject/finally/speciesconstructor"); + +testAsync(assert => { + assert.plan(2); + + class MyPromise extends Promise { + static get [Symbol.species]() { return Promise; } + } + + var p = Promise + .resolve() + .finally(() => MyPromise.resolve()); + + assert.equals(true, p instanceof Promise); + assert.equals(false, p instanceof MyPromise); +}, "finally/Symbol.Species"); + +testAsync(assert => { + assert.plan(3); + let resolve; + let value = 0; + + let p = new Promise(r => { resolve = r }); + + Promise.resolve() + .finally(() => { + return p; + }) + .then(() => { + value = 1; + }); + + // This makes sure we take the fast path in PromiseResolve that just + // returns the promise it receives as value. If we had to create + // another wrapper promise, that would cause an additional tick in + // the microtask queue. + Promise.resolve() + // onFinally has run. + .then(() => { resolve(); }) + // thenFinally has run. + .then(() => assert.equals(0, value)) + // promise returned by .finally has been resolved. + .then(() => assert.equals(0, value)) + // onFulfilled callback of .then() has run. + .then(() => assert.equals(1, value)); + +}, "PromiseResolve-ordering"); diff --git a/deps/v8/test/mjsunit/harmony/regexp-named-captures.js b/deps/v8/test/mjsunit/harmony/regexp-named-captures.js index be90427cfa..3ce947d1e5 100644 --- a/deps/v8/test/mjsunit/harmony/regexp-named-captures.js +++ b/deps/v8/test/mjsunit/harmony/regexp-named-captures.js @@ -360,6 +360,7 @@ function toSlowMode(re) { assertEquals("bacd", "abcd".replace(re, "$2$1")); assertEquals("cd", "abcd".replace(re, "$3")); assertEquals("$<sndcd", "abcd".replace(re, "$<snd")); + assertEquals("$<sndacd", "abcd".replace(re, "$<snd$1")); assertEquals("$<42a>cd", "abcd".replace(re, "$<42$1>")); assertEquals("$<fth>cd", "abcd".replace(re, "$<fth>")); assertEquals("$<a>cd", "abcd".replace(re, "$<$1>")); @@ -371,10 +372,11 @@ function toSlowMode(re) { assertEquals("badc", "abcd".replace(re, "$<snd>$<fst>")); assertEquals("badc", "abcd".replace(re, "$2$1")); assertEquals("", "abcd".replace(re, "$<thd>")); - assertThrows(() => "abcd".replace(re, "$<snd"), SyntaxError); - assertThrows(() => "abcd".replace(re, "$<42$1>"), SyntaxError); - assertThrows(() => "abcd".replace(re, "$<fth>"), SyntaxError); - assertThrows(() => "abcd".replace(re, "$<$1>"), SyntaxError); + assertEquals("$<snd$<snd", "abcd".replace(re, "$<snd")); + assertEquals("$<snda$<sndc", "abcd".replace(re, "$<snd$1")); + assertEquals("", "abcd".replace(re, "$<42$1>")); + assertEquals("", "abcd".replace(re, "$<fth>")); + assertEquals("", "abcd".replace(re, "$<$1>")); } // @@replace with a string replacement argument (non-global, named captures). @@ -383,10 +385,11 @@ function toSlowMode(re) { assertEquals("bacd", "abcd".replace(re, "$<snd>$<fst>")); assertEquals("bacd", "abcd".replace(re, "$2$1")); assertEquals("cd", "abcd".replace(re, "$<thd>")); - assertThrows(() => "abcd".replace(re, "$<snd"), SyntaxError); - assertThrows(() => "abcd".replace(re, "$<42$1>"), SyntaxError); - assertThrows(() => "abcd".replace(re, "$<fth>"), SyntaxError); - assertThrows(() => "abcd".replace(re, "$<$1>"), SyntaxError); + assertEquals("$<sndcd", "abcd".replace(re, "$<snd")); + assertEquals("$<sndacd", "abcd".replace(re, "$<snd$1")); + assertEquals("cd", "abcd".replace(re, "$<42$1>")); + assertEquals("cd", "abcd".replace(re, "$<fth>")); + assertEquals("cd", "abcd".replace(re, "$<$1>")); } // @@replace with a string replacement argument (slow, global, named captures). @@ -395,10 +398,11 @@ function toSlowMode(re) { assertEquals("badc", "abcd".replace(re, "$<snd>$<fst>")); assertEquals("badc", "abcd".replace(re, "$2$1")); assertEquals("", "abcd".replace(re, "$<thd>")); - assertThrows(() => "abcd".replace(re, "$<snd"), SyntaxError); - assertThrows(() => "abcd".replace(re, "$<42$1>"), SyntaxError); - assertThrows(() => "abcd".replace(re, "$<fth>"), SyntaxError); - assertThrows(() => "abcd".replace(re, "$<$1>"), SyntaxError); + assertEquals("$<snd$<snd", "abcd".replace(re, "$<snd")); + assertEquals("$<snda$<sndc", "abcd".replace(re, "$<snd$1")); + assertEquals("", "abcd".replace(re, "$<42$1>")); + assertEquals("", "abcd".replace(re, "$<fth>")); + assertEquals("", "abcd".replace(re, "$<$1>")); } // @@replace with a string replacement argument (slow, non-global, @@ -408,8 +412,9 @@ function toSlowMode(re) { assertEquals("bacd", "abcd".replace(re, "$<snd>$<fst>")); assertEquals("bacd", "abcd".replace(re, "$2$1")); assertEquals("cd", "abcd".replace(re, "$<thd>")); - assertThrows(() => "abcd".replace(re, "$<snd"), SyntaxError); - assertThrows(() => "abcd".replace(re, "$<42$1>"), SyntaxError); - assertThrows(() => "abcd".replace(re, "$<fth>"), SyntaxError); - assertThrows(() => "abcd".replace(re, "$<$1>"), SyntaxError); + assertEquals("$<sndcd", "abcd".replace(re, "$<snd")); + assertEquals("$<sndacd", "abcd".replace(re, "$<snd$1")); + assertEquals("cd", "abcd".replace(re, "$<42$1>")); + assertEquals("cd", "abcd".replace(re, "$<fth>")); + assertEquals("cd", "abcd".replace(re, "$<$1>")); } diff --git a/deps/v8/test/mjsunit/harmony/regress/regress-771470.js b/deps/v8/test/mjsunit/harmony/regress/regress-771470.js new file mode 100644 index 0000000000..9776fb0bad --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/regress/regress-771470.js @@ -0,0 +1,8 @@ +// Copyright 2017 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. + +// Flags: --enable-slow-asserts + +async function* gen() { }; +gen.prototype = 1; diff --git a/deps/v8/test/mjsunit/harmony/regress/regress-772649.js b/deps/v8/test/mjsunit/harmony/regress/regress-772649.js new file mode 100644 index 0000000000..d080410226 --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/regress/regress-772649.js @@ -0,0 +1,11 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax --harmony-async-iteration + +async function* gen([[notIterable]] = [null]) {} +assertThrows(() => gen(), TypeError); +assertThrows(() => gen(), TypeError); +%OptimizeFunctionOnNextCall(gen); +assertThrows(() => gen(), TypeError); diff --git a/deps/v8/test/mjsunit/messages.js b/deps/v8/test/mjsunit/messages.js index a57e1fcf1c..934a731e8f 100644 --- a/deps/v8/test/mjsunit/messages.js +++ b/deps/v8/test/mjsunit/messages.js @@ -70,12 +70,24 @@ test(function() { // kCalledOnNullOrUndefined test(function() { + String.prototype.includes.call(null); +}, "String.prototype.includes called on null or undefined", TypeError); + +test(function() { Array.prototype.shift.call(null); }, "Array.prototype.shift called on null or undefined", TypeError); test(function() { - String.prototype.includes.call(null); -}, "String.prototype.includes called on null or undefined", TypeError); + String.prototype.trim.call(null); +}, "String.prototype.trim called on null or undefined", TypeError); + +test(function() { + String.prototype.trimLeft.call(null); +}, "String.prototype.trimLeft called on null or undefined", TypeError); + +test(function() { + String.prototype.trimRight.call(null); +}, "String.prototype.trimRight called on null or undefined", TypeError); // kCannotFreezeArrayBufferView test(function() { @@ -428,6 +440,11 @@ test(function() { new Uint16Array(-1); }, "Invalid typed array length: -1", RangeError); +// kThrowInvalidStringLength +test(function() { + "a".repeat(1 << 30); +}, "Invalid string length", RangeError); + // kNormalizationForm test(function() { "".normalize("ABC"); diff --git a/deps/v8/test/mjsunit/mjsunit.js b/deps/v8/test/mjsunit/mjsunit.js index 77f8b7605b..d3db2e2e94 100644 --- a/deps/v8/test/mjsunit/mjsunit.js +++ b/deps/v8/test/mjsunit/mjsunit.js @@ -550,7 +550,7 @@ var failWithMessage; try { success(result); } catch (e) { - failWithMessage(e); + failWithMessage(String(e)); } }, result => { @@ -582,7 +582,8 @@ var failWithMessage; return OptimizationStatusImpl(fun, sync_opt); } - assertUnoptimized = function assertUnoptimized(fun, sync_opt, name_opt) { + assertUnoptimized = function assertUnoptimized(fun, sync_opt, name_opt, + skip_if_maybe_deopted = true) { if (sync_opt === undefined) sync_opt = ""; var opt_status = OptimizationStatus(fun, sync_opt); // Tests that use assertUnoptimized() do not make sense if --always-opt @@ -590,7 +591,8 @@ var failWithMessage; assertFalse((opt_status & V8OptimizationStatus.kAlwaysOptimize) !== 0, "test does not make sense with --always-opt"); assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0, name_opt); - if ((opt_status & V8OptimizationStatus.kMaybeDeopted) !== 0) { + if (skip_if_maybe_deopted && + (opt_status & V8OptimizationStatus.kMaybeDeopted) !== 0) { // When --deopt-every-n-times flag is specified it's no longer guaranteed // that particular function is still deoptimized, so keep running the test // to stress test the deoptimizer. @@ -599,7 +601,8 @@ var failWithMessage; assertFalse((opt_status & V8OptimizationStatus.kOptimized) !== 0, name_opt); } - assertOptimized = function assertOptimized(fun, sync_opt, name_opt) { + assertOptimized = function assertOptimized(fun, sync_opt, name_opt, + skip_if_maybe_deopted = true) { if (sync_opt === undefined) sync_opt = ""; var opt_status = OptimizationStatus(fun, sync_opt); // Tests that use assertOptimized() do not make sense if --no-opt @@ -607,7 +610,8 @@ var failWithMessage; assertFalse((opt_status & V8OptimizationStatus.kNeverOptimize) !== 0, "test does not make sense with --no-opt"); assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0, name_opt); - if ((opt_status & V8OptimizationStatus.kMaybeDeopted) !== 0) { + if (skip_if_maybe_deopted && + (opt_status & V8OptimizationStatus.kMaybeDeopted) !== 0) { // When --deopt-every-n-times flag is specified it's no longer guaranteed // that particular function is still optimized, so keep running the test // to stress test the deoptimizer. diff --git a/deps/v8/test/mjsunit/mjsunit.status b/deps/v8/test/mjsunit/mjsunit.status index 4f49fdd595..b1b6f6aeb1 100644 --- a/deps/v8/test/mjsunit/mjsunit.status +++ b/deps/v8/test/mjsunit/mjsunit.status @@ -328,6 +328,7 @@ 'unicodelctest-no-optimization': [PASS, SLOW], 'unicodelctest': [PASS, SLOW], 'unicode-test': [PASS, SLOW], + 'wasm/atomics': [PASS, SLOW], 'whitespaces': [PASS, SLOW], }], # 'arch == arm64' @@ -656,4 +657,10 @@ 'mjsunit-assertion-error' : [SKIP], }], # no_harness +############################################################################## +['arch != x64 or deopt_fuzzer', { + # Skip stress-deopt-count tests since it's in x64 only + 'compiler/stress-deopt-count-*': [SKIP], +}], # arch != x64 or deopt_fuzzer + ] diff --git a/deps/v8/test/mjsunit/optimized-foreach-polymorph.js b/deps/v8/test/mjsunit/optimized-foreach-polymorph.js new file mode 100644 index 0000000000..ed4958354f --- /dev/null +++ b/deps/v8/test/mjsunit/optimized-foreach-polymorph.js @@ -0,0 +1,111 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax --expose-gc --turbo-inline-array-builtins + +var a = [0, 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,0,0]; +var b = [{}, {}]; +var c = [,,,,,2,3,4]; +var d = [0.5,3,4]; +var e = [,,,,0.5,3,4]; + +// Make sure that calls to forEach handle a certain degree of polymorphism (no +// hole check) +(function() { + var result = 0; + var polymorph1 = function(arg) { + var sum = function(v,i,o) { + result += i; + } + arg.forEach(sum); + } + polymorph1(a); + polymorph1(a); + polymorph1(b); + polymorph1(a); + polymorph1(a); + %OptimizeFunctionOnNextCall(polymorph1); + polymorph1(a); + polymorph1(b); + assertEquals(1757, result); +})(); + +// Make sure that calls to forEach handle a certain degree of polymorphism. +(function() { + var result = 0; + var polymorph1 = function(arg) { + var sum = function(v,i,o) { + result += i; + } + arg.forEach(sum); + } + polymorph1(a); + polymorph1(a); + polymorph1(b); + polymorph1(a); + polymorph1(c); + polymorph1(a); + %OptimizeFunctionOnNextCall(polymorph1); + polymorph1(a); + polymorph1(b); + assertEquals(1775, result); +})(); + +// Make sure that calls to forEach with mixed object/double arrays don't inline +// forEach. +(function() { + var result = 0; + var polymorph1 = function(arg) { + var sum = function(v,i,o) { + result += i; + } + arg.forEach(sum); + } + polymorph1(a); + polymorph1(a); + polymorph1(b); + polymorph1(a); + polymorph1(d); + polymorph1(a); + %OptimizeFunctionOnNextCall(polymorph1); + polymorph1(a); + polymorph1(b); + assertEquals(1760, result); +})(); + +// Make sure that calls to forEach with double arrays get the right result +(function() { + var result = 0; + var polymorph1 = function(arg) { + var sum = function(v,i,o) { + result += v; + } + arg.forEach(sum); + } + polymorph1(d); + polymorph1(d); + polymorph1(d); + %OptimizeFunctionOnNextCall(polymorph1); + polymorph1(d); + polymorph1(d); + assertEquals(37.5, result); +})(); + +// Make sure that calls to forEach with mixed double arrays get the right result +(function() { + var result = 0; + var polymorph1 = function(arg) { + var sum = function(v,i,o) { + result += v; + } + arg.forEach(sum); + } + polymorph1(d); + polymorph1(e); + polymorph1(d); + %OptimizeFunctionOnNextCall(polymorph1); + polymorph1(d); + polymorph1(e); + assertEquals(37.5, result); +})(); diff --git a/deps/v8/test/mjsunit/regress/regress-2435.js b/deps/v8/test/mjsunit/regress/regress-2435.js new file mode 100644 index 0000000000..05a4027339 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-2435.js @@ -0,0 +1,25 @@ +// Copyright 2017 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. + +function arrayLikeToString(a) { + return String.fromCharCode.apply(this, a); +} + +const klasses = [ + Int8Array, + Uint8Array, + Uint8ClampedArray, + Int16Array, + Uint16Array, + Int32Array, + Uint32Array, + Float32Array, + Float64Array +]; +const string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + +for (const klass of klasses) { + const array = klass.from(string, s => s.charCodeAt(0)); + assertEquals(string, arrayLikeToString(array)); +} diff --git a/deps/v8/test/mjsunit/regress/regress-6838-1.js b/deps/v8/test/mjsunit/regress/regress-6838-1.js new file mode 100644 index 0000000000..bab6a194d3 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-6838-1.js @@ -0,0 +1,33 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax + +(function TestMathMaxOnLargeInt() { + function Module(stdlib) { + "use asm"; + var max = stdlib.Math.max; + function f() { + return max(42,0xffffffff); + } + return f; + } + var f = Module(this); + assertEquals(0xffffffff, f()); + assertFalse(%IsAsmWasmCode(Module)); +})(); + +(function TestMathMinOnLargeInt() { + function Module(stdlib) { + "use asm"; + var min = stdlib.Math.min; + function f() { + return min(42,0xffffffff); + } + return f; + } + var f = Module(this); + assertEquals(42, f()); + assertFalse(%IsAsmWasmCode(Module)); +})(); diff --git a/deps/v8/test/mjsunit/regress/regress-6838-2.js b/deps/v8/test/mjsunit/regress/regress-6838-2.js new file mode 100644 index 0000000000..31b94b43c2 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-6838-2.js @@ -0,0 +1,101 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax + +(function TestMathCeilReturningFloatish() { + function Module(stdlib) { + "use asm"; + var ceil = stdlib.Math.ceil; + var fround = stdlib.Math.fround; + function f(a) { + a = fround(a); + return ceil(a); + } + return f; + } + var f = Module(this); + assertEquals(3, f(2.2)); + assertFalse(%IsAsmWasmCode(Module)); +})(); + +(function TestMathFloorReturningFloatish() { + function Module(stdlib) { + "use asm"; + var floor = stdlib.Math.floor; + var fround = stdlib.Math.fround; + function f(a) { + a = fround(a); + return floor(a); + } + return f; + } + var f = Module(this); + assertEquals(2, f(2.2)); + assertFalse(%IsAsmWasmCode(Module)); +})(); + +(function TestMathSqrtReturningFloatish() { + function Module(stdlib) { + "use asm"; + var sqrt = stdlib.Math.sqrt; + var fround = stdlib.Math.fround; + function f(a) { + a = fround(a); + return sqrt(a); + } + return f; + } + var f = Module(this); + assertEquals(Math.sqrt(Math.fround(2.2)), f(2.2)); + assertFalse(%IsAsmWasmCode(Module)); +})(); + +(function TestMathAbsReturningFloatish() { + function Module(stdlib) { + "use asm"; + var abs = stdlib.Math.abs; + var fround = stdlib.Math.fround; + function f(a) { + a = fround(a); + return abs(a); + } + return f; + } + var f = Module(this); + assertEquals(Math.fround(2.2), f(-2.2)); + assertFalse(%IsAsmWasmCode(Module)); +})(); + +(function TestMathMinReturningFloat() { + function Module(stdlib) { + "use asm"; + var min = stdlib.Math.min; + var fround = stdlib.Math.fround; + function f(a) { + a = fround(a); + return min(a, a); + } + return f; + } + var f = Module(this); + assertEquals(Math.fround(2.2), f(2.2)); + assertTrue(%IsAsmWasmCode(Module)); +})(); + +(function TestMathMaxReturningFloat() { + function Module(stdlib) { + "use asm"; + var max = stdlib.Math.max; + var fround = stdlib.Math.fround; + function f(a) { + a = fround(a); + return max(a, a); + } + return f; + } + var f = Module(this); + assertEquals(Math.fround(2.2), f(2.2)); + assertTrue(%IsAsmWasmCode(Module)); +})(); diff --git a/deps/v8/test/mjsunit/regress/regress-6838-3.js b/deps/v8/test/mjsunit/regress/regress-6838-3.js new file mode 100644 index 0000000000..639ffa5da7 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-6838-3.js @@ -0,0 +1,39 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax + +(function TestMathAbsReturningUnsigned() { + function Module(stdlib) { + "use asm"; + var abs=stdlib.Math.abs; + function f(a, b) { + a = a | 0; + b = b | 0; + return (abs(a >> 0) == (b >>> 0)) | 0; + } + return f; + } + var f = Module(this); + assertEquals(0, f(1, 2)); + assertEquals(1, f(23, 23)); + assertEquals(1, f(-42, 42)); + assertEquals(1, f(-0x7fffffff, 0x7fffffff)); + assertEquals(1, f(-0x80000000, 0x80000000)); + assertTrue(%IsAsmWasmCode(Module)); +})(); + +(function TestMathAbsOverflowSignedValue() { + function Module(stdlib) { + "use asm"; + var abs=stdlib.Math.abs; + function f() { + return (abs(-0x80000000) > 0) | 0; + } + return f; + } + var f = Module(this); + assertEquals(1, f()); + assertTrue(%IsAsmWasmCode(Module)); +})(); diff --git a/deps/v8/test/mjsunit/regress/regress-6907.js b/deps/v8/test/mjsunit/regress/regress-6907.js new file mode 100644 index 0000000000..0749365fed --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-6907.js @@ -0,0 +1,21 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax + +(function TestDematerializedContextInBuiltin() { + var f = function() { + var b = [1,2,3]; + var callback = function(v,i,o) { + %_DeoptimizeNow(); + }; + try { throw 0 } catch(e) { + return b.forEach(callback); + } + } + f(); + f(); + %OptimizeFunctionOnNextCall(f); + f(); +})(); diff --git a/deps/v8/test/mjsunit/regress/regress-719380.js b/deps/v8/test/mjsunit/regress/regress-719380.js index 18d541a5fe..4d41609c51 100644 --- a/deps/v8/test/mjsunit/regress/regress-719380.js +++ b/deps/v8/test/mjsunit/regress/regress-719380.js @@ -3,5 +3,5 @@ // found in the LICENSE file. TypeError.prototype.__defineGetter__("name", () => { throw 42; }); -console.log({ toString: () => { throw new TypeError() }}); +try { console.log({ toString: () => { throw new TypeError() }}); } catch (e) {} try { new WebAssembly.Table({}); } catch (e) {} diff --git a/deps/v8/test/mjsunit/regress/regress-760268.js b/deps/v8/test/mjsunit/regress/regress-760268.js new file mode 100644 index 0000000000..6884ae1dca --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-760268.js @@ -0,0 +1,11 @@ +// Copyright 2017 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. + +var obj = this; +var handler = { + has: function() { return false; } +} +var proxy = new Proxy(obj, handler); +Object.defineProperty(obj, "nonconf", {}); +assertThrows("'nonconf' in proxy"); diff --git a/deps/v8/test/mjsunit/regress/regress-760790.js b/deps/v8/test/mjsunit/regress/regress-760790.js new file mode 100644 index 0000000000..75770bad18 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-760790.js @@ -0,0 +1,11 @@ +// Copyright 2017 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. + +function g() { + var a = Array(0); + a[0]++; +} +g(); +g(); +g(); diff --git a/deps/v8/test/mjsunit/regress/regress-761639.js b/deps/v8/test/mjsunit/regress/regress-761639.js new file mode 100644 index 0000000000..a5fa69f6d8 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-761639.js @@ -0,0 +1,10 @@ +// Copyright 2017 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. + +// Regression test for hitting a DCHECK in StoreProxy. + + +for (var i = 0; i < 10; i++) { + __proto__ = new Proxy({}, { getPrototypeOf() { } }); +} diff --git a/deps/v8/test/mjsunit/regress/regress-772190.js b/deps/v8/test/mjsunit/regress/regress-772190.js new file mode 100644 index 0000000000..008ed63b4d --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-772190.js @@ -0,0 +1,10 @@ +// Copyright 2017 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. + +// Flags: --always-opt + +assertThrows(function() { + __v_13383[4]; + let __v_13383 = {}; +}); diff --git a/deps/v8/test/mjsunit/regress/regress-774475.js b/deps/v8/test/mjsunit/regress/regress-774475.js new file mode 100644 index 0000000000..b11ea6c231 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-774475.js @@ -0,0 +1,938 @@ +// Copyright 2017 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. + +var o = function f3() { + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; + x = 1; +} diff --git a/deps/v8/test/mjsunit/regress/regress-781218.js b/deps/v8/test/mjsunit/regress/regress-781218.js new file mode 100644 index 0000000000..ae00cc5c08 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-781218.js @@ -0,0 +1,43 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax + +var m = new Map(); + +function C() { } + +// Make sure slack tracking kicks in and shrinks the default size to prevent +// any further in-object properties. +%CompleteInobjectSlackTracking(new C()); + +function f(o) { + o.x = true; +} + +// Warm up {f}. +f(new C()); +f(new C()); + + +var o = new C(); +%HeapObjectVerify(o); + +m.set(o, 1); // This creates hash code on o. + +// Add an out-of-object property. +o.x = true; +%HeapObjectVerify(o); +// Delete the property (so we have no out-of-object properties). +delete o.x; +%HeapObjectVerify(o); + + +// Ensure that growing the properties backing store in optimized code preserves +// the hash. +%OptimizeFunctionOnNextCall(f); +f(o); + +%HeapObjectVerify(o); +assertEquals(1, m.get(o)); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-537444.js b/deps/v8/test/mjsunit/regress/regress-crbug-537444.js index 6f56fd148d..d6fe6b89a3 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-537444.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-537444.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --stress-inline "use strict"; @@ -19,8 +19,6 @@ function h(x) { return z + 1; } -%SetForceInlineFlag(g); -%SetForceInlineFlag(f); h(1); h(1); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-593697-2.js b/deps/v8/test/mjsunit/regress/regress-crbug-593697-2.js index c8af4a4e08..c26fdfdf67 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-593697-2.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-593697-2.js @@ -2,12 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --stress-inline "use strict"; -%SetForceInlineFlag(Math.cos); - var f5 = (function f6(stdlib) { "use asm"; var cos = stdlib.Math.cos; diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-598998.js b/deps/v8/test/mjsunit/regress/regress-crbug-598998.js index bbabf1e31d..a2a02623f5 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-598998.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-598998.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --stress-inline "use strict"; @@ -22,8 +22,6 @@ function h(x) { g(x, 1); } -%SetForceInlineFlag(g); -%SetForceInlineFlag(f); %NeverOptimizeFunction(deopt_function); h(1); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-608278.js b/deps/v8/test/mjsunit/regress/regress-crbug-608278.js index 251ecad86c..c8d2fcc745 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-608278.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-608278.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --stress-inline "use strict"; @@ -21,7 +21,6 @@ function h() { function g(v) { return h(); } -%SetForceInlineFlag(g); function f1() { diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-647217.js b/deps/v8/test/mjsunit/regress/regress-crbug-647217.js index e3968a19d6..ab45c9afa9 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-647217.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-647217.js @@ -2,11 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --stack-size=100 +// Flags: --allow-natives-syntax --stack-size=100 --stress-inline var source = "return 1" + new Array(2048).join(' + a') + ""; eval("function g(a) {" + source + "}"); -%SetForceInlineFlag(g); function f(a) { return g(a) } %OptimizeFunctionOnNextCall(f); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-714696.js b/deps/v8/test/mjsunit/regress/regress-crbug-714696.js index 16b09604e9..ad5925478d 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-714696.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-714696.js @@ -5,6 +5,6 @@ if (this.Intl) { new Intl.v8BreakIterator(); new Intl.DateTimeFormat(); - console.log({ toString: function() { throw 1; }}); + try { console.log({ toString: function() { throw 1; }}); } catch (e) {} new Intl.v8BreakIterator(); } diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-722871.js b/deps/v8/test/mjsunit/regress/regress-crbug-722871.js new file mode 100644 index 0000000000..c5b7958f49 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-722871.js @@ -0,0 +1,113 @@ +// Copyright 2017 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. +let sab = new SharedArrayBuffer(10 * 4); +let memory = new Int32Array(sab); +let workers = []; +let runningWorkers = 0; + +function startWorker(script) { + let worker = new Worker(script); + worker.done = false; + worker.idx = workers.length; + workers.push(worker); + worker.postMessage(memory); + ++runningWorkers; +}; + +let shared = ` + function wait(memory, index, waitCondition, wakeCondition) { + while (memory[index] == waitCondition) { + var result = Atomics.wait(memory, index, waitCondition); + switch (result) { + case 'not-equal': + case 'ok': + break; + default: + postMessage('Error: bad result from wait: ' + result); + break; + } + var value = memory[index]; + if (value != wakeCondition) { + postMessage( + 'Error: wait returned not-equal but the memory has a bad value: ' + + value); + } + } + var value = memory[index]; + if (value != wakeCondition) { + postMessage( + 'Error: done waiting but the memory has a bad value: ' + value); + } + } + + function wake(memory, index) { + var result = Atomics.wake(memory, index, 1); + if (result != 0 && result != 1) { + postMessage('Error: bad result from wake: ' + result); + } + } +`; + +let worker1 = startWorker(shared + ` + onmessage = function(msg) { + let memory = msg; + const didStartIdx = 0; + const shouldGoIdx = 1; + const didEndIdx = 2; + + postMessage("started"); + postMessage("memory: " + memory); + wait(memory, didStartIdx, 0, 1); + memory[shouldGoIdx] = 1; + wake(memory, shouldGoIdx); + wait(memory, didEndIdx, 0, 1); + postMessage("memory: " + memory); + postMessage("done"); + }; +`); + +let worker2 = startWorker(shared + ` + onmessage = function(msg) { + let memory = msg; + const didStartIdx = 0; + const shouldGoIdx = 1; + const didEndIdx = 2; + + postMessage("started"); + postMessage("memory: " + memory); + Atomics.store(memory, didStartIdx, 1); + wake(memory, didStartIdx); + wait(memory, shouldGoIdx, 0, 1); + Atomics.store(memory, didEndIdx, 1); + wake(memory, didEndIdx, 1); + postMessage("memory: " + memory); + postMessage("done"); + }; +`); + +let running = true; +while (running) { + for (let worker of workers) { + if (worker.done) continue; + + let msg = worker.getMessage(); + if (msg) { + switch (msg) { + case "done": + if (worker.done === false) { + print("worker #" + worker.idx + " done."); + worker.done = true; + if (--runningWorkers === 0) { + running = false; + } + } + break; + + default: + print("msg from worker #" + worker.idx + ": " + msg); + break; + } + } + } +} diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-764219.js b/deps/v8/test/mjsunit/regress/regress-crbug-764219.js new file mode 100644 index 0000000000..2a92d66d2e --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-764219.js @@ -0,0 +1,35 @@ +// Copyright 2017 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. + +(function() { + function f(o) { + o.x = 42; + }; + + f({}); + f(this); + f(this); +})(); + +(function() { + function f(o) { + o.y = 153; + }; + + Object.setPrototypeOf(this, new Proxy({}, {})); + f({}); + f(this); + f(this); +})(); + +(function() { + function f(o) { + o.z = 153; + }; + + Object.setPrototypeOf(this, new Proxy({get z(){}}, {})); + f({}); + f(this); + f(this); +})(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-768080.js b/deps/v8/test/mjsunit/regress/regress-crbug-768080.js new file mode 100644 index 0000000000..cfd1fc1f35 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-768080.js @@ -0,0 +1,64 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax + +(function TestReflectConstructBogusNewTarget1() { + class C {} + function g() { + Reflect.construct(C, arguments, 23); + } + function f() { + return new g(); + } + new C(); // Warm-up! + assertThrows(f, TypeError); + assertThrows(f, TypeError); + %OptimizeFunctionOnNextCall(f); + assertThrows(f, TypeError); +})(); + +(function TestReflectConstructBogusNewTarget2() { + class C {} + // Note that {unescape} is an example of a non-constructable function. If that + // ever changes and this test needs to be adapted, make sure to choose another + // non-constructable {JSFunction} object instead. + function g() { + Reflect.construct(C, arguments, unescape); + } + function f() { + return new g(); + } + new C(); // Warm-up! + assertThrows(f, TypeError); + assertThrows(f, TypeError); + %OptimizeFunctionOnNextCall(f); + assertThrows(f, TypeError); +})(); + +(function TestReflectConstructBogusTarget() { + function g() { + Reflect.construct(23, arguments); + } + function f() { + return new g(); + } + assertThrows(f, TypeError); + assertThrows(f, TypeError); + %OptimizeFunctionOnNextCall(f); + assertThrows(f, TypeError); +})(); + +(function TestReflectApplyBogusTarget() { + function g() { + Reflect.apply(23, this, arguments); + } + function f() { + return g(); + } + assertThrows(f, TypeError); + assertThrows(f, TypeError); + %OptimizeFunctionOnNextCall(f); + assertThrows(f, TypeError); +})(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-768367.js b/deps/v8/test/mjsunit/regress/regress-crbug-768367.js new file mode 100644 index 0000000000..d1041f32ce --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-768367.js @@ -0,0 +1,14 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax + +const o = {}; + +function foo() { return o[4294967295]; } + +assertEquals(undefined, foo()); +assertEquals(undefined, foo()); +%OptimizeFunctionOnNextCall(foo); +assertEquals(undefined, foo()); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-769852.js b/deps/v8/test/mjsunit/regress/regress-crbug-769852.js new file mode 100644 index 0000000000..120ea0109e --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-769852.js @@ -0,0 +1,14 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax + +function f(o) { + function g() {} + Object.keys(o).forEach(suite => g()); +} +assertDoesNotThrow(() => f({})); +assertDoesNotThrow(() => f({ x:0 })); +%OptimizeFunctionOnNextCall(f); +assertDoesNotThrow(() => f({ x:0 })); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-770543.js b/deps/v8/test/mjsunit/regress/regress-crbug-770543.js new file mode 100644 index 0000000000..5397a499c3 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-770543.js @@ -0,0 +1,31 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax + +(function FunctionCallerFromInlinedBuiltin() { + function f() { + function g() { + Object.getOwnPropertyDescriptor(g, "caller"); + }; + [0].forEach(g); + } + f(); + f(); + %OptimizeFunctionOnNextCall(f); + f(); +})(); + +(function FunctionArgumentsFromInlinedBuiltin() { + function g() { + g.arguments; + } + function f() { + [0].forEach(g); + } + f(); + f(); + %OptimizeFunctionOnNextCall(f); + f(); +})(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-770581.js b/deps/v8/test/mjsunit/regress/regress-crbug-770581.js new file mode 100644 index 0000000000..64edec97cd --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-770581.js @@ -0,0 +1,22 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax + +function f(callback) { + [Object].forEach(callback); +} + +function message_of_f() { + try { + f("a teapot"); + } catch(e) { + return String(e); + } +} + +assertEquals("TypeError: a teapot is not a function", message_of_f()); +assertEquals("TypeError: a teapot is not a function", message_of_f()); +%OptimizeFunctionOnNextCall(f); +assertEquals("TypeError: a teapot is not a function", message_of_f()); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-771971.js b/deps/v8/test/mjsunit/regress/regress-crbug-771971.js new file mode 100644 index 0000000000..cb40db5aa3 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-771971.js @@ -0,0 +1,12 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax + +function f() { Object.is(); } + +f(); +f(); +%OptimizeFunctionOnNextCall(f); +f(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-772056.js b/deps/v8/test/mjsunit/regress/regress-crbug-772056.js new file mode 100644 index 0000000000..380bae356d --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-772056.js @@ -0,0 +1,17 @@ +// Copyright 2017 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. + +// Flags: --expose-wasm + +load("test/mjsunit/wasm/wasm-constants.js"); +load("test/mjsunit/wasm/wasm-module-builder.js"); + +var builder = new WasmModuleBuilder(); +builder.addImportedTable("x", "table", 1, 10000000); +let module = new WebAssembly.Module(builder.toBuffer()); +let table = new WebAssembly.Table({element: "anyfunc", + initial: 1, maximum:1000000}); +let instance = new WebAssembly.Instance(module, {x: {table:table}}); + +assertThrows(() => table.grow(Infinity), RangeError); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-772610.js b/deps/v8/test/mjsunit/regress/regress-crbug-772610.js new file mode 100644 index 0000000000..d68ebbf2be --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-772610.js @@ -0,0 +1,18 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax --verify-heap --expose-gc + +function f() { + var o = [{ + [Symbol.toPrimitive]() {} + }]; + %_DeoptimizeNow(); + return o.length; +} +assertEquals(1, f()); +assertEquals(1, f()); +%OptimizeFunctionOnNextCall(f); +assertEquals(1, f()); +gc(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-772672.js b/deps/v8/test/mjsunit/regress/regress-crbug-772672.js new file mode 100644 index 0000000000..86e738344a --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-772672.js @@ -0,0 +1,11 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax + +function foo() { return new Array(120 * 1024); } + +foo()[0] = 0.1; +%OptimizeFunctionOnNextCall(foo); +foo(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-772689.js b/deps/v8/test/mjsunit/regress/regress-crbug-772689.js new file mode 100644 index 0000000000..32e220daa7 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-772689.js @@ -0,0 +1,23 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax + +const A = class A extends Array { + constructor() { + super(); + this.y = 1; + } +} + +function foo(x) { + var a = new A(); + if (x) return a.y; +} + +assertEquals(undefined, foo(false)); +assertEquals(undefined, foo(false)); +%OptimizeFunctionOnNextCall(foo); +assertEquals(undefined, foo(false)); +assertEquals(1, foo(true)); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-772720.js b/deps/v8/test/mjsunit/regress/regress-crbug-772720.js new file mode 100644 index 0000000000..3e359f6c16 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-772720.js @@ -0,0 +1,15 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax + +var global; +function f() { + var local = 'abcdefghijklmnopqrst'; + local += 'abcdefghijkl' + (0 + global); + global += 'abcdefghijkl'; +} +f(); +%OptimizeFunctionOnNextCall(f); +f(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-772897.js b/deps/v8/test/mjsunit/regress/regress-crbug-772897.js new file mode 100644 index 0000000000..c2e4b25fb0 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-772897.js @@ -0,0 +1,20 @@ +// Copyright 2017 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. + +function store(obj, name) { + return obj[name] = 0; +} + +function f(obj) { + var key = { + toString() { throw new Error("boom"); } + }; + store(obj, key); +} + +(function() { + var proxy = new Proxy({}, {}); + store(proxy, 0) + assertThrows(() => f(proxy), Error); +})(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-774994.js b/deps/v8/test/mjsunit/regress/regress-crbug-774994.js new file mode 100644 index 0000000000..5810417f79 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-774994.js @@ -0,0 +1,34 @@ +// Copyright 2017 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. +// +// Flags: --preparser-scope-analysis + +function f() { + new class extends Object { + constructor() { + eval("super(); super.__f_10();"); + } + } +} +assertThrows(f, TypeError); + +function g() { + let obj = { + m() { + eval("super.foo()"); + } + } + obj.m(); +} +assertThrows(g, TypeError); + +function h() { + let obj = { + get m() { + eval("super.foo()"); + } + } + obj.m; +} +assertThrows(h, TypeError); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-783132.js b/deps/v8/test/mjsunit/regress/regress-crbug-783132.js new file mode 100644 index 0000000000..600a6bf5b6 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-783132.js @@ -0,0 +1,15 @@ +// Copyright 2017 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. + +// Flags: --verify-heap + +function f(o, v) { + try { + f(o, v + 1); + } catch (e) { + } + o[v] = 43.35 + v * 5.3; +} + +f(Array.prototype, 0); diff --git a/deps/v8/test/mjsunit/regress/regress-v8-6940.js b/deps/v8/test/mjsunit/regress/regress-v8-6940.js new file mode 100644 index 0000000000..c5bb6a950a --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-v8-6940.js @@ -0,0 +1,9 @@ +// Copyright 2017 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. + +assertTrue(/[ŸŶ]/i.test('ÿ')); +assertTrue(/[ŸY]/i.test('ÿ')); + +assertTrue(/[YÝŸŶỲ]/i.test('ÿ')); +assertTrue(/[YÝŸŶỲ]/iu.test('ÿ')); diff --git a/deps/v8/test/mjsunit/regress/wasm/regress-775710.js b/deps/v8/test/mjsunit/regress/wasm/regress-775710.js new file mode 100644 index 0000000000..5e6fb8c50b --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regress-775710.js @@ -0,0 +1,20 @@ +// Copyright 2017 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. + +// Flags: --validate-asm --allow-natives-syntax + +const kMaxLocals = 50000; +const fn_template = '"use asm";\nfunction f() { LOCALS }\nreturn f;'; +for (var num_locals = kMaxLocals; num_locals < kMaxLocals + 2; ++num_locals) { + const fn_code = fn_template.replace( + 'LOCALS', + Array(num_locals) + .fill() + .map((_, idx) => 'var l' + idx + ' = 0;') + .join('\n')); + const asm_fn = new Function(fn_code); + const f = asm_fn(); + f(); + assertEquals(num_locals <= kMaxLocals, %IsAsmWasmCode(asm_fn)); +} diff --git a/deps/v8/test/mjsunit/regress/wasm/regression-648079.js b/deps/v8/test/mjsunit/regress/wasm/regression-648079.js index 2fa6b4db7a..acc6146ef5 100644 --- a/deps/v8/test/mjsunit/regress/wasm/regression-648079.js +++ b/deps/v8/test/mjsunit/regress/wasm/regression-648079.js @@ -8,7 +8,6 @@ load("test/mjsunit/wasm/wasm-constants.js"); load("test/mjsunit/wasm/wasm-module-builder.js"); // Non-standard opcodes. -let kWasmS128 = 0x7b; let kSig_s_v = makeSig([], [kWasmS128]); let kExprS128LoadMem = 0xc0; diff --git a/deps/v8/test/mjsunit/regress/wasm/regression-702460.js b/deps/v8/test/mjsunit/regress/wasm/regression-702460.js index 2d63440255..73c01e13a0 100644 --- a/deps/v8/test/mjsunit/regress/wasm/regression-702460.js +++ b/deps/v8/test/mjsunit/regress/wasm/regression-702460.js @@ -6,7 +6,6 @@ load("test/mjsunit/wasm/wasm-constants.js"); load("test/mjsunit/wasm/wasm-module-builder.js"); // Non-standard opcodes. -let kWasmS128 = 0x7b; let kSig_s_v = makeSig([], [kWasmS128]); let kExprS128LoadMem = 0xc0; diff --git a/deps/v8/test/mjsunit/regress/wasm/regression-763697.js b/deps/v8/test/mjsunit/regress/wasm/regression-763697.js new file mode 100644 index 0000000000..faf74e1cff --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regression-763697.js @@ -0,0 +1,15 @@ +// Copyright 2017 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. + +// Flags: --expose-wasm --no-experimental-wasm-simd + +load('test/mjsunit/wasm/wasm-constants.js'); +load('test/mjsunit/wasm/wasm-module-builder.js'); + +let builder = new WasmModuleBuilder(); + builder.addFunction("main", kSig_i_i) + .addBody([kExprGetLocal, 0]) + .addLocals({s128_count: 1}); + + assertFalse(WebAssembly.validate(builder.toBuffer())); diff --git a/deps/v8/test/mjsunit/regress/wasm/regression-769846.js b/deps/v8/test/mjsunit/regress/wasm/regression-769846.js new file mode 100644 index 0000000000..297da84f5f --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regression-769846.js @@ -0,0 +1,15 @@ +// Copyright 2017 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. + +function Module() { + "use asm"; + function div_(__v_6) { + __v_6 = __v_6 | 0; + } + return { f: div_} +}; +var __f_0 = Module().f; +__v_8 = [0]; +__v_8.__defineGetter__(0, function() { return __f_0(__v_8); }); +__v_8[0]; diff --git a/deps/v8/test/mjsunit/skipping-inner-functions-bailout.js b/deps/v8/test/mjsunit/skipping-inner-functions-bailout.js index f09f1d9bb7..f2b6c5bc41 100644 --- a/deps/v8/test/mjsunit/skipping-inner-functions-bailout.js +++ b/deps/v8/test/mjsunit/skipping-inner-functions-bailout.js @@ -76,3 +76,9 @@ function TestMultiBailout3() { function not_skippable_either() {} } TestMultiBailout3(); + +// Regression test for +// https://bugs.chromium.org/p/chromium/issues/detail?id=761980. The conditions +// triggering a bailout occur in a context where we're not generating data +// anyway (inside an arrow function). (This needs to be at top level.) +x => { (y=eval()) => {} } diff --git a/deps/v8/test/mjsunit/skipping-inner-functions.js b/deps/v8/test/mjsunit/skipping-inner-functions.js index 51c9fd5534..e228b258c4 100644 --- a/deps/v8/test/mjsunit/skipping-inner-functions.js +++ b/deps/v8/test/mjsunit/skipping-inner-functions.js @@ -295,3 +295,73 @@ function TestSkippableFunctionInForOfHeaderAndBody() { } TestSkippableFunctionInForOfHeaderAndBody(); + +(function TestSkippableGeneratorInSloppyBlock() { + var result = 0; + + function lazy(ctxt_alloc_param) { + var ctxt_alloc_var = 10; + { + function *skip_me() { + result = ctxt_alloc_param + ctxt_alloc_var; + yield 3; + } + return skip_me; + } + } + // Test that parameters and variables of the outer function get context + // allocated even if we skip the inner function. + assertEquals(3, lazy(9)().next().value); + assertEquals(19, result); +})(); + +(function TestRestoringDataToAsyncArrowFunctionWithNonSimpleParams_1() { + // Regression test for + // https://bugs.chromium.org/p/chromium/issues/detail?id=765532 + function lazy() { + // The arrow function is not skippable, but we need to traverse its scopes + // and restore data to them. + async(a=0) => { const d = 0; } + function skippable() {} + } + lazy(); +})(); + +(function TestRestoringDataToAsyncArrowFunctionWithNonSimpleParams_2() { + // Regression test for + // https://bugs.chromium.org/p/chromium/issues/detail?id=765532 + function lazy() { + // The arrow function is not skippable, but we need to traverse its scopes + // and restore data to them. + async(...a) => { const d = 0; } + function skippable() {} + } + lazy(); +})(); + +(function TestSloppyBlockFunctionShadowingCatchVariable() { + // Regression test for + // https://bugs.chromium.org/p/chromium/issues/detail?id=771474 + function lazy() { + try { + } catch (my_var) { + if (false) { + function my_var() { } + } + } + } + lazy(); +})(); + + +(function TestLazinessDecisionWithDefaultConstructors() { + // Regression test for + // https://bugs.chromium.org/p/chromium/issues/detail?id=773576 + + // The problem was that Parser and PreParser treated default constructors + // differently, and that threw off the "next / previous function is likely + // called" logic. + + function lazy(p = (function() {}, class {}, function() {}, class { method1() { } })) { } + lazy(); +})(); diff --git a/deps/v8/test/mjsunit/string-charcodeat.js b/deps/v8/test/mjsunit/string-charcodeat.js index 335c4b317f..6031096e0b 100644 --- a/deps/v8/test/mjsunit/string-charcodeat.js +++ b/deps/v8/test/mjsunit/string-charcodeat.js @@ -239,6 +239,3 @@ for (var i = 0; i < 5; i++) { } %OptimizeFunctionOnNextCall(directlyOnPrototype); directlyOnPrototype(); - -assertTrue(isNaN(%_StringCharCodeAt("ABC", -1))); -assertTrue(isNaN(%_StringCharCodeAt("ABC", 4))); diff --git a/deps/v8/test/mjsunit/third_party/regexp-pcre/regexp-pcre.js b/deps/v8/test/mjsunit/third_party/regexp-pcre/regexp-pcre.js index 68b8f0525b..8b603e45d1 100644 --- a/deps/v8/test/mjsunit/third_party/regexp-pcre/regexp-pcre.js +++ b/deps/v8/test/mjsunit/third_party/regexp-pcre/regexp-pcre.js @@ -899,7 +899,7 @@ res[819] = /:/; res[820] = /([\da-f:]+)$/i; res[821] = /^.*\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/; res[822] = /^(\d+)\s+IN\s+SOA\s+(\S+)\s+(\S+)\s*\(\s*$/; -res[823] = /^[a-zA-Z\d][a-zA-Z\d\-]*(\.[a-zA-Z\d][a-zA-z\d\-]*)*\.$/; +res[823] = /^[a-zA-Z\d][a-zA-Z\d\-]*(\.[a-zA-Z\d][a-zA-Z\d\-]*)*\.$/; res[824] = /^\*\.[a-z]([a-z\-\d]*[a-z\d]+)?(\.[a-z]([a-z\-\d]*[a-z\d]+)?)*$/; res[825] = /^(?=ab(de))(abd)(e)/; res[826] = /^(?!(ab)de|x)(abd)(f)/; diff --git a/deps/v8/test/mjsunit/type-profile/collect-type-profile.js b/deps/v8/test/mjsunit/type-profile/collect-type-profile.js deleted file mode 100644 index d21d11d9d2..0000000000 --- a/deps/v8/test/mjsunit/type-profile/collect-type-profile.js +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2017 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. - -// Flags: --type-profile --allow-natives-syntax - -function check_collect_types(name, expected) { - const type_profile = %TypeProfile(name); - if (type_profile !== undefined) { - const result = JSON.stringify(type_profile); - print(result); - assertEquals(expected, result, name + " failed"); - - } -} - -function testFunction(param, flag) { - // We want to test 2 different return positions in one function. - if (flag) { - var first_var = param; - return first_var; - } - var second_var = param; - return second_var; -} - -class MyClass { - constructor() {} -} - -var expected = `{}`; -check_collect_types(testFunction, expected); - -testFunction({}); -testFunction(123, true); -testFunction('hello'); -testFunction(123); - -expected = `{\"495\":[\"Object\",\"number\",\"string\",\"number\"],\"502\":[\"undefined\",\"boolean\",\"undefined\",\"undefined\"],\"691\":[\"Object\",\"number\",\"string\",\"number\"]}`; -check_collect_types(testFunction, expected); - -testFunction(undefined); -testFunction('hello', true); -testFunction({x: 12}, true); -testFunction({x: 12}); -testFunction(new MyClass()); - -expected = `{\"495\":[\"Object\",\"number\",\"string\",\"number\",\"undefined\",\"string\",\"Object\",\"Object\",\"MyClass\"],\"502\":[\"undefined\",\"boolean\",\"undefined\",\"undefined\",\"undefined\",\"boolean\",\"boolean\",\"undefined\",\"undefined\"],\"691\":[\"Object\",\"number\",\"string\",\"number\",\"undefined\",\"string\",\"Object\",\"Object\",\"MyClass\"]}`; -check_collect_types(testFunction, expected); - - -function testReturnOfNonVariable() { - return 32; -} -testReturnOfNonVariable(); -expected = `{\"1724\":[\"number\"]}`; -check_collect_types(testReturnOfNonVariable, expected); - -// Return statement is reached but its expression is never really returned. -function try_finally() { - try { - return 23; - } finally { - return "nope, string is better" - } -} -try_finally(); -expected = `{\"2026\":[\"string\"]}`; -check_collect_types(try_finally, expected); - -// Fall-off return. -function fall_off() { - //nothing -} -fall_off(); -expected = `{\"2180\":[\"undefined\"]}`; -check_collect_types(fall_off, expected); - -// Do not collect types when the function is never run. -function never_called() {} -expected = `{}`; -check_collect_types(never_called, expected); - - -function several_params(a, b, c, d) { - //nothing -} -several_params(2, 'foo', {}, new MyClass()); -expected = `{\"2448\":[\"number\"],\"2451\":[\"string\"],\"2454\":[\"Object\"],\"2457\":[\"MyClass\"],\"2474\":[\"undefined\"]}`; -check_collect_types(several_params, expected); diff --git a/deps/v8/test/mjsunit/unbox-double-arrays.js b/deps/v8/test/mjsunit/unbox-double-arrays.js index 2bebddb449..d6fc0938f9 100644 --- a/deps/v8/test/mjsunit/unbox-double-arrays.js +++ b/deps/v8/test/mjsunit/unbox-double-arrays.js @@ -50,11 +50,6 @@ function force_to_fast_double_array(a) { assertTrue(%HasDoubleElements(a)); } -function make_object_like_array(size) { - obj = new Object(); - obj.length = size; - return obj; -} function testOneArrayType(allocator) { var large_array = new allocator(large_array_size); @@ -349,11 +344,18 @@ function testOneArrayType(allocator) { assertTrue(%HasDoubleElements(large_array)); } +class ArraySubclass extends Array { + constructor(...args) { + super(...args); + this.marker = 42; + } +} + // Force gc here to start with a clean heap if we repeat this test multiple // times. gc(); -testOneArrayType(make_object_like_array); testOneArrayType(Array); +testOneArrayType(ArraySubclass); var large_array = new Array(large_array_size); force_to_fast_double_array(large_array); diff --git a/deps/v8/test/mjsunit/value-of.js b/deps/v8/test/mjsunit/value-of.js index 1a242c0ec4..88dad0a9b9 100644 --- a/deps/v8/test/mjsunit/value-of.js +++ b/deps/v8/test/mjsunit/value-of.js @@ -25,8 +25,18 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -function MyException() { } +let valueOf = Object.prototype.valueOf; + +assertEquals('object', typeof valueOf.call(true)); +assertEquals('object', typeof valueOf.call(false)); +assertEquals('object', typeof valueOf.call(1.23)); +assertEquals('object', typeof valueOf.call(0)); +assertEquals('object', typeof valueOf.call('a')); +assertEquals('object', typeof valueOf.call(Symbol.isConcatSpreadable)); +assertThrows(() => valueOf.call(undefined), TypeError); +assertThrows(() => valueOf.call(null), TypeError); +function MyException() { } var o = new Object(); o.valueOf = function() { throw new MyException(); } diff --git a/deps/v8/test/mjsunit/wasm/asm-with-wasm-off.js b/deps/v8/test/mjsunit/wasm/asm-with-wasm-off.js index bf3bbe712f..2fec37d6e8 100644 --- a/deps/v8/test/mjsunit/wasm/asm-with-wasm-off.js +++ b/deps/v8/test/mjsunit/wasm/asm-with-wasm-off.js @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --validate-asm --allow-natives-syntax +// Flags: --noexpose-wasm --validate-asm --allow-natives-syntax -// NOTE: This is in it's own file because it calls %DisallowCodegenFromStrings, +// NOTE: This is in its own file because it calls %DisallowCodegenFromStrings, // which messes with the isolate's state. (function testAsmWithWasmOff() { - %DisallowCodegenFromStrings(); + %DisallowCodegenFromStrings(true); function Module() { 'use asm'; function foo() { diff --git a/deps/v8/test/mjsunit/wasm/atomics.js b/deps/v8/test/mjsunit/wasm/atomics.js index 089accb45b..a8940af1d1 100644 --- a/deps/v8/test/mjsunit/wasm/atomics.js +++ b/deps/v8/test/mjsunit/wasm/atomics.js @@ -21,43 +21,77 @@ function Exchange(a, b) { return b; } let maxSize = 10; let memory = new WebAssembly.Memory({initial: 1, maximum: maxSize, shared: true}); -function GetAtomicBinOpFunction(wasmExpression) { +function GetAtomicBinOpFunction(wasmExpression, alignment, offset) { let builder = new WasmModuleBuilder(); - builder.addImportedMemory("m", "imported_mem"); + builder.addImportedMemory("m", "imported_mem", 0, maxSize, "shared"); builder.addFunction("main", kSig_i_ii) .addBody([ kExprGetLocal, 0, kExprGetLocal, 1, kAtomicPrefix, - wasmExpression]) + wasmExpression, alignment, offset]) .exportAs("main"); // Instantiate module, get function exports let module = new WebAssembly.Module(builder.toBuffer()); - let instance = (new WebAssembly.Instance(module, - {m: {imported_mem: memory}})); + let instance = new WebAssembly.Instance(module, + {m: {imported_mem: memory}}); return instance.exports.main; } -function GetAtomicCmpExchangeFunction(wasmExpression) { +function GetAtomicCmpExchangeFunction(wasmExpression, alignment, offset) { let builder = new WasmModuleBuilder(); - builder.addImportedMemory("m", "imported_mem"); + builder.addImportedMemory("m", "imported_mem", 0, maxSize, "shared"); builder.addFunction("main", kSig_i_iii) .addBody([ kExprGetLocal, 0, kExprGetLocal, 1, kExprGetLocal, 2, kAtomicPrefix, - wasmExpression]) + wasmExpression, alignment, offset]) .exportAs("main"); // Instantiate module, get function exports let module = new WebAssembly.Module(builder.toBuffer()); - let instance = (new WebAssembly.Instance(module, - {m: {imported_mem: memory}})); + let instance = new WebAssembly.Instance(module, + {m: {imported_mem: memory}}); return instance.exports.main; } +function GetAtomicLoadFunction(wasmExpression, alignment, offset) { + let builder = new WasmModuleBuilder(); + builder.addImportedMemory("m", "imported_mem", 0, maxSize, "shared"); + builder.addFunction("main", kSig_i_i) + .addBody([ + kExprGetLocal, 0, + kAtomicPrefix, + wasmExpression, alignment, offset]) + .exportAs("main"); + + // Instantiate module, get function exports + let module = new WebAssembly.Module(builder.toBuffer()); + let instance = new WebAssembly.Instance(module, + {m: {imported_mem: memory}}); + return instance.exports.main; +} + +function GetAtomicStoreFunction(wasmExpression, alignment, offset) { + let builder = new WasmModuleBuilder(); + builder.addImportedMemory("m", "imported_mem", 0, maxSize, "shared"); + builder.addFunction("main", kSig_v_ii) + .addBody([ + kExprGetLocal, 0, + kExprGetLocal, 1, + kAtomicPrefix, + wasmExpression, alignment, offset]) + .exportAs("main"); + + // Instantiate module, get function exports + let module = new WebAssembly.Module(builder.toBuffer()); + let instance = new WebAssembly.Instance(module, + {m: {imported_mem: memory}}); + return instance.exports.main; +} function VerifyBoundsCheck(func, memtype_size) { const kPageSize = 65536; @@ -108,109 +142,109 @@ function Test8Op(operation, func) { (function TestAtomicAdd() { print("TestAtomicAdd"); - let wasmAdd = GetAtomicBinOpFunction(kExprI32AtomicAdd); + let wasmAdd = GetAtomicBinOpFunction(kExprI32AtomicAdd, 2, 0); Test32Op(Add, wasmAdd); })(); (function TestAtomicAdd16U() { print("TestAtomicAdd16U"); - let wasmAdd = GetAtomicBinOpFunction(kExprI32AtomicAdd16U); + let wasmAdd = GetAtomicBinOpFunction(kExprI32AtomicAdd16U, 1, 0); Test16Op(Add, wasmAdd); })(); (function TestAtomicAdd8U() { print("TestAtomicAdd8U"); - let wasmAdd = GetAtomicBinOpFunction(kExprI32AtomicAdd8U); + let wasmAdd = GetAtomicBinOpFunction(kExprI32AtomicAdd8U, 0, 0); Test8Op(Add, wasmAdd); })(); (function TestAtomicSub() { print("TestAtomicSub"); - let wasmSub = GetAtomicBinOpFunction(kExprI32AtomicSub); + let wasmSub = GetAtomicBinOpFunction(kExprI32AtomicSub, 2, 0); Test32Op(Sub, wasmSub); })(); (function TestAtomicSub16U() { print("TestAtomicSub16U"); - let wasmSub = GetAtomicBinOpFunction(kExprI32AtomicSub16U); + let wasmSub = GetAtomicBinOpFunction(kExprI32AtomicSub16U, 1, 0); Test16Op(Sub, wasmSub); })(); (function TestAtomicSub8U() { print("TestAtomicSub8U"); - let wasmSub = GetAtomicBinOpFunction(kExprI32AtomicSub8U); + let wasmSub = GetAtomicBinOpFunction(kExprI32AtomicSub8U, 0, 0); Test8Op(Sub, wasmSub); })(); (function TestAtomicAnd() { print("TestAtomicAnd"); - let wasmAnd = GetAtomicBinOpFunction(kExprI32AtomicAnd); + let wasmAnd = GetAtomicBinOpFunction(kExprI32AtomicAnd, 2, 0); Test32Op(And, wasmAnd); })(); (function TestAtomicAnd16U() { print("TestAtomicAnd16U"); - let wasmAnd = GetAtomicBinOpFunction(kExprI32AtomicAnd16U); + let wasmAnd = GetAtomicBinOpFunction(kExprI32AtomicAnd16U, 1, 0); Test16Op(And, wasmAnd); })(); (function TestAtomicAnd8U() { print("TestAtomicAnd8U"); - let wasmAnd = GetAtomicBinOpFunction(kExprI32AtomicAnd8U); + let wasmAnd = GetAtomicBinOpFunction(kExprI32AtomicAnd8U, 0, 0); Test8Op(And, wasmAnd); })(); (function TestAtomicOr() { print("TestAtomicOr"); - let wasmOr = GetAtomicBinOpFunction(kExprI32AtomicOr); + let wasmOr = GetAtomicBinOpFunction(kExprI32AtomicOr, 2, 0); Test32Op(Or, wasmOr); })(); (function TestAtomicOr16U() { print("TestAtomicOr16U"); - let wasmOr = GetAtomicBinOpFunction(kExprI32AtomicOr16U); + let wasmOr = GetAtomicBinOpFunction(kExprI32AtomicOr16U, 1, 0); Test16Op(Or, wasmOr); })(); (function TestAtomicOr8U() { print("TestAtomicOr8U"); - let wasmOr = GetAtomicBinOpFunction(kExprI32AtomicOr8U); + let wasmOr = GetAtomicBinOpFunction(kExprI32AtomicOr8U, 0, 0); Test8Op(Or, wasmOr); })(); (function TestAtomicXor() { print("TestAtomicXor"); - let wasmXor = GetAtomicBinOpFunction(kExprI32AtomicXor); + let wasmXor = GetAtomicBinOpFunction(kExprI32AtomicXor, 2, 0); Test32Op(Xor, wasmXor); })(); (function TestAtomicXor16U() { print("TestAtomicXor16U"); - let wasmXor = GetAtomicBinOpFunction(kExprI32AtomicXor16U); + let wasmXor = GetAtomicBinOpFunction(kExprI32AtomicXor16U, 1, 0); Test16Op(Xor, wasmXor); })(); (function TestAtomicXor8U() { print("TestAtomicXor8U"); - let wasmXor = GetAtomicBinOpFunction(kExprI32AtomicXor8U); + let wasmXor = GetAtomicBinOpFunction(kExprI32AtomicXor8U, 0, 0); Test8Op(Xor, wasmXor); })(); (function TestAtomicExchange() { print("TestAtomicExchange"); - let wasmExchange = GetAtomicBinOpFunction(kExprI32AtomicExchange); + let wasmExchange = GetAtomicBinOpFunction(kExprI32AtomicExchange, 2, 0); Test32Op(Exchange, wasmExchange); })(); (function TestAtomicExchange16U() { print("TestAtomicExchange16U"); - let wasmExchange = GetAtomicBinOpFunction(kExprI32AtomicExchange16U); + let wasmExchange = GetAtomicBinOpFunction(kExprI32AtomicExchange16U, 1, 0); Test16Op(Exchange, wasmExchange); })(); (function TestAtomicExchange8U() { print("TestAtomicExchange8U"); - let wasmExchange = GetAtomicBinOpFunction(kExprI32AtomicExchange8U); + let wasmExchange = GetAtomicBinOpFunction(kExprI32AtomicExchange8U, 0, 0); Test8Op(Exchange, wasmExchange); })(); @@ -232,7 +266,7 @@ function TestCmpExchange(func, buffer, params, size) { (function TestAtomicCompareExchange() { print("TestAtomicCompareExchange"); let wasmCmpExchange = - GetAtomicCmpExchangeFunction(kExprI32AtomicCompareExchange); + GetAtomicCmpExchangeFunction(kExprI32AtomicCompareExchange, 2, 0); let i32 = new Uint32Array(memory.buffer); let params = [0x00000001, 0x00000555, 0x00099999, 0xffffffff]; TestCmpExchange(wasmCmpExchange, i32, params, kMemtypeSize32); @@ -241,7 +275,7 @@ function TestCmpExchange(func, buffer, params, size) { (function TestAtomicCompareExchange16U() { print("TestAtomicCompareExchange16U"); let wasmCmpExchange = - GetAtomicCmpExchangeFunction(kExprI32AtomicCompareExchange16U); + GetAtomicCmpExchangeFunction(kExprI32AtomicCompareExchange16U, 1, 0); let i16 = new Uint16Array(memory.buffer); let params = [0x0001, 0x0555, 0x9999]; TestCmpExchange(wasmCmpExchange, i16, params, kMemtypeSize16); @@ -250,8 +284,130 @@ function TestCmpExchange(func, buffer, params, size) { (function TestAtomicCompareExchange8U() { print("TestAtomicCompareExchange8U"); let wasmCmpExchange = - GetAtomicCmpExchangeFunction(kExprI32AtomicCompareExchange8U); + GetAtomicCmpExchangeFunction(kExprI32AtomicCompareExchange8U, 0, 0); let i8 = new Uint8Array(memory.buffer); let params = [0x01, 0x0d, 0xf9]; TestCmpExchange(wasmCmpExchange, i8, params, kMemtypeSize8); })(); + +function TestLoad(func, buffer, value, size) { + for (let i = 0; i < buffer.length; i++) { + buffer[i] = value; + assertEquals(value, func(i * size) >>> 0); + } + VerifyBoundsCheck(func, size); +} + +(function TestAtomicLoad() { + print("TestAtomicLoad"); + let wasmLoad = GetAtomicLoadFunction(kExprI32AtomicLoad, 2, 0); + let i32 = new Uint32Array(memory.buffer); + let value = 0xacedaced; + TestLoad(wasmLoad, i32, value, kMemtypeSize32); +})(); + +(function TestAtomicLoad16U() { + print("TestAtomicLoad16U"); + let wasmLoad = GetAtomicLoadFunction(kExprI32AtomicLoad16U, 1, 0); + let i16 = new Uint16Array(memory.buffer); + let value = 0xaced; + TestLoad(wasmLoad, i16, value, kMemtypeSize16); +})(); + +(function TestAtomicLoad8U() { + print("TestAtomicLoad8U"); + let wasmLoad = GetAtomicLoadFunction(kExprI32AtomicLoad8U, 0, 0); + let i8 = new Uint8Array(memory.buffer); + let value = 0xac; + TestLoad(wasmLoad, i8, value, kMemtypeSize8); +})(); + +function TestStore(func, buffer, value, size) { + for (let i = 0; i < buffer.length; i++) { + func(i * size, value) + assertEquals(value, buffer[i]); + } + VerifyBoundsCheck(func, size); +} + +(function TestAtomicStore() { + print("TestAtomicStore"); + let wasmStore = GetAtomicStoreFunction(kExprI32AtomicStore, 2, 0); + let i32 = new Uint32Array(memory.buffer); + let value = 0xacedaced; + TestStore(wasmStore, i32, value, kMemtypeSize32); +})(); + +(function TestAtomicStore16U() { + print("TestAtomicStore16U"); + let wasmStore = GetAtomicStoreFunction(kExprI32AtomicStore16U, 1, 0); + let i16 = new Uint16Array(memory.buffer); + let value = 0xaced; + TestStore(wasmStore, i16, value, kMemtypeSize16); +})(); + +(function TestAtomicStore8U() { + print("TestAtomicStore8U"); + let wasmStore = GetAtomicStoreFunction(kExprI32AtomicStore8U, 0, 0); + let i8 = new Uint8Array(memory.buffer); + let value = 0xac; + TestCmpExchange(wasmStore, i8, value, kMemtypeSize8); +})(); + +(function TestAtomicLoadStoreOffset() { + print("TestAtomicLoadStoreOffset"); + var builder = new WasmModuleBuilder(); + let memory = new WebAssembly.Memory({ + initial: 16, maximum: 128, shared: true}); + builder.addImportedMemory("m", "imported_mem", 16, 128, "shared"); + builder.addFunction("loadStore", kSig_i_v) + .addBody([ + kExprI32Const, 16, + kExprI32Const, 20, + kAtomicPrefix, + kExprI32AtomicStore, 0, 0xFC, 0xFF, 0x3a, + kExprI32Const, 16, + kAtomicPrefix, + kExprI32AtomicLoad, 0, 0xFC, 0xFF, 0x3a]) + .exportAs("loadStore"); + builder.addFunction("storeOob", kSig_v_v) + .addBody([ + kExprI32Const, 16, + kExprI32Const, 20, + kAtomicPrefix, + kExprI32AtomicStore, 0, 0xFC, 0xFF, 0xFF, 0x3a]) + .exportAs("storeOob"); + let module = new WebAssembly.Module(builder.toBuffer()); + let instance = (new WebAssembly.Instance(module, + {m: {imported_mem: memory}})); + let buf = memory.buffer; + assertEquals(20, instance.exports.loadStore()); + assertTraps(kTrapMemOutOfBounds, instance.exports.storeOob); +})(); + +(function TestAtomicOpinLoop() { + print("TestAtomicOpinLoop"); + var builder = new WasmModuleBuilder(); + let memory = new WebAssembly.Memory({ + initial: 16, maximum: 128, shared: true}); + builder.addImportedMemory("m", "imported_mem", 16, 128, "shared"); + builder.addFunction("main", kSig_i_v) + .addBody([ + kExprLoop, kWasmStmt, + kExprI32Const, 16, + kExprI32Const, 20, + kAtomicPrefix, + kExprI32AtomicStore, 2, 0, + kExprI32Const, 16, + kAtomicPrefix, + kExprI32AtomicLoad, 2, 0, + kExprReturn, + kExprEnd, + kExprI32Const, 0 + ]) + .exportFunc(); + let module = new WebAssembly.Module(builder.toBuffer()); + let instance = (new WebAssembly.Instance(module, + {m: {imported_mem: memory}})); + assertEquals(20, instance.exports.main()); +})(); diff --git a/deps/v8/test/mjsunit/wasm/disable-trap-handler.js b/deps/v8/test/mjsunit/wasm/disable-trap-handler.js new file mode 100644 index 0000000000..3389ba8cad --- /dev/null +++ b/deps/v8/test/mjsunit/wasm/disable-trap-handler.js @@ -0,0 +1,9 @@ +// Copyright 2017 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. + +// Flags: --allow-natives-syntax --no-wasm-trap-handler + +// This test makes sure that --no-wasm-trap-handler has the correct effect. + +assertFalse(%IsWasmTrapHandlerEnabled()); diff --git a/deps/v8/test/mjsunit/wasm/disallow-codegen.js b/deps/v8/test/mjsunit/wasm/disallow-codegen.js new file mode 100644 index 0000000000..3374a9efd7 --- /dev/null +++ b/deps/v8/test/mjsunit/wasm/disallow-codegen.js @@ -0,0 +1,104 @@ +// Copyright 2017 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. + +// Flags: --expose-wasm --allow-natives-syntax + +load("test/mjsunit/wasm/wasm-constants.js"); +load("test/mjsunit/wasm/wasm-module-builder.js"); + +let kReturnValue = 19; + +let buffer = (function CreateBuffer() { + let builder = new WasmModuleBuilder(); + builder.addMemory(1, 1, true); + builder.addFunction('main', kSig_i_v) + .addBody([kExprI32Const, kReturnValue]) + .exportFunc(); + + return builder.toBuffer(); +})(); + +%DisallowCodegenFromStrings(true); + +async function SyncTestOk() { + print('sync module compile (ok)...'); + %DisallowCodegenFromStrings(false); + let module = new WebAssembly.Module(buffer); + assertInstanceof(module, WebAssembly.Module); +} + +async function SyncTestFail() { + print('sync module compile (fail)...'); + %DisallowCodegenFromStrings(true); + try { + let module = new WebAssembly.Module(buffer); + assertUnreachable(); + } catch (e) { + print(" " + e); + assertInstanceof(e, WebAssembly.CompileError); + } +} + +async function AsyncTestOk() { + print('async module compile (ok)...'); + %DisallowCodegenFromStrings(false); + let promise = WebAssembly.compile(buffer); + assertPromiseResult( + promise, module => assertInstanceof(module, WebAssembly.Module)); +} + +async function AsyncTestFail() { + print('async module compile (fail)...'); + %DisallowCodegenFromStrings(true); + try { + let m = await WebAssembly.compile(buffer); + assertUnreachable(); + } catch (e) { + print(" " + e); + assertInstanceof(e, WebAssembly.CompileError); + } +} + +async function StreamingTestOk() { + print('streaming module compile (ok)...'); + // TODO(titzer): compileStreaming must be supplied by embedder. + // (and it takes a response, not a buffer) + %DisallowCodegenFromStrings(false); + if ("Function" != typeof WebAssembly.compileStreaming) { + print(" no embedder for streaming compilation"); + return; + } + let promise = WebAssembly.compileStreaming(buffer); + assertPromiseResult( + promise, module => assertInstanceof(module, WebAssembly.Module)); +} + +async function StreamingTestFail() { + print('streaming module compile (fail)...'); + %DisallowCodegenFromStrings(true); + // TODO(titzer): compileStreaming must be supplied by embedder. + // (and it takes a response, not a buffer) + if ("Function" != typeof WebAssembly.compileStreaming) { + print(" no embedder for streaming compilation"); + return; + } + try { + let m = await WebAssembly.compileStreaming(buffer); + assertUnreachable(); + } catch (e) { + print(" " + e); + assertInstanceof(e, WebAssembly.CompileError); + } +} + +async function RunAll() { + await SyncTestOk(); + await SyncTestFail(); + await AsyncTestOk(); + await AsyncTestFail(); + await StreamingTestOk(); + await StreamingTestFail(); +} + +assertPromiseResult(RunAll()); diff --git a/deps/v8/test/mjsunit/wasm/exceptions.js b/deps/v8/test/mjsunit/wasm/exceptions.js index 8fcfd15ff4..74d8e7dfb5 100644 --- a/deps/v8/test/mjsunit/wasm/exceptions.js +++ b/deps/v8/test/mjsunit/wasm/exceptions.js @@ -19,7 +19,7 @@ var test_throw = (function () { kExprI32Const, 0, kExprI32Ne, kExprIf, kWasmStmt, - kExprThrow, 0, + kExprThrow, 0, kExprEnd, kExprI32Const, 1 ]).exportFunc(); @@ -36,8 +36,8 @@ assertEquals("function", typeof test_throw.exports.throw_if_param_not_zero); // Test expected behavior of throws assertEquals(1, test_throw.exports.throw_if_param_not_zero(0)); -assertWasmThrows([], function() { test_throw.exports.throw_if_param_not_zero(10) }); -assertWasmThrows([], function() { test_throw.exports.throw_if_param_not_zero(-1) }); +assertWasmThrows(0, [], function() { test_throw.exports.throw_if_param_not_zero(10) }); +assertWasmThrows(0, [], function() { test_throw.exports.throw_if_param_not_zero(-1) }); // Now that we know throwing works, we test catching the exceptions we raise. var test_catch = (function () { @@ -72,32 +72,315 @@ assertEquals("function", typeof test_catch.exports.simple_throw_catch_to_0_1); assertEquals(0, test_catch.exports.simple_throw_catch_to_0_1(0)); assertEquals(1, test_catch.exports.simple_throw_catch_to_0_1(1)); +// Test that we can distinguish which exception was thrown. +var test_catch_2 = (function () { + var builder = new WasmModuleBuilder(); + + builder.addException(kSig_v_v); + builder.addException(kSig_v_v); + builder.addException(kSig_v_v); + builder.addFunction("catch_different_exceptions", kSig_i_i) + .addBody([ + kExprTry, kWasmI32, + kExprTry, kWasmI32, + kExprGetLocal, 0, + kExprI32Eqz, + kExprIf, kWasmStmt, + kExprThrow, 0, + kExprElse, + kExprGetLocal, 0, + kExprI32Const, 1, + kExprI32Eq, + kExprIf, kWasmStmt, + kExprThrow, 1, + kExprElse, + kExprThrow, 2, + kExprEnd, + kExprEnd, + kExprI32Const, 2, + kExprCatch, 0, + kExprI32Const, 3, + kExprEnd, + kExprCatch, 1, + kExprI32Const, 4, + kExprEnd + ]).exportFunc(); + return builder.instantiate(); +})(); + +assertFalse(test_catch_2 === undefined); +assertFalse(test_catch_2 === null); +assertFalse(test_catch_2 === 0); +assertEquals("object", typeof test_catch_2.exports); +assertEquals("function", typeof test_catch_2.exports.catch_different_exceptions); + +assertEquals(3, test_catch_2.exports.catch_different_exceptions(0)); +assertEquals(4, test_catch_2.exports.catch_different_exceptions(1)); +assertWasmThrows(2, [], function() { test_catch_2.exports.catch_different_exceptions(2) }); + +// Test throwing an exception with multiple values. +var test_throw_1_2 = (function() { + var builder = new WasmModuleBuilder(); + builder.addException(kSig_v_ii); + builder.addFunction("throw_1_2", kSig_v_v) + .addBody([ + kExprI32Const, 1, + kExprI32Const, 2, + kExprThrow, 0, + ]).exportFunc(); + + return builder.instantiate(); +})(); + +assertFalse(test_throw_1_2 === undefined); +assertFalse(test_throw_1_2 === null); +assertFalse(test_throw_1_2 === 0); +assertEquals("object", typeof test_throw_1_2.exports); +assertEquals("function", typeof test_throw_1_2.exports.throw_1_2); + +assertWasmThrows(0, [0, 1, 0, 2], function() { test_throw_1_2.exports.throw_1_2(); }); + +// Test throwing/catching the i32 parameter value. +var test_throw_catch_param_i = (function () { + var builder = new WasmModuleBuilder(); + builder.addException(kSig_v_i); + builder.addFunction("throw_catch_param", kSig_i_i) + .addBody([ + kExprTry, kWasmI32, + kExprGetLocal, 0, + kExprThrow, 0, + kExprI32Const, 2, + kExprCatch, 0, + kExprReturn, + kExprEnd, + ]).exportFunc(); + + return builder.instantiate(); +})(); + +assertFalse(test_throw_catch_param_i === undefined); +assertFalse(test_throw_catch_param_i === null); +assertFalse(test_throw_catch_param_i === 0); +assertEquals("object", typeof test_throw_catch_param_i.exports); +assertEquals("function", + typeof test_throw_catch_param_i.exports.throw_catch_param); + +assertEquals(0, test_throw_catch_param_i.exports.throw_catch_param(0)); +assertEquals(1, test_throw_catch_param_i.exports.throw_catch_param(1)); +assertEquals(10, test_throw_catch_param_i.exports.throw_catch_param(10)); + +// Test the encoding of a thrown exception with an integer exception. + +var test_throw_param_i = (function () { + var builder = new WasmModuleBuilder(); + builder.addException(kSig_v_i); + builder.addFunction("throw_param", kSig_v_i) + .addBody([ + kExprGetLocal, 0, + kExprThrow, 0, + ]).exportFunc(); + + return builder.instantiate(); +})(); + +assertFalse(test_throw_param_i === undefined); +assertFalse(test_throw_param_i === null); +assertFalse(test_throw_param_i === 0); +assertEquals("object", typeof test_throw_param_i.exports); +assertEquals("function", + typeof test_throw_param_i.exports.throw_param); + +assertWasmThrows(0, [0, 5], function() { test_throw_param_i.exports.throw_param(5); }); +assertWasmThrows(0, [6, 31026], + function() { test_throw_param_i.exports.throw_param(424242); }); + +// Test throwing/catching the f32 parameter value. +var test_throw_catch_param_f = (function () { + var builder = new WasmModuleBuilder(); + builder.addException(kSig_v_f); + builder.addFunction("throw_catch_param", kSig_f_f) + .addBody([ + kExprTry, kWasmF32, + kExprGetLocal, 0, + kExprThrow, 0, + kExprF32Const, 0, 0, 0, 0, + kExprCatch, 0, + kExprReturn, + kExprEnd, + ]).exportFunc(); + + return builder.instantiate(); +})(); + +assertFalse(test_throw_catch_param_f === undefined); +assertFalse(test_throw_catch_param_f === null); +assertFalse(test_throw_catch_param_f === 0); +assertEquals("object", typeof test_throw_catch_param_f.exports); +assertEquals("function", + typeof test_throw_catch_param_f.exports.throw_catch_param); + +assertEquals(5.0, test_throw_catch_param_f.exports.throw_catch_param(5.0)); +assertEquals(10.5, test_throw_catch_param_f.exports.throw_catch_param(10.5)); + +// Test the encoding of a thrown exception with a float value. + +var test_throw_param_f = (function () { + var builder = new WasmModuleBuilder(); + builder.addException(kSig_v_f); + builder.addFunction("throw_param", kSig_v_f) + .addBody([ + kExprGetLocal, 0, + kExprThrow, 0, + ]).exportFunc(); + + return builder.instantiate(); +})(); + +assertFalse(test_throw_param_f === undefined); +assertFalse(test_throw_param_f === null); +assertFalse(test_throw_param_f === 0); +assertEquals("object", typeof test_throw_param_f.exports); +assertEquals("function", + typeof test_throw_param_f.exports.throw_param); + +assertWasmThrows(0, [16544, 0], + function() { test_throw_param_f.exports.throw_param(5.0); }); +assertWasmThrows(0, [16680, 0], + function() { test_throw_param_f.exports.throw_param(10.5); }); + +// Test throwing/catching an I64 value +var test_throw_catch_param_l = (function () { + var builder = new WasmModuleBuilder(); + builder.addException(kSig_v_l); + builder.addFunction("throw_catch_param", kSig_i_i) + .addBody([ + kExprGetLocal, 0, + kExprI64UConvertI32, + kExprSetLocal, 1, + kExprTry, kWasmI32, + kExprGetLocal, 1, + kExprThrow, 0, + kExprI32Const, 2, + kExprCatch, 0, + kExprGetLocal, 1, + kExprI64Eq, + kExprIf, kWasmI32, + kExprI32Const, 1, + kExprElse, + kExprI32Const, 0, + kExprEnd, + // TODO(kschimpf): Why is this return necessary? + kExprReturn, + kExprEnd, + ]).addLocals({i64_count: 1}).exportFunc(); + + return builder.instantiate(); +})(); + +assertFalse(test_throw_catch_param_l === undefined); +assertFalse(test_throw_catch_param_l === null); +assertFalse(test_throw_catch_param_l === 0); +assertEquals("object", typeof test_throw_catch_param_l.exports); +assertEquals("function", + typeof test_throw_catch_param_l.exports.throw_catch_param); + +assertEquals(1, test_throw_catch_param_l.exports.throw_catch_param(5)); +assertEquals(1, test_throw_catch_param_l.exports.throw_catch_param(0)); +assertEquals(1, test_throw_catch_param_l.exports.throw_catch_param(-1)); + +// Test the encoding of a thrown exception with an I64 value. + +var test_throw_param_l = (function () { + var builder = new WasmModuleBuilder(); + builder.addException(kSig_v_l); + builder.addFunction("throw_param", kSig_v_ii) + .addBody([ + kExprGetLocal, 0, + kExprI64UConvertI32, + kExprI64Const, 32, + kExprI64Shl, + kExprGetLocal, 1, + kExprI64UConvertI32, + kExprI64Ior, + kExprThrow, 0 + ]).exportFunc(); + + return builder.instantiate(); +})(); + +assertFalse(test_throw_param_l === undefined); +assertFalse(test_throw_param_l === null); +assertFalse(test_throw_param_l === 0); +assertEquals("object", typeof test_throw_param_l.exports); +assertEquals("function", + typeof test_throw_param_l.exports.throw_param); + +assertWasmThrows(0, [0, 10, 0, 5], + function() { test_throw_param_l.exports.throw_param(10, 5); }); +assertWasmThrows(0, [65535, 65535, 0, 13], + function() { test_throw_param_l.exports.throw_param(-1, 13); }); + +// Test throwing/catching the F64 parameter value +var test_throw_catch_param_d = (function () { + var builder = new WasmModuleBuilder(); + builder.addException(kSig_v_d); + builder.addFunction("throw_catch_param", kSig_d_d) + .addBody([ + kExprTry, kWasmF64, + kExprGetLocal, 0, + kExprThrow, 0, + kExprF64Const, 0, 0, 0, 0, 0, 0, 0, 0, + kExprCatch, 0, + kExprReturn, + kExprEnd, + ]).exportFunc(); + + return builder.instantiate(); +})(); + +assertFalse(test_throw_catch_param_d === undefined); +assertFalse(test_throw_catch_param_d === null); +assertFalse(test_throw_catch_param_d === 0); +assertEquals("object", typeof test_throw_catch_param_d.exports); +assertEquals("function", + typeof test_throw_catch_param_d.exports.throw_catch_param); + +assertEquals(5.0, test_throw_catch_param_d.exports.throw_catch_param(5.0)); +assertEquals(10.5, test_throw_catch_param_d.exports.throw_catch_param(10.5)); + +// Test the encoding of a thrown exception with an f64 value. + +var test_throw_param_d = (function () { + var builder = new WasmModuleBuilder(); + builder.addException(kSig_v_d); + builder.addFunction("throw_param", kSig_v_f) + .addBody([ + kExprGetLocal, 0, + kExprF64ConvertF32, + kExprThrow, 0 + ]).exportFunc(); + + return builder.instantiate(); +})(); + +assertFalse(test_throw_param_d === undefined); +assertFalse(test_throw_param_d === null); +assertFalse(test_throw_param_d === 0); +assertEquals("object", typeof test_throw_param_d.exports); +assertEquals("function", + typeof test_throw_param_d.exports.throw_param); + +assertWasmThrows(0, [16404, 0, 0, 0], + function() { test_throw_param_d.exports.throw_param(5.0); }); +assertWasmThrows(0, [16739, 4816, 0, 0], + function() { test_throw_param_d.exports.throw_param(10000000.5); }); + /* TODO(kschimpf) Convert these tests to work for the proposed exceptions. // The following methods do not attempt to catch the exception they raise. var test_throw = (function () { var builder = new WasmModuleBuilder(); - builder.addFunction("throw_param_if_not_zero", kSig_i_i) - .addBody([ - kExprGetLocal, 0, - kExprI32Const, 0, - kExprI32Ne, - kExprIf, kWasmStmt, - kExprGetLocal, 0, - kExprThrow, - kExprEnd, - kExprI32Const, 1 - ]) - .exportFunc() - - builder.addFunction("throw_20", kSig_v_v) - .addBody([ - kExprI32Const, 20, - kExprThrow, - ]) - .exportFunc() - builder.addFunction("throw_expr_with_params", kSig_v_ddi) .addBody([ // p2 * (p0 + min(p0, p1))|0 - 20 @@ -123,14 +406,9 @@ assertFalse(test_throw === undefined); assertFalse(test_throw === null); assertFalse(test_throw === 0); assertEquals("object", typeof test_throw.exports); -assertEquals("function", typeof test_throw.exports.throw_param_if_not_zero); -assertEquals("function", typeof test_throw.exports.throw_20); assertEquals("function", typeof test_throw.exports.throw_expr_with_params); assertEquals(1, test_throw.exports.throw_param_if_not_zero(0)); -assertWasmThrows(10, function() { test_throw.exports.throw_param_if_not_zero(10) }); -assertWasmThrows(-1, function() { test_throw.exports.throw_param_if_not_zero(-1) }); -assertWasmThrows(20, test_throw.exports.throw_20); assertWasmThrows( -8, function() { test_throw.exports.throw_expr_with_params(1.5, 2.5, 4); }); assertWasmThrows( diff --git a/deps/v8/test/mjsunit/wasm/expose-wasm.js b/deps/v8/test/mjsunit/wasm/expose-wasm.js new file mode 100644 index 0000000000..836c619025 --- /dev/null +++ b/deps/v8/test/mjsunit/wasm/expose-wasm.js @@ -0,0 +1,7 @@ +// Copyright 2017 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. + +// Flags: --noexpose-wasm + +assertThrows(() => { let x = WebAssembly.compile; }); diff --git a/deps/v8/test/mjsunit/wasm/js-api.js b/deps/v8/test/mjsunit/wasm/js-api.js index 352f7caefa..952c6296cd 100644 --- a/deps/v8/test/mjsunit/wasm/js-api.js +++ b/deps/v8/test/mjsunit/wasm/js-api.js @@ -16,7 +16,7 @@ function unexpectedFail(error) { } function assertEq(val, expected) { - assertEquals(expected, val); + assertSame(expected, val); } function assertArrayBuffer(val, expected) { assertTrue(val instanceof ArrayBuffer); @@ -512,13 +512,40 @@ assertTrue(buf !== mem.buffer); assertEq(buf.byteLength, 0); buf = mem.buffer; assertEq(buf.byteLength, kPageSize); -assertEq(mem.grow(1), 1); +assertEq(mem.grow(1, 23), 1); +assertTrue(buf !== mem.buffer); +assertEq(buf.byteLength, 0); +buf = mem.buffer; +assertEq(buf.byteLength, 2 * kPageSize); +assertEq(mem.grow(), 2); assertTrue(buf !== mem.buffer); assertEq(buf.byteLength, 0); buf = mem.buffer; assertEq(buf.byteLength, 2 * kPageSize); assertErrorMessage(() => mem.grow(1), Error, /failed to grow memory/); +assertErrorMessage(() => mem.grow(Infinity), Error, /failed to grow memory/); +assertErrorMessage(() => mem.grow(-Infinity), Error, /failed to grow memory/); assertEq(buf, mem.buffer); +let throwOnValueOf = { + valueOf: function() { + throw Error('throwOnValueOf') + } +}; +assertErrorMessage(() => mem.grow(throwOnValueOf), Error, /throwOnValueOf/); +assertEq(buf, mem.buffer); +let zero_wrapper = { + valueOf: function() { + ++this.call_counter; + return 0; + }, + call_counter: 0 +}; +assertEq(mem.grow(zero_wrapper), 2); +assertEq(zero_wrapper.call_counter, 1); +assertTrue(buf !== mem.buffer); +assertEq(buf.byteLength, 0); +buf = mem.buffer; +assertEq(buf.byteLength, 2 * kPageSize); let empty_mem = new Memory({initial: 0, maximum: 5}); let empty_buf = empty_mem.buffer; @@ -571,8 +598,9 @@ assertTrue(new Table({initial: 1, element: 'anyfunc'}) instanceof Table); assertTrue(new Table({initial: 1.5, element: 'anyfunc'}) instanceof Table); assertTrue( new Table({initial: 1, maximum: 1.5, element: 'anyfunc'}) instanceof Table); -// TODO:maximum assertTrue(new Table({initial:1, maximum:Math.pow(2,32)-1, -// element:"anyfunc"}) instanceof Table); +assertTrue( + new Table({initial: 1, maximum: Math.pow(2, 32) - 1, element: 'anyfunc'}) + instanceof Table); // 'WebAssembly.Table.prototype' data property let tableProtoDesc = Object.getOwnPropertyDescriptor(Table, 'prototype'); @@ -623,15 +651,17 @@ assertErrorMessage( () => get.call(), TypeError, /called on incompatible undefined/); assertErrorMessage( () => get.call({}), TypeError, /called on incompatible Object/); +assertEq(get.call(tbl1), null); assertEq(get.call(tbl1, 0), null); +assertEq(get.call(tbl1, 0, Infinity), null); assertEq(get.call(tbl1, 1), null); assertEq(get.call(tbl1, 1.5), null); assertErrorMessage(() => get.call(tbl1, 2), RangeError, /bad Table get index/); assertErrorMessage( () => get.call(tbl1, 2.5), RangeError, /bad Table get index/); assertErrorMessage(() => get.call(tbl1, -1), RangeError, /bad Table get index/); -// TODO assertErrorMessage(() => get.call(tbl1, Math.pow(2,33)), RangeError, -// /bad Table get index/); +assertErrorMessage( + () => get.call(tbl1, Math.pow(2, 33)), RangeError, /bad Table get index/); assertErrorMessage( () => get.call(tbl1, {valueOf() { throw new Error('hi') }}), Error, 'hi'); @@ -651,15 +681,26 @@ assertErrorMessage( assertErrorMessage( () => set.call(tbl1, 0), TypeError, /requires more than 1 argument/); assertErrorMessage( + () => set.call(tbl1, undefined), TypeError, + /requires more than 1 argument/); +assertErrorMessage( () => set.call(tbl1, 2, null), RangeError, /bad Table set index/); assertErrorMessage( () => set.call(tbl1, -1, null), RangeError, /bad Table set index/); -// TODO assertErrorMessage(() => set.call(tbl1, Math.pow(2,33), null), -// RangeError, /bad Table set index/); +assertErrorMessage( + () => set.call(tbl1, Math.pow(2, 33), null), RangeError, + /bad Table set index/); +assertErrorMessage( + () => set.call(tbl1, Infinity, null), RangeError, /bad Table set index/); +assertErrorMessage( + () => set.call(tbl1, -Infinity, null), RangeError, /bad Table set index/); assertErrorMessage( () => set.call(tbl1, 0, undefined), TypeError, /can only assign WebAssembly exported functions to Table/); assertErrorMessage( + () => set.call(tbl1, undefined, undefined), TypeError, + /can only assign WebAssembly exported functions to Table/); +assertErrorMessage( () => set.call(tbl1, 0, {}), TypeError, /can only assign WebAssembly exported functions to Table/); assertErrorMessage(() => set.call(tbl1, 0, function() { @@ -672,6 +713,7 @@ assertErrorMessage( 'hai'); assertEq(set.call(tbl1, 0, null), undefined); assertEq(set.call(tbl1, 1, null), undefined); +assertEq(set.call(tbl1, undefined, null), undefined); // 'WebAssembly.Table.prototype.grow' data property let tblGrowDesc = Object.getOwnPropertyDescriptor(tableProto, 'grow'); @@ -693,11 +735,21 @@ assertErrorMessage( /bad Table grow delta/); var tbl = new Table({element: 'anyfunc', initial: 1, maximum: 2}); assertEq(tbl.length, 1); +assertErrorMessage( + () => tbl.grow(Infinity), RangeError, /failed to grow table/); +assertErrorMessage( + () => tbl.grow(-Infinity), RangeError, /failed to grow table/); assertEq(tbl.grow(0), 1); assertEq(tbl.length, 1); -assertEq(tbl.grow(1), 1); +assertEq(tbl.grow(1, 4), 1); +assertEq(tbl.length, 2); +assertEq(tbl.grow(), 2); assertEq(tbl.length, 2); assertErrorMessage(() => tbl.grow(1), Error, /failed to grow table/); +assertErrorMessage( + () => tbl.grow(Infinity), RangeError, /failed to grow table/); +assertErrorMessage( + () => tbl.grow(-Infinity), RangeError, /failed to grow table/); // 'WebAssembly.validate' function assertErrorMessage(() => WebAssembly.validate(), TypeError); @@ -841,3 +893,17 @@ assertInstantiateSuccess(importingModuleBinary, {'': {f: () => {}}}); assertInstantiateSuccess(importingModuleBinary.buffer, {'': {f: () => {}}}); assertInstantiateSuccess( memoryImportingModuleBinary, {'': {'my_memory': scratch_memory}}); + +(function TestSubclassing() { + class M extends WebAssembly.Module { } + assertThrows(() => new M()); + + class I extends WebAssembly.Instance { } + assertThrows(() => new I()); + + class T extends WebAssembly.Table { } + assertThrows(() => new T()); + + class Y extends WebAssembly.Memory { } + assertThrows(() => new Y()); +})(); diff --git a/deps/v8/test/mjsunit/wasm/memory-external-call.js b/deps/v8/test/mjsunit/wasm/memory-external-call.js new file mode 100644 index 0000000000..0095ba1e7d --- /dev/null +++ b/deps/v8/test/mjsunit/wasm/memory-external-call.js @@ -0,0 +1,149 @@ +// Copyright 2017 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. + +// Flags: --expose-wasm + +load('test/mjsunit/wasm/wasm-constants.js'); +load('test/mjsunit/wasm/wasm-module-builder.js'); + +let initialMemoryPages = 1; +let maximumMemoryPages = 5; +let other_fn_idx = 0; + +// This builder can be used to generate a module with memory + load/store +// functions and/or an additional imported function. +function generateBuilder(add_memory, import_sig) { + let builder = new WasmModuleBuilder(); + if (import_sig) { + // Add the import if we expect a module builder with imported functions. + let idx = builder.addImport('import_module', 'other_module_fn', import_sig); + // The imported function should always have index 0. With this assertion we + // verify that we can use other_fn_idx to refer to this function. + assertEquals(idx, other_fn_idx) + } + if (add_memory) { + // Add the memory if we expect a module builder with memory and load/store. + builder.addMemory(initialMemoryPages, maximumMemoryPages, true); + builder.addFunction('load', kSig_i_i) + .addBody([kExprGetLocal, 0, kExprI32LoadMem, 0, 0]) + .exportFunc(); + builder.addFunction('store', kSig_i_ii) + .addBody([ + kExprGetLocal, 0, kExprGetLocal, 1, kExprI32StoreMem, 0, 0, + kExprGetLocal, 1 + ]) + .exportFunc(); + } + return builder; +} + +// This test verifies that when a Wasm module without memory invokes a function +// imported from another module that has memory, the second module reads its own +// memory and returns the expected value. +(function TestExternalCallBetweenTwoWasmModulesWithoutAndWithMemory() { + print('TestExternalCallBetweenTwoWasmModulesWithoutAndWithMemory'); + + let first_module = generateBuilder(add_memory = false, import_sig = kSig_i_i); + // Function to invoke the imported function and add 1 to the result. + first_module.addFunction('plus_one', kSig_i_i) + .addBody([ + kExprGetLocal, 0, // - + kExprCallFunction, other_fn_idx, // call the imported function + kExprI32Const, 1, // - + kExprI32Add, // add 1 to the result + kExprReturn // - + ]) + .exportFunc(); + let second_module = + generateBuilder(add_memory = true, import_sig = undefined); + + let index = kPageSize - 4; + let second_value = 2222; + // Instantiate the instances. + let second_instance = second_module.instantiate(); + let first_instance = first_module.instantiate( + {import_module: {other_module_fn: second_instance.exports.load}}); + // Write the values in the second instance. + second_instance.exports.store(index, second_value); + assertEquals(second_value, second_instance.exports.load(index)); + // Verify that the value is correct when passing from the imported function. + assertEquals(second_value + 1, first_instance.exports.plus_one(index)); +})(); + +// This test verifies that when a Wasm module with memory invokes a function +// imported from another module that also has memory, the second module reads +// its own memory and returns the expected value. +(function TestExternalCallBetweenTwoWasmModulesWithMemory() { + print('TestExternalCallBetweenTwoWasmModulesWithMemory'); + + let first_module = generateBuilder(add_memory = true, import_sig = kSig_i_i); + // Function to invoke the imported function and add 1 to the result. + first_module.addFunction('plus_one', kSig_i_i) + .addBody([ + kExprGetLocal, 0, // - + kExprCallFunction, other_fn_idx, // call the imported function + kExprI32Const, 1, // - + kExprI32Add, // add 1 to the result + kExprReturn // - + ]) + .exportFunc(); + let second_module = + generateBuilder(add_memory = true, import_sig = undefined); + + let index = kPageSize - 4; + let first_value = 1111; + let second_value = 2222; + // Instantiate the instances. + let second_instance = second_module.instantiate(); + let first_instance = first_module.instantiate( + {import_module: {other_module_fn: second_instance.exports.load}}); + // Write the values in the two instances. + first_instance.exports.store(index, first_value); + second_instance.exports.store(index, second_value); + // Verify that the values were stored to memory. + assertEquals(first_value, first_instance.exports.load(index)); + assertEquals(second_value, second_instance.exports.load(index)); + // Verify that the value is correct when passing from the imported function. + assertEquals(second_value + 1, first_instance.exports.plus_one(index)); +})(); + +// This test verifies that the correct memory is accessed after returning +// from a function imported from another module that also has memory. +(function TestCorrectMemoryAccessedAfterReturningFromExternalCall() { + print('TestCorrectMemoryAccessedAfterReturningFromExternalCall'); + + let first_module = generateBuilder(add_memory = true, import_sig = kSig_i_ii); + // Function to invoke the imported function and add 1 to the result. + first_module.addFunction('sandwich', kSig_i_iii) + .addBody([ + kExprGetLocal, 0, // param0 (index) + kExprGetLocal, 1, // param1 (first_value) + kExprI32StoreMem, 0, 0, // store value in first_instance + kExprGetLocal, 0, // param0 (index) + kExprGetLocal, 2, // param2 (second_value) + kExprCallFunction, other_fn_idx, // call the imported function + kExprDrop, // drop the return value + kExprGetLocal, 0, // param0 (index) + kExprI32LoadMem, 0, 0, // load from first_instance + kExprReturn // - + ]) + .exportFunc(); + let second_module = + generateBuilder(add_memory = true, import_sig = undefined); + + let index = kPageSize - 4; + let first_value = 1111; + let second_value = 2222; + // Instantiate the instances. + let second_instance = second_module.instantiate(); + let first_instance = first_module.instantiate( + {import_module: {other_module_fn: second_instance.exports.store}}); + // Call the sandwich function and check that it returns the correct value. + assertEquals( + first_value, + first_instance.exports.sandwich(index, first_value, second_value)); + // Verify that the values are correct in both memories. + assertEquals(first_value, first_instance.exports.load(index)); + assertEquals(second_value, second_instance.exports.load(index)); +})(); diff --git a/deps/v8/test/mjsunit/wasm/module-memory.js b/deps/v8/test/mjsunit/wasm/module-memory.js index fdab182665..f5b5981436 100644 --- a/deps/v8/test/mjsunit/wasm/module-memory.js +++ b/deps/v8/test/mjsunit/wasm/module-memory.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --expose-wasm --expose-gc --stress-compaction +// Flags: --expose-wasm --expose-gc --stress-compaction --allow-natives-syntax load("test/mjsunit/wasm/wasm-constants.js"); load("test/mjsunit/wasm/wasm-module-builder.js"); @@ -162,8 +162,12 @@ function testOOBThrows() { for (offset = 65534; offset < 66536; offset++) { + const trap_count = %GetWasmRecoveredTrapCount(); assertTraps(kTrapMemOutOfBounds, read); assertTraps(kTrapMemOutOfBounds, write); + if (%IsWasmTrapHandlerEnabled()) { + assertEquals(trap_count + 2, %GetWasmRecoveredTrapCount()); + } } } diff --git a/deps/v8/test/mjsunit/wasm/shared-memory.js b/deps/v8/test/mjsunit/wasm/shared-memory.js index 98ebd57e79..fa51a8307f 100644 --- a/deps/v8/test/mjsunit/wasm/shared-memory.js +++ b/deps/v8/test/mjsunit/wasm/shared-memory.js @@ -4,6 +4,9 @@ // Flags: --experimental-wasm-threads +load("test/mjsunit/wasm/wasm-constants.js"); +load("test/mjsunit/wasm/wasm-module-builder.js"); + function assertMemoryIsValid(memory) { assertSame(WebAssembly.Memory.prototype, memory.__proto__); assertSame(WebAssembly.Memory, memory.constructor); @@ -50,3 +53,51 @@ function assertMemoryIsValid(memory) { assertThrows(() => new WebAssembly.Memory({initial: 0, shared: true}), TypeError); })(); + +(function TestCompileWithUndefinedShared() { + print("TestCompileWithUndefinedShared"); + let memory = new WebAssembly.Memory({ + initial: 0, maximum: 10, shared: true}); + let builder = new WasmModuleBuilder(); + builder.addImportedMemory("m", "imported_mem", 0, undefined, "shared"); + assertThrows(() => new WebAssembly.Module(builder.toBuffer()), + WebAssembly.CompileError); +})(); + +(function TestCompileAtomicOpUndefinedShared() { + print("TestCompileAtomicOpUndefinedShared"); + let memory = new WebAssembly.Memory({ + initial: 0, maximum: 10, shared: true}); + let builder = new WasmModuleBuilder(); + builder.addFunction("main", kSig_i_ii) + .addBody([ + kExprGetLocal, 0, + kExprGetLocal, 1, + kAtomicPrefix, + kExprI32AtomicAdd]); + builder.addImportedMemory("m", "imported_mem"); + assertThrows(() => new WebAssembly.Module(builder.toBuffer()), + WebAssembly.CompileError); +})(); + +(function TestInstantiateWithUndefinedShared() { + print("TestInstantiateWithUndefinedShared"); + let memory = new WebAssembly.Memory({ + initial: 0, maximum: 10, shared: true}); + let builder = new WasmModuleBuilder(); + builder.addImportedMemory("m", "imported_mem"); + let module = new WebAssembly.Module(builder.toBuffer()); + assertThrows(() => new WebAssembly.Instance(module, + {m: {imported_mem: memory}}), WebAssembly.LinkError); +})(); + +(function TestInstantiateWithImportNotSharedDefined() { + print("TestInstantiateWithImportNotSharedDefined"); + let memory = new WebAssembly.Memory({ + initial: 0, maximum: 10, shared: false}); + let builder = new WasmModuleBuilder(); + builder.addImportedMemory("m", "imported_mem", 0, 10, "shared"); + let module = new WebAssembly.Module(builder.toBuffer()); + assertThrows(() => new WebAssembly.Instance(module, + {m: {imported_mem: memory}}), WebAssembly.LinkError); +})(); diff --git a/deps/v8/test/mjsunit/wasm/stack.js b/deps/v8/test/mjsunit/wasm/stack.js index 57e57d6467..f49dca3585 100644 --- a/deps/v8/test/mjsunit/wasm/stack.js +++ b/deps/v8/test/mjsunit/wasm/stack.js @@ -128,7 +128,6 @@ Error.prepareStackTrace = function(error, frames) { } })(); - (function testStackOverflow() { print("testStackOverflow"); var builder = new WasmModuleBuilder(); @@ -139,7 +138,7 @@ Error.prepareStackTrace = function(error, frames) { kExprI32Const, 0, kExprCallIndirect, sig_index, kTableZero ]) - .exportFunc() + .exportFunc(); builder.appendToTable([0]); try { @@ -157,3 +156,29 @@ Error.prepareStackTrace = function(error, frames) { ]); } })(); + +(function testBigOffset() { + print('testBigOffset'); + var builder = new WasmModuleBuilder(); + + let body = [kExprI32Const, 0, kExprI32Add]; + while (body.length <= 65536) body = body.concat(body); + body.unshift(kExprI32Const, 0); + body.push(kExprUnreachable); + let unreachable_pos = body.length - 1; + + builder.addFunction('main', kSig_v_v).addBody(body).exportFunc(); + + try { + builder.instantiate().exports.main(); + fail('expected wasm exception'); + } catch (e) { + assertEquals('unreachable', e.message, 'trap reason'); + verifyStack(e.stack, [ + // isWasm, function, line, pos, file + [true, 'main', 0, unreachable_pos + 1, null], // - + [false, 'testBigOffset', 173, 0, 'stack.js'], //- + [false, null, 184, 0, 'stack.js'] + ]); + } +})(); diff --git a/deps/v8/test/mjsunit/wasm/streaming-compile.js b/deps/v8/test/mjsunit/wasm/streaming-compile.js new file mode 100644 index 0000000000..5f2ca6b9fa --- /dev/null +++ b/deps/v8/test/mjsunit/wasm/streaming-compile.js @@ -0,0 +1,7 @@ +// Copyright 2017 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. + +// Flags: --wasm-test-streaming -async-compilation --expose-wasm --allow-natives-syntax + +load("test/mjsunit/wasm/async-compile.js"); diff --git a/deps/v8/test/mjsunit/wasm/streaming-error-position.js b/deps/v8/test/mjsunit/wasm/streaming-error-position.js new file mode 100644 index 0000000000..c2b86c03fa --- /dev/null +++ b/deps/v8/test/mjsunit/wasm/streaming-error-position.js @@ -0,0 +1,374 @@ +// Copyright 2017 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. + +// Flags: --wasm-test-streaming --wasm-async-compilation --expose-wasm --allow-natives-syntax + +'use strict'; + +load('test/mjsunit/wasm/wasm-constants.js'); +load('test/mjsunit/wasm/wasm-module-builder.js'); + +function module(bytes) { + let buffer = bytes; + if (typeof buffer === 'string') { + buffer = new ArrayBuffer(bytes.length); + let view = new Uint8Array(buffer); + for (let i = 0; i < bytes.length; ++i) { + view[i] = bytes.charCodeAt(i); + } + } + return new WebAssembly.Module(buffer); +} + +function toBuffer(binary) { + let buffer = new ArrayBuffer(binary.length); + let view = new Uint8Array(buffer); + for (let i = 0; i < binary.length; i++) { + let val = binary[i]; + if ((typeof val) == 'string') val = val.charCodeAt(0); + view[i] = val | 0; + } + return buffer; +} + +function testErrorPosition(bytes, pos, test_name) { + assertPromiseResult( + WebAssembly.compile(toBuffer(bytes)), assertUnreachable, e => { + print(test_name); + assertInstanceof(e, WebAssembly.CompileError); + let regex = new RegExp('@\\+' + pos); + print(e.message); + assertMatches(regex, e.message, 'Error Position'); + }); +} + +(function testInvalidMagic() { + let bytes = new Binary; + bytes.push( + kWasmH0, kWasmH1 + 1, kWasmH2, kWasmH3, kWasmV0, kWasmV1, kWasmV2, + kWasmV3); + // Error at pos==0 because that's where the magic word is. + testErrorPosition(bytes, 0, 'testInvalidMagic'); +})(); + +(function testInvalidVersion() { + let bytes = new Binary; + bytes.push( + kWasmH0, kWasmH1, kWasmH2, kWasmH3, kWasmV0, kWasmV1 + 1, kWasmV2, + kWasmV3); + // Error at pos==4 because that's where the version word is. + testErrorPosition(bytes, 4, 'testInvalidVersion'); +})(); + +(function testSectionLengthInvalidVarint() { + let bytes = new Binary; + bytes.emit_header(); + bytes.emit_u8(kTypeSectionCode); + bytes.push(0x80, 0x80, 0x80, 0x80, 0x80, 0x00); + let pos = bytes.length - 1 - 1; + testErrorPosition(bytes, pos, 'testSectionLengthInvalidVarint'); +})(); + +(function testSectionLengthTooBig() { + let bytes = new Binary; + bytes.emit_header(); + bytes.emit_u8(kTypeSectionCode); + bytes.emit_u32v(0xffffff23); + let pos = bytes.length - 1; + testErrorPosition(bytes, pos, 'testSectionLengthTooBig'); +})(); + +(function testFunctionsCountInvalidVarint() { + let bytes = new Binary; + bytes.emit_header(); + bytes.push( + kTypeSectionCode, // section id + 1, // section length + 0 // number of types + ); + bytes.push( + kFunctionSectionCode, // section id + 1, // section length + 0 // number of functions + ); + bytes.push( + kCodeSectionCode, // section id + 20, // section length (arbitrary value > 6) + ); + // Functions count + bytes.push(0x80, 0x80, 0x80, 0x80, 0x80, 0x00); + + let pos = bytes.length - 1 - 1; + testErrorPosition(bytes, pos, 'testFunctionsCountInvalidVarint'); +})(); + +(function testFunctionsCountTooBig() { + let bytes = new Binary; + bytes.emit_header(); + bytes.push( + kTypeSectionCode, // section id + 1, // section length + 0 // number of types + ); + bytes.push( + kFunctionSectionCode, // section id + 1, // section length + 0 // number of functions + ); + bytes.push( + kCodeSectionCode, // section id + 20, // section length (arbitrary value > 6) + ); + // Functions count + bytes.emit_u32v(0xffffff23); + + let pos = bytes.length - 1; + testErrorPosition(bytes, pos, 'testFunctionsCountTooBig'); +})(); + +(function testFunctionsCountDoesNotMatch() { + let bytes = new Binary; + bytes.emit_header(); + bytes.push( + kTypeSectionCode, // section id + 1, // section length + 0 // number of types + ); + bytes.push( + kFunctionSectionCode, // section id + 1, // section length + 0 // number of functions + ); + bytes.push( + kCodeSectionCode, // section id + 20, // section length (arbitrary value > 6) + ); + // Functions count (different than the count in the functions section. + bytes.emit_u32v(5); + + let pos = bytes.length - 1; + testErrorPosition(bytes, pos, 'testFunctionsCountDoesNotMatch'); +})(); + +(function testBodySizeInvalidVarint() { + let bytes = new Binary; + bytes.emit_header(); + bytes.push( + kTypeSectionCode, // section id + 4, // section length + 1, // number of types + kWasmFunctionTypeForm, // type + 0, // number of parameter + 0 // number of returns + ); + bytes.push( + kFunctionSectionCode, // section id + 2, // section length + 1, // number of functions + 0 // signature index + ); + bytes.push( + kCodeSectionCode, // section id + 20, // section length (arbitrary value > 6) + 1 // functions count + ); + // Invalid function body size. + bytes.push(0x80, 0x80, 0x80, 0x80, 0x80, 0x00); + + let pos = bytes.length - 1 - 1; + testErrorPosition(bytes, pos, 'testBodySizeInvalidVarint'); +})(); + +(function testBodySizeTooBig() { + let bytes = new Binary; + bytes.emit_header(); + bytes.push( + kTypeSectionCode, // section id + 4, // section length + 1, // number of types + kWasmFunctionTypeForm, // type + 0, // number of parameter + 0 // number of returns + ); + bytes.push( + kFunctionSectionCode, // section id + 2, // section length + 1, // number of functions + 0 // signature index + ); + bytes.push( + kCodeSectionCode, // section id + 20, // section length (arbitrary value > 6) + 1 // functions count + ); + // Invalid function body size. + bytes.emit_u32v(0xffffff23); + + let pos = bytes.length - 1; + testErrorPosition(bytes, pos, 'testBodySizeTooBig'); +})(); + +(function testBodySizeDoesNotFit() { + let bytes = new Binary; + bytes.emit_header(); + bytes.push( + kTypeSectionCode, // section id + 4, // section length + 1, // number of types + kWasmFunctionTypeForm, // type + 0, // number of parameter + 0 // number of returns + ); + bytes.push( + kFunctionSectionCode, // section id + 2, // section length + 1, // number of functions + 0 // signature index + ); + bytes.push( + kCodeSectionCode, // section id + 20, // section length (arbitrary value > 6) + 1 // functions count + ); + // Invalid function body size (does not fit into the code section). + bytes.emit_u32v(20); + + let pos = bytes.length - 1; + testErrorPosition(bytes, pos, 'testBodySizeDoesNotFit'); +})(); + +(function testBodySizeIsZero() { + let bytes = new Binary; + bytes.emit_header(); + bytes.push( + kTypeSectionCode, // section id + 4, // section length + 1, // number of types + kWasmFunctionTypeForm, // type + 0, // number of parameter + 0 // number of returns + ); + bytes.push( + kFunctionSectionCode, // section id + 2, // section length + 1, // number of functions + 0 // signature index + ); + bytes.push( + kCodeSectionCode, // section id + 20, // section length (arbitrary value > 6) + 1 // functions count + ); + // Invalid function body size (body size of 0 is invalid). + bytes.emit_u32v(0); + + let pos = bytes.length - 1; + testErrorPosition(bytes, pos, 'testBodySizeIsZero'); +})(); + +(function testStaleCodeSectionBytes() { + let bytes = new Binary; + bytes.emit_header(); + bytes.push( + kTypeSectionCode, // section id + 4, // section length + 1, // number of types + kWasmFunctionTypeForm, // type + 0, // number of parameter + 0 // number of returns + ); + bytes.push( + kFunctionSectionCode, // section id + 2, // section length + 1, // number of functions + 0 // signature index + ); + bytes.push( + kCodeSectionCode, // section id + 20, // section length (too big) + 1, // functions count + 2, // body size + 0, // locals count + kExprEnd // body + ); + + let pos = bytes.length - 1; + testErrorPosition(bytes, pos, 'testStaleCodeSectionBytes'); +})(); + +(function testInvalidCode() { + let bytes = new Binary; + bytes.emit_header(); + bytes.push( + kTypeSectionCode, // section id + 4, // section length + 1, // number of types + kWasmFunctionTypeForm, // type + 0, // number of parameter + 0 // number of returns + ); + bytes.push( + kFunctionSectionCode, // section id + 2, // section length + 1, // number of functions + 0 // signature index + ); + bytes.push( + kCodeSectionCode, // section id + 6, // section length (too big) + 1, // functions count + 4, // body size + 0, // locals count + kExprGetLocal, 0, // Access a non-existing local + kExprEnd // -- + ); + + // Find error at the index of kExprGetLocal. + let pos = bytes.length - 1 - 1; + testErrorPosition(bytes, pos, 'testInvalidCode'); +})(); + +(function testCodeSectionSizeZero() { + let bytes = new Binary; + bytes.emit_header(); + bytes.push( + kTypeSectionCode, // section id + 4, // section length + 1, // number of types + kWasmFunctionTypeForm, // type + 0, // number of parameter + 0 // number of returns + ); + bytes.push( + kFunctionSectionCode, // section id + 2, // section length + 1, // number of functions + 0 // signature index + ); + bytes.push( + kCodeSectionCode, // section id + 0, // section length (too big) + ); + + // Find error at the index of kExprGetLocal. + let pos = bytes.length - 1; + testErrorPosition(bytes, pos, 'testCodeSectionSizeZero'); +})(); + +(function testInvalidSection() { + let bytes = new Binary; + bytes.emit_header(); + bytes.push( + kTypeSectionCode, // section id + 5, // section length + 1, // number of types + kWasmFunctionTypeForm, // type + 1, // number of parameter + 0x7b, // invalid type + 0 // number of returns + ); + + let pos = bytes.length - 1 - 1; + testErrorPosition(bytes, pos, 'testInvalidSection'); +})(); diff --git a/deps/v8/test/mjsunit/wasm/streaming-trap-location.js b/deps/v8/test/mjsunit/wasm/streaming-trap-location.js new file mode 100644 index 0000000000..1607ca76f2 --- /dev/null +++ b/deps/v8/test/mjsunit/wasm/streaming-trap-location.js @@ -0,0 +1,7 @@ +// Copyright 2017 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. + +// Flags: --wasm-test-streaming --wasm-async-compilation --expose-wasm + +load("test/mjsunit/wasm/trap-location.js"); diff --git a/deps/v8/test/mjsunit/wasm/trap-location.js b/deps/v8/test/mjsunit/wasm/trap-location.js index 390ad74d8d..0c646c92cd 100644 --- a/deps/v8/test/mjsunit/wasm/trap-location.js +++ b/deps/v8/test/mjsunit/wasm/trap-location.js @@ -14,12 +14,16 @@ Error.prepareStackTrace = function(error, frames) { function testTrapLocations(instance, expected_stack_length) { function testWasmTrap(value, reason, position) { + let function_name = arguments.callee.name; try { instance.exports.main(value); fail('expected wasm exception'); } catch (e) { assertEquals(kTrapMsgs[reason], e.message, 'trap reason'); - assertEquals(expected_stack_length, e.stack.length, 'number of frames'); + // Check that the trapping function is the one which was called from this + // function. + assertTrue( + e.stack[1].toString().startsWith(function_name), 'stack depth'); assertEquals(0, e.stack[0].getLineNumber(), 'wasmFunctionIndex'); assertEquals(position, e.stack[0].getPosition(), 'position'); } diff --git a/deps/v8/test/mjsunit/wasm/unreachable-validation.js b/deps/v8/test/mjsunit/wasm/unreachable-validation.js index 113bcc3102..5b98b1713b 100644 --- a/deps/v8/test/mjsunit/wasm/unreachable-validation.js +++ b/deps/v8/test/mjsunit/wasm/unreachable-validation.js @@ -128,3 +128,5 @@ run(I, "U (block (iblock 0 0 brt01) drop)", [unr, ...block, ...iblock, ...zero, run(V, "(iblock (iblock U 0 brt01)) drop", [...iblock, ...iblock, unr, ...zero, ...brt01, end, end, drop]); run(I, "(block (fblock U 0 brt01) drop)", [...iblock, ...fblock, unr, ...zero, ...brt01, end, drop, end]); run(I, "(iblock (fblock U 0 brt01) drop 0) drop", [...iblock, ...fblock, unr, ...zero, ...brt01, end, drop, ...zero, end, drop]); + +run(I, "(iblock (block (U brif 1))", [...iblock, ...block, unr, kExprBrIf, 0, end, end, kExprDrop]); diff --git a/deps/v8/test/mjsunit/wasm/wasm-constants.js b/deps/v8/test/mjsunit/wasm/wasm-constants.js index c556b109a1..cc5f1e9c4a 100644 --- a/deps/v8/test/mjsunit/wasm/wasm-constants.js +++ b/deps/v8/test/mjsunit/wasm/wasm-constants.js @@ -92,6 +92,7 @@ let kWasmI32 = 0x7f; let kWasmI64 = 0x7e; let kWasmF32 = 0x7d; let kWasmF64 = 0x7c; +let kWasmS128 = 0x7b; let kExternalFunction = 0; let kExternalTable = 1; @@ -123,6 +124,10 @@ let kSig_v_d = makeSig([kWasmF64], []); let kSig_v_dd = makeSig([kWasmF64, kWasmF64], []); let kSig_v_ddi = makeSig([kWasmF64, kWasmF64, kWasmI32], []); +let kSig_v_f = makeSig([kWasmF32], []); +let kSig_f_f = makeSig([kWasmF32], [kWasmF32]); +let kSig_d_d = makeSig([kWasmF64], [kWasmF64]); + function makeSig(params, results) { return {params: params, results: results}; } @@ -327,6 +332,12 @@ let kExprF64ReinterpretI64 = 0xbf; // Prefix opcodes let kAtomicPrefix = 0xfe; +let kExprI32AtomicLoad = 0x10; +let kExprI32AtomicLoad8U = 0x12; +let kExprI32AtomicLoad16U = 0x13; +let kExprI32AtomicStore = 0x17; +let kExprI32AtomicStore8U = 0x19; +let kExprI32AtomicStore16U = 0x1a; let kExprI32AtomicAdd = 0x1e; let kExprI32AtomicAdd8U = 0x20; let kExprI32AtomicAdd16U = 0x21; @@ -387,7 +398,7 @@ function assertTraps(trap, code) { throw new MjsUnitAssertionError('Did not trap, expected: ' + kTrapMsgs[trap]); } -function assertWasmThrows(values, code) { +function assertWasmThrows(runtime_id, values, code) { try { if (typeof code === 'function') { code(); @@ -396,15 +407,18 @@ function assertWasmThrows(values, code) { } } catch (e) { assertTrue(e instanceof WebAssembly.RuntimeError); - assertNotEquals(e['WasmExceptionTag'], undefined); - assertTrue(Number.isInteger(e['WasmExceptionTag'])); - // TODO(kschimpf): Extract values from the exception. - let e_values = []; - assertEquals(values, e_values); + var e_runtime_id = e['WasmExceptionRuntimeId']; + assertEquals(e_runtime_id, runtime_id); + assertTrue(Number.isInteger(e_runtime_id)); + var e_values = e['WasmExceptionValues']; + assertEquals(values.length, e_values.length); + for (i = 0; i < values.length; ++i) { + assertEquals(values[i], e_values[i]); + } // Success. return; } - throw new MjsUnitAssertionError('Did not throw, expected: ' + values); + throw new MjsUnitAssertionError('Did not throw expected: ' + runtime_id + values); } function wasmI32Const(val) { diff --git a/deps/v8/test/mjsunit/wasm/wasm-module-builder.js b/deps/v8/test/mjsunit/wasm/wasm-module-builder.js index 78e3d6bde8..d21067b36e 100644 --- a/deps/v8/test/mjsunit/wasm/wasm-module-builder.js +++ b/deps/v8/test/mjsunit/wasm/wasm-module-builder.js @@ -171,8 +171,8 @@ class WasmModuleBuilder { return this; } - addMemory(min, max, exp) { - this.memory = {min: min, max: max, exp: exp}; + addMemory(min, max, exp, shared) { + this.memory = {min: min, max: max, exp: exp, shared: shared}; return this; } @@ -240,9 +240,9 @@ class WasmModuleBuilder { return this.num_imported_globals++; } - addImportedMemory(module = "", name, initial = 0, maximum) { + addImportedMemory(module = "", name, initial = 0, maximum, shared) { let o = {module: module, name: name, kind: kExternalMemory, - initial: initial, maximum: maximum}; + initial: initial, maximum: maximum, shared: shared}; this.imports.push(o); return this; } @@ -348,7 +348,12 @@ class WasmModuleBuilder { section.emit_u8(imp.mutable); } else if (imp.kind == kExternalMemory) { var has_max = (typeof imp.maximum) != "undefined"; - section.emit_u8(has_max ? 1 : 0); // flags + var is_shared = (typeof imp.shared) != "undefined"; + if (is_shared) { + section.emit_u8(has_max ? 3 : 2); // flags + } else { + section.emit_u8(has_max ? 1 : 0); // flags + } section.emit_u32v(imp.initial); // initial if (has_max) section.emit_u32v(imp.maximum); // maximum } else if (imp.kind == kExternalTable) { @@ -395,9 +400,16 @@ class WasmModuleBuilder { binary.emit_section(kMemorySectionCode, section => { section.emit_u8(1); // one memory entry const has_max = wasm.memory.max !== undefined; - section.emit_u32v(has_max ? kResizableMaximumFlag : 0); + const is_shared = wasm.memory.shared !== undefined; + // Emit flags (bit 0: reszeable max, bit 1: shared memory) + if (is_shared) { + section.emit_u8(has_max ? 3 : 2); + } else { + section.emit_u8(has_max ? 1 : 0); + } section.emit_u32v(wasm.memory.min); if (has_max) section.emit_u32v(wasm.memory.max); + if (wasm.memory.shared) section.emit_u8(1); }); } @@ -511,7 +523,7 @@ class WasmModuleBuilder { for (let type of wasm.exceptions) { section.emit_u32v(type.params.length); for (let param of type.params) { - section.enit_u8(param); + section.emit_u8(param); } } }); @@ -541,6 +553,9 @@ class WasmModuleBuilder { if (l.f64_count > 0) { local_decls.push({count: l.f64_count, type: kWasmF64}); } + if (l.s128_count > 0) { + local_decls.push({count: l.s128_count, type: kWasmS128}); + } } let header = new Binary; diff --git a/deps/v8/test/mozilla/mozilla.status b/deps/v8/test/mozilla/mozilla.status index 7ba7b7bc52..686018c007 100644 --- a/deps/v8/test/mozilla/mozilla.status +++ b/deps/v8/test/mozilla/mozilla.status @@ -297,6 +297,10 @@ # This section is for tests that fail in both V8 and JSC. Thus they # have been determined to be incompatible between Mozilla and V8/JSC. + # d8 does not implement a window object. + 'js1_5/Regress/regress-317476': [FAIL], + 'js1_5/Regress/regress-314401': [FAIL], + # Any local 'arguments' variable should not be allowed to shadow the value # returned via the indirect 'arguments' property accessor. 'js1_4/Functions/function-001': [FAIL_OK], diff --git a/deps/v8/test/test262/local-tests/test/intl402/NumberFormat/prototype/formatToParts/default-parameter.js b/deps/v8/test/test262/local-tests/test/intl402/NumberFormat/prototype/formatToParts/default-parameter.js new file mode 100644 index 0000000000..408694c48c --- /dev/null +++ b/deps/v8/test/test262/local-tests/test/intl402/NumberFormat/prototype/formatToParts/default-parameter.js @@ -0,0 +1,30 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: #sec-intl.numberformat.prototype.formattoparts +description: Intl.NumberFormat.prototype.formatToParts called with no parameters +info: > + Intl.NumberFormat.prototype.formatToParts ([ value ]) + + 3. If value is not provided, let value be undefined. +---*/ + +var nf = new Intl.NumberFormat(); + +// Example value: [{"type":"nan","value":"NaN"}] +var implicit = nf.formatToParts(); +var explicit = nf.formatToParts(undefined); + +assert(partsEquals(implicit, explicit), + "formatToParts() should be equivalent to formatToParts(undefined)"); + +function partsEquals(parts1, parts2) { + if (parts1.length !== parts2.length) return false; + for (var i = 0; i < parts1.length; i++) { + var part1 = parts1[i]; + var part2 = parts2[i]; + if (part1.type !== part2.type) return false; + if (part1.value !== part2.value) return false; + } + return true; +} diff --git a/deps/v8/test/test262/test262.status b/deps/v8/test/test262/test262.status index eec9d869b7..8e716309ee 100644 --- a/deps/v8/test/test262/test262.status +++ b/deps/v8/test/test262/test262.status @@ -109,11 +109,6 @@ 'built-ins/TypedArray/prototype/map/callbackfn-detachbuffer': [FAIL], 'built-ins/TypedArray/prototype/reduce/callbackfn-detachbuffer': [FAIL], 'built-ins/TypedArray/prototype/reduceRight/callbackfn-detachbuffer': [FAIL], - 'built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-get-src-value-throws': [FAIL], - 'built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-tointeger-offset-throws': [FAIL], - 'built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-throws': [FAIL], - 'built-ins/TypedArray/prototype/set/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws': [FAIL], - 'built-ins/TypedArray/prototype/set/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws': [FAIL], 'built-ins/TypedArray/prototype/slice/detached-buffer-custom-ctor-other-targettype': [FAIL], 'built-ins/TypedArray/prototype/slice/detached-buffer-custom-ctor-same-targettype': [FAIL], 'built-ins/TypedArray/prototype/slice/detached-buffer-get-ctor': [FAIL], @@ -203,6 +198,7 @@ 'language/statements/for-of/dstr-array-rest-iter-thrw-close': [FAIL], 'language/statements/for-of/dstr-array-rest-iter-thrw-close-err': [FAIL], 'language/statements/for-of/dstr-array-rest-lref-err': [FAIL], + 'language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-rtrn-close-null': [FAIL], # https://bugs.chromium.org/p/v8/issues/detail?id=896 'built-ins/RegExp/property-escapes/binary-properties-with-value': [FAIL], @@ -364,11 +360,6 @@ 'language/expressions/object/method-definition/name-param-redecl': [FAIL], 'language/statements/async-function/early-errors-declaration-formals-body-duplicate': [FAIL], - # Module-related tests - # https://github.com/tc39/ecma262/pull/858 - 'language/module-code/namespace/internals/set': [FAIL], - 'language/module-code/namespace/internals/define-own-property': [FAIL], - # https://bugs.chromium.org/p/v8/issues/detail?id=5601 'intl402/PluralRules/*': ['--harmony-plural-rules'], @@ -458,6 +449,13 @@ # https://bugs.chromium.org/p/v8/issues/detail?id=4743#c28 'built-ins/RegExp/property-escapes/generated/Emoji_Component': [FAIL], + # ICU 59 uses Unicode 9 data; property escape tests were generated for Unicode 10 + 'built-ins/RegExp/property-escapes/generated/*': [SKIP], + + # https://bugs.chromium.org/p/v8/issues/detail?id=6776 + 'built-ins/Proxy/ownKeys/return-duplicate-entries-throws': [FAIL], + 'built-ins/Proxy/ownKeys/return-duplicate-symbol-entries-throws': [FAIL], + ######################## NEEDS INVESTIGATION ########################### # These test failures are specific to the intl402 suite and need investigation @@ -467,15 +465,12 @@ 'intl402/6.2.3': [FAIL], 'intl402/Collator/10.1.2_a': [PASS, FAIL], 'intl402/Collator/10.2.3_b': [PASS, FAIL], - 'intl402/Collator/prototype/10.3_a': [FAIL], 'intl402/DateTimeFormat/12.1.2': [PASS, FAIL], 'intl402/DateTimeFormat/12.2.3_b': [FAIL], - 'intl402/DateTimeFormat/prototype/12.3_a': [FAIL], 'intl402/Number/prototype/toLocaleString/13.2.1_5': [PASS, FAIL], 'intl402/NumberFormat/11.1.1_20_c': [FAIL], 'intl402/NumberFormat/11.1.2': [PASS, FAIL], 'intl402/NumberFormat/11.2.3_b': [FAIL], - 'intl402/NumberFormat/prototype/11.3_a': [FAIL], 'intl402/String/prototype/localeCompare/13.1.1_7': [PASS, FAIL], ##################### DELIBERATE INCOMPATIBILITIES ##################### @@ -513,14 +508,14 @@ 'language/statements/for-await-of/escaped-of': [FAIL], 'language/statements/for-of/escaped-of': [FAIL], - # https://bugs.chromium.org/p/v8/issues/detail?id=6542 - 'built-ins/Array/prototype/sort/comparefn-nonfunction-call-throws': [FAIL], - 'built-ins/TypedArray/prototype/sort/comparefn-nonfunction-call-throws': [FAIL], - # https://bugs.chromium.org/p/v8/issues/detail?id=6543 'language/statements/labeled/value-await-non-module-escaped': [FAIL], 'language/statements/labeled/value-yield-non-strict-escaped': [FAIL], + # https://bugs.chromium.org/p/v8/issues/detail?id=6912 + 'built-ins/RegExp/named-groups/string-replace-missing': [FAIL], + 'built-ins/RegExp/named-groups/string-replace-unclosed': [FAIL], + ############################ INVALID TESTS ############################# # Test makes unjustified assumptions about the number of calls to SortCompare. @@ -539,81 +534,9 @@ 'built-ins/Date/prototype/setFullYear/new-value-time-clip': [PASS, FAIL], 'built-ins/Date/prototype/setMonth/new-value-time-clip': [PASS, FAIL], - # https://github.com/tc39/test262/issues/1085 - 'language/directive-prologue/10.1.1-5gs': [PASS, FAIL_SLOPPY], - 'language/directive-prologue/10.1.1-2gs': [PASS, FAIL_SLOPPY], - 'language/directive-prologue/14.1-4gs': [PASS, FAIL_SLOPPY], - 'language/directive-prologue/10.1.1-8gs': [PASS, FAIL_SLOPPY], - 'language/directive-prologue/14.1-5gs': [PASS, FAIL_SLOPPY], - # Test against internals of harness; we plug in differently 'harness/detachArrayBuffer': [SKIP], - 'harness/detachArrayBuffer-$262.detachArrayBuffer': [SKIP], - - # Invalid {Assignment,Binding}RestPattern - # https://bugs.chromium.org/p/v8/issues/detail?id=6500 - 'language/expressions/assignment/dstr-obj-rest-obj-own-property': [FAIL], - 'language/statements/for-of/dstr-obj-rest-obj-own-property': [FAIL], - 'language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-obj-nested-rest': [FAIL], - 'language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-rest-obj-own-property': [FAIL], - 'language/statements/for-await-of/async-gen-decl-dstr-obj-rest-nested-obj': [FAIL], - 'language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-obj-nested-rest': [FAIL], - 'language/expressions/assignment/dstr-obj-rest-nested-obj-nested-rest': [FAIL], - 'language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-obj-own-property': [FAIL], - 'language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-rest-obj-nested-rest': [FAIL], - 'language/statements/for-await-of/async-func-dstr-const-obj-ptrn-rest-nested-obj': [FAIL], - 'language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-obj-own-property': [FAIL], - 'language/statements/for-await-of/async-func-dstr-let-obj-ptrn-rest-obj-nested-rest': [FAIL], - 'language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-rest-obj-own-property': [FAIL], - 'language/expressions/assignment/dstr-obj-rest-nested-obj': [FAIL], - 'language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-rest-nested-obj': [FAIL], - 'language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-obj-nested-rest': [FAIL], - 'language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-rest-obj-nested-rest': [FAIL], - 'language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-obj-nested-rest': [FAIL], - 'language/statements/for-of/dstr-obj-rest-nested-obj': [FAIL], - 'language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-rest-obj-nested-rest': [FAIL], - 'language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-nested-obj': [FAIL], - 'language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-obj-own-property': [FAIL], - 'language/statements/for-await-of/async-gen-decl-dstr-obj-rest-nested-obj-nested-rest': [FAIL], - 'language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-obj-own-property': [FAIL], - 'language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-rest-nested-obj': [FAIL], - 'language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-rest-obj-own-property': [FAIL], - 'language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-obj-nested-rest': [FAIL], - 'language/statements/for-await-of/async-func-decl-dstr-obj-rest-nested-obj-nested-rest': [FAIL], - 'language/statements/for-await-of/async-func-decl-dstr-obj-rest-obj-own-property': [FAIL], - 'language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-nested-obj': [FAIL], - 'language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-nested-obj': [FAIL], - 'language/statements/for-await-of/async-func-dstr-var-obj-ptrn-rest-nested-obj': [FAIL], - 'language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-nested-obj': [FAIL], - 'language/statements/for-await-of/async-func-decl-dstr-obj-rest-nested-obj': [FAIL], - 'language/statements/for-await-of/async-func-dstr-var-obj-ptrn-rest-obj-nested-rest': [FAIL], - 'language/statements/for-await-of/async-gen-decl-dstr-obj-rest-obj-own-property': [FAIL], - 'language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-obj-nested-rest': [FAIL], - 'language/statements/for-await-of/async-func-dstr-let-obj-ptrn-rest-obj-own-property': [FAIL], - 'language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-nested-obj': [FAIL], - 'language/statements/for-of/dstr-obj-rest-nested-obj-nested-rest': [FAIL], - 'language/statements/for-await-of/async-func-dstr-const-obj-ptrn-rest-obj-nested-rest': [FAIL], - 'language/statements/for-await-of/async-func-dstr-let-obj-ptrn-rest-nested-obj': [FAIL], - 'language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-nested-obj': [FAIL], - 'language/statements/for-await-of/async-func-dstr-var-obj-ptrn-rest-obj-own-property': [FAIL], - 'language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-obj-own-property': [FAIL], - 'language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-obj-own-property': [FAIL], - 'language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-rest-nested-obj': [FAIL], - 'language/statements/for-await-of/async-func-dstr-const-obj-ptrn-rest-obj-own-property': [FAIL], - - # Async Iteration https://github.com/tc39/test262/issues/1154 - 'language/statements/for-await-of/async-func-decl-dstr-array-elem-init-let': [FAIL], - 'language/statements/for-await-of/async-func-decl-dstr-array-elem-put-let': [FAIL], - 'language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-let': [FAIL], - 'language/statements/for-await-of/async-gen-decl-dstr-array-elem-put-let': [FAIL], - 'language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-elision-iter-abpt': [FAIL], - 'language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-get-err': [FAIL], - 'language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-list-nrml-close-null': [FAIL], - 'language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-list-rtrn-close-err': [FAIL], - 'language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-list-rtrn-close-null': [FAIL], - 'language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-rest-rtrn-close-null': [FAIL], - 'language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-list-rtrn-close': [FAIL], - 'language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-rest-rtrn-close-err': [PASS, FAIL], + 'harness/detachArrayBuffer-host-detachArrayBuffer': [SKIP], ############################ SKIPPED TESTS ############################# diff --git a/deps/v8/test/test262/testcfg.py b/deps/v8/test/test262/testcfg.py index 59650f3d25..849a3036cd 100644 --- a/deps/v8/test/test262/testcfg.py +++ b/deps/v8/test/test262/testcfg.py @@ -47,8 +47,11 @@ FEATURE_FLAGS = { 'regexp-named-groups': '--harmony-regexp-named-captures', 'regexp-unicode-property-escapes': '--harmony-regexp-property', 'regexp-lookbehind': '--harmony-regexp-lookbehind', + 'Promise.prototype.finally': '--harmony-promise-finally', } +SKIPPED_FEATURES = set(['BigInt', 'class-fields', 'optional-catch-binding']) + DATA = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data") ARCHIVE = DATA + ".tar" @@ -130,7 +133,6 @@ class Test262TestSuite(testsuite.TestSuite): self.ParseTestRecord = None def ListTests(self, context): - tests = [] testnames = set() for dirname, dirs, files in itertools.chain(os.walk(self.testroot), os.walk(self.localtestroot)): @@ -148,7 +150,10 @@ class Test262TestSuite(testsuite.TestSuite): fullpath = os.path.join(dirname, filename) relpath = re.match(TEST_262_RELPATH_REGEXP, fullpath).group(1) testnames.add(relpath.replace(os.path.sep, "/")) - return [testcase.TestCase(self, testname) for testname in testnames] + cases = [testcase.TestCase(self, testname) for testname in testnames] + return [case for case in cases if len( + SKIPPED_FEATURES.intersection( + self.GetTestRecord(case).get("features", []))) == 0] def GetFlagsForTestCase(self, testcase, context): return (testcase.flags + context.mode_flags + self.harness + diff --git a/deps/v8/test/unittests/BUILD.gn b/deps/v8/test/unittests/BUILD.gn index 37b9e46f8c..0f8d8c6cfc 100644 --- a/deps/v8/test/unittests/BUILD.gn +++ b/deps/v8/test/unittests/BUILD.gn @@ -7,6 +7,30 @@ import("../../gni/v8.gni") v8_executable("unittests") { testonly = true + # TODO(machenbach): Translate from gyp. + #['OS=="aix"', { + # 'ldflags': [ '-Wl,-bbigtoc' ], + #}], + + deps = [ + ":unittests_sources", + "../..:v8_for_testing", + "../..:v8_libbase", + "../..:v8_libplatform", + "//build/config:exe_and_shlib_deps", + "//build/win:default_exe_manifest", + "//testing/gmock", + "//testing/gtest", + ] + + configs = [ + "../..:external_config", + "../..:internal_config_base", + ] +} +v8_source_set("unittests_sources") { + testonly = true + sources = [ "../../test/common/wasm/wasm-macro-gen.h", "../../testing/gmock-support.h", @@ -41,6 +65,8 @@ v8_executable("unittests") { "base/utils/random-number-generator-unittest.cc", "cancelable-tasks-unittest.cc", "char-predicates-unittest.cc", + "code-stub-assembler-unittest.cc", + "code-stub-assembler-unittest.h", "compiler-dispatcher/compiler-dispatcher-tracer-unittest.cc", "compiler-dispatcher/compiler-dispatcher-unittest.cc", "compiler-dispatcher/optimizing-compile-dispatcher-unittest.cc", @@ -48,6 +74,8 @@ v8_executable("unittests") { "compiler/branch-elimination-unittest.cc", "compiler/bytecode-analysis-unittest.cc", "compiler/checkpoint-elimination-unittest.cc", + "compiler/code-assembler-unittest.cc", + "compiler/code-assembler-unittest.h", "compiler/common-operator-reducer-unittest.cc", "compiler/common-operator-unittest.cc", "compiler/compiler-test-utils.h", @@ -56,7 +84,6 @@ v8_executable("unittests") { "compiler/dead-code-elimination-unittest.cc", "compiler/diamond-unittest.cc", "compiler/effect-control-linearizer-unittest.cc", - "compiler/escape-analysis-unittest.cc", "compiler/graph-reducer-unittest.cc", "compiler/graph-reducer-unittest.h", "compiler/graph-trimmer-unittest.cc", @@ -101,8 +128,10 @@ v8_executable("unittests") { "compiler/value-numbering-reducer-unittest.cc", "compiler/zone-stats-unittest.cc", "counters-unittest.cc", + "detachable-vector-unittest.cc", "eh-frame-iterator-unittest.cc", "eh-frame-writer-unittest.cc", + "heap/barrier-unittest.cc", "heap/bitmap-unittest.cc", "heap/embedder-tracing-unittest.cc", "heap/gc-idle-time-handler-unittest.cc", @@ -153,6 +182,7 @@ v8_executable("unittests") { "wasm/loop-assignment-analysis-unittest.cc", "wasm/module-decoder-unittest.cc", "wasm/streaming-decoder-unittest.cc", + "wasm/wasm-heap-unittest.cc", "wasm/wasm-macro-gen-unittest.cc", "wasm/wasm-module-builder-unittest.cc", "wasm/wasm-opcodes-unittest.cc", @@ -162,6 +192,15 @@ v8_executable("unittests") { "zone/zone-unittest.cc", ] + if (use_jumbo_build) { + jumbo_excluded_sources = [ + # TODO(mostynb@opera.com): figure out how to make this build in both + # modes. Template issues on windows if we add a functional_unittest + # namespace as with the other files. + "base/functional-unittest.cc", + ] + } + if (v8_current_cpu == "arm") { sources += [ "compiler/arm/instruction-selector-arm-unittest.cc" ] } else if (v8_current_cpu == "arm64") { @@ -185,11 +224,6 @@ v8_executable("unittests") { "../..:internal_config_base", ] - # TODO(machenbach): Translate from gyp. - #['OS=="aix"', { - # 'ldflags': [ '-Wl,-bbigtoc' ], - #}], - deps = [ "../..:v8_for_testing", "../..:v8_libbase", diff --git a/deps/v8/test/unittests/api/remote-object-unittest.cc b/deps/v8/test/unittests/api/remote-object-unittest.cc index 27612fae6f..40754d50f4 100644 --- a/deps/v8/test/unittests/api/remote-object-unittest.cc +++ b/deps/v8/test/unittests/api/remote-object-unittest.cc @@ -11,6 +11,7 @@ #include "test/unittests/test-utils.h" namespace v8 { +namespace remote_object_unittest { typedef TestWithIsolate RemoteObjectTest; @@ -115,4 +116,5 @@ TEST_F(RemoteObjectTest, ClassOf) { EXPECT_STREQ("test_class", *result); } +} // namespace remote_object_unittest } // namespace v8 diff --git a/deps/v8/test/unittests/base/logging-unittest.cc b/deps/v8/test/unittests/base/logging-unittest.cc index 35da8a33db..fd334ec49d 100644 --- a/deps/v8/test/unittests/base/logging-unittest.cc +++ b/deps/v8/test/unittests/base/logging-unittest.cc @@ -10,6 +10,7 @@ namespace v8 { namespace base { +namespace logging_unittest { namespace { @@ -67,6 +68,23 @@ TEST(LoggingTest, CompareAgainstStaticConstPointer) { CHECK_##name(lhs, rhs); \ DCHECK_##name(lhs, rhs) +namespace { +std::string FailureMessage(const char* msg, const char* debug_msg) { + std::string regexp(msg); +#ifdef DEBUG + regexp.append(" (").append(debug_msg).append(")"); +#endif + size_t last_pos = 0; + do { + size_t pos = regexp.find_first_of("(){}+*", last_pos); + if (pos == std::string::npos) break; + regexp.insert(pos, "\\"); + last_pos = pos + 2; + } while (true); + return regexp; +} +} // namespace + TEST(LoggingTest, CompareWithDifferentSignedness) { int32_t i32 = 10; uint32_t u32 = 20; @@ -80,6 +98,11 @@ TEST(LoggingTest, CompareWithDifferentSignedness) { CHECK_BOTH(IMPLIES, i32, i64); CHECK_BOTH(IMPLIES, u32, i64); CHECK_BOTH(IMPLIES, !u32, !i64); + + // Check that the values are output correctly on error. + ASSERT_DEATH_IF_SUPPORTED( + ([&] { CHECK_GT(i32, u64); })(), + FailureMessage("Check failed: i32 > u64", "10 vs. 40")); } TEST(LoggingTest, CompareWithReferenceType) { @@ -93,7 +116,134 @@ TEST(LoggingTest, CompareWithReferenceType) { CHECK_BOTH(LT, *&i32, u64); CHECK_BOTH(IMPLIES, *&i32, i64); CHECK_BOTH(IMPLIES, *&i32, u64); + + // Check that the values are output correctly on error. + ASSERT_DEATH_IF_SUPPORTED( + ([&] { CHECK_GT(*&i32, u64); })(), + FailureMessage("Check failed: *&i32 > u64", "10 vs. 40")); +} + +enum TestEnum1 { ONE, TWO }; +enum TestEnum2 : uint16_t { FOO = 14, BAR = 5 }; +enum class TestEnum3 { A, B }; +enum class TestEnum4 : uint8_t { FIRST, SECOND }; + +TEST(LoggingTest, CompareEnumTypes) { + // All these checks should compile (!) and succeed. + CHECK_BOTH(EQ, ONE, ONE); + CHECK_BOTH(LT, ONE, TWO); + CHECK_BOTH(EQ, BAR, 5); + CHECK_BOTH(LT, BAR, FOO); + CHECK_BOTH(EQ, TestEnum3::A, TestEnum3::A); + CHECK_BOTH(LT, TestEnum3::A, TestEnum3::B); + CHECK_BOTH(EQ, TestEnum4::FIRST, TestEnum4::FIRST); + CHECK_BOTH(LT, TestEnum4::FIRST, TestEnum4::SECOND); +} + +class TestClass1 { + public: + bool operator==(const TestClass1&) const { return true; } + bool operator!=(const TestClass1&) const { return false; } +}; +class TestClass2 { + public: + explicit TestClass2(int val) : val_(val) {} + bool operator<(const TestClass2& other) const { return val_ < other.val_; } + int val() const { return val_; } + + private: + int val_; +}; +std::ostream& operator<<(std::ostream& str, const TestClass2& val) { + return str << "TestClass2(" << val.val() << ")"; +} + +TEST(LoggingTest, CompareClassTypes) { + // All these checks should compile (!) and succeed. + CHECK_BOTH(EQ, TestClass1{}, TestClass1{}); + CHECK_BOTH(LT, TestClass2{2}, TestClass2{7}); + + // Check that the values are output correctly on error. + ASSERT_DEATH_IF_SUPPORTED( + ([&] { CHECK_NE(TestClass1{}, TestClass1{}); })(), + FailureMessage("Check failed: TestClass1{} != TestClass1{}", + "<unprintable> vs. <unprintable>")); + ASSERT_DEATH_IF_SUPPORTED( + ([&] { CHECK_LT(TestClass2{4}, TestClass2{3}); })(), + FailureMessage("Check failed: TestClass2{4} < TestClass2{3}", + "TestClass2(4) vs. TestClass2(3)")); +} + +TEST(LoggingDeathTest, OutputEnumValues) { + ASSERT_DEATH_IF_SUPPORTED( + ([&] { CHECK_EQ(ONE, TWO); })(), + FailureMessage("Check failed: ONE == TWO", "0 vs. 1")); + ASSERT_DEATH_IF_SUPPORTED( + ([&] { CHECK_NE(BAR, 2 + 3); })(), + FailureMessage("Check failed: BAR != 2 + 3", "5 vs. 5")); + ASSERT_DEATH_IF_SUPPORTED( + ([&] { CHECK_EQ(TestEnum3::A, TestEnum3::B); })(), + FailureMessage("Check failed: TestEnum3::A == TestEnum3::B", "0 vs. 1")); + ASSERT_DEATH_IF_SUPPORTED( + ([&] { CHECK_GE(TestEnum4::FIRST, TestEnum4::SECOND); })(), + FailureMessage("Check failed: TestEnum4::FIRST >= TestEnum4::SECOND", + "0 vs. 1")); +} + +enum TestEnum5 { TEST_A, TEST_B }; +enum class TestEnum6 { TEST_C, TEST_D }; +std::ostream& operator<<(std::ostream& str, TestEnum5 val) { + return str << (val == TEST_A ? "A" : "B"); +} +void operator<<(std::ostream& str, TestEnum6 val) { + str << (val == TestEnum6::TEST_C ? "C" : "D"); +} + +TEST(LoggingDeathTest, OutputEnumWithOutputOperator) { + ASSERT_DEATH_IF_SUPPORTED( + ([&] { CHECK_EQ(TEST_A, TEST_B); })(), + FailureMessage("Check failed: TEST_A == TEST_B", "A vs. B")); + ASSERT_DEATH_IF_SUPPORTED( + ([&] { CHECK_GE(TestEnum6::TEST_C, TestEnum6::TEST_D); })(), + FailureMessage("Check failed: TestEnum6::TEST_C >= TestEnum6::TEST_D", + "C vs. D")); +} + +TEST(LoggingDeathTest, FatalKills) { + ASSERT_DEATH_IF_SUPPORTED(FATAL("Dread pirate"), "Dread pirate"); +} + +TEST(LoggingDeathTest, DcheckIsOnlyFatalInDebug) { +#ifdef DEBUG + ASSERT_DEATH_IF_SUPPORTED(DCHECK(false && "Dread pirate"), "Dread pirate"); +#else + // DCHECK should be non-fatal if DEBUG is undefined. + DCHECK(false && "I'm a benign teapot"); +#endif +} + +namespace { +void DcheckOverrideFunction(const char*, int, const char*) {} +} // namespace + +TEST(LoggingDeathTest, V8_DcheckCanBeOverridden) { + // Default DCHECK state should be fatal. + ASSERT_DEATH_IF_SUPPORTED(V8_Dcheck(__FILE__, __LINE__, "Dread pirate"), + "Dread pirate"); + + ASSERT_DEATH_IF_SUPPORTED( + { + v8::base::SetDcheckFunction(&DcheckOverrideFunction); + // This should be non-fatal. + V8_Dcheck(__FILE__, __LINE__, "I'm a benign teapot."); + + // Restore default behavior, and assert on lethality. + v8::base::SetDcheckFunction(nullptr); + V8_Dcheck(__FILE__, __LINE__, "Dread pirate"); + }, + "Dread pirate"); } +} // namespace logging_unittest } // namespace base } // namespace v8 diff --git a/deps/v8/test/unittests/base/template-utils-unittest.cc b/deps/v8/test/unittests/base/template-utils-unittest.cc index 1f434faee8..ea8796a123 100644 --- a/deps/v8/test/unittests/base/template-utils-unittest.cc +++ b/deps/v8/test/unittests/base/template-utils-unittest.cc @@ -8,6 +8,7 @@ namespace v8 { namespace base { +namespace template_utils_unittest { //////////////////////////// // Test make_array. @@ -80,5 +81,26 @@ TEST_PASS_VALUE_OR_REF0(false, const std::string&, const std::string&); TEST_PASS_VALUE_OR_REF0(false, int, const int); TEST_PASS_VALUE_OR_REF0(false, int, const int&); +////////////////////////////// +// Test has_output_operator. +////////////////////////////// + +// Intrinsic types: +static_assert(has_output_operator<int>::value, "int can be output"); +static_assert(has_output_operator<void*>::value, "void* can be output"); +static_assert(has_output_operator<uint64_t>::value, "int can be output"); + +// Classes: +class TestClass1 {}; +class TestClass2 {}; +extern std::ostream& operator<<(std::ostream& str, TestClass2&); +static_assert(!has_output_operator<TestClass1>::value, + "TestClass1 can not be output"); +static_assert(has_output_operator<TestClass2>::value, + "non-const TestClass2 can be output"); +static_assert(!has_output_operator<const TestClass2>::value, + "const TestClass2 can not be output"); + +} // namespace template_utils_unittest } // namespace base } // namespace v8 diff --git a/deps/v8/test/unittests/code-stub-assembler-unittest.cc b/deps/v8/test/unittests/code-stub-assembler-unittest.cc new file mode 100644 index 0000000000..0ef06c71ff --- /dev/null +++ b/deps/v8/test/unittests/code-stub-assembler-unittest.cc @@ -0,0 +1,72 @@ +// Copyright 2017 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 "test/unittests/code-stub-assembler-unittest.h" + +#include "src/code-factory.h" +#include "src/compiler/node.h" +#include "src/interface-descriptors.h" +#include "src/isolate.h" +#include "src/objects-inl.h" +#include "test/unittests/compiler/compiler-test-utils.h" +#include "test/unittests/compiler/node-test-utils.h" + +using ::testing::_; +using v8::internal::compiler::Node; + +namespace c = v8::internal::compiler; + +namespace v8 { +namespace internal { + +#ifdef ENABLE_VERIFY_CSA +#define IS_BITCAST_WORD_TO_TAGGED_SIGNED(x) IsBitcastWordToTaggedSigned(x) +#define IS_BITCAST_TAGGED_TO_WORD(x) IsBitcastTaggedToWord(x) +#else +#define IS_BITCAST_WORD_TO_TAGGED_SIGNED(x) (x) +#define IS_BITCAST_TAGGED_TO_WORD(x) (x) +#endif + +CodeStubAssemblerTestState::CodeStubAssemblerTestState( + CodeStubAssemblerTest* test) + : compiler::CodeAssemblerState(test->isolate(), test->zone(), + VoidDescriptor(test->isolate()), Code::STUB, + "test") {} + +TARGET_TEST_F(CodeStubAssemblerTest, SmiTag) { + CodeStubAssemblerTestState state(this); + CodeStubAssemblerForTest m(&state); + Node* value = m.Int32Constant(44); + EXPECT_THAT(m.SmiTag(value), + IS_BITCAST_WORD_TO_TAGGED_SIGNED(c::IsIntPtrConstant( + static_cast<intptr_t>(44) << (kSmiShiftSize + kSmiTagSize)))); + EXPECT_THAT(m.SmiUntag(value), + c::IsIntPtrConstant(static_cast<intptr_t>(44) >> + (kSmiShiftSize + kSmiTagSize))); +} + +TARGET_TEST_F(CodeStubAssemblerTest, IntPtrMax) { + CodeStubAssemblerTestState state(this); + CodeStubAssemblerForTest m(&state); + { + Node* a = m.IntPtrConstant(100); + Node* b = m.IntPtrConstant(1); + Node* z = m.IntPtrMax(a, b); + EXPECT_THAT(z, c::IsIntPtrConstant(100)); + } +} + +TARGET_TEST_F(CodeStubAssemblerTest, IntPtrMin) { + CodeStubAssemblerTestState state(this); + CodeStubAssemblerForTest m(&state); + { + Node* a = m.IntPtrConstant(100); + Node* b = m.IntPtrConstant(1); + Node* z = m.IntPtrMin(a, b); + EXPECT_THAT(z, c::IsIntPtrConstant(1)); + } +} + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/unittests/code-stub-assembler-unittest.h b/deps/v8/test/unittests/code-stub-assembler-unittest.h new file mode 100644 index 0000000000..2c32e0f9b7 --- /dev/null +++ b/deps/v8/test/unittests/code-stub-assembler-unittest.h @@ -0,0 +1,35 @@ +// Copyright 2017 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. + +#ifndef V8_UNITTESTS_CODE_STUB_ASSEMBLER_UNITTEST_H_ +#define V8_UNITTESTS_CODE_STUB_ASSEMBLER_UNITTEST_H_ + +#include "src/code-stub-assembler.h" +#include "test/unittests/test-utils.h" +#include "testing/gmock-support.h" + +namespace v8 { +namespace internal { + +class CodeStubAssemblerTest : public TestWithIsolateAndZone { + public: + CodeStubAssemblerTest() {} + ~CodeStubAssemblerTest() override {} +}; + +class CodeStubAssemblerTestState : public compiler::CodeAssemblerState { + public: + explicit CodeStubAssemblerTestState(CodeStubAssemblerTest* test); +}; + +class CodeStubAssemblerForTest : public CodeStubAssembler { + public: + explicit CodeStubAssemblerForTest(CodeStubAssemblerTestState* state) + : CodeStubAssembler(state) {} +}; + +} // namespace internal +} // namespace v8 + +#endif // V8_UNITTESTS_CODE_STUB_ASSEMBLER_UNITTEST_H_ diff --git a/deps/v8/test/unittests/compiler-dispatcher/compiler-dispatcher-unittest.cc b/deps/v8/test/unittests/compiler-dispatcher/compiler-dispatcher-unittest.cc index 317feaab1c..5d776d318b 100644 --- a/deps/v8/test/unittests/compiler-dispatcher/compiler-dispatcher-unittest.cc +++ b/deps/v8/test/unittests/compiler-dispatcher/compiler-dispatcher-unittest.cc @@ -160,6 +160,10 @@ class MockPlatform : public v8::Platform { return time_; } + double CurrentClockTimeMillis() override { + return time_ * base::Time::kMillisecondsPerSecond; + } + v8::TracingController* GetTracingController() override { return tracing_controller_; } diff --git a/deps/v8/test/unittests/compiler-dispatcher/optimizing-compile-dispatcher-unittest.cc b/deps/v8/test/unittests/compiler-dispatcher/optimizing-compile-dispatcher-unittest.cc index c78b817c69..8280810293 100644 --- a/deps/v8/test/unittests/compiler-dispatcher/optimizing-compile-dispatcher-unittest.cc +++ b/deps/v8/test/unittests/compiler-dispatcher/optimizing-compile-dispatcher-unittest.cc @@ -30,8 +30,7 @@ class BlockingCompilationJob : public CompilationJob { State::kReadyToExecute), shared_(function->shared()), parse_info_(shared_), - info_(parse_info_.zone(), function->GetIsolate(), parse_info_.script(), - shared_, function), + info_(parse_info_.zone(), function->GetIsolate(), shared_, function), blocking_(false), semaphore_(0) {} ~BlockingCompilationJob() override = default; diff --git a/deps/v8/test/unittests/compiler-dispatcher/unoptimized-compile-job-unittest.cc b/deps/v8/test/unittests/compiler-dispatcher/unoptimized-compile-job-unittest.cc index d852a19026..36bafcf006 100644 --- a/deps/v8/test/unittests/compiler-dispatcher/unoptimized-compile-job-unittest.cc +++ b/deps/v8/test/unittests/compiler-dispatcher/unoptimized-compile-job-unittest.cc @@ -351,7 +351,7 @@ TEST_F(UnoptimizedCompileJobTest, LazyInnerFunctions) { Handle<JSFunction> e = Handle<JSFunction>::cast(test::RunJS(isolate(), "f();")); - ASSERT_FALSE(e->shared()->HasBaselineCode()); + ASSERT_FALSE(e->shared()->is_compiled()); job->ResetOnMainThread(i_isolate()); ASSERT_JOB_STATUS(UnoptimizedCompileJob::Status::kInitial, job); diff --git a/deps/v8/test/unittests/compiler/code-assembler-unittest.cc b/deps/v8/test/unittests/compiler/code-assembler-unittest.cc new file mode 100644 index 0000000000..604e1baf86 --- /dev/null +++ b/deps/v8/test/unittests/compiler/code-assembler-unittest.cc @@ -0,0 +1,254 @@ +// Copyright 2017 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 "test/unittests/compiler/code-assembler-unittest.h" + +#include "src/code-factory.h" +#include "src/compiler/node.h" +#include "src/interface-descriptors.h" +#include "src/isolate.h" +#include "src/objects-inl.h" +#include "test/unittests/compiler/compiler-test-utils.h" +#include "test/unittests/compiler/node-test-utils.h" + +using ::testing::_; + +namespace v8 { +namespace internal { +namespace compiler { + +CodeAssemblerTestState::CodeAssemblerTestState(CodeAssemblerTest* test) + : CodeAssemblerState(test->isolate(), test->zone(), + VoidDescriptor(test->isolate()), Code::STUB, "test") {} + +TARGET_TEST_F(CodeAssemblerTest, IntPtrAdd) { + CodeAssemblerTestState state(this); + CodeAssemblerForTest m(&state); + { + Node* a = m.Parameter(0); + Node* b = m.Int32Constant(1); + Node* add = m.IntPtrAdd(a, b); + EXPECT_THAT(add, IsIntPtrAdd(a, b)); + } + // x + 0 => x + { + Node* a = m.Parameter(0); + Node* b = m.Int32Constant(0); + Node* add = m.IntPtrAdd(a, b); + EXPECT_THAT(add, a); + } + // 0 + x => x + { + Node* a = m.Parameter(0); + Node* b = m.Int32Constant(0); + Node* add = m.IntPtrAdd(b, a); + EXPECT_THAT(add, a); + } + // CONST_a + CONST_b => CONST_c + { + Node* a = m.IntPtrConstant(22); + Node* b = m.IntPtrConstant(33); + Node* c = m.IntPtrAdd(a, b); + EXPECT_THAT(c, IsIntPtrConstant(55)); + } +} + +TARGET_TEST_F(CodeAssemblerTest, IntPtrSub) { + CodeAssemblerTestState state(this); + CodeAssemblerForTest m(&state); + { + Node* a = m.Parameter(0); + Node* b = m.Int32Constant(1); + Node* sub = m.IntPtrSub(a, b); + EXPECT_THAT(sub, IsIntPtrSub(a, b)); + } + // x - 0 => x + { + Node* a = m.Parameter(0); + Node* b = m.Int32Constant(0); + Node* c = m.IntPtrSub(a, b); + EXPECT_THAT(c, a); + } + // CONST_a - CONST_b => CONST_c + { + Node* a = m.IntPtrConstant(100); + Node* b = m.IntPtrConstant(1); + Node* c = m.IntPtrSub(a, b); + EXPECT_THAT(c, IsIntPtrConstant(99)); + } +} + +TARGET_TEST_F(CodeAssemblerTest, IntPtrMul) { + CodeAssemblerTestState state(this); + CodeAssemblerForTest m(&state); + { + Node* a = m.Parameter(0); + Node* b = m.Int32Constant(100); + Node* mul = m.IntPtrMul(a, b); + EXPECT_THAT(mul, IsIntPtrMul(a, b)); + } + // x * 1 => x + { + Node* a = m.Parameter(0); + Node* b = m.Int32Constant(1); + Node* mul = m.IntPtrMul(a, b); + EXPECT_THAT(mul, a); + } + // 1 * x => x + { + Node* a = m.Parameter(0); + Node* b = m.Int32Constant(1); + Node* mul = m.IntPtrMul(b, a); + EXPECT_THAT(mul, a); + } + // CONST_a * CONST_b => CONST_c + { + Node* a = m.IntPtrConstant(100); + Node* b = m.IntPtrConstant(5); + Node* c = m.IntPtrMul(a, b); + EXPECT_THAT(c, IsIntPtrConstant(500)); + } +} + +TARGET_TEST_F(CodeAssemblerTest, WordShl) { + CodeAssemblerTestState state(this); + CodeAssemblerForTest m(&state); + { + Node* a = m.Parameter(0); + Node* add = m.WordShl(a, 10); + EXPECT_THAT(add, IsWordShl(a, IsIntPtrConstant(10))); + } + // x << 0 => x + { + Node* a = m.Parameter(0); + Node* add = m.WordShl(a, 0); + EXPECT_THAT(add, a); + } + // CONST_a << CONST_b => CONST_c + { + Node* a = m.IntPtrConstant(1024); + Node* shl = m.WordShl(a, 2); + EXPECT_THAT(shl, IsIntPtrConstant(4096)); + } +} + +TARGET_TEST_F(CodeAssemblerTest, WordShr) { + CodeAssemblerTestState state(this); + CodeAssemblerForTest m(&state); + { + Node* a = m.Parameter(0); + Node* shr = m.WordShr(a, 10); + EXPECT_THAT(shr, IsWordShr(a, IsIntPtrConstant(10))); + } + // x >> 0 => x + { + Node* a = m.Parameter(0); + Node* shr = m.WordShr(a, 0); + EXPECT_THAT(shr, a); + } + // +CONST_a >> CONST_b => CONST_c + { + Node* a = m.IntPtrConstant(4096); + Node* shr = m.WordShr(a, 2); + EXPECT_THAT(shr, IsIntPtrConstant(1024)); + } + // -CONST_a >> CONST_b => CONST_c + { + Node* a = m.IntPtrConstant(-1234); + Node* shr = m.WordShr(a, 2); + EXPECT_THAT(shr, IsIntPtrConstant(static_cast<uintptr_t>(-1234) >> 2)); + } +} + +TARGET_TEST_F(CodeAssemblerTest, WordSar) { + CodeAssemblerTestState state(this); + CodeAssemblerForTest m(&state); + { + Node* a = m.Parameter(0); + Node* sar = m.WordSar(a, m.IntPtrConstant(10)); + EXPECT_THAT(sar, IsWordSar(a, IsIntPtrConstant(10))); + } + // x >>> 0 => x + { + Node* a = m.Parameter(0); + Node* sar = m.WordSar(a, m.IntPtrConstant(0)); + EXPECT_THAT(sar, a); + } + // +CONST_a >>> CONST_b => CONST_c + { + Node* a = m.IntPtrConstant(4096); + Node* sar = m.WordSar(a, m.IntPtrConstant(2)); + EXPECT_THAT(sar, IsIntPtrConstant(1024)); + } + // -CONST_a >>> CONST_b => CONST_c + { + Node* a = m.IntPtrConstant(-1234); + Node* sar = m.WordSar(a, m.IntPtrConstant(2)); + EXPECT_THAT(sar, IsIntPtrConstant(static_cast<intptr_t>(-1234) >> 2)); + } +} + +TARGET_TEST_F(CodeAssemblerTest, WordOr) { + CodeAssemblerTestState state(this); + CodeAssemblerForTest m(&state); + { + Node* a = m.Parameter(0); + Node* z = m.WordOr(a, m.IntPtrConstant(8)); + EXPECT_THAT(z, IsWordOr(a, IsIntPtrConstant(8))); + } + // x | 0 => x + { + Node* a = m.Parameter(0); + Node* z = m.WordOr(a, m.IntPtrConstant(0)); + EXPECT_THAT(z, a); + } + // 0 | x => x + { + Node* a = m.Parameter(0); + Node* z = m.WordOr(m.IntPtrConstant(0), a); + EXPECT_THAT(z, a); + } + // CONST_a | CONST_b => CONST_c + { + Node* a = m.IntPtrConstant(3); + Node* b = m.WordOr(a, m.IntPtrConstant(7)); + EXPECT_THAT(b, IsIntPtrConstant(7)); + } +} + +TARGET_TEST_F(CodeAssemblerTest, WordAnd) { + CodeAssemblerTestState state(this); + CodeAssemblerForTest m(&state); + { + Node* a = m.Parameter(0); + Node* z = m.WordAnd(a, m.IntPtrConstant(8)); + EXPECT_THAT(z, IsWordAnd(a, IsIntPtrConstant(8))); + } + // CONST_a & CONST_b => CONST_c + { + Node* a = m.IntPtrConstant(3); + Node* b = m.WordAnd(a, m.IntPtrConstant(7)); + EXPECT_THAT(b, IsIntPtrConstant(3)); + } +} + +TARGET_TEST_F(CodeAssemblerTest, WordXor) { + CodeAssemblerTestState state(this); + CodeAssemblerForTest m(&state); + { + Node* a = m.Parameter(0); + Node* z = m.WordXor(a, m.IntPtrConstant(8)); + EXPECT_THAT(z, IsWordXor(a, IsIntPtrConstant(8))); + } + // CONST_a ^ CONST_b => CONST_c + { + Node* a = m.IntPtrConstant(3); + Node* b = m.WordXor(a, m.IntPtrConstant(7)); + EXPECT_THAT(b, IsIntPtrConstant(4)); + } +} + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/unittests/compiler/code-assembler-unittest.h b/deps/v8/test/unittests/compiler/code-assembler-unittest.h new file mode 100644 index 0000000000..21f3df5f4b --- /dev/null +++ b/deps/v8/test/unittests/compiler/code-assembler-unittest.h @@ -0,0 +1,37 @@ +// Copyright 2017 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. + +#ifndef V8_UNITTESTS_COMPILER_CODE_ASSEMBLER_UNITTEST_H_ +#define V8_UNITTESTS_COMPILER_CODE_ASSEMBLER_UNITTEST_H_ + +#include "src/compiler/code-assembler.h" +#include "test/unittests/test-utils.h" +#include "testing/gmock-support.h" + +namespace v8 { +namespace internal { +namespace compiler { + +class CodeAssemblerTest : public TestWithIsolateAndZone { + public: + CodeAssemblerTest() {} + ~CodeAssemblerTest() override {} +}; + +class CodeAssemblerTestState : public CodeAssemblerState { + public: + explicit CodeAssemblerTestState(CodeAssemblerTest* test); +}; + +class CodeAssemblerForTest : public CodeAssembler { + public: + explicit CodeAssemblerForTest(CodeAssemblerTestState* state) + : CodeAssembler(state) {} +}; + +} // namespace compiler +} // namespace internal +} // namespace v8 + +#endif // V8_UNITTESTS_COMPILER_CODE_ASSEMBLER_UNITTEST_H_ diff --git a/deps/v8/test/unittests/compiler/common-operator-reducer-unittest.cc b/deps/v8/test/unittests/compiler/common-operator-reducer-unittest.cc index ecc3070785..6618dfb452 100644 --- a/deps/v8/test/unittests/compiler/common-operator-reducer-unittest.cc +++ b/deps/v8/test/unittests/compiler/common-operator-reducer-unittest.cc @@ -17,6 +17,7 @@ using testing::StrictMock; namespace v8 { namespace internal { namespace compiler { +namespace common_operator_reducer_unittest { class CommonOperatorReducerTest : public GraphTest { public: @@ -491,6 +492,7 @@ TEST_F(CommonOperatorReducerTest, SelectToFloat64Abs) { EXPECT_THAT(r.replacement(), IsFloat64Abs(p0)); } +} // namespace common_operator_reducer_unittest } // namespace compiler } // namespace internal } // namespace v8 diff --git a/deps/v8/test/unittests/compiler/common-operator-unittest.cc b/deps/v8/test/unittests/compiler/common-operator-unittest.cc index 761ce70a01..b51d5f3cf6 100644 --- a/deps/v8/test/unittests/compiler/common-operator-unittest.cc +++ b/deps/v8/test/unittests/compiler/common-operator-unittest.cc @@ -13,7 +13,7 @@ namespace v8 { namespace internal { namespace compiler { - +namespace common_operator_unittest { // ----------------------------------------------------------------------------- // Shared operators. @@ -387,6 +387,7 @@ TEST_F(CommonOperatorTest, Projection) { } } +} // namespace common_operator_unittest } // namespace compiler } // namespace internal } // namespace v8 diff --git a/deps/v8/test/unittests/compiler/dead-code-elimination-unittest.cc b/deps/v8/test/unittests/compiler/dead-code-elimination-unittest.cc index d0351bf5f5..d1f914c68e 100644 --- a/deps/v8/test/unittests/compiler/dead-code-elimination-unittest.cc +++ b/deps/v8/test/unittests/compiler/dead-code-elimination-unittest.cc @@ -14,6 +14,7 @@ using testing::StrictMock; namespace v8 { namespace internal { namespace compiler { +namespace dead_code_elimination_unittest { class DeadCodeEliminationTest : public GraphTest { public: @@ -368,6 +369,7 @@ TEST_F(DeadCodeEliminationTest, TerminateWithDeadControlInput) { EXPECT_THAT(r.replacement(), IsDead()); } +} // namespace dead_code_elimination_unittest } // namespace compiler } // namespace internal } // namespace v8 diff --git a/deps/v8/test/unittests/compiler/diamond-unittest.cc b/deps/v8/test/unittests/compiler/diamond-unittest.cc index 5b28a001ef..17a45a5894 100644 --- a/deps/v8/test/unittests/compiler/diamond-unittest.cc +++ b/deps/v8/test/unittests/compiler/diamond-unittest.cc @@ -131,13 +131,13 @@ TEST_F(DiamondTest, DiamondPhis) { TEST_F(DiamondTest, BranchHint) { Diamond dn(graph(), common(), Parameter(0)); - CHECK(BranchHint::kNone == BranchHintOf(dn.branch->op())); + CHECK_EQ(BranchHint::kNone, BranchHintOf(dn.branch->op())); Diamond dt(graph(), common(), Parameter(0), BranchHint::kTrue); - CHECK(BranchHint::kTrue == BranchHintOf(dt.branch->op())); + CHECK_EQ(BranchHint::kTrue, BranchHintOf(dt.branch->op())); Diamond df(graph(), common(), Parameter(0), BranchHint::kFalse); - CHECK(BranchHint::kFalse == BranchHintOf(df.branch->op())); + CHECK_EQ(BranchHint::kFalse, BranchHintOf(df.branch->op())); } diff --git a/deps/v8/test/unittests/compiler/escape-analysis-unittest.cc b/deps/v8/test/unittests/compiler/escape-analysis-unittest.cc deleted file mode 100644 index 55c0f42fe1..0000000000 --- a/deps/v8/test/unittests/compiler/escape-analysis-unittest.cc +++ /dev/null @@ -1,523 +0,0 @@ -// Copyright 2015 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/compiler/escape-analysis.h" -#include "src/bit-vector.h" -#include "src/compiler/escape-analysis-reducer.h" -#include "src/compiler/graph-visualizer.h" -#include "src/compiler/js-graph.h" -#include "src/compiler/node-properties.h" -#include "src/compiler/simplified-operator.h" -#include "src/compiler/types.h" -#include "src/zone/zone-containers.h" -#include "test/unittests/compiler/graph-unittest.h" - -namespace v8 { -namespace internal { -namespace compiler { - -class EscapeAnalysisTest : public TypedGraphTest { - public: - EscapeAnalysisTest() - : simplified_(zone()), - jsgraph_(isolate(), graph(), common(), nullptr, nullptr, nullptr), - escape_analysis_(graph(), common(), zone()), - effect_(graph()->start()), - control_(graph()->start()) {} - - ~EscapeAnalysisTest() {} - - EscapeAnalysis* escape_analysis() { return &escape_analysis_; } - - protected: - void Analysis() { escape_analysis_.Run(); } - - void Transformation() { - GraphReducer graph_reducer(zone(), graph()); - EscapeAnalysisReducer escape_reducer(&graph_reducer, &jsgraph_, - &escape_analysis_, zone()); - graph_reducer.AddReducer(&escape_reducer); - graph_reducer.ReduceGraph(); - } - - // ---------------------------------Node Creation Helper---------------------- - - Node* BeginRegion(Node* effect = nullptr) { - if (!effect) { - effect = effect_; - } - - return effect_ = graph()->NewNode( - common()->BeginRegion(RegionObservability::kObservable), effect); - } - - Node* FinishRegion(Node* value, Node* effect = nullptr) { - if (!effect) { - effect = effect_; - } - return effect_ = graph()->NewNode(common()->FinishRegion(), value, effect); - } - - Node* Allocate(Node* size, Node* effect = nullptr, Node* control = nullptr) { - if (!effect) { - effect = effect_; - } - if (!control) { - control = control_; - } - return effect_ = graph()->NewNode(simplified()->Allocate(Type::Any()), size, - effect, control); - } - - Node* Constant(int num) { - return graph()->NewNode(common()->NumberConstant(num)); - } - - Node* Store(const FieldAccess& access, Node* allocation, Node* value, - Node* effect = nullptr, Node* control = nullptr) { - if (!effect) { - effect = effect_; - } - if (!control) { - control = control_; - } - return effect_ = graph()->NewNode(simplified()->StoreField(access), - allocation, value, effect, control); - } - - Node* StoreElement(const ElementAccess& access, Node* allocation, Node* index, - Node* value, Node* effect = nullptr, - Node* control = nullptr) { - if (!effect) { - effect = effect_; - } - if (!control) { - control = control_; - } - return effect_ = - graph()->NewNode(simplified()->StoreElement(access), allocation, - index, value, effect, control); - } - - Node* Load(const FieldAccess& access, Node* from, Node* effect = nullptr, - Node* control = nullptr) { - if (!effect) { - effect = effect_; - } - if (!control) { - control = control_; - } - return graph()->NewNode(simplified()->LoadField(access), from, effect, - control); - } - - Node* Return(Node* value, Node* effect = nullptr, Node* control = nullptr) { - if (!effect) { - effect = effect_; - } - if (!control) { - control = control_; - } - Node* zero = graph()->NewNode(common()->NumberConstant(0)); - return control_ = graph()->NewNode(common()->Return(), zero, value, effect, - control); - } - - void EndGraph() { - for (Edge edge : graph()->end()->input_edges()) { - if (NodeProperties::IsControlEdge(edge)) { - edge.UpdateTo(control_); - } - } - } - - Node* Branch() { - return control_ = - graph()->NewNode(common()->Branch(), Constant(0), control_); - } - - Node* IfTrue() { - return control_ = graph()->NewNode(common()->IfTrue(), control_); - } - - Node* IfFalse() { return graph()->NewNode(common()->IfFalse(), control_); } - - Node* Merge2(Node* control1, Node* control2) { - return control_ = graph()->NewNode(common()->Merge(2), control1, control2); - } - - FieldAccess FieldAccessAtIndex(int offset) { - FieldAccess access = {kTaggedBase, offset, - MaybeHandle<Name>(), MaybeHandle<Map>(), - Type::Any(), MachineType::AnyTagged(), - kFullWriteBarrier}; - return access; - } - - ElementAccess MakeElementAccess(int header_size) { - ElementAccess access = {kTaggedBase, header_size, Type::Any(), - MachineType::AnyTagged(), kFullWriteBarrier}; - return access; - } - - // ---------------------------------Assertion Helper-------------------------- - - void ExpectReplacement(Node* node, Node* rep) { - EXPECT_EQ(rep, escape_analysis()->GetReplacement(node)); - } - - void ExpectReplacementPhi(Node* node, Node* left, Node* right) { - Node* rep = escape_analysis()->GetReplacement(node); - ASSERT_NE(nullptr, rep); - ASSERT_EQ(IrOpcode::kPhi, rep->opcode()); - EXPECT_EQ(left, NodeProperties::GetValueInput(rep, 0)); - EXPECT_EQ(right, NodeProperties::GetValueInput(rep, 1)); - } - - void ExpectVirtual(Node* node) { - EXPECT_TRUE(node->opcode() == IrOpcode::kAllocate || - node->opcode() == IrOpcode::kFinishRegion); - EXPECT_TRUE(escape_analysis()->IsVirtual(node)); - } - - void ExpectEscaped(Node* node) { - EXPECT_TRUE(node->opcode() == IrOpcode::kAllocate || - node->opcode() == IrOpcode::kFinishRegion); - EXPECT_TRUE(escape_analysis()->IsEscaped(node)); - } - - SimplifiedOperatorBuilder* simplified() { return &simplified_; } - - Node* effect() { return effect_; } - Node* control() { return control_; } - - private: - SimplifiedOperatorBuilder simplified_; - JSGraph jsgraph_; - EscapeAnalysis escape_analysis_; - - Node* effect_; - Node* control_; -}; - - -// ----------------------------------------------------------------------------- -// Test cases. - - -TEST_F(EscapeAnalysisTest, StraightNonEscape) { - Node* object1 = Constant(1); - BeginRegion(); - Node* allocation = Allocate(Constant(kPointerSize)); - Store(FieldAccessAtIndex(0), allocation, object1); - Node* finish = FinishRegion(allocation); - Node* load = Load(FieldAccessAtIndex(0), finish); - Node* result = Return(load); - EndGraph(); - - Analysis(); - - ExpectVirtual(allocation); - ExpectReplacement(load, object1); - - Transformation(); - - ASSERT_EQ(object1, NodeProperties::GetValueInput(result, 1)); -} - - -TEST_F(EscapeAnalysisTest, StraightNonEscapeNonConstStore) { - Node* object1 = Constant(1); - Node* object2 = Constant(2); - BeginRegion(); - Node* allocation = Allocate(Constant(kPointerSize)); - Store(FieldAccessAtIndex(0), allocation, object1); - Node* index = - graph()->NewNode(common()->Select(MachineRepresentation::kTagged), - object1, object2, control()); - StoreElement(MakeElementAccess(0), allocation, index, object1); - Node* finish = FinishRegion(allocation); - Node* load = Load(FieldAccessAtIndex(0), finish); - Node* result = Return(load); - EndGraph(); - - Analysis(); - - ExpectEscaped(allocation); - ExpectReplacement(load, nullptr); - - Transformation(); - - ASSERT_EQ(load, NodeProperties::GetValueInput(result, 1)); -} - - -TEST_F(EscapeAnalysisTest, StraightEscape) { - Node* object1 = Constant(1); - BeginRegion(); - Node* allocation = Allocate(Constant(kPointerSize)); - Store(FieldAccessAtIndex(0), allocation, object1); - Node* finish = FinishRegion(allocation); - Node* load = Load(FieldAccessAtIndex(0), finish); - Node* result = Return(allocation); - EndGraph(); - graph()->end()->AppendInput(zone(), load); - - Analysis(); - - ExpectEscaped(allocation); - ExpectReplacement(load, object1); - - Transformation(); - - ASSERT_EQ(allocation, NodeProperties::GetValueInput(result, 1)); -} - - -TEST_F(EscapeAnalysisTest, StoreLoadEscape) { - Node* object1 = Constant(1); - - BeginRegion(); - Node* allocation1 = Allocate(Constant(kPointerSize)); - Store(FieldAccessAtIndex(0), allocation1, object1); - Node* finish1 = FinishRegion(allocation1); - - BeginRegion(); - Node* allocation2 = Allocate(Constant(kPointerSize)); - Store(FieldAccessAtIndex(0), allocation2, finish1); - Node* finish2 = FinishRegion(allocation2); - - Node* load = Load(FieldAccessAtIndex(0), finish2); - Node* result = Return(load); - EndGraph(); - Analysis(); - - ExpectEscaped(allocation1); - ExpectVirtual(allocation2); - ExpectReplacement(load, finish1); - - Transformation(); - - ASSERT_EQ(finish1, NodeProperties::GetValueInput(result, 1)); -} - - -TEST_F(EscapeAnalysisTest, BranchNonEscape) { - Node* object1 = Constant(1); - Node* object2 = Constant(2); - BeginRegion(); - Node* allocation = Allocate(Constant(kPointerSize)); - Store(FieldAccessAtIndex(0), allocation, object1); - Node* finish = FinishRegion(allocation); - Branch(); - Node* ifFalse = IfFalse(); - Node* ifTrue = IfTrue(); - Node* effect1 = - Store(FieldAccessAtIndex(0), allocation, object1, finish, ifFalse); - Node* effect2 = - Store(FieldAccessAtIndex(0), allocation, object2, finish, ifTrue); - Node* merge = Merge2(ifFalse, ifTrue); - Node* phi = graph()->NewNode(common()->EffectPhi(2), effect1, effect2, merge); - Node* load = Load(FieldAccessAtIndex(0), finish, phi, merge); - Node* result = Return(load, phi); - EndGraph(); - graph()->end()->AppendInput(zone(), result); - - Analysis(); - - ExpectVirtual(allocation); - ExpectReplacementPhi(load, object1, object2); - Node* replacement_phi = escape_analysis()->GetReplacement(load); - - Transformation(); - - ASSERT_EQ(replacement_phi, NodeProperties::GetValueInput(result, 1)); -} - - -TEST_F(EscapeAnalysisTest, BranchEscapeOne) { - Node* object1 = Constant(1); - Node* object2 = Constant(2); - Node* index = graph()->NewNode(common()->Parameter(0), start()); - BeginRegion(); - Node* allocation = Allocate(Constant(kPointerSize)); - Store(FieldAccessAtIndex(0), allocation, object1); - Node* finish = FinishRegion(allocation); - Branch(); - Node* ifFalse = IfFalse(); - Node* ifTrue = IfTrue(); - Node* effect1 = - Store(FieldAccessAtIndex(0), allocation, object1, finish, ifFalse); - Node* effect2 = StoreElement(MakeElementAccess(0), allocation, index, object2, - finish, ifTrue); - Node* merge = Merge2(ifFalse, ifTrue); - Node* phi = graph()->NewNode(common()->EffectPhi(2), effect1, effect2, merge); - Node* load = Load(FieldAccessAtIndex(0), finish, phi, merge); - Node* result = Return(load, phi); - EndGraph(); - - Analysis(); - - ExpectEscaped(allocation); - ExpectReplacement(load, nullptr); - - Transformation(); - - ASSERT_EQ(load, NodeProperties::GetValueInput(result, 1)); -} - - -TEST_F(EscapeAnalysisTest, BranchEscapeThroughStore) { - Node* object1 = Constant(1); - Node* object2 = Constant(2); - BeginRegion(); - Node* allocation = Allocate(Constant(kPointerSize)); - Store(FieldAccessAtIndex(0), allocation, object1); - FinishRegion(allocation); - BeginRegion(); - Node* allocation2 = Allocate(Constant(kPointerSize)); - Store(FieldAccessAtIndex(0), allocation, object2); - Node* finish2 = FinishRegion(allocation2); - Branch(); - Node* ifFalse = IfFalse(); - Node* ifTrue = IfTrue(); - Node* effect1 = - Store(FieldAccessAtIndex(0), allocation, allocation2, finish2, ifFalse); - Node* merge = Merge2(ifFalse, ifTrue); - Node* phi = graph()->NewNode(common()->EffectPhi(2), effect1, finish2, merge); - Node* load = Load(FieldAccessAtIndex(0), finish2, phi, merge); - Node* result = Return(allocation, phi); - EndGraph(); - graph()->end()->AppendInput(zone(), load); - - Analysis(); - - ExpectEscaped(allocation); - ExpectEscaped(allocation2); - ExpectReplacement(load, nullptr); - - Transformation(); - - ASSERT_EQ(allocation, NodeProperties::GetValueInput(result, 1)); -} - - -TEST_F(EscapeAnalysisTest, DanglingLoadOrder) { - Node* object1 = Constant(1); - Node* object2 = Constant(2); - Node* allocation = Allocate(Constant(kPointerSize)); - Node* store1 = Store(FieldAccessAtIndex(0), allocation, object1); - Node* load1 = Load(FieldAccessAtIndex(0), allocation); - Node* store2 = Store(FieldAccessAtIndex(0), allocation, object2); - Node* load2 = Load(FieldAccessAtIndex(0), allocation, store1); - Node* result = Return(load2); - EndGraph(); - graph()->end()->AppendInput(zone(), store2); - graph()->end()->AppendInput(zone(), load1); - - Analysis(); - - ExpectVirtual(allocation); - ExpectReplacement(load1, object1); - ExpectReplacement(load2, object1); - - Transformation(); - - ASSERT_EQ(object1, NodeProperties::GetValueInput(result, 1)); -} - - -TEST_F(EscapeAnalysisTest, DeoptReplacement) { - Node* object1 = Constant(1); - BeginRegion(); - Node* allocation = Allocate(Constant(kPointerSize)); - Store(FieldAccessAtIndex(0), allocation, object1); - Node* finish = FinishRegion(allocation); - Node* effect1 = Store(FieldAccessAtIndex(0), allocation, object1, finish); - Branch(); - Node* ifFalse = IfFalse(); - Node* state_values1 = graph()->NewNode( - common()->StateValues(1, SparseInputMask::Dense()), finish); - Node* state_values2 = - graph()->NewNode(common()->StateValues(0, SparseInputMask::Dense())); - Node* state_values3 = - graph()->NewNode(common()->StateValues(0, SparseInputMask::Dense())); - Node* frame_state = graph()->NewNode( - common()->FrameState(BailoutId::None(), OutputFrameStateCombine::Ignore(), - nullptr), - state_values1, state_values2, state_values3, UndefinedConstant(), - graph()->start(), graph()->start()); - Node* deopt = graph()->NewNode( - common()->Deoptimize(DeoptimizeKind::kEager, DeoptimizeReason::kNoReason), - frame_state, effect1, ifFalse); - Node* ifTrue = IfTrue(); - Node* load = Load(FieldAccessAtIndex(0), finish, effect1, ifTrue); - Node* result = Return(load, effect1, ifTrue); - EndGraph(); - graph()->end()->AppendInput(zone(), deopt); - Analysis(); - - ExpectVirtual(allocation); - ExpectReplacement(load, object1); - - Transformation(); - - ASSERT_EQ(object1, NodeProperties::GetValueInput(result, 1)); - Node* object_state = NodeProperties::GetValueInput(state_values1, 0); - ASSERT_EQ(object_state->opcode(), IrOpcode::kObjectState); - ASSERT_EQ(1, object_state->op()->ValueInputCount()); - ASSERT_EQ(object1, NodeProperties::GetValueInput(object_state, 0)); -} - -TEST_F(EscapeAnalysisTest, DISABLED_DeoptReplacementIdentity) { - Node* object1 = Constant(1); - BeginRegion(); - Node* allocation = Allocate(Constant(kPointerSize * 2)); - Store(FieldAccessAtIndex(0), allocation, object1); - Store(FieldAccessAtIndex(kPointerSize), allocation, allocation); - Node* finish = FinishRegion(allocation); - Node* effect1 = Store(FieldAccessAtIndex(0), allocation, object1, finish); - Branch(); - Node* ifFalse = IfFalse(); - Node* state_values1 = graph()->NewNode( - common()->StateValues(1, SparseInputMask::Dense()), finish); - Node* state_values2 = graph()->NewNode( - common()->StateValues(1, SparseInputMask::Dense()), finish); - Node* state_values3 = - graph()->NewNode(common()->StateValues(0, SparseInputMask::Dense())); - Node* frame_state = graph()->NewNode( - common()->FrameState(BailoutId::None(), OutputFrameStateCombine::Ignore(), - nullptr), - state_values1, state_values2, state_values3, UndefinedConstant(), - graph()->start(), graph()->start()); - Node* deopt = graph()->NewNode( - common()->Deoptimize(DeoptimizeKind::kEager, DeoptimizeReason::kNoReason), - frame_state, effect1, ifFalse); - Node* ifTrue = IfTrue(); - Node* load = Load(FieldAccessAtIndex(0), finish, effect1, ifTrue); - Node* result = Return(load, effect1, ifTrue); - EndGraph(); - graph()->end()->AppendInput(zone(), deopt); - Analysis(); - - ExpectVirtual(allocation); - ExpectReplacement(load, object1); - - Transformation(); - - ASSERT_EQ(object1, NodeProperties::GetValueInput(result, 1)); - - Node* object_state = NodeProperties::GetValueInput(state_values1, 0); - ASSERT_EQ(object_state->opcode(), IrOpcode::kObjectState); - ASSERT_EQ(2, object_state->op()->ValueInputCount()); - ASSERT_EQ(object1, NodeProperties::GetValueInput(object_state, 0)); - ASSERT_EQ(object_state, NodeProperties::GetValueInput(object_state, 1)); - - Node* object_state2 = NodeProperties::GetValueInput(state_values1, 0); - ASSERT_EQ(object_state, object_state2); -} - -} // namespace compiler -} // namespace internal -} // namespace v8 diff --git a/deps/v8/test/unittests/compiler/graph-reducer-unittest.cc b/deps/v8/test/unittests/compiler/graph-reducer-unittest.cc index f6f5994932..dc2f2189d1 100644 --- a/deps/v8/test/unittests/compiler/graph-reducer-unittest.cc +++ b/deps/v8/test/unittests/compiler/graph-reducer-unittest.cc @@ -21,6 +21,7 @@ using testing::UnorderedElementsAre; namespace v8 { namespace internal { namespace compiler { +namespace graph_reducer_unittest { namespace { @@ -872,6 +873,7 @@ TEST_F(GraphReducerTest, Order) { } } +} // namespace graph_reducer_unittest } // namespace compiler } // namespace internal } // namespace v8 diff --git a/deps/v8/test/unittests/compiler/ia32/instruction-selector-ia32-unittest.cc b/deps/v8/test/unittests/compiler/ia32/instruction-selector-ia32-unittest.cc index 8f2161a303..b9f5fc4b9f 100644 --- a/deps/v8/test/unittests/compiler/ia32/instruction-selector-ia32-unittest.cc +++ b/deps/v8/test/unittests/compiler/ia32/instruction-selector-ia32-unittest.cc @@ -4,6 +4,8 @@ #include "test/unittests/compiler/instruction-selector-unittest.h" +#include "src/objects-inl.h" + namespace v8 { namespace internal { namespace compiler { diff --git a/deps/v8/test/unittests/compiler/instruction-sequence-unittest.cc b/deps/v8/test/unittests/compiler/instruction-sequence-unittest.cc index ee9f7914a6..d629639c49 100644 --- a/deps/v8/test/unittests/compiler/instruction-sequence-unittest.cc +++ b/deps/v8/test/unittests/compiler/instruction-sequence-unittest.cc @@ -113,7 +113,7 @@ InstructionSequence* InstructionSequenceTest::sequence() { void InstructionSequenceTest::StartLoop(int loop_blocks) { - CHECK(current_block_ == nullptr); + CHECK_NULL(current_block_); if (!loop_blocks_.empty()) { CHECK(!loop_blocks_.back().loop_header_.IsValid()); } @@ -123,7 +123,7 @@ void InstructionSequenceTest::StartLoop(int loop_blocks) { void InstructionSequenceTest::EndLoop() { - CHECK(current_block_ == nullptr); + CHECK_NULL(current_block_); CHECK(!loop_blocks_.empty()); CHECK_EQ(0, loop_blocks_.back().expected_blocks_); loop_blocks_.pop_back(); @@ -158,7 +158,7 @@ Instruction* InstructionSequenceTest::EndBlock(BlockCompletion completion) { break; } completions_.push_back(completion); - CHECK(current_block_ != nullptr); + CHECK_NOT_NULL(current_block_); sequence()->EndBlock(current_block_->rpo_number()); current_block_ = nullptr; return result; @@ -195,7 +195,7 @@ PhiInstruction* InstructionSequenceTest::Phi(VReg incoming_vreg_0, for (; input_count < arraysize(inputs); ++input_count) { if (inputs[input_count].value_ == kNoValue) break; } - CHECK(input_count > 0); + CHECK_LT(0, input_count); auto phi = new (zone()) PhiInstruction(zone(), NewReg().value_, input_count); for (size_t i = 0; i < input_count; ++i) { SetInput(phi, i, inputs[i]); @@ -216,7 +216,7 @@ PhiInstruction* InstructionSequenceTest::Phi(VReg incoming_vreg_0, void InstructionSequenceTest::SetInput(PhiInstruction* phi, size_t input, VReg vreg) { - CHECK(vreg.value_ != kNoValue); + CHECK_NE(kNoValue, vreg.value_); phi->SetInput(input, vreg.value_); } @@ -474,7 +474,7 @@ InstructionOperand InstructionSequenceTest::ConvertOutputOp(VReg vreg, InstructionBlock* InstructionSequenceTest::NewBlock(bool deferred) { - CHECK(current_block_ == nullptr); + CHECK_NULL(current_block_); Rpo rpo = Rpo::FromInt(static_cast<int>(instruction_blocks_.size())); Rpo loop_header = Rpo::Invalid(); Rpo loop_end = Rpo::Invalid(); diff --git a/deps/v8/test/unittests/compiler/instruction-unittest.cc b/deps/v8/test/unittests/compiler/instruction-unittest.cc index 443c42b62a..96add7fdd8 100644 --- a/deps/v8/test/unittests/compiler/instruction-unittest.cc +++ b/deps/v8/test/unittests/compiler/instruction-unittest.cc @@ -10,6 +10,7 @@ namespace v8 { namespace internal { namespace compiler { +namespace instruction_unittest { namespace { @@ -170,6 +171,7 @@ TEST_F(InstructionTest, PrepareInsertAfter) { } } +} // namespace instruction_unittest } // namespace compiler } // namespace internal } // namespace v8 diff --git a/deps/v8/test/unittests/compiler/int64-lowering-unittest.cc b/deps/v8/test/unittests/compiler/int64-lowering-unittest.cc index 35f296442e..a6bd1f2dad 100644 --- a/deps/v8/test/unittests/compiler/int64-lowering-unittest.cc +++ b/deps/v8/test/unittests/compiler/int64-lowering-unittest.cc @@ -298,11 +298,11 @@ TEST_F(Int64LoweringTest, TruncateInt64ToInt32) { } TEST_F(Int64LoweringTest, Parameter) { - LowerGraph(Parameter(0), MachineRepresentation::kWord64, + LowerGraph(Parameter(1), MachineRepresentation::kWord64, MachineRepresentation::kWord64, 1); EXPECT_THAT(graph()->end()->InputAt(1), - IsReturn2(IsParameter(0), IsParameter(1), start(), start())); + IsReturn2(IsParameter(1), IsParameter(2), start(), start())); } TEST_F(Int64LoweringTest, Parameter2) { @@ -316,17 +316,23 @@ TEST_F(Int64LoweringTest, Parameter2) { sig_builder.AddParam(MachineRepresentation::kWord32); int start_parameter = start()->op()->ValueOutputCount(); - LowerGraph(Parameter(4), sig_builder.Build()); + LowerGraph(Parameter(5), sig_builder.Build()); EXPECT_THAT(graph()->end()->InputAt(1), - IsReturn(IsParameter(6), start(), start())); + IsReturn(IsParameter(7), start(), start())); // The parameter of the start node should increase by 2, because we lowered // two parameter nodes. EXPECT_THAT(start()->op()->ValueOutputCount(), start_parameter + 2); } +// The following tests assume that pointers are 32 bit and therefore pointers do +// not get lowered. This assumption does not hold on 64 bit platforms, which +// invalidates these tests. +// TODO(wasm): We can find an alternative to re-activate these tests. +#if V8_TARGET_ARCH_32_BIT TEST_F(Int64LoweringTest, CallI64Return) { int32_t function = 0x9999; + Node* context_address = Int32Constant(0); Signature<MachineRepresentation>::Builder sig_builder(zone(), 1, 0); sig_builder.AddReturn(MachineRepresentation::kWord64); @@ -335,7 +341,7 @@ TEST_F(Int64LoweringTest, CallI64Return) { compiler::GetWasmCallDescriptor(zone(), sig_builder.Build()); LowerGraph(graph()->NewNode(common()->Call(desc), Int32Constant(function), - start(), start()), + context_address, start(), start()), MachineRepresentation::kWord64); Capture<Node*> call; @@ -355,6 +361,7 @@ TEST_F(Int64LoweringTest, CallI64Return) { TEST_F(Int64LoweringTest, CallI64Parameter) { int32_t function = 0x9999; + Node* context_address = Int32Constant(0); Signature<MachineRepresentation>::Builder sig_builder(zone(), 1, 3); sig_builder.AddReturn(MachineRepresentation::kWord32); @@ -366,14 +373,14 @@ TEST_F(Int64LoweringTest, CallI64Parameter) { compiler::GetWasmCallDescriptor(zone(), sig_builder.Build()); LowerGraph(graph()->NewNode(common()->Call(desc), Int32Constant(function), - Int64Constant(value(0)), + context_address, Int64Constant(value(0)), Int32Constant(low_word_value(1)), Int64Constant(value(2)), start(), start()), MachineRepresentation::kWord32); EXPECT_THAT( graph()->end()->InputAt(1), - IsReturn(IsCall(testing::_, IsInt32Constant(function), + IsReturn(IsCall(testing::_, IsInt32Constant(function), context_address, IsInt32Constant(low_word_value(0)), IsInt32Constant(high_word_value(0)), IsInt32Constant(low_word_value(1)), @@ -401,6 +408,7 @@ TEST_F(Int64LoweringTest, Int64Add) { IsProjection(1, AllOf(CaptureEq(&add), add_matcher)), start(), start())); } +#endif TEST_F(Int64LoweringTest, Int64Sub) { LowerGraph(graph()->NewNode(machine()->Int64Sub(), Int64Constant(value(0)), diff --git a/deps/v8/test/unittests/compiler/js-create-lowering-unittest.cc b/deps/v8/test/unittests/compiler/js-create-lowering-unittest.cc index 7fac0e6bc5..e185c64795 100644 --- a/deps/v8/test/unittests/compiler/js-create-lowering-unittest.cc +++ b/deps/v8/test/unittests/compiler/js-create-lowering-unittest.cc @@ -40,8 +40,7 @@ class JSCreateLoweringTest : public TypedGraphTest { &machine); // TODO(titzer): mock the GraphReducer here for better unit testing. GraphReducer graph_reducer(zone(), graph()); - JSCreateLowering reducer(&graph_reducer, &deps_, &jsgraph, - MaybeHandle<FeedbackVector>(), native_context(), + JSCreateLowering reducer(&graph_reducer, &deps_, &jsgraph, native_context(), zone()); return reducer.Reduce(node); } @@ -93,7 +92,7 @@ TEST_F(JSCreateLoweringTest, JSCreateArgumentsInlinedMapped) { Node* const closure = Parameter(Type::Any()); Node* const context = UndefinedConstant(); Node* const effect = graph()->start(); - Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); + Handle<SharedFunctionInfo> shared(isolate()->script_function()->shared()); Node* const frame_state_outer = FrameState(shared, graph()->start()); Node* const frame_state_inner = FrameState(shared, frame_state_outer); Reduction r = Reduce(graph()->NewNode( @@ -111,7 +110,7 @@ TEST_F(JSCreateLoweringTest, JSCreateArgumentsInlinedUnmapped) { Node* const closure = Parameter(Type::Any()); Node* const context = UndefinedConstant(); Node* const effect = graph()->start(); - Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); + Handle<SharedFunctionInfo> shared(isolate()->script_function()->shared()); Node* const frame_state_outer = FrameState(shared, graph()->start()); Node* const frame_state_inner = FrameState(shared, frame_state_outer); Reduction r = Reduce(graph()->NewNode( @@ -129,7 +128,7 @@ TEST_F(JSCreateLoweringTest, JSCreateArgumentsInlinedRestArray) { Node* const closure = Parameter(Type::Any()); Node* const context = UndefinedConstant(); Node* const effect = graph()->start(); - Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); + Handle<SharedFunctionInfo> shared(isolate()->script_function()->shared()); Node* const frame_state_outer = FrameState(shared, graph()->start()); Node* const frame_state_inner = FrameState(shared, frame_state_outer); Reduction r = Reduce(graph()->NewNode( diff --git a/deps/v8/test/unittests/compiler/js-operator-unittest.cc b/deps/v8/test/unittests/compiler/js-operator-unittest.cc index 886fbe02ce..8a458a736f 100644 --- a/deps/v8/test/unittests/compiler/js-operator-unittest.cc +++ b/deps/v8/test/unittests/compiler/js-operator-unittest.cc @@ -11,6 +11,7 @@ namespace v8 { namespace internal { namespace compiler { +namespace js_operator_unittest { // ----------------------------------------------------------------------------- // Shared operators. @@ -112,6 +113,7 @@ TEST_P(JSSharedOperatorTest, Properties) { INSTANTIATE_TEST_CASE_P(JSOperatorTest, JSSharedOperatorTest, ::testing::ValuesIn(kSharedOperators)); +} // namespace js_operator_unittest } // namespace compiler } // namespace internal } // namespace v8 diff --git a/deps/v8/test/unittests/compiler/mips/instruction-selector-mips-unittest.cc b/deps/v8/test/unittests/compiler/mips/instruction-selector-mips-unittest.cc index b041597ccd..2f1e7e8be2 100644 --- a/deps/v8/test/unittests/compiler/mips/instruction-selector-mips-unittest.cc +++ b/deps/v8/test/unittests/compiler/mips/instruction-selector-mips-unittest.cc @@ -4,6 +4,8 @@ #include "test/unittests/compiler/instruction-selector-unittest.h" +#include "src/objects-inl.h" + namespace v8 { namespace internal { namespace compiler { diff --git a/deps/v8/test/unittests/compiler/mips64/instruction-selector-mips64-unittest.cc b/deps/v8/test/unittests/compiler/mips64/instruction-selector-mips64-unittest.cc index 5c57e5ce9f..74af374379 100644 --- a/deps/v8/test/unittests/compiler/mips64/instruction-selector-mips64-unittest.cc +++ b/deps/v8/test/unittests/compiler/mips64/instruction-selector-mips64-unittest.cc @@ -4,6 +4,8 @@ #include "test/unittests/compiler/instruction-selector-unittest.h" +#include "src/objects-inl.h" + namespace v8 { namespace internal { namespace compiler { diff --git a/deps/v8/test/unittests/compiler/node-cache-unittest.cc b/deps/v8/test/unittests/compiler/node-cache-unittest.cc index 3c92876abd..f77377deda 100644 --- a/deps/v8/test/unittests/compiler/node-cache-unittest.cc +++ b/deps/v8/test/unittests/compiler/node-cache-unittest.cc @@ -12,6 +12,7 @@ using testing::Contains; namespace v8 { namespace internal { namespace compiler { +namespace node_cache_unittest { typedef GraphTest NodeCacheTest; @@ -154,6 +155,7 @@ TEST_F(NodeCacheTest, GetCachedNodes_int64) { } } +} // namespace node_cache_unittest } // namespace compiler } // namespace internal } // namespace v8 diff --git a/deps/v8/test/unittests/compiler/node-properties-unittest.cc b/deps/v8/test/unittests/compiler/node-properties-unittest.cc index a18f2032f5..b3b76cef79 100644 --- a/deps/v8/test/unittests/compiler/node-properties-unittest.cc +++ b/deps/v8/test/unittests/compiler/node-properties-unittest.cc @@ -14,6 +14,7 @@ using testing::IsNull; namespace v8 { namespace internal { namespace compiler { +namespace node_properties_unittest { class NodePropertiesTest : public TestWithZone { public: @@ -118,6 +119,7 @@ TEST_F(NodePropertiesTest, CollectControlProjections_Switch) { EXPECT_EQ(if_default, result[2]); } +} // namespace node_properties_unittest } // namespace compiler } // namespace internal } // namespace v8 diff --git a/deps/v8/test/unittests/compiler/node-test-utils.cc b/deps/v8/test/unittests/compiler/node-test-utils.cc index 0e903f9c76..52fd02b0a6 100644 --- a/deps/v8/test/unittests/compiler/node-test-utils.cc +++ b/deps/v8/test/unittests/compiler/node-test-utils.cc @@ -47,10 +47,9 @@ bool PrintMatchAndExplain(const T& value, const std::string& value_name, return true; } - -class NodeMatcher : public MatcherInterface<Node*> { +class TestNodeMatcher : public MatcherInterface<Node*> { public: - explicit NodeMatcher(IrOpcode::Value opcode) : opcode_(opcode) {} + explicit TestNodeMatcher(IrOpcode::Value opcode) : opcode_(opcode) {} void DescribeTo(std::ostream* os) const override { *os << "is a " << IrOpcode::Mnemonic(opcode_) << " node"; @@ -74,17 +73,16 @@ class NodeMatcher : public MatcherInterface<Node*> { const IrOpcode::Value opcode_; }; - -class IsBranchMatcher final : public NodeMatcher { +class IsBranchMatcher final : public TestNodeMatcher { public: IsBranchMatcher(const Matcher<Node*>& value_matcher, const Matcher<Node*>& control_matcher) - : NodeMatcher(IrOpcode::kBranch), + : TestNodeMatcher(IrOpcode::kBranch), value_matcher_(value_matcher), control_matcher_(control_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose value ("; value_matcher_.DescribeTo(os); *os << ") and control ("; @@ -93,7 +91,7 @@ class IsBranchMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "value", value_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetControlInput(node), @@ -105,17 +103,16 @@ class IsBranchMatcher final : public NodeMatcher { const Matcher<Node*> control_matcher_; }; - -class IsSwitchMatcher final : public NodeMatcher { +class IsSwitchMatcher final : public TestNodeMatcher { public: IsSwitchMatcher(const Matcher<Node*>& value_matcher, const Matcher<Node*>& control_matcher) - : NodeMatcher(IrOpcode::kSwitch), + : TestNodeMatcher(IrOpcode::kSwitch), value_matcher_(value_matcher), control_matcher_(control_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose value ("; value_matcher_.DescribeTo(os); *os << ") and control ("; @@ -124,7 +121,7 @@ class IsSwitchMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "value", value_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetControlInput(node), @@ -136,17 +133,16 @@ class IsSwitchMatcher final : public NodeMatcher { const Matcher<Node*> control_matcher_; }; - -class IsIfValueMatcher final : public NodeMatcher { +class IsIfValueMatcher final : public TestNodeMatcher { public: IsIfValueMatcher(const Matcher<int32_t>& value_matcher, const Matcher<Node*>& control_matcher) - : NodeMatcher(IrOpcode::kIfValue), + : TestNodeMatcher(IrOpcode::kIfValue), value_matcher_(value_matcher), control_matcher_(control_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose value ("; value_matcher_.DescribeTo(os); *os << ") and control ("; @@ -155,7 +151,7 @@ class IsIfValueMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(OpParameter<int32_t>(node->op()), "value", value_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetControlInput(node), @@ -167,22 +163,21 @@ class IsIfValueMatcher final : public NodeMatcher { const Matcher<Node*> control_matcher_; }; - -class IsControl1Matcher final : public NodeMatcher { +class IsControl1Matcher final : public TestNodeMatcher { public: IsControl1Matcher(IrOpcode::Value opcode, const Matcher<Node*>& control_matcher) - : NodeMatcher(opcode), control_matcher_(control_matcher) {} + : TestNodeMatcher(opcode), control_matcher_(control_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose control ("; control_matcher_.DescribeTo(os); *os << ")"; } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(NodeProperties::GetControlInput(node), "control", control_matcher_, listener)); } @@ -191,18 +186,17 @@ class IsControl1Matcher final : public NodeMatcher { const Matcher<Node*> control_matcher_; }; - -class IsControl2Matcher final : public NodeMatcher { +class IsControl2Matcher final : public TestNodeMatcher { public: IsControl2Matcher(IrOpcode::Value opcode, const Matcher<Node*>& control0_matcher, const Matcher<Node*>& control1_matcher) - : NodeMatcher(opcode), + : TestNodeMatcher(opcode), control0_matcher_(control0_matcher), control1_matcher_(control1_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose control0 ("; control0_matcher_.DescribeTo(os); *os << ") and control1 ("; @@ -211,7 +205,7 @@ class IsControl2Matcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(NodeProperties::GetControlInput(node, 0), "control0", control0_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetControlInput(node, 1), @@ -223,20 +217,19 @@ class IsControl2Matcher final : public NodeMatcher { const Matcher<Node*> control1_matcher_; }; - -class IsControl3Matcher final : public NodeMatcher { +class IsControl3Matcher final : public TestNodeMatcher { public: IsControl3Matcher(IrOpcode::Value opcode, const Matcher<Node*>& control0_matcher, const Matcher<Node*>& control1_matcher, const Matcher<Node*>& control2_matcher) - : NodeMatcher(opcode), + : TestNodeMatcher(opcode), control0_matcher_(control0_matcher), control1_matcher_(control1_matcher), control2_matcher_(control2_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose control0 ("; control0_matcher_.DescribeTo(os); *os << ") and control1 ("; @@ -247,7 +240,7 @@ class IsControl3Matcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(NodeProperties::GetControlInput(node, 0), "control0", control0_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetControlInput(node, 1), @@ -262,21 +255,21 @@ class IsControl3Matcher final : public NodeMatcher { const Matcher<Node*> control2_matcher_; }; - -class IsBeginRegionMatcher final : public NodeMatcher { +class IsBeginRegionMatcher final : public TestNodeMatcher { public: explicit IsBeginRegionMatcher(const Matcher<Node*>& effect_matcher) - : NodeMatcher(IrOpcode::kBeginRegion), effect_matcher_(effect_matcher) {} + : TestNodeMatcher(IrOpcode::kBeginRegion), + effect_matcher_(effect_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose effect ("; effect_matcher_.DescribeTo(os); *os << ")"; } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", effect_matcher_, listener)); } @@ -285,17 +278,16 @@ class IsBeginRegionMatcher final : public NodeMatcher { const Matcher<Node*> effect_matcher_; }; - -class IsFinishRegionMatcher final : public NodeMatcher { +class IsFinishRegionMatcher final : public TestNodeMatcher { public: IsFinishRegionMatcher(const Matcher<Node*>& value_matcher, const Matcher<Node*>& effect_matcher) - : NodeMatcher(IrOpcode::kFinishRegion), + : TestNodeMatcher(IrOpcode::kFinishRegion), value_matcher_(value_matcher), effect_matcher_(effect_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose value ("; value_matcher_.DescribeTo(os); *os << ") and effect ("; @@ -304,7 +296,7 @@ class IsFinishRegionMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "value", value_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", @@ -316,13 +308,12 @@ class IsFinishRegionMatcher final : public NodeMatcher { const Matcher<Node*> effect_matcher_; }; - -class IsReturnMatcher final : public NodeMatcher { +class IsReturnMatcher final : public TestNodeMatcher { public: IsReturnMatcher(const Matcher<Node*>& value_matcher, const Matcher<Node*>& effect_matcher, const Matcher<Node*>& control_matcher) - : NodeMatcher(IrOpcode::kReturn), + : TestNodeMatcher(IrOpcode::kReturn), value_matcher_(value_matcher), value2_matcher_(_), effect_matcher_(effect_matcher), @@ -333,7 +324,7 @@ class IsReturnMatcher final : public NodeMatcher { const Matcher<Node*>& value2_matcher, const Matcher<Node*>& effect_matcher, const Matcher<Node*>& control_matcher) - : NodeMatcher(IrOpcode::kReturn), + : TestNodeMatcher(IrOpcode::kReturn), value_matcher_(value_matcher), value2_matcher_(value2_matcher), effect_matcher_(effect_matcher), @@ -341,7 +332,7 @@ class IsReturnMatcher final : public NodeMatcher { has_second_return_value_(true) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose value ("; value_matcher_.DescribeTo(os); if (has_second_return_value_) { @@ -356,7 +347,7 @@ class IsReturnMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), "value", value_matcher_, listener) && (!has_second_return_value_ || @@ -376,17 +367,16 @@ class IsReturnMatcher final : public NodeMatcher { bool has_second_return_value_; }; - -class IsTerminateMatcher final : public NodeMatcher { +class IsTerminateMatcher final : public TestNodeMatcher { public: IsTerminateMatcher(const Matcher<Node*>& effect_matcher, const Matcher<Node*>& control_matcher) - : NodeMatcher(IrOpcode::kTerminate), + : TestNodeMatcher(IrOpcode::kTerminate), effect_matcher_(effect_matcher), control_matcher_(control_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose effect ("; effect_matcher_.DescribeTo(os); *os << ") and control ("; @@ -395,7 +385,7 @@ class IsTerminateMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", effect_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetControlInput(node), @@ -407,16 +397,16 @@ class IsTerminateMatcher final : public NodeMatcher { const Matcher<Node*> control_matcher_; }; -class IsTypeGuardMatcher final : public NodeMatcher { +class IsTypeGuardMatcher final : public TestNodeMatcher { public: IsTypeGuardMatcher(const Matcher<Node*>& value_matcher, const Matcher<Node*>& control_matcher) - : NodeMatcher(IrOpcode::kTypeGuard), + : TestNodeMatcher(IrOpcode::kTypeGuard), value_matcher_(value_matcher), control_matcher_(control_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose value ("; value_matcher_.DescribeTo(os); *os << ") and control ("; @@ -425,7 +415,7 @@ class IsTypeGuardMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "value", value_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetControlInput(node), @@ -438,20 +428,20 @@ class IsTypeGuardMatcher final : public NodeMatcher { }; template <typename T> -class IsConstantMatcher final : public NodeMatcher { +class IsConstantMatcher final : public TestNodeMatcher { public: IsConstantMatcher(IrOpcode::Value opcode, const Matcher<T>& value_matcher) - : NodeMatcher(opcode), value_matcher_(value_matcher) {} + : TestNodeMatcher(opcode), value_matcher_(value_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose value ("; value_matcher_.DescribeTo(os); *os << ")"; } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(OpParameter<T>(node), "value", value_matcher_, listener)); } @@ -460,21 +450,20 @@ class IsConstantMatcher final : public NodeMatcher { const Matcher<T> value_matcher_; }; - -class IsSelectMatcher final : public NodeMatcher { +class IsSelectMatcher final : public TestNodeMatcher { public: IsSelectMatcher(const Matcher<MachineRepresentation>& type_matcher, const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher, const Matcher<Node*>& value2_matcher) - : NodeMatcher(IrOpcode::kSelect), + : TestNodeMatcher(IrOpcode::kSelect), type_matcher_(type_matcher), value0_matcher_(value0_matcher), value1_matcher_(value1_matcher), value2_matcher_(value2_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose representation ("; type_matcher_.DescribeTo(os); *os << "), value0 ("; @@ -488,7 +477,7 @@ class IsSelectMatcher final : public NodeMatcher { bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { return ( - NodeMatcher::MatchAndExplain(node, listener) && + TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(SelectParametersOf(node->op()).representation(), "representation", type_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "value0", @@ -506,21 +495,20 @@ class IsSelectMatcher final : public NodeMatcher { const Matcher<Node*> value2_matcher_; }; - -class IsPhiMatcher final : public NodeMatcher { +class IsPhiMatcher final : public TestNodeMatcher { public: IsPhiMatcher(const Matcher<MachineRepresentation>& type_matcher, const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher, const Matcher<Node*>& control_matcher) - : NodeMatcher(IrOpcode::kPhi), + : TestNodeMatcher(IrOpcode::kPhi), type_matcher_(type_matcher), value0_matcher_(value0_matcher), value1_matcher_(value1_matcher), control_matcher_(control_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose representation ("; type_matcher_.DescribeTo(os); *os << "), value0 ("; @@ -533,7 +521,7 @@ class IsPhiMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(PhiRepresentationOf(node->op()), "representation", type_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), @@ -551,15 +539,14 @@ class IsPhiMatcher final : public NodeMatcher { const Matcher<Node*> control_matcher_; }; - -class IsPhi2Matcher final : public NodeMatcher { +class IsPhi2Matcher final : public TestNodeMatcher { public: IsPhi2Matcher(const Matcher<MachineRepresentation>& type_matcher, const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher, const Matcher<Node*>& value2_matcher, const Matcher<Node*>& control_matcher) - : NodeMatcher(IrOpcode::kPhi), + : TestNodeMatcher(IrOpcode::kPhi), type_matcher_(type_matcher), value0_matcher_(value0_matcher), value1_matcher_(value1_matcher), @@ -567,7 +554,7 @@ class IsPhi2Matcher final : public NodeMatcher { control_matcher_(control_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose representation ("; type_matcher_.DescribeTo(os); *os << "), value0 ("; @@ -582,7 +569,7 @@ class IsPhi2Matcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(PhiRepresentationOf(node->op()), "representation", type_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), @@ -603,19 +590,18 @@ class IsPhi2Matcher final : public NodeMatcher { const Matcher<Node*> control_matcher_; }; - -class IsEffectPhiMatcher final : public NodeMatcher { +class IsEffectPhiMatcher final : public TestNodeMatcher { public: IsEffectPhiMatcher(const Matcher<Node*>& effect0_matcher, const Matcher<Node*>& effect1_matcher, const Matcher<Node*>& control_matcher) - : NodeMatcher(IrOpcode::kEffectPhi), + : TestNodeMatcher(IrOpcode::kEffectPhi), effect0_matcher_(effect0_matcher), effect1_matcher_(effect1_matcher), control_matcher_(control_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << "), effect0 ("; effect0_matcher_.DescribeTo(os); *os << "), effect1 ("; @@ -626,7 +612,7 @@ class IsEffectPhiMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(NodeProperties::GetEffectInput(node, 0), "effect0", effect0_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetEffectInput(node, 1), @@ -641,17 +627,16 @@ class IsEffectPhiMatcher final : public NodeMatcher { const Matcher<Node*> control_matcher_; }; - -class IsProjectionMatcher final : public NodeMatcher { +class IsProjectionMatcher final : public TestNodeMatcher { public: IsProjectionMatcher(const Matcher<size_t>& index_matcher, const Matcher<Node*>& base_matcher) - : NodeMatcher(IrOpcode::kProjection), + : TestNodeMatcher(IrOpcode::kProjection), index_matcher_(index_matcher), base_matcher_(base_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose index ("; index_matcher_.DescribeTo(os); *os << ") and base ("; @@ -660,7 +645,7 @@ class IsProjectionMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(OpParameter<size_t>(node), "index", index_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", @@ -672,21 +657,20 @@ class IsProjectionMatcher final : public NodeMatcher { const Matcher<Node*> base_matcher_; }; - -class IsCallMatcher final : public NodeMatcher { +class IsCallMatcher final : public TestNodeMatcher { public: IsCallMatcher(const Matcher<const CallDescriptor*>& descriptor_matcher, const std::vector<Matcher<Node*>>& value_matchers, const Matcher<Node*>& effect_matcher, const Matcher<Node*>& control_matcher) - : NodeMatcher(IrOpcode::kCall), + : TestNodeMatcher(IrOpcode::kCall), descriptor_matcher_(descriptor_matcher), value_matchers_(value_matchers), effect_matcher_(effect_matcher), control_matcher_(control_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); for (size_t i = 0; i < value_matchers_.size(); ++i) { if (i == 0) { *os << " whose value0 ("; @@ -703,7 +687,7 @@ class IsCallMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - if (!NodeMatcher::MatchAndExplain(node, listener) || + if (!TestNodeMatcher::MatchAndExplain(node, listener) || !PrintMatchAndExplain(OpParameter<const CallDescriptor*>(node), "descriptor", descriptor_matcher_, listener)) { return false; @@ -738,21 +722,20 @@ class IsCallMatcher final : public NodeMatcher { const Matcher<Node*> control_matcher_; }; - -class IsTailCallMatcher final : public NodeMatcher { +class IsTailCallMatcher final : public TestNodeMatcher { public: IsTailCallMatcher(const Matcher<CallDescriptor const*>& descriptor_matcher, const std::vector<Matcher<Node*>>& value_matchers, const Matcher<Node*>& effect_matcher, const Matcher<Node*>& control_matcher) - : NodeMatcher(IrOpcode::kTailCall), + : TestNodeMatcher(IrOpcode::kTailCall), descriptor_matcher_(descriptor_matcher), value_matchers_(value_matchers), effect_matcher_(effect_matcher), control_matcher_(control_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); for (size_t i = 0; i < value_matchers_.size(); ++i) { if (i == 0) { *os << " whose value0 ("; @@ -769,7 +752,7 @@ class IsTailCallMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - if (!NodeMatcher::MatchAndExplain(node, listener) || + if (!TestNodeMatcher::MatchAndExplain(node, listener) || !PrintMatchAndExplain(OpParameter<CallDescriptor const*>(node), "descriptor", descriptor_matcher_, listener)) { return false; @@ -804,7 +787,7 @@ class IsTailCallMatcher final : public NodeMatcher { const Matcher<Node*> control_matcher_; }; -class IsSpeculativeBinopMatcher final : public NodeMatcher { +class IsSpeculativeBinopMatcher final : public TestNodeMatcher { public: IsSpeculativeBinopMatcher(IrOpcode::Value opcode, const Matcher<NumberOperationHint>& hint_matcher, @@ -812,7 +795,7 @@ class IsSpeculativeBinopMatcher final : public NodeMatcher { const Matcher<Node*>& rhs_matcher, const Matcher<Node*>& effect_matcher, const Matcher<Node*>& control_matcher) - : NodeMatcher(opcode), + : TestNodeMatcher(opcode), hint_matcher_(hint_matcher), lhs_matcher_(lhs_matcher), rhs_matcher_(rhs_matcher), @@ -820,7 +803,7 @@ class IsSpeculativeBinopMatcher final : public NodeMatcher { control_matcher_(control_matcher) {} bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && // TODO(bmeurer): The type parameter is currently ignored. PrintMatchAndExplain(OpParameter<NumberOperationHint>(node->op()), "hints", hint_matcher_, listener) && @@ -843,18 +826,18 @@ class IsSpeculativeBinopMatcher final : public NodeMatcher { const Matcher<Node*> control_matcher_; }; -class IsAllocateMatcher final : public NodeMatcher { +class IsAllocateMatcher final : public TestNodeMatcher { public: IsAllocateMatcher(const Matcher<Node*>& size_matcher, const Matcher<Node*>& effect_matcher, const Matcher<Node*>& control_matcher) - : NodeMatcher(IrOpcode::kAllocate), + : TestNodeMatcher(IrOpcode::kAllocate), size_matcher_(size_matcher), effect_matcher_(effect_matcher), control_matcher_(control_matcher) {} bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "size", size_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", @@ -869,21 +852,20 @@ class IsAllocateMatcher final : public NodeMatcher { const Matcher<Node*> control_matcher_; }; - -class IsLoadFieldMatcher final : public NodeMatcher { +class IsLoadFieldMatcher final : public TestNodeMatcher { public: IsLoadFieldMatcher(const Matcher<FieldAccess>& access_matcher, const Matcher<Node*>& base_matcher, const Matcher<Node*>& effect_matcher, const Matcher<Node*>& control_matcher) - : NodeMatcher(IrOpcode::kLoadField), + : TestNodeMatcher(IrOpcode::kLoadField), access_matcher_(access_matcher), base_matcher_(base_matcher), effect_matcher_(effect_matcher), control_matcher_(control_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose access ("; access_matcher_.DescribeTo(os); *os << "), base ("; @@ -896,7 +878,7 @@ class IsLoadFieldMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(OpParameter<FieldAccess>(node), "access", access_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", @@ -914,15 +896,14 @@ class IsLoadFieldMatcher final : public NodeMatcher { const Matcher<Node*> control_matcher_; }; - -class IsStoreFieldMatcher final : public NodeMatcher { +class IsStoreFieldMatcher final : public TestNodeMatcher { public: IsStoreFieldMatcher(const Matcher<FieldAccess>& access_matcher, const Matcher<Node*>& base_matcher, const Matcher<Node*>& value_matcher, const Matcher<Node*>& effect_matcher, const Matcher<Node*>& control_matcher) - : NodeMatcher(IrOpcode::kStoreField), + : TestNodeMatcher(IrOpcode::kStoreField), access_matcher_(access_matcher), base_matcher_(base_matcher), value_matcher_(value_matcher), @@ -930,7 +911,7 @@ class IsStoreFieldMatcher final : public NodeMatcher { control_matcher_(control_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose access ("; access_matcher_.DescribeTo(os); *os << "), base ("; @@ -945,7 +926,7 @@ class IsStoreFieldMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(OpParameter<FieldAccess>(node), "access", access_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", @@ -966,14 +947,14 @@ class IsStoreFieldMatcher final : public NodeMatcher { const Matcher<Node*> control_matcher_; }; -class IsLoadElementMatcher final : public NodeMatcher { +class IsLoadElementMatcher final : public TestNodeMatcher { public: IsLoadElementMatcher(const Matcher<ElementAccess>& access_matcher, const Matcher<Node*>& base_matcher, const Matcher<Node*>& index_matcher, const Matcher<Node*>& effect_matcher, const Matcher<Node*>& control_matcher) - : NodeMatcher(IrOpcode::kLoadElement), + : TestNodeMatcher(IrOpcode::kLoadElement), access_matcher_(access_matcher), base_matcher_(base_matcher), index_matcher_(index_matcher), @@ -981,7 +962,7 @@ class IsLoadElementMatcher final : public NodeMatcher { control_matcher_(control_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose access ("; access_matcher_.DescribeTo(os); *os << "), base ("; @@ -996,7 +977,7 @@ class IsLoadElementMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(OpParameter<ElementAccess>(node), "access", access_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", @@ -1017,8 +998,7 @@ class IsLoadElementMatcher final : public NodeMatcher { const Matcher<Node*> control_matcher_; }; - -class IsStoreElementMatcher final : public NodeMatcher { +class IsStoreElementMatcher final : public TestNodeMatcher { public: IsStoreElementMatcher(const Matcher<ElementAccess>& access_matcher, const Matcher<Node*>& base_matcher, @@ -1026,7 +1006,7 @@ class IsStoreElementMatcher final : public NodeMatcher { const Matcher<Node*>& value_matcher, const Matcher<Node*>& effect_matcher, const Matcher<Node*>& control_matcher) - : NodeMatcher(IrOpcode::kStoreElement), + : TestNodeMatcher(IrOpcode::kStoreElement), access_matcher_(access_matcher), base_matcher_(base_matcher), index_matcher_(index_matcher), @@ -1035,7 +1015,7 @@ class IsStoreElementMatcher final : public NodeMatcher { control_matcher_(control_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose access ("; access_matcher_.DescribeTo(os); *os << "), base ("; @@ -1052,7 +1032,7 @@ class IsStoreElementMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(OpParameter<ElementAccess>(node), "access", access_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", @@ -1077,14 +1057,14 @@ class IsStoreElementMatcher final : public NodeMatcher { }; #define LOAD_MATCHER(kLoad) \ - class Is##kLoad##Matcher final : public NodeMatcher { \ + class Is##kLoad##Matcher final : public TestNodeMatcher { \ public: \ Is##kLoad##Matcher(const Matcher<kLoad##Representation>& rep_matcher, \ const Matcher<Node*>& base_matcher, \ const Matcher<Node*>& index_matcher, \ const Matcher<Node*>& effect_matcher, \ const Matcher<Node*>& control_matcher) \ - : NodeMatcher(IrOpcode::k##kLoad), \ + : TestNodeMatcher(IrOpcode::k##kLoad), \ rep_matcher_(rep_matcher), \ base_matcher_(base_matcher), \ index_matcher_(index_matcher), \ @@ -1092,7 +1072,7 @@ class IsStoreElementMatcher final : public NodeMatcher { control_matcher_(control_matcher) {} \ \ void DescribeTo(std::ostream* os) const final { \ - NodeMatcher::DescribeTo(os); \ + TestNodeMatcher::DescribeTo(os); \ *os << " whose rep ("; \ rep_matcher_.DescribeTo(os); \ *os << "), base ("; \ @@ -1116,7 +1096,7 @@ class IsStoreElementMatcher final : public NodeMatcher { if (NodeProperties::FirstControlIndex(node) < node->InputCount()) { \ control_node = NodeProperties::GetControlInput(node); \ } \ - return (NodeMatcher::MatchAndExplain(node, listener) && \ + return (TestNodeMatcher::MatchAndExplain(node, listener) && \ PrintMatchAndExplain(OpParameter<kLoad##Representation>(node), \ "rep", rep_matcher_, listener) && \ PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), \ @@ -1141,7 +1121,7 @@ LOAD_MATCHER(Load) LOAD_MATCHER(UnalignedLoad) #define STORE_MATCHER(kStore) \ - class Is##kStore##Matcher final : public NodeMatcher { \ + class Is##kStore##Matcher final : public TestNodeMatcher { \ public: \ Is##kStore##Matcher(const Matcher<kStore##Representation>& rep_matcher, \ const Matcher<Node*>& base_matcher, \ @@ -1149,7 +1129,7 @@ LOAD_MATCHER(UnalignedLoad) const Matcher<Node*>& value_matcher, \ const Matcher<Node*>& effect_matcher, \ const Matcher<Node*>& control_matcher) \ - : NodeMatcher(IrOpcode::k##kStore), \ + : TestNodeMatcher(IrOpcode::k##kStore), \ rep_matcher_(rep_matcher), \ base_matcher_(base_matcher), \ index_matcher_(index_matcher), \ @@ -1158,7 +1138,7 @@ LOAD_MATCHER(UnalignedLoad) control_matcher_(control_matcher) {} \ \ void DescribeTo(std::ostream* os) const final { \ - NodeMatcher::DescribeTo(os); \ + TestNodeMatcher::DescribeTo(os); \ *os << " whose rep ("; \ rep_matcher_.DescribeTo(os); \ *os << "), base ("; \ @@ -1184,7 +1164,7 @@ LOAD_MATCHER(UnalignedLoad) if (NodeProperties::FirstControlIndex(node) < node->InputCount()) { \ control_node = NodeProperties::GetControlInput(node); \ } \ - return (NodeMatcher::MatchAndExplain(node, listener) && \ + return (TestNodeMatcher::MatchAndExplain(node, listener) && \ PrintMatchAndExplain(OpParameter<kStore##Representation>(node), \ "rep", rep_matcher_, listener) && \ PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), \ @@ -1211,21 +1191,21 @@ LOAD_MATCHER(UnalignedLoad) STORE_MATCHER(Store) STORE_MATCHER(UnalignedStore) -class IsStackSlotMatcher final : public NodeMatcher { +class IsStackSlotMatcher final : public TestNodeMatcher { public: explicit IsStackSlotMatcher( const Matcher<StackSlotRepresentation>& rep_matcher) - : NodeMatcher(IrOpcode::kStackSlot), rep_matcher_(rep_matcher) {} + : TestNodeMatcher(IrOpcode::kStackSlot), rep_matcher_(rep_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose rep ("; rep_matcher_.DescribeTo(os); *os << ")"; } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(OpParameter<StackSlotRepresentation>(node), "rep", rep_matcher_, listener)); } @@ -1234,20 +1214,20 @@ class IsStackSlotMatcher final : public NodeMatcher { const Matcher<StackSlotRepresentation> rep_matcher_; }; -class IsToNumberMatcher final : public NodeMatcher { +class IsToNumberMatcher final : public TestNodeMatcher { public: IsToNumberMatcher(const Matcher<Node*>& base_matcher, const Matcher<Node*>& context_matcher, const Matcher<Node*>& effect_matcher, const Matcher<Node*>& control_matcher) - : NodeMatcher(IrOpcode::kJSToNumber), + : TestNodeMatcher(IrOpcode::kJSToNumber), base_matcher_(base_matcher), context_matcher_(context_matcher), effect_matcher_(effect_matcher), control_matcher_(control_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose base ("; base_matcher_.DescribeTo(os); *os << "), context ("; @@ -1260,7 +1240,7 @@ class IsToNumberMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", base_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetContextInput(node), @@ -1278,17 +1258,16 @@ class IsToNumberMatcher final : public NodeMatcher { const Matcher<Node*> control_matcher_; }; - -class IsLoadContextMatcher final : public NodeMatcher { +class IsLoadContextMatcher final : public TestNodeMatcher { public: IsLoadContextMatcher(const Matcher<ContextAccess>& access_matcher, const Matcher<Node*>& context_matcher) - : NodeMatcher(IrOpcode::kJSLoadContext), + : TestNodeMatcher(IrOpcode::kJSLoadContext), access_matcher_(access_matcher), context_matcher_(context_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose access ("; access_matcher_.DescribeTo(os); *os << ") and context ("; @@ -1297,7 +1276,7 @@ class IsLoadContextMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(OpParameter<ContextAccess>(node), "access", access_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetContextInput(node), @@ -1309,20 +1288,20 @@ class IsLoadContextMatcher final : public NodeMatcher { const Matcher<Node*> context_matcher_; }; -class IsQuadopMatcher final : public NodeMatcher { +class IsQuadopMatcher final : public TestNodeMatcher { public: IsQuadopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& a_matcher, const Matcher<Node*>& b_matcher, const Matcher<Node*>& c_matcher, const Matcher<Node*>& d_matcher) - : NodeMatcher(opcode), + : TestNodeMatcher(opcode), a_matcher_(a_matcher), b_matcher_(b_matcher), c_matcher_(c_matcher), d_matcher_(d_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose a ("; a_matcher_.DescribeTo(os); *os << ") and b ("; @@ -1335,7 +1314,7 @@ class IsQuadopMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "a", a_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), "b", @@ -1353,18 +1332,18 @@ class IsQuadopMatcher final : public NodeMatcher { const Matcher<Node*> d_matcher_; }; -class IsTernopMatcher final : public NodeMatcher { +class IsTernopMatcher final : public TestNodeMatcher { public: IsTernopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& lhs_matcher, const Matcher<Node*>& mid_matcher, const Matcher<Node*>& rhs_matcher) - : NodeMatcher(opcode), + : TestNodeMatcher(opcode), lhs_matcher_(lhs_matcher), mid_matcher_(mid_matcher), rhs_matcher_(rhs_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose lhs ("; lhs_matcher_.DescribeTo(os); *os << ") and mid ("; @@ -1375,7 +1354,7 @@ class IsTernopMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "lhs", lhs_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), "mid", @@ -1390,16 +1369,16 @@ class IsTernopMatcher final : public NodeMatcher { const Matcher<Node*> rhs_matcher_; }; -class IsBinopMatcher final : public NodeMatcher { +class IsBinopMatcher final : public TestNodeMatcher { public: IsBinopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& lhs_matcher, const Matcher<Node*>& rhs_matcher) - : NodeMatcher(opcode), + : TestNodeMatcher(opcode), lhs_matcher_(lhs_matcher), rhs_matcher_(rhs_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose lhs ("; lhs_matcher_.DescribeTo(os); *os << ") and rhs ("; @@ -1408,7 +1387,7 @@ class IsBinopMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "lhs", lhs_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), "rhs", @@ -1420,21 +1399,20 @@ class IsBinopMatcher final : public NodeMatcher { const Matcher<Node*> rhs_matcher_; }; - -class IsUnopMatcher final : public NodeMatcher { +class IsUnopMatcher final : public TestNodeMatcher { public: IsUnopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& input_matcher) - : NodeMatcher(opcode), input_matcher_(input_matcher) {} + : TestNodeMatcher(opcode), input_matcher_(input_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose input ("; input_matcher_.DescribeTo(os); *os << ")"; } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "input", input_matcher_, listener)); } @@ -1443,11 +1421,10 @@ class IsUnopMatcher final : public NodeMatcher { const Matcher<Node*> input_matcher_; }; - -class IsParameterMatcher final : public NodeMatcher { +class IsParameterMatcher final : public TestNodeMatcher { public: explicit IsParameterMatcher(const Matcher<int>& index_matcher) - : NodeMatcher(IrOpcode::kParameter), index_matcher_(index_matcher) {} + : TestNodeMatcher(IrOpcode::kParameter), index_matcher_(index_matcher) {} void DescribeTo(std::ostream* os) const override { *os << "is a Parameter node with index("; @@ -1456,7 +1433,7 @@ class IsParameterMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(ParameterIndexOf(node->op()), "index", index_matcher_, listener)); } @@ -1468,7 +1445,7 @@ class IsParameterMatcher final : public NodeMatcher { } // namespace Matcher<Node*> IsDead() { - return MakeMatcher(new NodeMatcher(IrOpcode::kDead)); + return MakeMatcher(new TestNodeMatcher(IrOpcode::kDead)); } Matcher<Node*> IsEnd(const Matcher<Node*>& control0_matcher) { @@ -2050,11 +2027,11 @@ Matcher<Node*> IsParameter(const Matcher<int> index_matcher) { Matcher<Node*> IsLoadFramePointer() { - return MakeMatcher(new NodeMatcher(IrOpcode::kLoadFramePointer)); + return MakeMatcher(new TestNodeMatcher(IrOpcode::kLoadFramePointer)); } Matcher<Node*> IsLoadParentFramePointer() { - return MakeMatcher(new NodeMatcher(IrOpcode::kLoadParentFramePointer)); + return MakeMatcher(new TestNodeMatcher(IrOpcode::kLoadParentFramePointer)); } #define IS_QUADOP_MATCHER(Name) \ @@ -2110,8 +2087,10 @@ IS_BINOP_MATCHER(Word32Ror) IS_BINOP_MATCHER(Word32Equal) IS_BINOP_MATCHER(Word64And) IS_BINOP_MATCHER(Word64Or) +IS_BINOP_MATCHER(Word64Xor) IS_BINOP_MATCHER(Word64Sar) IS_BINOP_MATCHER(Word64Shl) +IS_BINOP_MATCHER(Word64Shr) IS_BINOP_MATCHER(Word64Equal) IS_BINOP_MATCHER(Int32AddWithOverflow) IS_BINOP_MATCHER(Int32SubWithOverflow) diff --git a/deps/v8/test/unittests/compiler/node-test-utils.h b/deps/v8/test/unittests/compiler/node-test-utils.h index 683ee2c964..81e471f30f 100644 --- a/deps/v8/test/unittests/compiler/node-test-utils.h +++ b/deps/v8/test/unittests/compiler/node-test-utils.h @@ -358,8 +358,12 @@ Matcher<Node*> IsWord64And(const Matcher<Node*>& lhs_matcher, const Matcher<Node*>& rhs_matcher); Matcher<Node*> IsWord64Or(const Matcher<Node*>& lhs_matcher, const Matcher<Node*>& rhs_matcher); +Matcher<Node*> IsWord64Xor(const Matcher<Node*>& lhs_matcher, + const Matcher<Node*>& rhs_matcher); Matcher<Node*> IsWord64Shl(const Matcher<Node*>& lhs_matcher, const Matcher<Node*>& rhs_matcher); +Matcher<Node*> IsWord64Shr(const Matcher<Node*>& lhs_matcher, + const Matcher<Node*>& rhs_matcher); Matcher<Node*> IsWord64Sar(const Matcher<Node*>& lhs_matcher, const Matcher<Node*>& rhs_matcher); Matcher<Node*> IsWord64Equal(const Matcher<Node*>& lhs_matcher, @@ -473,6 +477,81 @@ Matcher<Node*> IsWord32ReverseBytes(const Matcher<Node*>& value_matcher); Matcher<Node*> IsStackSlot(); +// Helpers +static inline Matcher<Node*> IsIntPtrConstant(const intptr_t value) { + return kPointerSize == 8 ? IsInt64Constant(static_cast<int64_t>(value)) + : IsInt32Constant(static_cast<int32_t>(value)); +} + +static inline Matcher<Node*> IsIntPtrAdd(const Matcher<Node*>& lhs_matcher, + const Matcher<Node*>& rhs_matcher) { + return kPointerSize == 8 ? IsInt64Add(lhs_matcher, rhs_matcher) + : IsInt32Add(lhs_matcher, rhs_matcher); +} + +static inline Matcher<Node*> IsIntPtrSub(const Matcher<Node*>& lhs_matcher, + const Matcher<Node*>& rhs_matcher) { + return kPointerSize == 8 ? IsInt64Sub(lhs_matcher, rhs_matcher) + : IsInt32Sub(lhs_matcher, rhs_matcher); +} + +static inline Matcher<Node*> IsIntPtrMul(const Matcher<Node*>& lhs_matcher, + const Matcher<Node*>& rhs_matcher) { + return kPointerSize == 8 ? IsInt64Mul(lhs_matcher, rhs_matcher) + : IsInt32Mul(lhs_matcher, rhs_matcher); +} + +static inline Matcher<Node*> IsWordShl(const Matcher<Node*>& lhs_matcher, + const Matcher<Node*>& rhs_matcher) { + return kPointerSize == 8 ? IsWord64Shl(lhs_matcher, rhs_matcher) + : IsWord32Shl(lhs_matcher, rhs_matcher); +} + +static inline Matcher<Node*> IsWordShr(const Matcher<Node*>& lhs_matcher, + const Matcher<Node*>& rhs_matcher) { + return kPointerSize == 8 ? IsWord64Shr(lhs_matcher, rhs_matcher) + : IsWord32Shr(lhs_matcher, rhs_matcher); +} + +static inline Matcher<Node*> IsWordSar(const Matcher<Node*>& lhs_matcher, + const Matcher<Node*>& rhs_matcher) { + return kPointerSize == 8 ? IsWord64Sar(lhs_matcher, rhs_matcher) + : IsWord32Sar(lhs_matcher, rhs_matcher); +} + +static inline Matcher<Node*> IsWordAnd(const Matcher<Node*>& lhs_matcher, + const Matcher<Node*>& rhs_matcher) { + return kPointerSize == 8 ? IsWord64And(lhs_matcher, rhs_matcher) + : IsWord32And(lhs_matcher, rhs_matcher); +} + +static inline Matcher<Node*> IsWordOr(const Matcher<Node*>& lhs_matcher, + const Matcher<Node*>& rhs_matcher) { + return kPointerSize == 8 ? IsWord64Or(lhs_matcher, rhs_matcher) + : IsWord32Or(lhs_matcher, rhs_matcher); +} + +static inline Matcher<Node*> IsWordXor(const Matcher<Node*>& lhs_matcher, + const Matcher<Node*>& rhs_matcher) { + return kPointerSize == 8 ? IsWord64Xor(lhs_matcher, rhs_matcher) + : IsWord32Xor(lhs_matcher, rhs_matcher); +} + +static inline Matcher<Node*> IsChangeInt32ToIntPtr( + const Matcher<Node*>& matcher) { + return kPointerSize == 8 ? IsChangeInt32ToInt64(matcher) : matcher; +} + +static inline Matcher<Node*> IsChangeUint32ToWord( + const Matcher<Node*>& matcher) { + return kPointerSize == 8 ? IsChangeUint32ToUint64(matcher) : matcher; +} + +static inline Matcher<Node*> IsTruncateWordToWord32( + const Matcher<Node*>& matcher) { + return kPointerSize == 8 ? IsTruncateInt64ToInt32(matcher) : matcher; +} + } // namespace compiler } // namespace internal } // namespace v8 diff --git a/deps/v8/test/unittests/compiler/ppc/instruction-selector-ppc-unittest.cc b/deps/v8/test/unittests/compiler/ppc/instruction-selector-ppc-unittest.cc index 5fe72eec40..86f7d69ec9 100644 --- a/deps/v8/test/unittests/compiler/ppc/instruction-selector-ppc-unittest.cc +++ b/deps/v8/test/unittests/compiler/ppc/instruction-selector-ppc-unittest.cc @@ -4,6 +4,8 @@ #include "test/unittests/compiler/instruction-selector-unittest.h" +#include "src/assembler-inl.h" + namespace v8 { namespace internal { namespace compiler {} // namespace compiler diff --git a/deps/v8/test/unittests/compiler/regalloc/move-optimizer-unittest.cc b/deps/v8/test/unittests/compiler/regalloc/move-optimizer-unittest.cc index 2dc161b150..0ad114241f 100644 --- a/deps/v8/test/unittests/compiler/regalloc/move-optimizer-unittest.cc +++ b/deps/v8/test/unittests/compiler/regalloc/move-optimizer-unittest.cc @@ -296,7 +296,7 @@ TEST_F(MoveOptimizerTest, GapsCanMoveOverInstruction) { last->GetParallelMove(Instruction::GapPosition::START); CHECK(inst1_start == nullptr || NonRedundantSize(inst1_start) == 0); CHECK(inst1_end == nullptr || NonRedundantSize(inst1_end) == 0); - CHECK(last_start->size() == 2); + CHECK_EQ(2, last_start->size()); int redundants = 0; int assignment = 0; for (MoveOperands* move : *last_start) { diff --git a/deps/v8/test/unittests/compiler/s390/instruction-selector-s390-unittest.cc b/deps/v8/test/unittests/compiler/s390/instruction-selector-s390-unittest.cc index 5fe72eec40..86f7d69ec9 100644 --- a/deps/v8/test/unittests/compiler/s390/instruction-selector-s390-unittest.cc +++ b/deps/v8/test/unittests/compiler/s390/instruction-selector-s390-unittest.cc @@ -4,6 +4,8 @@ #include "test/unittests/compiler/instruction-selector-unittest.h" +#include "src/assembler-inl.h" + namespace v8 { namespace internal { namespace compiler {} // namespace compiler diff --git a/deps/v8/test/unittests/compiler/simplified-operator-reducer-unittest.cc b/deps/v8/test/unittests/compiler/simplified-operator-reducer-unittest.cc index cde85133f3..2e67c0d4df 100644 --- a/deps/v8/test/unittests/compiler/simplified-operator-reducer-unittest.cc +++ b/deps/v8/test/unittests/compiler/simplified-operator-reducer-unittest.cc @@ -19,6 +19,7 @@ using testing::BitEq; namespace v8 { namespace internal { namespace compiler { +namespace simplified_operator_reducer_unittest { class SimplifiedOperatorReducerTest : public GraphTest { public: @@ -498,6 +499,7 @@ TEST_F(SimplifiedOperatorReducerTest, ObjectIsSmiWithNumberConstant) { } } +} // namespace simplified_operator_reducer_unittest } // namespace compiler } // namespace internal } // namespace v8 diff --git a/deps/v8/test/unittests/compiler/typed-optimization-unittest.cc b/deps/v8/test/unittests/compiler/typed-optimization-unittest.cc index 820ef56e60..b527a36c55 100644 --- a/deps/v8/test/unittests/compiler/typed-optimization-unittest.cc +++ b/deps/v8/test/unittests/compiler/typed-optimization-unittest.cc @@ -22,6 +22,7 @@ using testing::IsNaN; namespace v8 { namespace internal { namespace compiler { +namespace typed_optimization_unittest { namespace { @@ -219,6 +220,7 @@ TEST_F(TypedOptimizationTest, JSToBooleanWithNonZeroPlainNumber) { EXPECT_THAT(r.replacement(), IsTrueConstant()); } +} // namespace typed_optimization_unittest } // namespace compiler } // namespace internal } // namespace v8 diff --git a/deps/v8/test/unittests/detachable-vector-unittest.cc b/deps/v8/test/unittests/detachable-vector-unittest.cc new file mode 100644 index 0000000000..f9c846df22 --- /dev/null +++ b/deps/v8/test/unittests/detachable-vector-unittest.cc @@ -0,0 +1,67 @@ +// Copyright 2017 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/detachable-vector.h" + +#include "testing/gtest/include/gtest/gtest.h" + +namespace v8 { +namespace internal { + +TEST(DetachableVector, ConstructIsEmpty) { + DetachableVector<int> v; + + size_t empty_size = 0; + EXPECT_EQ(empty_size, v.size()); + EXPECT_TRUE(v.empty()); +} + +TEST(DetachableVector, PushAddsElement) { + DetachableVector<int> v; + + v.push_back(1); + + EXPECT_EQ(1, v.front()); + EXPECT_EQ(1, v.back()); + EXPECT_EQ(1, v.at(0)); + size_t one_size = 1; + EXPECT_EQ(one_size, v.size()); + EXPECT_FALSE(v.empty()); +} + +TEST(DetachableVector, AfterFreeIsEmpty) { + DetachableVector<int> v; + + v.push_back(1); + v.free(); + + size_t empty_size = 0; + EXPECT_EQ(empty_size, v.size()); + EXPECT_TRUE(v.empty()); +} + +// This test relies on ASAN to detect leaks and double-frees. +TEST(DetachableVector, DetachLeaksBackingStore) { + DetachableVector<int> v; + DetachableVector<int> v2; + + size_t one_size = 1; + EXPECT_TRUE(v2.empty()); + + // Force allocation of the backing store. + v.push_back(1); + // Bit-copy the data structure. + memcpy(&v2, &v, sizeof(DetachableVector<int>)); + // The backing store should be leaked here - free was not called. + v.detach(); + + // We have transferred the backing store to the second vector. + EXPECT_EQ(one_size, v2.size()); + EXPECT_TRUE(v.empty()); + + // The destructor of v2 will release the backing store. +} + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/unittests/eh-frame-iterator-unittest.cc b/deps/v8/test/unittests/eh-frame-iterator-unittest.cc index 1b8adddaee..b228cc9caf 100644 --- a/deps/v8/test/unittests/eh-frame-iterator-unittest.cc +++ b/deps/v8/test/unittests/eh-frame-iterator-unittest.cc @@ -5,12 +5,13 @@ #include "src/eh-frame.h" #include "testing/gtest/include/gtest/gtest.h" +namespace v8 { +namespace internal { + // Test enabled only on supported architectures. #if defined(V8_TARGET_ARCH_X64) || defined(V8_TARGET_ARCH_ARM) || \ defined(V8_TARGET_ARCH_ARM64) -using namespace v8::internal; - namespace { class EhFrameIteratorTest : public testing::Test {}; @@ -59,3 +60,6 @@ TEST_F(EhFrameIteratorTest, SLEB128DecodingNegative) { } #endif + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/unittests/eh-frame-writer-unittest.cc b/deps/v8/test/unittests/eh-frame-writer-unittest.cc index 13b970f448..0213835e9f 100644 --- a/deps/v8/test/unittests/eh-frame-writer-unittest.cc +++ b/deps/v8/test/unittests/eh-frame-writer-unittest.cc @@ -5,12 +5,13 @@ #include "src/eh-frame.h" #include "test/unittests/test-utils.h" +namespace v8 { +namespace internal { + // Test enabled only on supported architectures. #if defined(V8_TARGET_ARCH_X64) || defined(V8_TARGET_ARCH_ARM) || \ defined(V8_TARGET_ARCH_ARM64) -using namespace v8::internal; - namespace { class EhFrameWriterTest : public TestWithZone { @@ -467,3 +468,6 @@ TEST_F(EhFrameWriterTest, EhFrameHdrLayout) { } #endif + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/unittests/heap/barrier-unittest.cc b/deps/v8/test/unittests/heap/barrier-unittest.cc new file mode 100644 index 0000000000..1d42f97a4f --- /dev/null +++ b/deps/v8/test/unittests/heap/barrier-unittest.cc @@ -0,0 +1,145 @@ +// Copyright 2017 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/heap/barrier.h" +#include "src/base/platform/platform.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace v8 { +namespace internal { +namespace heap { + +TEST(OneshotBarrier, InitializeNotDone) { + OneshotBarrier barrier; + EXPECT_FALSE(barrier.DoneForTesting()); +} + +TEST(OneshotBarrier, DoneAfterWait_Sequential) { + OneshotBarrier barrier; + barrier.Start(); + barrier.Wait(); + EXPECT_TRUE(barrier.DoneForTesting()); +} + +namespace { + +class ThreadWaitingOnBarrier final : public base::Thread { + public: + ThreadWaitingOnBarrier() + : base::Thread(Options("ThreadWaitingOnBarrier")), barrier_(nullptr) {} + + void Initialize(OneshotBarrier* barrier) { barrier_ = barrier; } + + void Run() final { barrier_->Wait(); } + + private: + OneshotBarrier* barrier_; +}; + +} // namespace + +TEST(OneshotBarrier, DoneAfterWait_Concurrent) { + const int kThreadCount = 2; + OneshotBarrier barrier; + ThreadWaitingOnBarrier threads[kThreadCount]; + for (int i = 0; i < kThreadCount; i++) { + threads[i].Initialize(&barrier); + // All threads need to call Wait() to be done. + barrier.Start(); + } + for (int i = 0; i < kThreadCount; i++) { + threads[i].Start(); + } + for (int i = 0; i < kThreadCount; i++) { + threads[i].Join(); + } + EXPECT_TRUE(barrier.DoneForTesting()); +} + +TEST(OneshotBarrier, EarlyFinish_Concurrent) { + const int kThreadCount = 2; + OneshotBarrier barrier; + ThreadWaitingOnBarrier threads[kThreadCount]; + // Test that one thread that actually finishes processing work before other + // threads call Start() will move the barrier in Done state. + barrier.Start(); + barrier.Wait(); + EXPECT_TRUE(barrier.DoneForTesting()); + for (int i = 0; i < kThreadCount; i++) { + threads[i].Initialize(&barrier); + // All threads need to call Wait() to be done. + barrier.Start(); + } + for (int i = 0; i < kThreadCount; i++) { + threads[i].Start(); + } + for (int i = 0; i < kThreadCount; i++) { + threads[i].Join(); + } + EXPECT_TRUE(barrier.DoneForTesting()); +} + +namespace { + +class CountingThread final : public base::Thread { + public: + CountingThread(OneshotBarrier* barrier, base::Mutex* mutex, size_t* work) + : base::Thread(Options("CountingThread")), + barrier_(barrier), + mutex_(mutex), + work_(work), + processed_work_(0) {} + + void Run() final { + do { + ProcessWork(); + } while (!barrier_->Wait()); + // Main thread is not processing work, so we need one last step. + ProcessWork(); + } + + size_t processed_work() const { return processed_work_; } + + private: + void ProcessWork() { + base::LockGuard<base::Mutex> guard(mutex_); + processed_work_ += *work_; + *work_ = 0; + } + + OneshotBarrier* const barrier_; + base::Mutex* const mutex_; + size_t* const work_; + size_t processed_work_; +}; + +} // namespace + +TEST(OneshotBarrier, Processing_Concurrent) { + const size_t kWorkCounter = 173173; + OneshotBarrier barrier; + base::Mutex mutex; + size_t work = 0; + CountingThread counting_thread(&barrier, &mutex, &work); + barrier.Start(); + barrier.Start(); + EXPECT_FALSE(barrier.DoneForTesting()); + counting_thread.Start(); + + for (size_t i = 0; i < kWorkCounter; i++) { + { + base::LockGuard<base::Mutex> guard(&mutex); + work++; + } + barrier.NotifyAll(); + } + barrier.Wait(); + counting_thread.Join(); + EXPECT_TRUE(barrier.DoneForTesting()); + EXPECT_EQ(kWorkCounter, counting_thread.processed_work()); +} + +} // namespace heap +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/unittests/heap/heap-unittest.cc b/deps/v8/test/unittests/heap/heap-unittest.cc index 3b7b610c8c..1f2aab06d6 100644 --- a/deps/v8/test/unittests/heap/heap-unittest.cc +++ b/deps/v8/test/unittests/heap/heap-unittest.cc @@ -99,7 +99,7 @@ TEST_F(HeapTest, ASLR) { } if (hints.size() == 1) { EXPECT_TRUE((*hints.begin()) == nullptr); - EXPECT_TRUE(base::OS::GetRandomMmapAddr() == nullptr); + EXPECT_TRUE(v8::internal::GetRandomMmapAddr() == nullptr); } else { // It is unlikely that 1000 random samples will collide to less then 500 // values. diff --git a/deps/v8/test/unittests/heap/marking-unittest.cc b/deps/v8/test/unittests/heap/marking-unittest.cc index 073105f494..9dd432c175 100644 --- a/deps/v8/test/unittests/heap/marking-unittest.cc +++ b/deps/v8/test/unittests/heap/marking-unittest.cc @@ -32,7 +32,7 @@ TEST(Marking, TransitionWhiteBlackWhite) { free(bitmap); } -TEST(Marking, TransitionWhiteGreyBlackGrey) { +TEST(Marking, TransitionWhiteGreyBlack) { Bitmap* bitmap = reinterpret_cast<Bitmap*>( calloc(Bitmap::kSize / kPointerSize, kPointerSize)); const int kLocationsSize = 3; @@ -51,10 +51,6 @@ TEST(Marking, TransitionWhiteGreyBlackGrey) { CHECK(Marking::IsBlack(mark_bit)); CHECK(Marking::IsBlackOrGrey(mark_bit)); CHECK(!Marking::IsImpossible(mark_bit)); - Marking::BlackToGrey(mark_bit); - CHECK(Marking::IsGrey(mark_bit)); - CHECK(Marking::IsBlackOrGrey(mark_bit)); - CHECK(!Marking::IsImpossible(mark_bit)); Marking::MarkWhite(mark_bit); CHECK(Marking::IsWhite(mark_bit)); CHECK(!Marking::IsImpossible(mark_bit)); diff --git a/deps/v8/test/unittests/heap/worklist-unittest.cc b/deps/v8/test/unittests/heap/worklist-unittest.cc index 1a16ac60c0..49423dbe77 100644 --- a/deps/v8/test/unittests/heap/worklist-unittest.cc +++ b/deps/v8/test/unittests/heap/worklist-unittest.cc @@ -301,5 +301,31 @@ TEST(WorkListTest, MultipleSegmentsStolen) { EXPECT_TRUE(worklist.IsGlobalEmpty()); } +TEST(WorkListTest, MergeGlobalPool) { + TestWorklist worklist1; + TestWorklist::View worklist_view1(&worklist1, 0); + SomeObject dummy; + for (size_t i = 0; i < TestWorklist::kSegmentCapacity; i++) { + EXPECT_TRUE(worklist_view1.Push(&dummy)); + } + SomeObject* retrieved = nullptr; + // One more push/pop to publish the full segment. + EXPECT_TRUE(worklist_view1.Push(nullptr)); + EXPECT_TRUE(worklist_view1.Pop(&retrieved)); + EXPECT_EQ(nullptr, retrieved); + // Merging global pool into a new Worklist. + TestWorklist worklist2; + TestWorklist::View worklist_view2(&worklist2, 0); + worklist2.MergeGlobalPool(&worklist1); + EXPECT_FALSE(worklist2.IsGlobalEmpty()); + for (size_t i = 0; i < TestWorklist::kSegmentCapacity; i++) { + EXPECT_TRUE(worklist_view2.Pop(&retrieved)); + EXPECT_EQ(&dummy, retrieved); + EXPECT_FALSE(worklist_view1.Pop(&retrieved)); + } + EXPECT_TRUE(worklist1.IsGlobalEmpty()); + EXPECT_TRUE(worklist2.IsGlobalEmpty()); +} + } // namespace internal } // namespace v8 diff --git a/deps/v8/test/unittests/interpreter/bytecode-array-builder-unittest.cc b/deps/v8/test/unittests/interpreter/bytecode-array-builder-unittest.cc index fa93cb3f9e..5cdce7fc00 100644 --- a/deps/v8/test/unittests/interpreter/bytecode-array-builder-unittest.cc +++ b/deps/v8/test/unittests/interpreter/bytecode-array-builder-unittest.cc @@ -145,6 +145,9 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { builder.CreateArrayLiteral(0, 0, 0); builder.CreateObjectLiteral(0, 0, 0, reg); + // Emit tagged template operations. + builder.GetTemplateObject(0); + // Call operations. builder.CallAnyReceiver(reg, reg_list, 1) .CallProperty(reg, reg_list, 1) @@ -190,9 +193,12 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { .BinaryOperationSmiLiteral(Token::Value::SAR, Smi::FromInt(42), 2) .BinaryOperationSmiLiteral(Token::Value::SHR, Smi::FromInt(42), 2); - // Emit count operatior invocations - builder.CountOperation(Token::Value::ADD, 1) - .CountOperation(Token::Value::SUB, 1); + // Emit unary and count operator invocations. + builder.UnaryOperation(Token::Value::INC, 1) + .UnaryOperation(Token::Value::DEC, 1) + .UnaryOperation(Token::Value::ADD, 1) + .UnaryOperation(Token::Value::SUB, 1) + .UnaryOperation(Token::Value::BIT_NOT, 1); // Emit unary operator invocations. builder.LogicalNot(ToBooleanMode::kConvertToBoolean) @@ -221,7 +227,7 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { .CompareNull(); // Emit conversion operator invocations. - builder.ToNumber(reg, 1).ToObject(reg).ToName(reg); + builder.ToNumber(1).ToObject(reg).ToName(reg); // Emit GetSuperConstructor. builder.GetSuperConstructor(reg); @@ -295,7 +301,8 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { BytecodeLabel after_rethrow; builder.ReThrow().Bind(&after_rethrow); - builder.ForInPrepare(reg, triple) + builder.ForInEnumerate(reg) + .ForInPrepare(triple, 1) .ForInContinue(reg, reg) .ForInNext(reg, reg, pair, 1) .ForInStep(reg); @@ -374,6 +381,12 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { // Emit debugger bytecode. builder.Debugger(); + // Emit abort bytecode. + { + BytecodeLabel after; + builder.Abort(kGenerator).Bind(&after); + } + // Insert dummy ops to force longer jumps. for (int i = 0; i < 256; i++) { builder.Debugger(); @@ -420,11 +433,9 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { // Insert entry for illegal bytecode as this is never willingly emitted. scorecard[Bytecodes::ToByte(Bytecode::kIllegal)] = 1; - if (!FLAG_type_profile) { - // Bytecode for CollectTypeProfile is only emitted when - // Type Information for DevTools is turned on. - scorecard[Bytecodes::ToByte(Bytecode::kCollectTypeProfile)] = 1; - } + // Bytecode for CollectTypeProfile is only emitted when + // Type Information for DevTools is turned on. + scorecard[Bytecodes::ToByte(Bytecode::kCollectTypeProfile)] = 1; // Check return occurs at the end and only once in the BytecodeArray. CHECK_EQ(final_bytecode, Bytecode::kReturn); diff --git a/deps/v8/test/unittests/interpreter/bytecode-array-iterator-unittest.cc b/deps/v8/test/unittests/interpreter/bytecode-array-iterator-unittest.cc index 2befb103d6..aefef108bf 100644 --- a/deps/v8/test/unittests/interpreter/bytecode-array-iterator-unittest.cc +++ b/deps/v8/test/unittests/interpreter/bytecode-array-iterator-unittest.cc @@ -58,7 +58,7 @@ TEST_F(BytecodeArrayIteratorTest, IteratesBytecodeArray) { .BinaryOperation(Token::Value::ADD, reg_0, 3) .StoreAccumulatorInRegister(param) .CallRuntimeForPair(Runtime::kLoadLookupSlotForCall, param, pair) - .ForInPrepare(reg_0, triple) + .ForInPrepare(triple, feedback_slot) .CallRuntime(Runtime::kLoadIC_Miss, reg_0) .Debugger() .LoadGlobal(name, 0x10000000, TypeofMode::NOT_INSIDE_TYPEOF) @@ -70,217 +70,216 @@ TEST_F(BytecodeArrayIteratorTest, IteratesBytecodeArray) { const int kPrefixByteSize = 1; int offset = 0; - CHECK_EQ(iterator.current_bytecode(), Bytecode::kLdaConstant); - CHECK_EQ(iterator.current_offset(), offset); - CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); + EXPECT_EQ(iterator.current_bytecode(), Bytecode::kLdaConstant); + EXPECT_EQ(iterator.current_offset(), offset); + EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); CHECK(iterator.GetConstantForIndexOperand(0).is_identical_to( heap_num_0->value())); CHECK(!iterator.done()); offset += Bytecodes::Size(Bytecode::kLdaConstant, OperandScale::kSingle); iterator.Advance(); - CHECK_EQ(iterator.current_bytecode(), Bytecode::kStar); - CHECK_EQ(iterator.current_offset(), offset); - CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); - CHECK_EQ(iterator.GetRegisterOperand(0).index(), reg_0.index()); - CHECK_EQ(iterator.GetRegisterOperandRange(0), 1); + EXPECT_EQ(iterator.current_bytecode(), Bytecode::kStar); + EXPECT_EQ(iterator.current_offset(), offset); + EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); + EXPECT_EQ(iterator.GetRegisterOperand(0).index(), reg_0.index()); + EXPECT_EQ(iterator.GetRegisterOperandRange(0), 1); CHECK(!iterator.done()); offset += Bytecodes::Size(Bytecode::kStar, OperandScale::kSingle); iterator.Advance(); - CHECK_EQ(iterator.current_bytecode(), Bytecode::kLdaConstant); - CHECK_EQ(iterator.current_offset(), offset); - CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); + EXPECT_EQ(iterator.current_bytecode(), Bytecode::kLdaConstant); + EXPECT_EQ(iterator.current_offset(), offset); + EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); CHECK(iterator.GetConstantForIndexOperand(0).is_identical_to( heap_num_1->value())); CHECK(!iterator.done()); offset += Bytecodes::Size(Bytecode::kLdaConstant, OperandScale::kSingle); iterator.Advance(); - CHECK_EQ(iterator.current_bytecode(), Bytecode::kStar); - CHECK_EQ(iterator.current_offset(), offset); - CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); - CHECK_EQ(iterator.GetRegisterOperand(0).index(), reg_0.index()); - CHECK_EQ(iterator.GetRegisterOperandRange(0), 1); + EXPECT_EQ(iterator.current_bytecode(), Bytecode::kStar); + EXPECT_EQ(iterator.current_offset(), offset); + EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); + EXPECT_EQ(iterator.GetRegisterOperand(0).index(), reg_0.index()); + EXPECT_EQ(iterator.GetRegisterOperandRange(0), 1); CHECK(!iterator.done()); offset += Bytecodes::Size(Bytecode::kStar, OperandScale::kSingle); iterator.Advance(); - CHECK_EQ(iterator.current_bytecode(), Bytecode::kLdaZero); - CHECK_EQ(iterator.current_offset(), offset); - CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); + EXPECT_EQ(iterator.current_bytecode(), Bytecode::kLdaZero); + EXPECT_EQ(iterator.current_offset(), offset); + EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); CHECK(!iterator.done()); offset += Bytecodes::Size(Bytecode::kLdaZero, OperandScale::kSingle); iterator.Advance(); - CHECK_EQ(iterator.current_bytecode(), Bytecode::kStar); - CHECK_EQ(iterator.current_offset(), offset); - CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); - CHECK_EQ(iterator.GetRegisterOperand(0).index(), reg_0.index()); - CHECK_EQ(iterator.GetRegisterOperandRange(0), 1); + EXPECT_EQ(iterator.current_bytecode(), Bytecode::kStar); + EXPECT_EQ(iterator.current_offset(), offset); + EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); + EXPECT_EQ(iterator.GetRegisterOperand(0).index(), reg_0.index()); + EXPECT_EQ(iterator.GetRegisterOperandRange(0), 1); CHECK(!iterator.done()); offset += Bytecodes::Size(Bytecode::kStar, OperandScale::kSingle); iterator.Advance(); - CHECK_EQ(iterator.current_bytecode(), Bytecode::kLdaSmi); - CHECK_EQ(iterator.current_offset(), offset); - CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); - CHECK_EQ(Smi::FromInt(iterator.GetImmediateOperand(0)), smi_0); + EXPECT_EQ(iterator.current_bytecode(), Bytecode::kLdaSmi); + EXPECT_EQ(iterator.current_offset(), offset); + EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); + EXPECT_EQ(Smi::FromInt(iterator.GetImmediateOperand(0)), smi_0); CHECK(!iterator.done()); offset += Bytecodes::Size(Bytecode::kLdaSmi, OperandScale::kSingle); iterator.Advance(); - CHECK_EQ(iterator.current_bytecode(), Bytecode::kStackCheck); - CHECK_EQ(iterator.current_offset(), offset); - CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); - CHECK_EQ(Bytecodes::NumberOfOperands(iterator.current_bytecode()), 0); + EXPECT_EQ(iterator.current_bytecode(), Bytecode::kStackCheck); + EXPECT_EQ(iterator.current_offset(), offset); + EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); + EXPECT_EQ(Bytecodes::NumberOfOperands(iterator.current_bytecode()), 0); CHECK(!iterator.done()); offset += Bytecodes::Size(Bytecode::kStackCheck, OperandScale::kSingle); iterator.Advance(); - CHECK_EQ(iterator.current_bytecode(), Bytecode::kStar); - CHECK_EQ(iterator.current_offset(), offset); - CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); - CHECK_EQ(iterator.GetRegisterOperand(0).index(), reg_0.index()); - CHECK_EQ(iterator.GetRegisterOperandRange(0), 1); + EXPECT_EQ(iterator.current_bytecode(), Bytecode::kStar); + EXPECT_EQ(iterator.current_offset(), offset); + EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); + EXPECT_EQ(iterator.GetRegisterOperand(0).index(), reg_0.index()); + EXPECT_EQ(iterator.GetRegisterOperandRange(0), 1); CHECK(!iterator.done()); offset += Bytecodes::Size(Bytecode::kStar, OperandScale::kSingle); iterator.Advance(); - CHECK_EQ(iterator.current_bytecode(), Bytecode::kLdaSmi); - CHECK_EQ(iterator.current_offset(), offset); - CHECK_EQ(iterator.current_operand_scale(), OperandScale::kQuadruple); - CHECK_EQ(Smi::FromInt(iterator.GetImmediateOperand(0)), smi_1); + EXPECT_EQ(iterator.current_bytecode(), Bytecode::kLdaSmi); + EXPECT_EQ(iterator.current_offset(), offset); + EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kQuadruple); + EXPECT_EQ(Smi::FromInt(iterator.GetImmediateOperand(0)), smi_1); CHECK(!iterator.done()); offset += Bytecodes::Size(Bytecode::kLdaSmi, OperandScale::kQuadruple) + kPrefixByteSize; iterator.Advance(); - CHECK_EQ(iterator.current_bytecode(), Bytecode::kStackCheck); - CHECK_EQ(iterator.current_offset(), offset); - CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); - CHECK_EQ(Bytecodes::NumberOfOperands(iterator.current_bytecode()), 0); + EXPECT_EQ(iterator.current_bytecode(), Bytecode::kStackCheck); + EXPECT_EQ(iterator.current_offset(), offset); + EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); + EXPECT_EQ(Bytecodes::NumberOfOperands(iterator.current_bytecode()), 0); CHECK(!iterator.done()); offset += Bytecodes::Size(Bytecode::kStackCheck, OperandScale::kSingle); iterator.Advance(); - CHECK_EQ(iterator.current_bytecode(), Bytecode::kStar); - CHECK_EQ(iterator.current_offset(), offset); - CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); - CHECK_EQ(iterator.GetRegisterOperand(0).index(), reg_1.index()); - CHECK_EQ(iterator.GetRegisterOperandRange(0), 1); + EXPECT_EQ(iterator.current_bytecode(), Bytecode::kStar); + EXPECT_EQ(iterator.current_offset(), offset); + EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); + EXPECT_EQ(iterator.GetRegisterOperand(0).index(), reg_1.index()); + EXPECT_EQ(iterator.GetRegisterOperandRange(0), 1); CHECK(!iterator.done()); offset += Bytecodes::Size(Bytecode::kStar, OperandScale::kSingle); iterator.Advance(); - CHECK_EQ(iterator.current_bytecode(), Bytecode::kLdar); - CHECK_EQ(iterator.current_offset(), offset); - CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); - CHECK_EQ(iterator.GetRegisterOperand(0).index(), reg_0.index()); + EXPECT_EQ(iterator.current_bytecode(), Bytecode::kLdar); + EXPECT_EQ(iterator.current_offset(), offset); + EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); + EXPECT_EQ(iterator.GetRegisterOperand(0).index(), reg_0.index()); CHECK(!iterator.done()); offset += Bytecodes::Size(Bytecode::kLdar, OperandScale::kSingle); iterator.Advance(); - CHECK_EQ(iterator.current_bytecode(), Bytecode::kAdd); - CHECK_EQ(iterator.current_offset(), offset); - CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); - CHECK_EQ(iterator.GetRegisterOperand(0).index(), reg_0.index()); - CHECK_EQ(iterator.GetRegisterOperandRange(0), 1); + EXPECT_EQ(iterator.current_bytecode(), Bytecode::kAdd); + EXPECT_EQ(iterator.current_offset(), offset); + EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); + EXPECT_EQ(iterator.GetRegisterOperand(0).index(), reg_0.index()); + EXPECT_EQ(iterator.GetRegisterOperandRange(0), 1); CHECK(!iterator.done()); offset += Bytecodes::Size(Bytecode::kAdd, OperandScale::kSingle); iterator.Advance(); - CHECK_EQ(iterator.current_bytecode(), Bytecode::kStar); - CHECK_EQ(iterator.current_offset(), offset); - CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); - CHECK_EQ(iterator.GetRegisterOperand(0).index(), reg_1.index()); - CHECK_EQ(iterator.GetRegisterOperandRange(0), 1); + EXPECT_EQ(iterator.current_bytecode(), Bytecode::kStar); + EXPECT_EQ(iterator.current_offset(), offset); + EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); + EXPECT_EQ(iterator.GetRegisterOperand(0).index(), reg_1.index()); + EXPECT_EQ(iterator.GetRegisterOperandRange(0), 1); CHECK(!iterator.done()); offset += Bytecodes::Size(Bytecode::kStar, OperandScale::kSingle); iterator.Advance(); - CHECK_EQ(iterator.current_bytecode(), Bytecode::kLdaNamedProperty); - CHECK_EQ(iterator.current_offset(), offset); - CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); - CHECK_EQ(iterator.GetRegisterOperand(0).index(), reg_1.index()); - CHECK_EQ(iterator.GetIndexOperand(1), name_index); - CHECK_EQ(iterator.GetIndexOperand(2), feedback_slot); + EXPECT_EQ(iterator.current_bytecode(), Bytecode::kLdaNamedProperty); + EXPECT_EQ(iterator.current_offset(), offset); + EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); + EXPECT_EQ(iterator.GetRegisterOperand(0).index(), reg_1.index()); + EXPECT_EQ(iterator.GetIndexOperand(1), name_index); + EXPECT_EQ(iterator.GetIndexOperand(2), feedback_slot); CHECK(!iterator.done()); offset += Bytecodes::Size(Bytecode::kLdaNamedProperty, OperandScale::kSingle); iterator.Advance(); - CHECK_EQ(iterator.current_bytecode(), Bytecode::kAdd); - CHECK_EQ(iterator.current_offset(), offset); - CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); - CHECK_EQ(iterator.GetRegisterOperand(0).index(), reg_0.index()); - CHECK_EQ(iterator.GetRegisterOperandRange(0), 1); + EXPECT_EQ(iterator.current_bytecode(), Bytecode::kAdd); + EXPECT_EQ(iterator.current_offset(), offset); + EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); + EXPECT_EQ(iterator.GetRegisterOperand(0).index(), reg_0.index()); + EXPECT_EQ(iterator.GetRegisterOperandRange(0), 1); CHECK(!iterator.done()); offset += Bytecodes::Size(Bytecode::kAdd, OperandScale::kSingle); iterator.Advance(); - CHECK_EQ(iterator.current_bytecode(), Bytecode::kStar); - CHECK_EQ(iterator.current_offset(), offset); - CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); - CHECK_EQ(iterator.GetRegisterOperand(0).index(), param.index()); - CHECK_EQ(iterator.GetRegisterOperandRange(0), 1); + EXPECT_EQ(iterator.current_bytecode(), Bytecode::kStar); + EXPECT_EQ(iterator.current_offset(), offset); + EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); + EXPECT_EQ(iterator.GetRegisterOperand(0).index(), param.index()); + EXPECT_EQ(iterator.GetRegisterOperandRange(0), 1); CHECK(!iterator.done()); offset += Bytecodes::Size(Bytecode::kStar, OperandScale::kSingle); iterator.Advance(); - CHECK_EQ(iterator.current_bytecode(), Bytecode::kCallRuntimeForPair); - CHECK_EQ(iterator.current_offset(), offset); - CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); - CHECK_EQ(iterator.GetRuntimeIdOperand(0), Runtime::kLoadLookupSlotForCall); - CHECK_EQ(iterator.GetRegisterOperand(1).index(), param.index()); - CHECK_EQ(iterator.GetRegisterOperandRange(1), 1); - CHECK_EQ(iterator.GetRegisterCountOperand(2), 1u); - CHECK_EQ(iterator.GetRegisterOperand(3).index(), reg_0.index()); - CHECK_EQ(iterator.GetRegisterOperandRange(3), 2); + EXPECT_EQ(iterator.current_bytecode(), Bytecode::kCallRuntimeForPair); + EXPECT_EQ(iterator.current_offset(), offset); + EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); + EXPECT_EQ(iterator.GetRuntimeIdOperand(0), Runtime::kLoadLookupSlotForCall); + EXPECT_EQ(iterator.GetRegisterOperand(1).index(), param.index()); + EXPECT_EQ(iterator.GetRegisterOperandRange(1), 1); + EXPECT_EQ(iterator.GetRegisterCountOperand(2), 1u); + EXPECT_EQ(iterator.GetRegisterOperand(3).index(), reg_0.index()); + EXPECT_EQ(iterator.GetRegisterOperandRange(3), 2); CHECK(!iterator.done()); offset += Bytecodes::Size(Bytecode::kCallRuntimeForPair, OperandScale::kSingle); iterator.Advance(); - CHECK_EQ(iterator.current_bytecode(), Bytecode::kForInPrepare); - CHECK_EQ(iterator.current_offset(), offset); - CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); - CHECK_EQ(iterator.GetRegisterOperand(0).index(), reg_0.index()); - CHECK_EQ(iterator.GetRegisterOperandRange(0), 1); - CHECK_EQ(iterator.GetRegisterOperand(1).index(), reg_0.index()); - CHECK_EQ(iterator.GetRegisterOperandRange(1), 3); + EXPECT_EQ(iterator.current_bytecode(), Bytecode::kForInPrepare); + EXPECT_EQ(iterator.current_offset(), offset); + EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); + EXPECT_EQ(iterator.GetRegisterOperand(0).index(), reg_0.index()); + EXPECT_EQ(iterator.GetRegisterOperandRange(0), 3); + EXPECT_EQ(iterator.GetIndexOperand(1), feedback_slot); CHECK(!iterator.done()); offset += Bytecodes::Size(Bytecode::kForInPrepare, OperandScale::kSingle); iterator.Advance(); - CHECK_EQ(iterator.current_bytecode(), Bytecode::kCallRuntime); - CHECK_EQ(iterator.current_offset(), offset); - CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); - CHECK_EQ(iterator.GetRuntimeIdOperand(0), Runtime::kLoadIC_Miss); - CHECK_EQ(iterator.GetRegisterOperand(1).index(), reg_0.index()); - CHECK_EQ(iterator.GetRegisterCountOperand(2), 1u); + EXPECT_EQ(iterator.current_bytecode(), Bytecode::kCallRuntime); + EXPECT_EQ(iterator.current_offset(), offset); + EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); + EXPECT_EQ(iterator.GetRuntimeIdOperand(0), Runtime::kLoadIC_Miss); + EXPECT_EQ(iterator.GetRegisterOperand(1).index(), reg_0.index()); + EXPECT_EQ(iterator.GetRegisterCountOperand(2), 1u); CHECK(!iterator.done()); offset += Bytecodes::Size(Bytecode::kCallRuntime, OperandScale::kSingle); iterator.Advance(); - CHECK_EQ(iterator.current_bytecode(), Bytecode::kDebugger); - CHECK_EQ(iterator.current_offset(), offset); - CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); + EXPECT_EQ(iterator.current_bytecode(), Bytecode::kDebugger); + EXPECT_EQ(iterator.current_offset(), offset); + EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); CHECK(!iterator.done()); offset += Bytecodes::Size(Bytecode::kDebugger, OperandScale::kSingle); iterator.Advance(); - CHECK_EQ(iterator.current_bytecode(), Bytecode::kLdaGlobal); - CHECK_EQ(iterator.current_offset(), offset); - CHECK_EQ(iterator.current_operand_scale(), OperandScale::kQuadruple); - CHECK_EQ(iterator.current_bytecode_size(), 10); - CHECK_EQ(iterator.GetIndexOperand(1), 0x10000000u); + EXPECT_EQ(iterator.current_bytecode(), Bytecode::kLdaGlobal); + EXPECT_EQ(iterator.current_offset(), offset); + EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kQuadruple); + EXPECT_EQ(iterator.current_bytecode_size(), 10); + EXPECT_EQ(iterator.GetIndexOperand(1), 0x10000000u); offset += Bytecodes::Size(Bytecode::kLdaGlobal, OperandScale::kQuadruple) + kPrefixByteSize; iterator.Advance(); - CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); - CHECK_EQ(iterator.current_offset(), offset); - CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); + EXPECT_EQ(iterator.current_bytecode(), Bytecode::kReturn); + EXPECT_EQ(iterator.current_offset(), offset); + EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); CHECK(!iterator.done()); iterator.Advance(); CHECK(iterator.done()); diff --git a/deps/v8/test/unittests/interpreter/bytecode-array-random-iterator-unittest.cc b/deps/v8/test/unittests/interpreter/bytecode-array-random-iterator-unittest.cc index 294adf711f..7d9bcd09c0 100644 --- a/deps/v8/test/unittests/interpreter/bytecode-array-random-iterator-unittest.cc +++ b/deps/v8/test/unittests/interpreter/bytecode-array-random-iterator-unittest.cc @@ -57,7 +57,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, InvalidBeforeStart) { .BinaryOperation(Token::Value::ADD, reg_0, 3) .StoreAccumulatorInRegister(param) .CallRuntimeForPair(Runtime::kLoadLookupSlotForCall, param, pair) - .ForInPrepare(reg_0, triple) + .ForInPrepare(triple, feedback_slot) .CallRuntime(Runtime::kLoadIC_Miss, reg_0) .Debugger() .LoadGlobal(name, 0x10000000, TypeofMode::NOT_INSIDE_TYPEOF) @@ -111,7 +111,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, InvalidAfterEnd) { .BinaryOperation(Token::Value::ADD, reg_0, 3) .StoreAccumulatorInRegister(param) .CallRuntimeForPair(Runtime::kLoadLookupSlotForCall, param, pair) - .ForInPrepare(reg_0, triple) + .ForInPrepare(triple, feedback_slot) .CallRuntime(Runtime::kLoadIC_Miss, reg_0) .Debugger() .LoadGlobal(name, 0x10000000, TypeofMode::NOT_INSIDE_TYPEOF) @@ -165,7 +165,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, AccessesFirst) { .BinaryOperation(Token::Value::ADD, reg_0, 3) .StoreAccumulatorInRegister(param) .CallRuntimeForPair(Runtime::kLoadLookupSlotForCall, param, pair) - .ForInPrepare(reg_0, triple) + .ForInPrepare(triple, feedback_slot) .CallRuntime(Runtime::kLoadIC_Miss, reg_0) .Debugger() .LoadGlobal(name, 0x10000000, TypeofMode::NOT_INSIDE_TYPEOF) @@ -224,7 +224,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, AccessesLast) { .BinaryOperation(Token::Value::ADD, reg_0, 3) .StoreAccumulatorInRegister(param) .CallRuntimeForPair(Runtime::kLoadLookupSlotForCall, param, pair) - .ForInPrepare(reg_0, triple) + .ForInPrepare(triple, feedback_slot) .CallRuntime(Runtime::kLoadIC_Miss, reg_0) .Debugger() .LoadGlobal(name, 0x10000000, TypeofMode::NOT_INSIDE_TYPEOF) @@ -284,7 +284,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, RandomAccessValid) { .BinaryOperation(Token::Value::ADD, reg_0, 3) .StoreAccumulatorInRegister(param) .CallRuntimeForPair(Runtime::kLoadLookupSlotForCall, param, pair) - .ForInPrepare(reg_0, triple) + .ForInPrepare(triple, feedback_slot) .CallRuntime(Runtime::kLoadIC_Miss, reg_0) .Debugger() .LoadGlobal(name, 0x10000000, TypeofMode::NOT_INSIDE_TYPEOF) @@ -472,7 +472,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, IteratesBytecodeArray) { .BinaryOperation(Token::Value::ADD, reg_0, 3) .StoreAccumulatorInRegister(param) .CallRuntimeForPair(Runtime::kLoadLookupSlotForCall, param, pair) - .ForInPrepare(reg_0, triple) + .ForInPrepare(triple, feedback_slot) .CallRuntime(Runtime::kLoadIC_Miss, reg_0) .Debugger() .LoadGlobal(name, 0x10000000, TypeofMode::NOT_INSIDE_TYPEOF) @@ -680,9 +680,8 @@ TEST_F(BytecodeArrayRandomIteratorTest, IteratesBytecodeArray) { EXPECT_EQ(iterator.current_offset(), offset); EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); EXPECT_EQ(iterator.GetRegisterOperand(0).index(), reg_0.index()); - EXPECT_EQ(iterator.GetRegisterOperandRange(0), 1); - EXPECT_EQ(iterator.GetRegisterOperand(1).index(), reg_0.index()); - EXPECT_EQ(iterator.GetRegisterOperandRange(1), 3); + EXPECT_EQ(iterator.GetRegisterOperandRange(0), 3); + EXPECT_EQ(iterator.GetIndexOperand(1), feedback_slot); ASSERT_TRUE(iterator.IsValid()); offset += Bytecodes::Size(Bytecode::kForInPrepare, OperandScale::kSingle); ++iterator; @@ -764,7 +763,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, IteratesBytecodeArrayBackwards) { .BinaryOperation(Token::Value::ADD, reg_0, 3) .StoreAccumulatorInRegister(param) .CallRuntimeForPair(Runtime::kLoadLookupSlotForCall, param, pair) - .ForInPrepare(reg_0, triple) + .ForInPrepare(triple, feedback_slot) .CallRuntime(Runtime::kLoadIC_Miss, reg_0) .Debugger() .LoadGlobal(name, 0x10000000, TypeofMode::NOT_INSIDE_TYPEOF) @@ -822,9 +821,8 @@ TEST_F(BytecodeArrayRandomIteratorTest, IteratesBytecodeArrayBackwards) { EXPECT_EQ(iterator.current_offset(), offset); EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); EXPECT_EQ(iterator.GetRegisterOperand(0).index(), reg_0.index()); - EXPECT_EQ(iterator.GetRegisterOperandRange(0), 1); - EXPECT_EQ(iterator.GetRegisterOperand(1).index(), reg_0.index()); - EXPECT_EQ(iterator.GetRegisterOperandRange(1), 3); + EXPECT_EQ(iterator.GetRegisterOperandRange(0), 3); + EXPECT_EQ(iterator.GetIndexOperand(1), feedback_slot); ASSERT_TRUE(iterator.IsValid()); --iterator; diff --git a/deps/v8/test/unittests/interpreter/bytecode-array-writer-unittest.cc b/deps/v8/test/unittests/interpreter/bytecode-array-writer-unittest.cc index 680d8197b2..bd8f702d5f 100644 --- a/deps/v8/test/unittests/interpreter/bytecode-array-writer-unittest.cc +++ b/deps/v8/test/unittests/interpreter/bytecode-array-writer-unittest.cc @@ -169,7 +169,7 @@ TEST_F(BytecodeArrayWriterUnittest, ComplexExample) { /* 5 68 S> */ B(JumpIfUndefined), U8(39), /* 7 */ B(JumpIfNull), U8(37), /* 9 */ B(ToObject), R8(3), - /* 11 */ B(ForInPrepare), R8(3), R8(4), + /* 11 */ B(ForInPrepare), R8(3), U8(4), /* 14 */ B(LdaZero), /* 15 */ B(Star), R8(7), /* 17 63 S> */ B(ForInContinue), R8(7), R8(6), @@ -201,7 +201,7 @@ TEST_F(BytecodeArrayWriterUnittest, ComplexExample) { WriteJump(Bytecode::kJumpIfUndefined, &jump_end_1, {68, true}); WriteJump(Bytecode::kJumpIfNull, &jump_end_2); Write(Bytecode::kToObject, R(3)); - Write(Bytecode::kForInPrepare, R(3), R(4)); + Write(Bytecode::kForInPrepare, R(3), U8(4)); Write(Bytecode::kLdaZero); Write(Bytecode::kStar, R(7)); writer()->BindLabel(&back_jump); diff --git a/deps/v8/test/unittests/interpreter/bytecode-decoder-unittest.cc b/deps/v8/test/unittests/interpreter/bytecode-decoder-unittest.cc index f9c0877664..612b96e32c 100644 --- a/deps/v8/test/unittests/interpreter/bytecode-decoder-unittest.cc +++ b/deps/v8/test/unittests/interpreter/bytecode-decoder-unittest.cc @@ -6,6 +6,7 @@ #include "src/v8.h" +#include "src/contexts.h" #include "src/interpreter/bytecode-decoder.h" #include "src/runtime/runtime.h" #include "test/unittests/interpreter/bytecode-utils.h" @@ -42,10 +43,10 @@ TEST(BytecodeDecoder, DecodeBytecodeAndOperands) { 10, 0, "CallAnyReceiver.Wide r134, r135-r144, [177]"}, - {{B(ForInPrepare), R8(10), R8(11)}, + {{B(ForInPrepare), R8(10), U8(11)}, 3, 0, - " ForInPrepare r10, r11-r13"}, + " ForInPrepare r10-r12, [11]"}, {{B(CallRuntime), U16(Runtime::FunctionId::kIsDate), R8(0), U8(0)}, 5, 0, @@ -64,7 +65,10 @@ TEST(BytecodeDecoder, DecodeBytecodeAndOperands) { 6, 0, "JumpIfNull.ExtraWide [123456789]"}, - }; + {{B(CallJSRuntime), U8(Context::BOOLEAN_FUNCTION_INDEX), R8(0), U8(0)}, + 4, + 0, + " CallJSRuntime [boolean_function], r0-r0"}}; for (size_t i = 0; i < arraysize(cases); ++i) { // Generate reference string by prepending formatted bytes. diff --git a/deps/v8/test/unittests/interpreter/interpreter-assembler-unittest.cc b/deps/v8/test/unittests/interpreter/interpreter-assembler-unittest.cc index d06b5987e5..2c3f182395 100644 --- a/deps/v8/test/unittests/interpreter/interpreter-assembler-unittest.cc +++ b/deps/v8/test/unittests/interpreter/interpreter-assembler-unittest.cc @@ -13,20 +13,12 @@ #include "test/unittests/compiler/node-test-utils.h" using ::testing::_; +using v8::internal::compiler::Node; + +namespace c = v8::internal::compiler; namespace v8 { namespace internal { - -using namespace compiler; - -#ifdef ENABLE_VERIFY_CSA -#define IS_BITCAST_WORD_TO_TAGGED_SIGNED(x) IsBitcastWordToTaggedSigned(x) -#define IS_BITCAST_TAGGED_TO_WORD(x) IsBitcastTaggedToWord(x) -#else -#define IS_BITCAST_WORD_TO_TAGGED_SIGNED(x) (x) -#define IS_BITCAST_TAGGED_TO_WORD(x) (x) -#endif - namespace interpreter { InterpreterAssemblerTestState::InterpreterAssemblerTestState( @@ -34,8 +26,8 @@ InterpreterAssemblerTestState::InterpreterAssemblerTestState( : compiler::CodeAssemblerState( test->isolate(), test->zone(), InterpreterDispatchDescriptor(test->isolate()), - Code::ComputeFlags(Code::BYTECODE_HANDLER), - Bytecodes::ToString(bytecode), Bytecodes::ReturnCount(bytecode)) {} + Code::BYTECODE_HANDLER, Bytecodes::ToString(bytecode), + Bytecodes::ReturnCount(bytecode)) {} const interpreter::Bytecode kBytecodes[] = { #define DEFINE_BYTECODE(Name, ...) interpreter::Bytecode::k##Name, @@ -43,58 +35,6 @@ const interpreter::Bytecode kBytecodes[] = { #undef DEFINE_BYTECODE }; -Matcher<Node*> IsIntPtrConstant(const intptr_t value) { - return kPointerSize == 8 ? IsInt64Constant(static_cast<int64_t>(value)) - : IsInt32Constant(static_cast<int32_t>(value)); -} - -Matcher<Node*> IsIntPtrAdd(const Matcher<Node*>& lhs_matcher, - const Matcher<Node*>& rhs_matcher) { - return kPointerSize == 8 ? IsInt64Add(lhs_matcher, rhs_matcher) - : IsInt32Add(lhs_matcher, rhs_matcher); -} - -Matcher<Node*> IsIntPtrSub(const Matcher<Node*>& lhs_matcher, - const Matcher<Node*>& rhs_matcher) { - return kPointerSize == 8 ? IsInt64Sub(lhs_matcher, rhs_matcher) - : IsInt32Sub(lhs_matcher, rhs_matcher); -} - -Matcher<Node*> IsIntPtrMul(const Matcher<Node*>& lhs_matcher, - const Matcher<Node*>& rhs_matcher) { - return kPointerSize == 8 ? IsInt64Mul(lhs_matcher, rhs_matcher) - : IsInt32Mul(lhs_matcher, rhs_matcher); -} - -Matcher<Node*> IsWordShl(const Matcher<Node*>& lhs_matcher, - const Matcher<Node*>& rhs_matcher) { - return kPointerSize == 8 ? IsWord64Shl(lhs_matcher, rhs_matcher) - : IsWord32Shl(lhs_matcher, rhs_matcher); -} - -Matcher<Node*> IsWordSar(const Matcher<Node*>& lhs_matcher, - const Matcher<Node*>& rhs_matcher) { - return kPointerSize == 8 ? IsWord64Sar(lhs_matcher, rhs_matcher) - : IsWord32Sar(lhs_matcher, rhs_matcher); -} - -Matcher<Node*> IsWordOr(const Matcher<Node*>& lhs_matcher, - const Matcher<Node*>& rhs_matcher) { - return kPointerSize == 8 ? IsWord64Or(lhs_matcher, rhs_matcher) - : IsWord32Or(lhs_matcher, rhs_matcher); -} - -Matcher<Node*> IsChangeInt32ToIntPtr(const Matcher<Node*>& matcher) { - return kPointerSize == 8 ? IsChangeInt32ToInt64(matcher) : matcher; -} - -Matcher<Node*> IsChangeUint32ToWord(const Matcher<Node*>& matcher) { - return kPointerSize == 8 ? IsChangeUint32ToUint64(matcher) : matcher; -} - -Matcher<Node*> IsTruncateWordToWord32(const Matcher<Node*>& matcher) { - return kPointerSize == 8 ? IsTruncateInt64ToInt32(matcher) : matcher; -} InterpreterAssemblerTest::InterpreterAssemblerForTest:: ~InterpreterAssemblerForTest() { @@ -109,13 +49,13 @@ InterpreterAssemblerTest::InterpreterAssemblerForTest:: } Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest::IsLoad( - const Matcher<LoadRepresentation>& rep_matcher, + const Matcher<c::LoadRepresentation>& rep_matcher, const Matcher<Node*>& base_matcher, const Matcher<Node*>& index_matcher) { return ::i::compiler::IsLoad(rep_matcher, base_matcher, index_matcher, _, _); } Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest::IsStore( - const Matcher<StoreRepresentation>& rep_matcher, + const Matcher<c::StoreRepresentation>& rep_matcher, const Matcher<Node*>& base_matcher, const Matcher<Node*>& index_matcher, const Matcher<Node*>& value_matcher) { return ::i::compiler::IsStore(rep_matcher, base_matcher, index_matcher, @@ -127,9 +67,10 @@ InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedByteOperand( int offset) { return IsLoad( MachineType::Uint8(), - IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), - IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), - IsIntPtrConstant(offset))); + c::IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), + c::IsIntPtrAdd( + c::IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), + c::IsIntPtrConstant(offset))); } Matcher<Node*> @@ -137,9 +78,10 @@ InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedByteOperand( int offset) { return IsLoad( MachineType::Int8(), - IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), - IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), - IsIntPtrConstant(offset))); + c::IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), + c::IsIntPtrAdd( + c::IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), + c::IsIntPtrConstant(offset))); } Matcher<Node*> @@ -148,9 +90,10 @@ InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedShortOperand( if (TargetSupportsUnalignedAccess()) { return IsLoad( MachineType::Uint16(), - IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), - IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), - IsIntPtrConstant(offset))); + c::IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), + c::IsIntPtrAdd( + c::IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), + c::IsIntPtrConstant(offset))); } else { #if V8_TARGET_LITTLE_ENDIAN const int kStep = -1; @@ -165,13 +108,13 @@ InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedShortOperand( for (int i = 0; i < static_cast<int>(arraysize(bytes)); i++) { bytes[i] = IsLoad( MachineType::Uint8(), - IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), - IsIntPtrAdd( - IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), - IsIntPtrConstant(offset + kMsbOffset + kStep * i))); + c::IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), + c::IsIntPtrAdd( + c::IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), + c::IsIntPtrConstant(offset + kMsbOffset + kStep * i))); } - return IsWord32Or(IsWord32Shl(bytes[0], IsInt32Constant(kBitsPerByte)), - bytes[1]); + return c::IsWord32Or( + c::IsWord32Shl(bytes[0], c::IsInt32Constant(kBitsPerByte)), bytes[1]); } } @@ -181,9 +124,10 @@ InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedShortOperand( if (TargetSupportsUnalignedAccess()) { return IsLoad( MachineType::Int16(), - IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), - IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), - IsIntPtrConstant(offset))); + c::IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), + c::IsIntPtrAdd( + c::IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), + c::IsIntPtrConstant(offset))); } else { #if V8_TARGET_LITTLE_ENDIAN const int kStep = -1; @@ -198,13 +142,13 @@ InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedShortOperand( for (int i = 0; i < static_cast<int>(arraysize(bytes)); i++) { bytes[i] = IsLoad( (i == 0) ? MachineType::Int8() : MachineType::Uint8(), - IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), - IsIntPtrAdd( - IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), - IsIntPtrConstant(offset + kMsbOffset + kStep * i))); + c::IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), + c::IsIntPtrAdd( + c::IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), + c::IsIntPtrConstant(offset + kMsbOffset + kStep * i))); } - return IsWord32Or(IsWord32Shl(bytes[0], IsInt32Constant(kBitsPerByte)), - bytes[1]); + return c::IsWord32Or( + c::IsWord32Shl(bytes[0], c::IsInt32Constant(kBitsPerByte)), bytes[1]); } } @@ -214,9 +158,10 @@ InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedQuadOperand( if (TargetSupportsUnalignedAccess()) { return IsLoad( MachineType::Uint32(), - IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), - IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), - IsIntPtrConstant(offset))); + c::IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), + c::IsIntPtrAdd( + c::IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), + c::IsIntPtrConstant(offset))); } else { #if V8_TARGET_LITTLE_ENDIAN const int kStep = -1; @@ -231,17 +176,18 @@ InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedQuadOperand( for (int i = 0; i < static_cast<int>(arraysize(bytes)); i++) { bytes[i] = IsLoad( MachineType::Uint8(), - IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), - IsIntPtrAdd( - IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), - IsIntPtrConstant(offset + kMsbOffset + kStep * i))); + c::IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), + c::IsIntPtrAdd( + c::IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), + c::IsIntPtrConstant(offset + kMsbOffset + kStep * i))); } - return IsWord32Or( - IsWord32Shl(bytes[0], IsInt32Constant(3 * kBitsPerByte)), - IsWord32Or( - IsWord32Shl(bytes[1], IsInt32Constant(2 * kBitsPerByte)), - IsWord32Or(IsWord32Shl(bytes[2], IsInt32Constant(1 * kBitsPerByte)), - bytes[3]))); + return c::IsWord32Or( + c::IsWord32Shl(bytes[0], c::IsInt32Constant(3 * kBitsPerByte)), + c::IsWord32Or( + c::IsWord32Shl(bytes[1], c::IsInt32Constant(2 * kBitsPerByte)), + c::IsWord32Or( + c::IsWord32Shl(bytes[2], c::IsInt32Constant(1 * kBitsPerByte)), + bytes[3]))); } } @@ -251,9 +197,10 @@ InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedQuadOperand( if (TargetSupportsUnalignedAccess()) { return IsLoad( MachineType::Int32(), - IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), - IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), - IsIntPtrConstant(offset))); + c::IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), + c::IsIntPtrAdd( + c::IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), + c::IsIntPtrConstant(offset))); } else { #if V8_TARGET_LITTLE_ENDIAN const int kStep = -1; @@ -268,17 +215,18 @@ InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedQuadOperand( for (int i = 0; i < static_cast<int>(arraysize(bytes)); i++) { bytes[i] = IsLoad( (i == 0) ? MachineType::Int8() : MachineType::Uint8(), - IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), - IsIntPtrAdd( - IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), - IsIntPtrConstant(offset + kMsbOffset + kStep * i))); + c::IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), + c::IsIntPtrAdd( + c::IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), + c::IsIntPtrConstant(offset + kMsbOffset + kStep * i))); } - return IsWord32Or( - IsWord32Shl(bytes[0], IsInt32Constant(3 * kBitsPerByte)), - IsWord32Or( - IsWord32Shl(bytes[1], IsInt32Constant(2 * kBitsPerByte)), - IsWord32Or(IsWord32Shl(bytes[2], IsInt32Constant(1 * kBitsPerByte)), - bytes[3]))); + return c::IsWord32Or( + c::IsWord32Shl(bytes[0], c::IsInt32Constant(3 * kBitsPerByte)), + c::IsWord32Or( + c::IsWord32Shl(bytes[1], c::IsInt32Constant(2 * kBitsPerByte)), + c::IsWord32Or( + c::IsWord32Shl(bytes[2], c::IsInt32Constant(1 * kBitsPerByte)), + bytes[3]))); } } @@ -327,25 +275,27 @@ TARGET_TEST_F(InterpreterAssemblerTest, Jump) { InterpreterAssemblerForTest m(&state, bytecode); Node* tail_call_node = m.Jump(m.IntPtrConstant(jump_offset)); - Matcher<Node*> next_bytecode_offset_matcher = IsIntPtrAdd( - IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), - IsIntPtrConstant(jump_offset)); + Matcher<Node*> next_bytecode_offset_matcher = c::IsIntPtrAdd( + c::IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), + c::IsIntPtrConstant(jump_offset)); Matcher<Node*> target_bytecode_matcher = m.IsLoad(MachineType::Uint8(), _, next_bytecode_offset_matcher); - target_bytecode_matcher = IsChangeUint32ToWord(target_bytecode_matcher); - Matcher<Node*> code_target_matcher = - m.IsLoad(MachineType::Pointer(), - IsParameter(InterpreterDispatchDescriptor::kDispatchTable), - IsWordShl(target_bytecode_matcher, - IsIntPtrConstant(kPointerSizeLog2))); + target_bytecode_matcher = + c::IsChangeUint32ToWord(target_bytecode_matcher); + Matcher<Node*> code_target_matcher = m.IsLoad( + MachineType::Pointer(), + c::IsParameter(InterpreterDispatchDescriptor::kDispatchTable), + c::IsWordShl(target_bytecode_matcher, + c::IsIntPtrConstant(kPointerSizeLog2))); EXPECT_THAT( tail_call_node, - IsTailCall(_, code_target_matcher, - IsParameter(InterpreterDispatchDescriptor::kAccumulator), - next_bytecode_offset_matcher, _, - IsParameter(InterpreterDispatchDescriptor::kDispatchTable), - _, _)); + c::IsTailCall( + _, code_target_matcher, + c::IsParameter(InterpreterDispatchDescriptor::kAccumulator), + next_bytecode_offset_matcher, _, + c::IsParameter(InterpreterDispatchDescriptor::kDispatchTable), _, + _)); } } } @@ -377,7 +327,12 @@ TARGET_TEST_F(InterpreterAssemblerTest, BytecodeOperand) { break; case interpreter::OperandType::kIdx: EXPECT_THAT(m.BytecodeOperandIdx(i), - IsChangeUint32ToWord( + c::IsChangeUint32ToWord( + m.IsUnsignedOperand(offset, operand_size))); + break; + case interpreter::OperandType::kNativeContextIndex: + EXPECT_THAT(m.BytecodeOperandNativeContextIndex(i), + c::IsChangeUint32ToWord( m.IsUnsignedOperand(offset, operand_size))); break; case interpreter::OperandType::kUImm: @@ -396,9 +351,9 @@ TARGET_TEST_F(InterpreterAssemblerTest, BytecodeOperand) { case interpreter::OperandType::kRegOutPair: case interpreter::OperandType::kRegOutTriple: case interpreter::OperandType::kRegPair: - EXPECT_THAT( - m.BytecodeOperandReg(i), - IsChangeInt32ToIntPtr(m.IsSignedOperand(offset, operand_size))); + EXPECT_THAT(m.BytecodeOperandReg(i), + c::IsChangeInt32ToIntPtr( + m.IsSignedOperand(offset, operand_size))); break; case interpreter::OperandType::kRuntimeId: EXPECT_THAT(m.BytecodeOperandRuntimeId(i), @@ -423,9 +378,9 @@ TARGET_TEST_F(InterpreterAssemblerTest, GetContext) { InterpreterAssemblerForTest m(&state, bytecode); EXPECT_THAT( m.GetContext(), - m.IsLoad(MachineType::AnyTagged(), IsLoadParentFramePointer(), - IsIntPtrConstant(Register::current_context().ToOperand() - << kPointerSizeLog2))); + m.IsLoad(MachineType::AnyTagged(), c::IsLoadParentFramePointer(), + c::IsIntPtrConstant(Register::current_context().ToOperand() + << kPointerSizeLog2))); } } @@ -433,12 +388,13 @@ TARGET_TEST_F(InterpreterAssemblerTest, RegisterLocation) { TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { InterpreterAssemblerTestState state(this, bytecode); InterpreterAssemblerForTest m(&state, bytecode); - Node* reg_index_node = m.IntPtrConstant(44); + Node* reg_index_node = m.Parameter(0); Node* reg_location_node = m.RegisterLocation(reg_index_node); - EXPECT_THAT(reg_location_node, - IsIntPtrAdd(IsLoadParentFramePointer(), - IsWordShl(reg_index_node, - IsIntPtrConstant(kPointerSizeLog2)))); + EXPECT_THAT( + reg_location_node, + c::IsIntPtrAdd(c::IsLoadParentFramePointer(), + c::IsWordShl(reg_index_node, + c::IsIntPtrConstant(kPointerSizeLog2)))); } } @@ -446,12 +402,13 @@ TARGET_TEST_F(InterpreterAssemblerTest, LoadRegister) { TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { InterpreterAssemblerTestState state(this, bytecode); InterpreterAssemblerForTest m(&state, bytecode); - Node* reg_index_node = m.IntPtrConstant(44); + Node* reg_index_node = m.Parameter(0); Node* load_reg_node = m.LoadRegister(reg_index_node); - EXPECT_THAT(load_reg_node, - m.IsLoad(MachineType::AnyTagged(), IsLoadParentFramePointer(), - IsWordShl(reg_index_node, - IsIntPtrConstant(kPointerSizeLog2)))); + EXPECT_THAT( + load_reg_node, + m.IsLoad(MachineType::AnyTagged(), c::IsLoadParentFramePointer(), + c::IsWordShl(reg_index_node, + c::IsIntPtrConstant(kPointerSizeLog2)))); } } @@ -460,62 +417,15 @@ TARGET_TEST_F(InterpreterAssemblerTest, StoreRegister) { InterpreterAssemblerTestState state(this, bytecode); InterpreterAssemblerForTest m(&state, bytecode); Node* store_value = m.Int32Constant(0xdeadbeef); - Node* reg_index_node = m.IntPtrConstant(44); + Node* reg_index_node = m.Parameter(0); Node* store_reg_node = m.StoreRegister(store_value, reg_index_node); - EXPECT_THAT( - store_reg_node, - m.IsStore(StoreRepresentation(MachineRepresentation::kTagged, - kNoWriteBarrier), - IsLoadParentFramePointer(), - IsWordShl(reg_index_node, IsIntPtrConstant(kPointerSizeLog2)), - store_value)); - } -} - -TARGET_TEST_F(InterpreterAssemblerTest, SmiTag) { - TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { - InterpreterAssemblerTestState state(this, bytecode); - InterpreterAssemblerForTest m(&state, bytecode); - Node* value = m.Int32Constant(44); - EXPECT_THAT( - m.SmiTag(value), - IS_BITCAST_WORD_TO_TAGGED_SIGNED(IsIntPtrConstant( - static_cast<intptr_t>(44) << (kSmiShiftSize + kSmiTagSize)))); - EXPECT_THAT(m.SmiUntag(value), - IsWordSar(IS_BITCAST_TAGGED_TO_WORD(value), - IsIntPtrConstant(kSmiShiftSize + kSmiTagSize))); - } -} - -TARGET_TEST_F(InterpreterAssemblerTest, IntPtrAdd) { - TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { - InterpreterAssemblerTestState state(this, bytecode); - InterpreterAssemblerForTest m(&state, bytecode); - Node* a = m.Parameter(0); - Node* b = m.Int32Constant(1); - Node* add = m.IntPtrAdd(a, b); - EXPECT_THAT(add, IsIntPtrAdd(a, b)); - } -} - -TARGET_TEST_F(InterpreterAssemblerTest, IntPtrSub) { - TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { - InterpreterAssemblerTestState state(this, bytecode); - InterpreterAssemblerForTest m(&state, bytecode); - Node* a = m.Parameter(0); - Node* b = m.Int32Constant(1); - Node* add = m.IntPtrSub(a, b); - EXPECT_THAT(add, IsIntPtrSub(a, b)); - } -} - -TARGET_TEST_F(InterpreterAssemblerTest, WordShl) { - TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { - InterpreterAssemblerTestState state(this, bytecode); - InterpreterAssemblerForTest m(&state, bytecode); - Node* a = m.IntPtrConstant(0); - Node* add = m.WordShl(a, 10); - EXPECT_THAT(add, IsWordShl(a, IsIntPtrConstant(10))); + EXPECT_THAT(store_reg_node, + m.IsStore(c::StoreRepresentation(MachineRepresentation::kTagged, + kNoWriteBarrier), + c::IsLoadParentFramePointer(), + c::IsWordShl(reg_index_node, + c::IsIntPtrConstant(kPointerSizeLog2)), + store_value)); } } @@ -526,31 +436,32 @@ TARGET_TEST_F(InterpreterAssemblerTest, LoadConstantPoolEntry) { { Node* index = m.IntPtrConstant(2); Node* load_constant = m.LoadConstantPoolEntry(index); - Matcher<Node*> constant_pool_matcher = - m.IsLoad(MachineType::AnyTagged(), - IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), - IsIntPtrConstant(BytecodeArray::kConstantPoolOffset - - kHeapObjectTag)); - EXPECT_THAT(load_constant, - m.IsLoad(MachineType::AnyTagged(), constant_pool_matcher, - IsIntPtrConstant(FixedArray::OffsetOfElementAt(2) - - kHeapObjectTag))); + Matcher<Node*> constant_pool_matcher = m.IsLoad( + MachineType::AnyTagged(), + c::IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), + c::IsIntPtrConstant(BytecodeArray::kConstantPoolOffset - + kHeapObjectTag)); + EXPECT_THAT( + load_constant, + m.IsLoad(MachineType::AnyTagged(), constant_pool_matcher, + c::IsIntPtrConstant(FixedArray::OffsetOfElementAt(2) - + kHeapObjectTag))); } { Node* index = m.Parameter(2); Node* load_constant = m.LoadConstantPoolEntry(index); - Matcher<Node*> constant_pool_matcher = - m.IsLoad(MachineType::AnyTagged(), - IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), - IsIntPtrConstant(BytecodeArray::kConstantPoolOffset - - kHeapObjectTag)); + Matcher<Node*> constant_pool_matcher = m.IsLoad( + MachineType::AnyTagged(), + c::IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), + c::IsIntPtrConstant(BytecodeArray::kConstantPoolOffset - + kHeapObjectTag)); EXPECT_THAT( load_constant, m.IsLoad( MachineType::AnyTagged(), constant_pool_matcher, - IsIntPtrAdd( - IsIntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag), - IsWordShl(index, IsIntPtrConstant(kPointerSizeLog2))))); + c::IsIntPtrAdd( + c::IsIntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag), + c::IsWordShl(index, c::IsIntPtrConstant(kPointerSizeLog2))))); } } } @@ -564,7 +475,7 @@ TARGET_TEST_F(InterpreterAssemblerTest, LoadObjectField) { Node* load_field = m.LoadObjectField(object, offset); EXPECT_THAT(load_field, m.IsLoad(MachineType::AnyTagged(), object, - IsIntPtrConstant(offset - kHeapObjectTag))); + c::IsIntPtrConstant(offset - kHeapObjectTag))); } } @@ -576,8 +487,8 @@ TARGET_TEST_F(InterpreterAssemblerTest, CallRuntime2) { Node* arg2 = m.Int32Constant(3); Node* context = m.Int32Constant(4); Node* call_runtime = m.CallRuntime(Runtime::kAdd, context, arg1, arg2); - EXPECT_THAT(call_runtime, - IsCall(_, _, arg1, arg2, _, IsInt32Constant(2), context, _, _)); + EXPECT_THAT(call_runtime, c::IsCall(_, _, arg1, arg2, _, + c::IsInt32Constant(2), context, _, _)); } } @@ -596,21 +507,21 @@ TARGET_TEST_F(InterpreterAssemblerTest, CallRuntime) { Node* arg_count = m.Int32Constant(2); Node* context = m.IntPtrConstant(4); - Matcher<Node*> function_table = IsExternalConstant( + Matcher<Node*> function_table = c::IsExternalConstant( ExternalReference::runtime_function_table_address(isolate())); - Matcher<Node*> function = IsIntPtrAdd( + Matcher<Node*> function = c::IsIntPtrAdd( function_table, - IsChangeUint32ToWord(IsInt32Mul( - function_id, IsInt32Constant(sizeof(Runtime::Function))))); + c::IsChangeUint32ToWord(c::IsInt32Mul( + function_id, c::IsInt32Constant(sizeof(Runtime::Function))))); Matcher<Node*> function_entry = m.IsLoad(MachineType::Pointer(), function, - IsIntPtrConstant(offsetof(Runtime::Function, entry))); + c::IsIntPtrConstant(offsetof(Runtime::Function, entry))); Node* call_runtime = m.CallRuntimeN(function_id, context, first_arg, arg_count, result_size); EXPECT_THAT(call_runtime, - IsCall(_, IsHeapConstant(builtin.code()), arg_count, - first_arg, function_entry, context, _, _)); + c::IsCall(_, c::IsHeapConstant(builtin.code()), arg_count, + first_arg, function_entry, context, _, _)); } } } @@ -623,16 +534,17 @@ TARGET_TEST_F(InterpreterAssemblerTest, LoadFeedbackVector) { Node* feedback_vector = m.LoadFeedbackVector(); Matcher<Node*> load_function_matcher = - m.IsLoad(MachineType::AnyTagged(), IsLoadParentFramePointer(), - IsIntPtrConstant(Register::function_closure().ToOperand() - << kPointerSizeLog2)); - Matcher<Node*> load_vector_cell_matcher = m.IsLoad( - MachineType::AnyTagged(), load_function_matcher, - IsIntPtrConstant(JSFunction::kFeedbackVectorOffset - kHeapObjectTag)); + m.IsLoad(MachineType::AnyTagged(), c::IsLoadParentFramePointer(), + c::IsIntPtrConstant(Register::function_closure().ToOperand() + << kPointerSizeLog2)); + Matcher<Node*> load_vector_cell_matcher = + m.IsLoad(MachineType::AnyTagged(), load_function_matcher, + c::IsIntPtrConstant(JSFunction::kFeedbackVectorOffset - + kHeapObjectTag)); EXPECT_THAT( feedback_vector, m.IsLoad(MachineType::AnyTagged(), load_vector_cell_matcher, - IsIntPtrConstant(Cell::kValueOffset - kHeapObjectTag))); + c::IsIntPtrConstant(Cell::kValueOffset - kHeapObjectTag))); } } diff --git a/deps/v8/test/unittests/libplatform/default-platform-unittest.cc b/deps/v8/test/unittests/libplatform/default-platform-unittest.cc index 73816596cf..f9b3e0b98f 100644 --- a/deps/v8/test/unittests/libplatform/default-platform-unittest.cc +++ b/deps/v8/test/unittests/libplatform/default-platform-unittest.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "src/libplatform/default-platform.h" +#include "src/base/platform/time.h" #include "testing/gmock/include/gmock/gmock.h" using testing::InSequence; @@ -10,6 +11,7 @@ using testing::StrictMock; namespace v8 { namespace platform { +namespace default_platform_unittest { namespace { @@ -30,6 +32,9 @@ class DefaultPlatformWithMockTime : public DefaultPlatform { DefaultPlatformWithMockTime() : DefaultPlatform(IdleTaskSupport::kEnabled), time_(0) {} double MonotonicallyIncreasingTime() override { return time_; } + double CurrentClockTimeMillis() override { + return time_ * base::Time::kMillisecondsPerSecond; + } void IncreaseTime(double seconds) { time_ += seconds; } private: @@ -162,5 +167,6 @@ TEST(DefaultPlatformTest, PendingIdleTasksAreDestroyedOnShutdown) { } } +} // namespace default_platform_unittest } // namespace platform } // namespace v8 diff --git a/deps/v8/test/unittests/libplatform/task-queue-unittest.cc b/deps/v8/test/unittests/libplatform/task-queue-unittest.cc index 2de104b9c0..9bb160dd31 100644 --- a/deps/v8/test/unittests/libplatform/task-queue-unittest.cc +++ b/deps/v8/test/unittests/libplatform/task-queue-unittest.cc @@ -13,6 +13,7 @@ using testing::StrictMock; namespace v8 { namespace platform { +namespace task_queue_unittest { namespace { @@ -56,5 +57,6 @@ TEST(TaskQueueTest, TerminateMultipleReaders) { thread2.Join(); } +} // namespace task_queue_unittest } // namespace platform } // namespace v8 diff --git a/deps/v8/test/unittests/libplatform/worker-thread-unittest.cc b/deps/v8/test/unittests/libplatform/worker-thread-unittest.cc index f0b41e78dd..7079d22eb6 100644 --- a/deps/v8/test/unittests/libplatform/worker-thread-unittest.cc +++ b/deps/v8/test/unittests/libplatform/worker-thread-unittest.cc @@ -24,6 +24,25 @@ struct MockTask : public Task { } // namespace +// Needs to be in v8::platform due to BlockUntilQueueEmptyForTesting +// being private. +TEST(WorkerThreadTest, PostSingleTask) { + TaskQueue queue; + WorkerThread thread1(&queue); + WorkerThread thread2(&queue); + + InSequence s; + StrictMock<MockTask>* task = new StrictMock<MockTask>; + EXPECT_CALL(*task, Run()); + EXPECT_CALL(*task, Die()); + queue.Append(task); + + // The next call should not time out. + queue.BlockUntilQueueEmptyForTesting(); + queue.Terminate(); +} + +namespace worker_thread_unittest { TEST(WorkerThreadTest, Basic) { static const size_t kNumTasks = 10; @@ -44,21 +63,6 @@ TEST(WorkerThreadTest, Basic) { queue.Terminate(); } -TEST(WorkerThreadTest, PostSingleTask) { - TaskQueue queue; - WorkerThread thread1(&queue); - WorkerThread thread2(&queue); - - InSequence s; - StrictMock<MockTask>* task = new StrictMock<MockTask>; - EXPECT_CALL(*task, Run()); - EXPECT_CALL(*task, Die()); - queue.Append(task); - - // The next call should not time out. - queue.BlockUntilQueueEmptyForTesting(); - queue.Terminate(); -} - +} // namespace worker_thread_unittest } // namespace platform } // namespace v8 diff --git a/deps/v8/test/unittests/test-utils.cc b/deps/v8/test/unittests/test-utils.cc index 3a58bbb569..f433926e53 100644 --- a/deps/v8/test/unittests/test-utils.cc +++ b/deps/v8/test/unittests/test-utils.cc @@ -8,7 +8,6 @@ #include "src/base/platform/time.h" #include "src/flags.h" #include "src/isolate.h" -#include "src/list-inl.h" #include "src/objects-inl.h" #include "src/v8.h" @@ -101,9 +100,9 @@ SaveFlags::SaveFlags() { non_default_flags_ = FlagList::argv(); } SaveFlags::~SaveFlags() { FlagList::ResetAllFlags(); - int argc = non_default_flags_->length(); + int argc = static_cast<int>(non_default_flags_->size()); FlagList::SetFlagsFromCommandLine( - &argc, const_cast<char**>(non_default_flags_->begin()), + &argc, const_cast<char**>(non_default_flags_->data()), false /* remove_flags */); for (auto flag = non_default_flags_->begin(); flag != non_default_flags_->end(); ++flag) { diff --git a/deps/v8/test/unittests/test-utils.h b/deps/v8/test/unittests/test-utils.h index a5a4e5969b..3d832e6500 100644 --- a/deps/v8/test/unittests/test-utils.h +++ b/deps/v8/test/unittests/test-utils.h @@ -5,10 +5,11 @@ #ifndef V8_UNITTESTS_TEST_UTILS_H_ #define V8_UNITTESTS_TEST_UTILS_H_ +#include <vector> + #include "include/v8.h" #include "src/base/macros.h" #include "src/base/utils/random-number-generator.h" -#include "src/list.h" #include "src/zone/accounting-allocator.h" #include "src/zone/zone.h" #include "testing/gtest-support.h" @@ -142,7 +143,7 @@ class SaveFlags { ~SaveFlags(); private: - List<const char*>* non_default_flags_; + std::vector<const char*>* non_default_flags_; DISALLOW_COPY_AND_ASSIGN(SaveFlags); }; diff --git a/deps/v8/test/unittests/unicode-unittest.cc b/deps/v8/test/unittests/unicode-unittest.cc index 67edfb7331..c4df42c1c6 100644 --- a/deps/v8/test/unittests/unicode-unittest.cc +++ b/deps/v8/test/unittests/unicode-unittest.cc @@ -4,8 +4,10 @@ #include <memory> #include <string> +#include <vector> #include "src/unicode-decoder.h" +#include "src/unicode-inl.h" #include "testing/gtest/include/gtest/gtest.h" namespace v8 { @@ -23,6 +25,30 @@ void Decode(Utf8Decoder* decoder, const std::string& str) { decoder->Reset(buffer.get(), str.length()); } +void DecodeNormally(const std::vector<byte>& bytes, + std::vector<unibrow::uchar>* output) { + size_t cursor = 0; + while (cursor < bytes.size()) { + output->push_back( + unibrow::Utf8::ValueOf(bytes.data() + cursor, bytes.size(), &cursor)); + } +} + +void DecodeIncrementally(const std::vector<byte>& bytes, + std::vector<unibrow::uchar>* output) { + unibrow::Utf8::Utf8IncrementalBuffer buffer = 0; + for (auto b : bytes) { + unibrow::uchar result = unibrow::Utf8::ValueOfIncremental(b, &buffer); + if (result != unibrow::Utf8::kIncomplete) { + output->push_back(result); + } + } + unibrow::uchar result = unibrow::Utf8::ValueOfIncrementalFinish(&buffer); + if (result != unibrow::Utf8::kBufferEmpty) { + output->push_back(result); + } +} + } // namespace TEST(UnicodeTest, ReadOffEndOfUtf8String) { @@ -35,5 +61,382 @@ TEST(UnicodeTest, ReadOffEndOfUtf8String) { Decode(&decoder, "\xF4"); } +TEST(UnicodeTest, IncrementalUTF8DecodingVsNonIncrementalUtf8Decoding) { + // Unfortunately, V8 has two UTF-8 decoders. This test checks that they + // produce the same result. This test was inspired by + // https://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt . + typedef struct { + std::vector<byte> bytes; + std::vector<unibrow::uchar> unicode_expected; + } TestCase; + + TestCase data[] = { + // Correct UTF-8 text. + {{0xce, 0xba, 0xe1, 0xbd, 0xb9, 0xcf, 0x83, 0xce, 0xbc, 0xce, 0xb5}, + {0x3ba, 0x1f79, 0x3c3, 0x3bc, 0x3b5}}, + + // First possible sequence of a certain length: + // 1 byte + {{0x00}, {0x0}}, + // 2 bytes + {{0xc2, 0x80}, {0x80}}, + // 3 bytes + {{0xe0, 0xa0, 0x80}, {0x800}}, + // 4 bytes + {{0xf0, 0x90, 0x80, 0x80}, {0x10000}}, + // 5 bytes (not supported) + {{0xf8, 0x88, 0x80, 0x80, 0x80}, + {0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + // 6 bytes (not supported) + {{0xfc, 0x84, 0x80, 0x80, 0x80, 0x80}, + {0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + + // Last possible sequence of certain length: + // 1 byte + {{0x7f}, {0x7f}}, + // 2 bytes + {{0xdf, 0xbf}, {0x7ff}}, + // 3 bytes + {{0xef, 0xbf, 0xbf}, {0xffff}}, + // 4 bytes (this sequence is not a valid code point) + {{0xf7, 0xbf, 0xbf, 0xbf}, {0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + // 5 bytes (not supported) + {{0xfb, 0xbf, 0xbf, 0xbf, 0xbf}, + {0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + // 6 bytes (not supported) + {{0xfd, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf}, + {0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + // Other boundary conditions: + {{0xed, 0x9f, 0xbf}, {0xd7ff}}, + {{0xee, 0x80, 0x80}, {0xe000}}, + // U+fffd (invalid code point) + {{0xef, 0xbf, 0xbd}, {0xfffd}}, + // U+10ffff (last valid code point) + {{0xf4, 0x8f, 0xbf, 0xbf}, {0x10ffff}}, + // First invalid (too large) code point + {{0xf4, 0x90, 0x80, 0x80}, {0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + + // Malformed sequences: + // Unexpected continuation bytes: + // First continuation byte + {{0x80}, {0xfffd}}, + // Last continuation byte + {{0xbf}, {0xfffd}}, + // 2 continuation bytes + {{0x80, 0xbf}, {0xfffd, 0xfffd}}, + // 3 continuation bytes + {{0x80, 0xbf, 0x80}, {0xfffd, 0xfffd, 0xfffd}}, + // 4 continuation bytes + {{0x80, 0xbf, 0x80, 0xbf}, {0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + // 5 continuation bytes + {{0x80, 0xbf, 0x80, 0xbf, 0x80}, + {0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + // 6 continuation bytes + {{0x80, 0xbf, 0x80, 0xbf, 0x80, 0xbf}, + {0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + // 7 continuation bytes + {{0x80, 0xbf, 0x80, 0xbf, 0x80, 0xbf, 0xbf}, + {0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + // Sequence of all 64 possible continuation bytes + {{0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, + 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, + 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, + 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, + 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, + 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf}, + {0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, + 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, + 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, + 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, + 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, + 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, + 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, + 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + // Using each possible continuation byte in a two-byte sequence: + {{0xd0, 0x80, 0xd0, 0x81, 0xd0, 0x82, 0xd0, 0x83, 0xd0, 0x84, 0xd0, 0x85, + 0xd0, 0x86, 0xd0, 0x87, 0xd0, 0x88, 0xd0, 0x89, 0xd0, 0x8a, 0xd0, 0x8b, + 0xd0, 0x8c, 0xd0, 0x8d, 0xd0, 0x8e, 0xd0, 0x8f, 0xd0, 0x90, 0xd0, 0x91, + 0xd0, 0x92, 0xd0, 0x93, 0xd0, 0x94, 0xd0, 0x95, 0xd0, 0x96, 0xd0, 0x97, + 0xd0, 0x98, 0xd0, 0x99, 0xd0, 0x9a, 0xd0, 0x9b, 0xd0, 0x9c, 0xd0, 0x9d, + 0xd0, 0x9e, 0xd0, 0x9f, 0xd0, 0xa0, 0xd0, 0xa1, 0xd0, 0xa2, 0xd0, 0xa3, + 0xd0, 0xa4, 0xd0, 0xa5, 0xd0, 0xa6, 0xd0, 0xa7, 0xd0, 0xa8, 0xd0, 0xa9, + 0xd0, 0xaa, 0xd0, 0xab, 0xd0, 0xac, 0xd0, 0xad, 0xd0, 0xae, 0xd0, 0xaf, + 0xd0, 0xb0, 0xd0, 0xb1, 0xd0, 0xb2, 0xd0, 0xb3, 0xd0, 0xb4, 0xd0, 0xb5, + 0xd0, 0xb6, 0xd0, 0xb7, 0xd0, 0xb8, 0xd0, 0xb9, 0xd0, 0xba, 0xd0, 0xbb, + 0xd0, 0xbc, 0xd0, 0xbd, 0xd0, 0xbe, 0xd0, 0xbf}, + {0x400, 0x401, 0x402, 0x403, 0x404, 0x405, 0x406, 0x407, 0x408, 0x409, + 0x40a, 0x40b, 0x40c, 0x40d, 0x40e, 0x40f, 0x410, 0x411, 0x412, 0x413, + 0x414, 0x415, 0x416, 0x417, 0x418, 0x419, 0x41a, 0x41b, 0x41c, 0x41d, + 0x41e, 0x41f, 0x420, 0x421, 0x422, 0x423, 0x424, 0x425, 0x426, 0x427, + 0x428, 0x429, 0x42a, 0x42b, 0x42c, 0x42d, 0x42e, 0x42f, 0x430, 0x431, + 0x432, 0x433, 0x434, 0x435, 0x436, 0x437, 0x438, 0x439, 0x43a, 0x43b, + 0x43c, 0x43d, 0x43e, 0x43f}}, + + // Lonely first bytes: + // All 32 first bytes of 32-byte sequences, each followed by a space + // (generates 32 invalid char + space sequences. + {{0xc0, 0x20, 0xc1, 0x20, 0xc2, 0x20, 0xc3, 0x20, 0xc4, 0x20, 0xc5, + 0x20, 0xc6, 0x20, 0xc7, 0x20, 0xc8, 0x20, 0xc9, 0x20, 0xca, 0x20, + 0xcb, 0x20, 0xcc, 0x20, 0xcd, 0x20, 0xce, 0x20, 0xcf, 0x20, 0xd0, + 0x20, 0xd1, 0x20, 0xd2, 0x20, 0xd3, 0x20, 0xd4, 0x20, 0xd5, 0x20, + 0xd6, 0x20, 0xd7, 0x20, 0xd8, 0x20, 0xd9, 0x20, 0xda, 0x20, 0xdb, + 0x20, 0xdc, 0x20, 0xdd, 0x20, 0xde, 0x20, 0xdf, 0x20}, + {0xfffd, 0x20, 0xfffd, 0x20, 0xfffd, 0x20, 0xfffd, 0x20, 0xfffd, 0x20, + 0xfffd, 0x20, 0xfffd, 0x20, 0xfffd, 0x20, 0xfffd, 0x20, 0xfffd, 0x20, + 0xfffd, 0x20, 0xfffd, 0x20, 0xfffd, 0x20, 0xfffd, 0x20, 0xfffd, 0x20, + 0xfffd, 0x20, 0xfffd, 0x20, 0xfffd, 0x20, 0xfffd, 0x20, 0xfffd, 0x20, + 0xfffd, 0x20, 0xfffd, 0x20, 0xfffd, 0x20, 0xfffd, 0x20, 0xfffd, 0x20, + 0xfffd, 0x20, 0xfffd, 0x20, 0xfffd, 0x20, 0xfffd, 0x20, 0xfffd, 0x20, + 0xfffd, 0x20, 0xfffd, 0x20}}, + // All 16 first bytes of 3-byte sequences, each followed by a space + // (generates 16 invalid char + space sequences): + {{0xe0, 0x20, 0xe1, 0x20, 0xe2, 0x20, 0xe3, 0x20, 0xe4, 0x20, 0xe5, + 0x20, 0xe6, 0x20, 0xe7, 0x20, 0xe8, 0x20, 0xe9, 0x20, 0xea, 0x20, + 0xeb, 0x20, 0xec, 0x20, 0xed, 0x20, 0xee, 0x20, 0xef, 0x20}, + {0xfffd, 0x20, 0xfffd, 0x20, 0xfffd, 0x20, 0xfffd, 0x20, + 0xfffd, 0x20, 0xfffd, 0x20, 0xfffd, 0x20, 0xfffd, 0x20, + 0xfffd, 0x20, 0xfffd, 0x20, 0xfffd, 0x20, 0xfffd, 0x20, + 0xfffd, 0x20, 0xfffd, 0x20, 0xfffd, 0x20, 0xfffd, 0x20}}, + // All 8 first bytes of 4-byte sequences, each followed by a space + // (generates 8 invalid char + space sequences): + {{0xf0, 0x20, 0xf1, 0x20, 0xf2, 0x20, 0xf3, 0x20, 0xf4, 0x20, 0xf5, 0x20, + 0xf6, 0x20, 0xf7, 0x20}, + {0xfffd, 0x20, 0xfffd, 0x20, 0xfffd, 0x20, 0xfffd, 0x20, 0xfffd, 0x20, + 0xfffd, 0x20, 0xfffd, 0x20, 0xfffd, 0x20}}, + // All 4 first bytes of 5-byte sequences (not supported), each followed by + // a space (generates 4 invalid char + space sequences): + {{0xf8, 0x20, 0xf9, 0x20, 0xfa, 0x20, 0xfb, 0x20}, + {0xfffd, 0x20, 0xfffd, 0x20, 0xfffd, 0x20, 0xfffd, 0x20}}, + // All 2 first bytes of 6-byte sequences (not supported), each followed by + // a space (generates 2 invalid char + space sequences): + {{0xfc, 0x20, 0xfd, 0x20}, {0xfffd, 0x20, 0xfffd, 0x20}}, + + // Sequences with last continuation byte missing. Normally the whole + // incomplete sequence generates a single invalid character (exceptions + // explained below). + + // 2-byte sequences with last byte missing + {{0xc0}, {0xfffd}}, + {{0xdf}, {0xfffd}}, + // 3-byte sequences with last byte missing. + {{0xe8, 0x80}, {0xfffd}}, + {{0xe0, 0xbf}, {0xfffd}}, + {{0xef, 0xbf}, {0xfffd}}, + // Start of an overlong sequence. The first "maximal subpart" is the first + // byte; it creates an invalid character. Each following byte generates an + // invalid character too. + {{0xe0, 0x80}, {0xfffd, 0xfffd}}, + // 4-byte sequences with last byte missing + {{0xf1, 0x80, 0x80}, {0xfffd}}, + {{0xf4, 0x8f, 0xbf}, {0xfffd}}, + // Start of an overlong sequence. The first "maximal subpart" is the first + // byte; it creates an invalid character. Each following byte generates an + // invalid character too. + {{0xf0, 0x80, 0x80}, {0xfffd, 0xfffd, 0xfffd}}, + // 5-byte sequences (not supported) with last byte missing + {{0xf8, 0x80, 0x80, 0x80}, {0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + {{0xfb, 0xbf, 0xbf, 0xbf}, {0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + // 6-byte sequences (not supported) with last byte missing + {{0xfc, 0x80, 0x80, 0x80, 0x80}, + {0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + {{0xfd, 0xbf, 0xbf, 0xbf, 0xbf}, + {0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + + // Concatenation of incomplete sequences: above incomplete sequences + // concatenated. + {{0xc0, 0xdf, 0xe8, 0x80, 0xe0, 0xbf, 0xef, 0xbf, 0xe0, 0x80, + 0xf1, 0x80, 0x80, 0xf4, 0x8f, 0xbf, 0xf0, 0x80, 0x80, 0xf8, + 0x80, 0x80, 0x80, 0xfb, 0xbf, 0xbf, 0xbf, 0xfc, 0x80, 0x80, + 0x80, 0x80, 0xfd, 0xbf, 0xbf, 0xbf, 0xbf}, + {0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, + 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, + 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, + 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + + // Incomplete sequence tests repeated with a space after the incomplete + // sequence. + + // 2-byte sequences with last byte missing + {{0xc0, 0x20}, {0xfffd, 0x20}}, + {{0xdf, 0x20}, {0xfffd, 0x20}}, + // 3-byte sequences with last byte missing + {{0xe8, 0x80, 0x20}, {0xfffd, 0x20}}, + {{0xe0, 0xbf, 0x20}, {0xfffd, 0x20}}, + {{0xef, 0xbf, 0x20}, {0xfffd, 0x20}}, + // Start of overlong 3-byte sequence with last byte missing + {{0xe0, 0x80, 0x20}, {0xfffd, 0xfffd, 0x20}}, + // 4-byte sequences with last byte missing + {{0xf1, 0x80, 0x80, 0x20}, {0xfffd, 0x20}}, + {{0xf4, 0x8f, 0xbf, 0x20}, {0xfffd, 0x20}}, + // Start of overlong 4-byte sequence with last byte missing + {{0xf0, 0x80, 0x80, 0x20}, {0xfffd, 0xfffd, 0xfffd, 0x20}}, + // 5-byte sequences (not supported) with last byte missing + {{0xf8, 0x80, 0x80, 0x80, 0x20}, {0xfffd, 0xfffd, 0xfffd, 0xfffd, 0x20}}, + {{0xfb, 0xbf, 0xbf, 0xbf, 0x20}, {0xfffd, 0xfffd, 0xfffd, 0xfffd, 0x20}}, + // 6-byte sequences (not supported) with last byte missing + {{0xfc, 0x80, 0x80, 0x80, 0x80, 0x20}, + {0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0x20}}, + {{0xfd, 0xbf, 0xbf, 0xbf, 0xbf, 0x20}, + {0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0x20}}, + + // Impossible bytes + {{0xfe}, {0xfffd}}, + {{0xff}, {0xfffd}}, + {{0xfe, 0xfe, 0xff, 0xff}, {0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + // Lead-byte-like bytes which aren't valid lead bytes. + {{0xc0}, {0xfffd}}, + {{0xc0, 0xaa}, {0xfffd, 0xfffd}}, + {{0xc1}, {0xfffd}}, + {{0xc1, 0xaa}, {0xfffd, 0xfffd}}, + {{0xf5}, {0xfffd}}, + {{0xf5, 0xaa, 0xaa, 0xaa}, {0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + {{0xf6}, {0xfffd}}, + {{0xf6, 0xaa, 0xaa, 0xaa}, {0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + {{0xf7}, {0xfffd}}, + {{0xf7, 0xaa, 0xaa, 0xaa}, {0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + {{0xf8}, {0xfffd}}, + {{0xf8, 0xaa, 0xaa, 0xaa}, {0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + {{0xf9}, {0xfffd}}, + {{0xf9, 0xaa, 0xaa, 0xaa}, {0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + {{0xfa}, {0xfffd}}, + {{0xfa, 0xaa, 0xaa, 0xaa}, {0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + {{0xfb}, {0xfffd}}, + {{0xfb, 0xaa, 0xaa, 0xaa}, {0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + {{0xfc}, {0xfffd}}, + {{0xfc, 0xaa, 0xaa, 0xaa}, {0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + {{0xfd}, {0xfffd}}, + {{0xfd, 0xaa, 0xaa, 0xaa}, {0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + {{0xfe}, {0xfffd}}, + {{0xfe, 0xaa, 0xaa, 0xaa}, {0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + {{0xff}, {0xfffd}}, + {{0xff, 0xaa, 0xaa, 0xaa}, {0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + + // Overlong sequences: + + // Overlong encodings for "/" + {{0xc0, 0xaf}, {0xfffd, 0xfffd}}, + {{0xe0, 0x80, 0xaf}, {0xfffd, 0xfffd, 0xfffd}}, + {{0xf0, 0x80, 0x80, 0xaf}, {0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + // 5-byte sequence (not supported anyway) + {{0xf8, 0x80, 0x80, 0x80, 0xaf}, + {0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + // 6-byte sequence (not supported anyway) + {{0xfc, 0x80, 0x80, 0x80, 0x80, 0xaf}, + {0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + + // Maximum overlong sequences + {{0xc1, 0xbf}, {0xfffd, 0xfffd}}, + {{0xe0, 0x9f, 0xbf}, {0xfffd, 0xfffd, 0xfffd}}, + {{0xf0, 0x8f, 0xbf, 0xbf}, {0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + // 5-byte sequence (not supported anyway) + {{0xf8, 0x87, 0xbf, 0xbf, 0xbf}, + {0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + // 6-byte sequence (not supported anyway) + {{0xfc, 0x83, 0xbf, 0xbf, 0xbf, 0xbf}, + {0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + + // Overlong encodings for 0 + {{0xc0, 0x80}, {0xfffd, 0xfffd}}, + {{0xe0, 0x80, 0x80}, {0xfffd, 0xfffd, 0xfffd}}, + {{0xf0, 0x80, 0x80, 0x80}, {0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + // 5-byte sequence (not supported anyway) + {{0xf8, 0x80, 0x80, 0x80, 0x80}, + {0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + // 6-byte sequence (not supported anyway) + {{0xfc, 0x80, 0x80, 0x80, 0x80, 0x80}, + {0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + + // Illegal code positions: + + // Single UTF-16 surrogates + {{0xed, 0xa0, 0x80}, {0xfffd, 0xfffd, 0xfffd}}, + {{0xed, 0xa0, 0x80}, {0xfffd, 0xfffd, 0xfffd}}, + {{0xed, 0xad, 0xbf}, {0xfffd, 0xfffd, 0xfffd}}, + {{0xed, 0xae, 0x80}, {0xfffd, 0xfffd, 0xfffd}}, + {{0xed, 0xaf, 0xbf}, {0xfffd, 0xfffd, 0xfffd}}, + {{0xed, 0xb0, 0x80}, {0xfffd, 0xfffd, 0xfffd}}, + {{0xed, 0xbe, 0x80}, {0xfffd, 0xfffd, 0xfffd}}, + {{0xed, 0xbf, 0xbf}, {0xfffd, 0xfffd, 0xfffd}}, + + // Paired surrogates + {{0xed, 0xa0, 0x80, 0xed, 0xb0, 0x80}, + {0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + {{0xed, 0xa0, 0x80, 0xed, 0xbf, 0xbf}, + {0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + {{0xed, 0xad, 0xbf, 0xed, 0xb0, 0x80}, + {0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + {{0xed, 0xad, 0xbf, 0xed, 0xbf, 0xbf}, + {0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + {{0xed, 0xae, 0x80, 0xed, 0xb0, 0x80}, + {0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + {{0xed, 0xae, 0x80, 0xed, 0xbf, 0xbf}, + {0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + {{0xed, 0xaf, 0xbf, 0xed, 0xb0, 0x80}, + {0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + {{0xed, 0xaf, 0xbf, 0xed, 0xbf, 0xbf}, + {0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd}}, + + // Surrogates with the last byte missing. + {{0xed, 0xa0}, {0xfffd, 0xfffd}}, + {{0xed, 0xa0}, {0xfffd, 0xfffd}}, + {{0xed, 0xad}, {0xfffd, 0xfffd}}, + {{0xed, 0xae}, {0xfffd, 0xfffd}}, + {{0xed, 0xaf}, {0xfffd, 0xfffd}}, + {{0xed, 0xb0}, {0xfffd, 0xfffd}}, + {{0xed, 0xbe}, {0xfffd, 0xfffd}}, + {{0xed, 0xbf}, {0xfffd, 0xfffd}}, + + // Other non-characters + {{0xef, 0xbf, 0xbe}, {0xfffe}}, + {{0xef, 0xbf, 0xbf}, {0xffff}}, + {{0xef, 0xb7, 0x90, 0xef, 0xb7, 0x91, 0xef, 0xb7, 0x92, 0xef, 0xb7, 0x93, + 0xef, 0xb7, 0x94, 0xef, 0xb7, 0x95, 0xef, 0xb7, 0x96, 0xef, 0xb7, 0x97, + 0xef, 0xb7, 0x98, 0xef, 0xb7, 0x99, 0xef, 0xb7, 0x9a, 0xef, 0xb7, 0x9b, + 0xef, 0xb7, 0x9c, 0xef, 0xb7, 0x9d, 0xef, 0xb7, 0x9e, 0xef, 0xb7, 0x9f, + 0xef, 0xb7, 0xa0, 0xef, 0xb7, 0xa1, 0xef, 0xb7, 0xa2, 0xef, 0xb7, 0xa3, + 0xef, 0xb7, 0xa4, 0xef, 0xb7, 0xa5, 0xef, 0xb7, 0xa6, 0xef, 0xb7, 0xa7, + 0xef, 0xb7, 0xa8, 0xef, 0xb7, 0xa9, 0xef, 0xb7, 0xaa, 0xef, 0xb7, 0xab, + 0xef, 0xb7, 0xac, 0xef, 0xb7, 0xad, 0xef, 0xb7, 0xae, 0xef, 0xb7, 0xaf}, + {0xfdd0, 0xfdd1, 0xfdd2, 0xfdd3, 0xfdd4, 0xfdd5, 0xfdd6, 0xfdd7, + 0xfdd8, 0xfdd9, 0xfdda, 0xfddb, 0xfddc, 0xfddd, 0xfdde, 0xfddf, + 0xfde0, 0xfde1, 0xfde2, 0xfde3, 0xfde4, 0xfde5, 0xfde6, 0xfde7, + 0xfde8, 0xfde9, 0xfdea, 0xfdeb, 0xfdec, 0xfded, 0xfdee, 0xfdef}}, + {{0xf0, 0x9f, 0xbf, 0xbe, 0xf0, 0x9f, 0xbf, 0xbf, 0xf0, 0xaf, 0xbf, + 0xbe, 0xf0, 0xaf, 0xbf, 0xbf, 0xf0, 0xbf, 0xbf, 0xbe, 0xf0, 0xbf, + 0xbf, 0xbf, 0xf1, 0x8f, 0xbf, 0xbe, 0xf1, 0x8f, 0xbf, 0xbf, 0xf1, + 0x9f, 0xbf, 0xbe, 0xf1, 0x9f, 0xbf, 0xbf, 0xf1, 0xaf, 0xbf, 0xbe, + 0xf1, 0xaf, 0xbf, 0xbf, 0xf1, 0xbf, 0xbf, 0xbe, 0xf1, 0xbf, 0xbf, + 0xbf, 0xf2, 0x8f, 0xbf, 0xbe, 0xf2, 0x8f, 0xbf, 0xbf}, + {0x1fffe, 0x1ffff, 0x2fffe, 0x2ffff, 0x3fffe, 0x3ffff, 0x4fffe, 0x4ffff, + 0x5fffe, 0x5ffff, 0x6fffe, 0x6ffff, 0x7fffe, 0x7ffff, 0x8fffe, + 0x8ffff}}, + }; + + for (auto test : data) { + // For figuring out which test fails: + fprintf(stderr, "test: "); + for (auto b : test.bytes) { + fprintf(stderr, "%x ", b); + } + fprintf(stderr, "\n"); + + std::vector<unibrow::uchar> output_normal; + DecodeNormally(test.bytes, &output_normal); + + CHECK_EQ(output_normal.size(), test.unicode_expected.size()); + for (size_t i = 0; i < output_normal.size(); ++i) { + CHECK_EQ(output_normal[i], test.unicode_expected[i]); + } + + std::vector<unibrow::uchar> output_incremental; + DecodeIncrementally(test.bytes, &output_incremental); + + CHECK_EQ(output_incremental.size(), test.unicode_expected.size()); + for (size_t i = 0; i < output_incremental.size(); ++i) { + CHECK_EQ(output_incremental[i], test.unicode_expected[i]); + } + } +} + } // namespace internal } // namespace v8 diff --git a/deps/v8/test/unittests/unittests.gyp b/deps/v8/test/unittests/unittests.gyp index c3f8554c26..38d071d71e 100644 --- a/deps/v8/test/unittests/unittests.gyp +++ b/deps/v8/test/unittests/unittests.gyp @@ -38,9 +38,13 @@ 'base/utils/random-number-generator-unittest.cc', 'cancelable-tasks-unittest.cc', 'char-predicates-unittest.cc', + "code-stub-assembler-unittest.cc", + "code-stub-assembler-unittest.h", 'compiler/branch-elimination-unittest.cc', 'compiler/bytecode-analysis-unittest.cc', 'compiler/checkpoint-elimination-unittest.cc', + "compiler/code-assembler-unittest.cc", + "compiler/code-assembler-unittest.h", 'compiler/common-operator-reducer-unittest.cc', 'compiler/common-operator-unittest.cc', 'compiler/compiler-test-utils.h', @@ -49,7 +53,6 @@ 'compiler/dead-code-elimination-unittest.cc', 'compiler/diamond-unittest.cc', 'compiler/effect-control-linearizer-unittest.cc', - 'compiler/escape-analysis-unittest.cc', 'compiler/graph-reducer-unittest.cc', 'compiler/graph-reducer-unittest.h', 'compiler/graph-trimmer-unittest.cc', @@ -98,8 +101,10 @@ 'compiler-dispatcher/optimizing-compile-dispatcher-unittest.cc', 'compiler-dispatcher/unoptimized-compile-job-unittest.cc', 'counters-unittest.cc', + 'detachable-vector-unittest.cc', 'eh-frame-iterator-unittest.cc', 'eh-frame-writer-unittest.cc', + 'heap/barrier-unittest.cc', 'heap/bitmap-unittest.cc', 'heap/embedder-tracing-unittest.cc', 'heap/gc-idle-time-handler-unittest.cc', @@ -150,6 +155,7 @@ 'wasm/control-transfer-unittest.cc', 'wasm/decoder-unittest.cc', 'wasm/function-body-decoder-unittest.cc', + 'wasm/wasm-heap-unittest.cc', 'wasm/leb-helper-unittest.cc', 'wasm/loop-assignment-analysis-unittest.cc', 'wasm/module-decoder-unittest.cc', @@ -266,7 +272,7 @@ ], }], ['v8_use_snapshot=="true"', { - 'dependencies': ['../../src/v8.gyp:v8_builtins_generators'], + 'dependencies': ['../../src/v8.gyp:v8_initializers'], }], ], }, diff --git a/deps/v8/test/unittests/wasm/control-transfer-unittest.cc b/deps/v8/test/unittests/wasm/control-transfer-unittest.cc index f49ba9c862..2b1a034179 100644 --- a/deps/v8/test/unittests/wasm/control-transfer-unittest.cc +++ b/deps/v8/test/unittests/wasm/control-transfer-unittest.cc @@ -20,13 +20,6 @@ namespace v8 { namespace internal { namespace wasm { -#define B1(a) kExprBlock, a, kExprEnd -#define B2(a, b) kExprBlock, a, b, kExprEnd -#define B3(a, b, c) kExprBlock, a, b, c, kExprEnd - -#define TRANSFER_VOID 0 -#define TRANSFER_ONE 1 - struct ExpectedControlTransfer { pc_t pc; pcdiff_t pc_diff; diff --git a/deps/v8/test/unittests/wasm/decoder-unittest.cc b/deps/v8/test/unittests/wasm/decoder-unittest.cc index e0c7908b90..0f11933383 100644 --- a/deps/v8/test/unittests/wasm/decoder-unittest.cc +++ b/deps/v8/test/unittests/wasm/decoder-unittest.cc @@ -676,6 +676,11 @@ TEST_F(DecoderTest, FailOnNullData) { EXPECT_FALSE(decoder.toResult(nullptr).ok()); } +#undef CHECK_UINT32V_INLINE +#undef CHECK_INT32V_INLINE +#undef CHECK_UINT64V_INLINE +#undef CHECK_INT64V_INLINE + } // namespace wasm } // namespace internal } // namespace v8 diff --git a/deps/v8/test/unittests/wasm/function-body-decoder-unittest.cc b/deps/v8/test/unittests/wasm/function-body-decoder-unittest.cc index 5dc5b46cc5..bda1073281 100644 --- a/deps/v8/test/unittests/wasm/function-body-decoder-unittest.cc +++ b/deps/v8/test/unittests/wasm/function-body-decoder-unittest.cc @@ -19,9 +19,10 @@ #include "test/common/wasm/test-signatures.h" #include "test/common/wasm/wasm-macro-gen.h" -using namespace v8::internal; -using namespace v8::internal::wasm; -using namespace v8::internal::wasm::testing; +namespace v8 { +namespace internal { +namespace wasm { +namespace function_body_decoder_unittest { #define B1(a) WASM_BLOCK(a) #define B2(a, b) WASM_BLOCK(a, b) @@ -523,6 +524,8 @@ TEST_F(FunctionBodyDecoderTest, Block0_end) { EXPECT_FAILURE(v_v, WASM_EMPTY_BLOCK, kExprEnd); } +#undef WASM_EMPTY_BLOCK + TEST_F(FunctionBodyDecoderTest, Block1) { byte code[] = {WASM_BLOCK_I(WASM_GET_LOCAL(0))}; EXPECT_VERIFIES_C(i_i, code); @@ -1341,6 +1344,16 @@ TEST_F(FunctionBodyDecoderTest, StoreMemOffset_varint) { VARINT4(0x44444444)); } +#undef BYTE0 +#undef BYTE1 +#undef BYTE2 +#undef BYTE3 + +#undef VARINT1 +#undef VARINT2 +#undef VARINT3 +#undef VARINT4 + TEST_F(FunctionBodyDecoderTest, AllLoadMemCombinations) { TestModuleBuilder builder; module = builder.module(); @@ -1846,6 +1859,14 @@ TEST_F(FunctionBodyDecoderTest, BreakIfBinop_fail) { WASM_BLOCK_I(WASM_F32_ABS(WASM_BRV_IF(0, WASM_F32(0.0f), WASM_ZERO)))); } +TEST_F(FunctionBodyDecoderTest, BreakIfUnrNarrow) { + EXPECT_FAILURE_S( + sigs.f_ff(), + WASM_BLOCK_I(WASM_BRV_IF(0, WASM_UNREACHABLE, WASM_UNREACHABLE), + WASM_RETURN0), + WASM_F32(0.0)); +} + TEST_F(FunctionBodyDecoderTest, BreakNesting1) { for (int i = 0; i < 5; i++) { // (block[2] (loop[2] (if (get p) break[N]) (set p 1)) p) @@ -2145,6 +2166,69 @@ TEST_F(FunctionBodyDecoderTest, BrTable_invalid_br2) { } } +TEST_F(FunctionBodyDecoderTest, BrTable_arity_mismatch1) { + EXPECT_FAILURE( + v_v, + WASM_BLOCK(WASM_BLOCK_I( + WASM_ONE, WASM_BR_TABLE(WASM_ONE, 1, BR_TARGET(0), BR_TARGET(1))))); +} + +TEST_F(FunctionBodyDecoderTest, BrTable_arity_mismatch2) { + EXPECT_FAILURE( + v_v, + WASM_BLOCK_I(WASM_BLOCK( + WASM_ONE, WASM_BR_TABLE(WASM_ONE, 1, BR_TARGET(0), BR_TARGET(1))))); +} + +TEST_F(FunctionBodyDecoderTest, BrTable_arity_mismatch_loop1) { + EXPECT_FAILURE( + v_v, + WASM_LOOP(WASM_BLOCK_I( + WASM_ONE, WASM_BR_TABLE(WASM_ONE, 1, BR_TARGET(0), BR_TARGET(1))))); +} + +TEST_F(FunctionBodyDecoderTest, BrTable_arity_mismatch_loop2) { + EXPECT_FAILURE( + v_v, + WASM_BLOCK_I(WASM_LOOP( + WASM_ONE, WASM_BR_TABLE(WASM_ONE, 1, BR_TARGET(0), BR_TARGET(1))))); +} + +TEST_F(FunctionBodyDecoderTest, BrTable_loop_block) { + EXPECT_VERIFIES( + v_v, + WASM_LOOP(WASM_BLOCK( + WASM_ONE, WASM_BR_TABLE(WASM_ONE, 1, BR_TARGET(0), BR_TARGET(1))))); +} + +TEST_F(FunctionBodyDecoderTest, BrTable_block_loop) { + EXPECT_VERIFIES( + v_v, + WASM_LOOP(WASM_BLOCK( + WASM_ONE, WASM_BR_TABLE(WASM_ONE, 1, BR_TARGET(0), BR_TARGET(1))))); +} + +TEST_F(FunctionBodyDecoderTest, BrTable_type_mismatch1) { + EXPECT_FAILURE( + v_v, + WASM_BLOCK_I(WASM_BLOCK_F( + WASM_ONE, WASM_BR_TABLE(WASM_ONE, 1, BR_TARGET(0), BR_TARGET(1))))); +} + +TEST_F(FunctionBodyDecoderTest, BrTable_type_mismatch2) { + EXPECT_FAILURE( + v_v, + WASM_BLOCK_F(WASM_BLOCK_I( + WASM_ONE, WASM_BR_TABLE(WASM_ONE, 1, BR_TARGET(0), BR_TARGET(1))))); +} + +TEST_F(FunctionBodyDecoderTest, BrTable_type_mismatch_unreachable) { + EXPECT_FAILURE(v_v, + WASM_BLOCK_F(WASM_BLOCK_I( + WASM_UNREACHABLE, + WASM_BR_TABLE(WASM_ONE, 1, BR_TARGET(0), BR_TARGET(1))))); +} + TEST_F(FunctionBodyDecoderTest, BrUnreachable1) { EXPECT_VERIFIES(v_i, WASM_GET_LOCAL(0), kExprBrTable, 0, BR_TARGET(0)); } @@ -2253,8 +2337,7 @@ TEST_F(FunctionBodyDecoderTest, Throw) { // exception index out of range. EXPECT_FAILURE(v_v, kExprThrow, 2); - // TODO(kschimpf): Fix when we can create exceptions with values. - EXPECT_FAILURE(v_v, WASM_I32V(0), kExprThrow, 1); + EXPECT_VERIFIES(v_v, WASM_I32V(0), kExprThrow, 1); // TODO(kschimpf): Add more tests. } @@ -2275,7 +2358,6 @@ TEST_F(FunctionBodyDecoderTest, ThrowUnreachable) { } #define WASM_TRY_OP kExprTry, kLocalVoid - #define WASM_CATCH(index) kExprCatch, static_cast<byte>(index) TEST_F(FunctionBodyDecoderTest, TryCatch) { @@ -2300,6 +2382,9 @@ TEST_F(FunctionBodyDecoderTest, TryCatch) { EXPECT_FAILURE(v_i, WASM_TRY_OP, WASM_CATCH(0), WASM_CATCH(1), kExprEnd); } +#undef WASM_TRY_OP +#undef WASM_CATCH + TEST_F(FunctionBodyDecoderTest, MultiValBlock1) { EXPERIMENTAL_FLAG_SCOPE(mv); EXPECT_VERIFIES(i_ii, WASM_BLOCK_TT(kWasmI32, kWasmI32, WASM_GET_LOCAL(0), @@ -2421,6 +2506,9 @@ TEST_F(BranchTableIteratorTest, error0) { CHECK_BR_TABLE_ERROR(1, U32V_1(33)); } +#undef CHECK_BR_TABLE_LENGTH +#undef CHECK_BR_TABLE_ERROR + class WasmOpcodeLengthTest : public TestWithZone { public: WasmOpcodeLengthTest() : TestWithZone() {} @@ -2657,11 +2745,13 @@ TEST_F(WasmOpcodeLengthTest, SimdExpressions) { FOREACH_SIMD_1_OPERAND_OPCODE(TEST_SIMD) #undef TEST_SIMD EXPECT_LENGTH_N(18, kSimdPrefix, static_cast<byte>(kExprS8x16Shuffle & 0xff)); -#undef TEST_SIMD // test for bad simd opcode EXPECT_LENGTH_N(2, kSimdPrefix, 0xff); } +#undef EXPECT_LENGTH +#undef EXPECT_LENGTH_N + typedef ZoneVector<ValueType> TypesOfLocals; class LocalDeclDecoderTest : public TestWithZone { @@ -2845,3 +2935,23 @@ TEST_F(BytecodeIteratorTest, WithLocalDecls) { iter.next(); EXPECT_FALSE(iter.has_next()); } + +#undef B1 +#undef B2 +#undef B3 +#undef WASM_IF_OP +#undef WASM_LOOP_OP +#undef WASM_BRV_IF_ZERO +#undef EXPECT_VERIFIES_C +#undef EXPECT_FAILURE_C +#undef EXPECT_VERIFIES_SC +#undef EXPECT_FAILURE_SC +#undef EXPECT_VERIFIES_S +#undef EXPECT_FAILURE_S +#undef EXPECT_VERIFIES +#undef EXPECT_FAILURE + +} // namespace function_body_decoder_unittest +} // namespace wasm +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/unittests/wasm/leb-helper-unittest.cc b/deps/v8/test/unittests/wasm/leb-helper-unittest.cc index 7b380c5490..474d49c1c5 100644 --- a/deps/v8/test/unittests/wasm/leb-helper-unittest.cc +++ b/deps/v8/test/unittests/wasm/leb-helper-unittest.cc @@ -108,6 +108,8 @@ DECLARE_ENCODE_DECODE_CHECKER(uint32_t, u32v) DECLARE_ENCODE_DECODE_CHECKER(int64_t, i64v) DECLARE_ENCODE_DECODE_CHECKER(uint64_t, u64v) +#undef DECLARE_ENCODE_DECODE_CHECKER + TEST_F(LEBHelperTest, WriteAndDecode_u32v) { CheckEncodeDecode_u32v(0); CheckEncodeDecode_u32v(1); diff --git a/deps/v8/test/unittests/wasm/loop-assignment-analysis-unittest.cc b/deps/v8/test/unittests/wasm/loop-assignment-analysis-unittest.cc index e6507b9685..d089d94ca2 100644 --- a/deps/v8/test/unittests/wasm/loop-assignment-analysis-unittest.cc +++ b/deps/v8/test/unittests/wasm/loop-assignment-analysis-unittest.cc @@ -14,12 +14,12 @@ #include "test/common/wasm/test-signatures.h" #include "test/common/wasm/wasm-macro-gen.h" -#define WASM_SET_ZERO(i) WASM_SET_LOCAL(i, WASM_ZERO) - namespace v8 { namespace internal { namespace wasm { +#define WASM_SET_ZERO(i) WASM_SET_LOCAL(i, WASM_ZERO) + class WasmLoopAssignmentAnalyzerTest : public TestWithZone { public: WasmLoopAssignmentAnalyzerTest() : num_locals(0) {} @@ -191,6 +191,8 @@ TEST_F(WasmLoopAssignmentAnalyzerTest, regress_642867) { Analyze(code, code + arraysize(code)); } +#undef WASM_SET_ZERO + } // namespace wasm } // namespace internal } // namespace v8 diff --git a/deps/v8/test/unittests/wasm/module-decoder-unittest.cc b/deps/v8/test/unittests/wasm/module-decoder-unittest.cc index 377e47db4c..2e76d374d3 100644 --- a/deps/v8/test/unittests/wasm/module-decoder-unittest.cc +++ b/deps/v8/test/unittests/wasm/module-decoder-unittest.cc @@ -15,6 +15,7 @@ namespace v8 { namespace internal { namespace wasm { +namespace module_decoder_unittest { #define WASM_INIT_EXPR_I32V_1(val) WASM_I32V_1(val), kExprEnd #define WASM_INIT_EXPR_I32V_2(val) WASM_I32V_2(val), kExprEnd @@ -1649,6 +1650,8 @@ TEST_F(WasmModuleVerifyTest, InitExpr_f64) { EXPECT_INIT_EXPR(F64, f64, 77999.1, WASM_F64(77999.1)); } +#undef EXPECT_INIT_EXPR + #define EXPECT_INIT_EXPR_FAIL(...) \ { \ static const byte data[] = {__VA_ARGS__, kExprEnd}; \ @@ -1665,6 +1668,8 @@ TEST_F(WasmModuleVerifyTest, InitExpr_illegal) { EXPECT_INIT_EXPR_FAIL(WASM_IF_ELSE(WASM_ZERO, WASM_ZERO, WASM_ZERO)); } +#undef EXPECT_INIT_EXPR_FAIL + TEST_F(WasmModuleVerifyTest, Multiple_Named_Sections) { static const byte data[] = { SECTION(Unknown, 4), 1, 'X', 17, 18, // -- @@ -1760,6 +1765,55 @@ TEST_F(WasmModuleCustomSectionTest, TwoKnownTwoUnknownSections) { CheckSections(data, data + sizeof(data), expected, arraysize(expected)); } +#undef WASM_INIT_EXPR_I32V_1 +#undef WASM_INIT_EXPR_I32V_2 +#undef WASM_INIT_EXPR_I32V_3 +#undef WASM_INIT_EXPR_I32V_4 +#undef WASM_INIT_EXPR_I32V_5 +#undef WASM_INIT_EXPR_F32 +#undef WASM_INIT_EXPR_I64 +#undef WASM_INIT_EXPR_F64 +#undef WASM_INIT_EXPR_GLOBAL +#undef SIZEOF_EMPTY_FUNCTION +#undef EMPTY_BODY +#undef SIZEOF_EMPTY_BODY +#undef NOP_BODY +#undef SIZEOF_NOP_BODY +#undef SIG_ENTRY_i_i +#undef UNKNOWN_SECTION +#undef SECTION +#undef SIGNATURES_SECTION +#undef FUNCTION_SIGNATURES_SECTION +#undef FOO_STRING +#undef NO_LOCAL_NAMES +#undef EMPTY_SIGNATURES_SECTION +#undef EMPTY_FUNCTION_SIGNATURES_SECTION +#undef EMPTY_FUNCTION_BODIES_SECTION +#undef SECTION_NAMES +#undef SECTION_EXCEPTIONS +#undef EMPTY_NAMES_SECTION +#undef FAIL_IF_NO_EXPERIMENTAL_EH +#undef X1 +#undef X2 +#undef X3 +#undef X4 +#undef ONE_EMPTY_FUNCTION +#undef TWO_EMPTY_FUNCTIONS +#undef THREE_EMPTY_FUNCTIONS +#undef FOUR_EMPTY_FUNCTIONS +#undef ONE_EMPTY_BODY +#undef TWO_EMPTY_BODIES +#undef THREE_EMPTY_BODIES +#undef FOUR_EMPTY_BODIES +#undef SIGNATURES_SECTION_VOID_VOID +#undef LINEAR_MEMORY_INDEX_0 +#undef EXPECT_VERIFIES +#undef EXPECT_FAILURE_LEN +#undef EXPECT_FAILURE +#undef EXPECT_OFF_END_FAILURE +#undef EXPECT_OK + +} // namespace module_decoder_unittest } // namespace wasm } // namespace internal } // namespace v8 diff --git a/deps/v8/test/unittests/wasm/streaming-decoder-unittest.cc b/deps/v8/test/unittests/wasm/streaming-decoder-unittest.cc index 98b3e25457..2ed28125f0 100644 --- a/deps/v8/test/unittests/wasm/streaming-decoder-unittest.cc +++ b/deps/v8/test/unittests/wasm/streaming-decoder-unittest.cc @@ -17,38 +17,121 @@ namespace v8 { namespace internal { namespace wasm { +class MockStreamingProcessor : public StreamingProcessor { + public: + bool ProcessModuleHeader(Vector<const uint8_t> bytes, + uint32_t offset) override { + // TODO(ahaas): Share code with the module-decoder. + Decoder decoder(bytes.begin(), bytes.end()); + uint32_t magic_word = decoder.consume_u32("wasm magic"); + if (decoder.failed() || magic_word != kWasmMagic) { + ok_ = false; + return false; + } + uint32_t magic_version = decoder.consume_u32("wasm version"); + if (decoder.failed() || magic_version != kWasmVersion) { + ok_ = false; + return false; + } + return true; + } + // Process all sections but the code section. + bool ProcessSection(SectionCode section_code, Vector<const uint8_t> bytes, + uint32_t offset) override { + ++num_sections_; + return true; + } + + bool ProcessCodeSectionHeader(size_t num_functions, + uint32_t offset) override { + return true; + } + + // Process a function body. + bool ProcessFunctionBody(Vector<const uint8_t> bytes, + uint32_t offset) override { + ++num_functions_; + return true; + } + + void OnFinishedChunk() override {} + + // Finish the processing of the stream. + void OnFinishedStream(std::unique_ptr<uint8_t[]> bytes, + size_t length) override { + received_bytes_ = std::move(bytes); + length_ = length; + } + + // Report an error detected in the StreamingDecoder. + void OnError(DecodeResult result) override { ok_ = false; } + + void OnAbort() override {} + + size_t num_sections() const { return num_sections_; } + size_t num_functions() const { return num_functions_; } + bool ok() const { return ok_; } + Vector<const uint8_t> received_bytes() { + return Vector<const uint8_t>(received_bytes_.get(), length_); + } + + private: + size_t num_sections_ = 0; + size_t num_functions_ = 0; + bool ok_ = true; + std::unique_ptr<uint8_t[]> received_bytes_; + size_t length_; +}; + class WasmStreamingDecoderTest : public ::testing::Test { public: - void ExpectVerifies(Vector<const uint8_t> data) { + void ExpectVerifies(Vector<const uint8_t> data, size_t expected_sections, + size_t expected_functions) { for (int split = 0; split <= data.length(); ++split) { - StreamingDecoder stream(nullptr); + // Use a unique_ptr so that the StreamingDecoder can own the processor. + std::unique_ptr<MockStreamingProcessor> p(new MockStreamingProcessor()); + MockStreamingProcessor* processor = p.get(); + StreamingDecoder stream(std::move(p)); stream.OnBytesReceived(data.SubVector(0, split)); stream.OnBytesReceived(data.SubVector(split, data.length())); - EXPECT_TRUE(stream.FinishForTesting()); + stream.Finish(); + EXPECT_TRUE(processor->ok()); + EXPECT_EQ(expected_sections, processor->num_sections()); + EXPECT_EQ(expected_functions, processor->num_functions()); + EXPECT_EQ(data, processor->received_bytes()); } } void ExpectFailure(Vector<const uint8_t> data) { for (int split = 0; split <= data.length(); ++split) { - StreamingDecoder stream(nullptr); + std::unique_ptr<MockStreamingProcessor> p(new MockStreamingProcessor()); + MockStreamingProcessor* processor = p.get(); + StreamingDecoder stream(std::move(p)); stream.OnBytesReceived(data.SubVector(0, split)); stream.OnBytesReceived(data.SubVector(split, data.length())); - EXPECT_FALSE(stream.FinishForTesting()); + stream.Finish(); + EXPECT_FALSE(processor->ok()); } } }; TEST_F(WasmStreamingDecoderTest, EmptyStream) { - StreamingDecoder stream(nullptr); - EXPECT_FALSE(stream.FinishForTesting()); + std::unique_ptr<MockStreamingProcessor> p(new MockStreamingProcessor()); + MockStreamingProcessor* processor = p.get(); + StreamingDecoder stream(std::move(p)); + stream.Finish(); + EXPECT_FALSE(processor->ok()); } TEST_F(WasmStreamingDecoderTest, IncompleteModuleHeader) { const uint8_t data[] = {U32_LE(kWasmMagic), U32_LE(kWasmVersion)}; { - StreamingDecoder stream(nullptr); + std::unique_ptr<MockStreamingProcessor> p(new MockStreamingProcessor()); + MockStreamingProcessor* processor = p.get(); + StreamingDecoder stream(std::move(p)); stream.OnBytesReceived(Vector<const uint8_t>(data, 1)); - EXPECT_FALSE(stream.FinishForTesting()); + stream.Finish(); + EXPECT_FALSE(processor->ok()); } for (int length = 1; length < static_cast<int>(arraysize(data)); ++length) { ExpectFailure(Vector<const uint8_t>(data, length)); @@ -57,7 +140,7 @@ TEST_F(WasmStreamingDecoderTest, IncompleteModuleHeader) { TEST_F(WasmStreamingDecoderTest, MagicAndVersion) { const uint8_t data[] = {U32_LE(kWasmMagic), U32_LE(kWasmVersion)}; - ExpectVerifies(Vector<const uint8_t>(data, arraysize(data))); + ExpectVerifies(Vector<const uint8_t>(data, arraysize(data)), 0, 0); } TEST_F(WasmStreamingDecoderTest, BadMagic) { @@ -87,7 +170,7 @@ TEST_F(WasmStreamingDecoderTest, OneSection) { 0x0, // 5 0x0 // 6 }; - ExpectVerifies(Vector<const uint8_t>(data, arraysize(data))); + ExpectVerifies(Vector<const uint8_t>(data, arraysize(data)), 1, 0); } TEST_F(WasmStreamingDecoderTest, OneSection_b) { @@ -104,7 +187,7 @@ TEST_F(WasmStreamingDecoderTest, OneSection_b) { 0x0, // 5 0x0 // 6 }; - ExpectVerifies(Vector<const uint8_t>(data, arraysize(data))); + ExpectVerifies(Vector<const uint8_t>(data, arraysize(data)), 1, 0); } TEST_F(WasmStreamingDecoderTest, OneShortSection) { @@ -118,7 +201,7 @@ TEST_F(WasmStreamingDecoderTest, OneShortSection) { 0x0, // Payload 0x0 // 2 }; - ExpectVerifies(Vector<const uint8_t>(data, arraysize(data))); + ExpectVerifies(Vector<const uint8_t>(data, arraysize(data)), 1, 0); } TEST_F(WasmStreamingDecoderTest, OneShortSection_b) { @@ -132,7 +215,7 @@ TEST_F(WasmStreamingDecoderTest, OneShortSection_b) { 0x0, // Payload 0x0 // 2 }; - ExpectVerifies(Vector<const uint8_t>(data, arraysize(data))); + ExpectVerifies(Vector<const uint8_t>(data, arraysize(data)), 1, 0); } TEST_F(WasmStreamingDecoderTest, OneEmptySection) { @@ -142,7 +225,7 @@ TEST_F(WasmStreamingDecoderTest, OneEmptySection) { 0x1, // Section ID 0x0 // Section Length }; - ExpectVerifies(Vector<const uint8_t>(data, arraysize(data))); + ExpectVerifies(Vector<const uint8_t>(data, arraysize(data)), 1, 0); } TEST_F(WasmStreamingDecoderTest, OneSectionNotEnoughPayload1) { @@ -207,7 +290,7 @@ TEST_F(WasmStreamingDecoderTest, TwoLongSections) { 0x0, // 6 0x0 // 7 }; - ExpectVerifies(Vector<const uint8_t>(data, arraysize(data))); + ExpectVerifies(Vector<const uint8_t>(data, arraysize(data)), 2, 0); } TEST_F(WasmStreamingDecoderTest, TwoShortSections) { @@ -222,7 +305,7 @@ TEST_F(WasmStreamingDecoderTest, TwoShortSections) { 0x0, // Payload 0x0, // 2 }; - ExpectVerifies(Vector<const uint8_t>(data, arraysize(data))); + ExpectVerifies(Vector<const uint8_t>(data, arraysize(data)), 2, 0); } TEST_F(WasmStreamingDecoderTest, TwoSectionsShortLong) { @@ -242,7 +325,7 @@ TEST_F(WasmStreamingDecoderTest, TwoSectionsShortLong) { 0x0, // 6 0x0 // 7 }; - ExpectVerifies(Vector<const uint8_t>(data, arraysize(data))); + ExpectVerifies(Vector<const uint8_t>(data, arraysize(data)), 2, 0); } TEST_F(WasmStreamingDecoderTest, TwoEmptySections) { @@ -254,19 +337,7 @@ TEST_F(WasmStreamingDecoderTest, TwoEmptySections) { 0x2, // Section ID 0x0 // Section Length }; - ExpectVerifies(Vector<const uint8_t>(data, arraysize(data))); -} - -TEST_F(WasmStreamingDecoderTest, EmptyCodeSection) { - const uint8_t data[] = { - U32_LE(kWasmMagic), // -- - U32_LE(kWasmVersion), // -- - kCodeSectionCode, // Section ID - 0x0, // Section Length - 0xb, // Section ID - 0x0 // Section Length - }; - ExpectVerifies(Vector<const uint8_t>(data, arraysize(data))); + ExpectVerifies(Vector<const uint8_t>(data, arraysize(data)), 2, 0); } TEST_F(WasmStreamingDecoderTest, OneFunction) { @@ -284,7 +355,7 @@ TEST_F(WasmStreamingDecoderTest, OneFunction) { 0x0, // 5 0x0, // 6 }; - ExpectVerifies(Vector<const uint8_t>(data, arraysize(data))); + ExpectVerifies(Vector<const uint8_t>(data, arraysize(data)), 0, 1); } TEST_F(WasmStreamingDecoderTest, OneShortFunction) { @@ -297,7 +368,7 @@ TEST_F(WasmStreamingDecoderTest, OneShortFunction) { 0x1, // Function Length 0x0, // Function }; - ExpectVerifies(Vector<const uint8_t>(data, arraysize(data))); + ExpectVerifies(Vector<const uint8_t>(data, arraysize(data)), 0, 1); } TEST_F(WasmStreamingDecoderTest, EmptyFunction) { @@ -335,7 +406,7 @@ TEST_F(WasmStreamingDecoderTest, TwoFunctions) { 0x0, // 6 0x0, // 7 }; - ExpectVerifies(Vector<const uint8_t>(data, arraysize(data))); + ExpectVerifies(Vector<const uint8_t>(data, arraysize(data)), 0, 2); } TEST_F(WasmStreamingDecoderTest, TwoFunctions_b) { @@ -356,7 +427,17 @@ TEST_F(WasmStreamingDecoderTest, TwoFunctions_b) { 0x0, // 6 0x0, // 7 }; - ExpectVerifies(Vector<const uint8_t>(data, arraysize(data))); + ExpectVerifies(Vector<const uint8_t>(data, arraysize(data)), 0, 2); +} + +TEST_F(WasmStreamingDecoderTest, CodeSectionLengthZero) { + const uint8_t data[] = { + U32_LE(kWasmMagic), // -- + U32_LE(kWasmVersion), // -- + kCodeSectionCode, // Section ID + 0x0, // Section Length + }; + ExpectFailure(Vector<const uint8_t>(data, arraysize(data))); } TEST_F(WasmStreamingDecoderTest, CodeSectionLengthTooHigh) { @@ -493,6 +574,66 @@ TEST_F(WasmStreamingDecoderTest, NumberOfFunctionsTooLow) { }; ExpectFailure(Vector<const uint8_t>(data, arraysize(data))); } + +TEST_F(WasmStreamingDecoderTest, TwoCodeSections) { + const uint8_t data[] = { + U32_LE(kWasmMagic), // -- + U32_LE(kWasmVersion), // -- + kCodeSectionCode, // Section ID + 0x3, // Section Length + 0x1, // Number of Functions + 0x1, // Function Length + 0x0, // Function + kCodeSectionCode, // Section ID + 0x3, // Section Length + 0x1, // Number of Functions + 0x1, // Function Length + 0x0, // Function + }; + ExpectFailure(Vector<const uint8_t>(data, arraysize(data))); +} + +TEST_F(WasmStreamingDecoderTest, UnknownSection) { + const uint8_t data[] = { + U32_LE(kWasmMagic), // -- + U32_LE(kWasmVersion), // -- + kCodeSectionCode, // Section ID + 0x3, // Section Length + 0x1, // Number of Functions + 0x1, // Function Length + 0x0, // Function + kUnknownSectionCode, // Section ID + 0x3, // Section Length + 0x1, // Name Length + 0x1, // Name + 0x0, // Content + }; + ExpectVerifies(Vector<const uint8_t>(data, arraysize(data)), 1, 1); +} + +TEST_F(WasmStreamingDecoderTest, UnknownSectionSandwich) { + const uint8_t data[] = { + U32_LE(kWasmMagic), // -- + U32_LE(kWasmVersion), // -- + kCodeSectionCode, // Section ID + 0x3, // Section Length + 0x1, // Number of Functions + 0x1, // Function Length + 0x0, // Function + kUnknownSectionCode, // Section ID + 0x3, // Section Length + 0x1, // Name Length + 0x1, // Name + 0x0, // Content + kCodeSectionCode, // Section ID + 0x3, // Section Length + 0x1, // Number of Functions + 0x1, // Function Length + 0x0, // Function + }; + ExpectFailure(Vector<const uint8_t>(data, arraysize(data))); +} + } // namespace wasm } // namespace internal } // namespace v8 diff --git a/deps/v8/test/unittests/wasm/wasm-heap-unittest.cc b/deps/v8/test/unittests/wasm/wasm-heap-unittest.cc new file mode 100644 index 0000000000..6e75e84b43 --- /dev/null +++ b/deps/v8/test/unittests/wasm/wasm-heap-unittest.cc @@ -0,0 +1,157 @@ +// Copyright 2017 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 "test/unittests/test-utils.h" +#include "testing/gmock/include/gmock/gmock.h" + +#include "src/wasm/wasm-heap.h" + +namespace v8 { +namespace internal { +namespace wasm { +namespace wasm_heap_unittest { + +class DisjointAllocationPoolTest : public ::testing::Test { + public: + Address A(size_t n) { return reinterpret_cast<Address>(n); } + void CheckLooksLike(const DisjointAllocationPool& mem, + std::vector<std::pair<size_t, size_t>> expectation); + DisjointAllocationPool Make(std::vector<std::pair<size_t, size_t>> model); +}; + +void DisjointAllocationPoolTest::CheckLooksLike( + const DisjointAllocationPool& mem, + std::vector<std::pair<size_t, size_t>> expectation) { + const auto& ranges = mem.ranges(); + CHECK_EQ(ranges.size(), expectation.size()); + auto iter = expectation.begin(); + for (auto it = ranges.begin(), e = ranges.end(); it != e; ++it, ++iter) { + CHECK_EQ(it->first, A(iter->first)); + CHECK_EQ(it->second, A(iter->second)); + } +} + +DisjointAllocationPool DisjointAllocationPoolTest::Make( + std::vector<std::pair<size_t, size_t>> model) { + DisjointAllocationPool ret; + for (auto& pair : model) { + ret.Merge(DisjointAllocationPool(A(pair.first), A(pair.second))); + } + return ret; +} + +TEST_F(DisjointAllocationPoolTest, Construct) { + DisjointAllocationPool a; + CHECK(a.IsEmpty()); + CHECK_EQ(a.ranges().size(), 0); + DisjointAllocationPool b = Make({{1, 5}}); + CHECK(!b.IsEmpty()); + CHECK_EQ(b.ranges().size(), 1); + a.Merge(std::move(b)); + CheckLooksLike(a, {{1, 5}}); + DisjointAllocationPool c; + a.Merge(std::move(c)); + CheckLooksLike(a, {{1, 5}}); + DisjointAllocationPool e, f; + e.Merge(std::move(f)); + CHECK(e.IsEmpty()); +} + +TEST_F(DisjointAllocationPoolTest, SimpleExtract) { + DisjointAllocationPool a = Make({{1, 5}}); + DisjointAllocationPool b = a.AllocatePool(2); + CheckLooksLike(a, {{3, 5}}); + CheckLooksLike(b, {{1, 3}}); + a.Merge(std::move(b)); + CheckLooksLike(a, {{1, 5}}); + CHECK_EQ(a.ranges().size(), 1); + CHECK_EQ(a.ranges().front().first, A(1)); + CHECK_EQ(a.ranges().front().second, A(5)); +} + +TEST_F(DisjointAllocationPoolTest, ExtractAll) { + DisjointAllocationPool a(A(1), A(5)); + DisjointAllocationPool b = a.AllocatePool(4); + CheckLooksLike(b, {{1, 5}}); + CHECK(a.IsEmpty()); + a.Merge(std::move(b)); + CheckLooksLike(a, {{1, 5}}); +} + +TEST_F(DisjointAllocationPoolTest, ExtractAccross) { + DisjointAllocationPool a = Make({{1, 5}, {10, 20}}); + DisjointAllocationPool b = a.AllocatePool(5); + CheckLooksLike(a, {{11, 20}}); + CheckLooksLike(b, {{1, 5}, {10, 11}}); + a.Merge(std::move(b)); + CheckLooksLike(a, {{1, 5}, {10, 20}}); +} + +TEST_F(DisjointAllocationPoolTest, ReassembleOutOfOrder) { + DisjointAllocationPool a = Make({{1, 5}, {10, 15}}); + DisjointAllocationPool b = Make({{7, 8}, {20, 22}}); + a.Merge(std::move(b)); + CheckLooksLike(a, {{1, 5}, {7, 8}, {10, 15}, {20, 22}}); + + DisjointAllocationPool c = Make({{1, 5}, {10, 15}}); + DisjointAllocationPool d = Make({{7, 8}, {20, 22}}); + d.Merge(std::move(c)); + CheckLooksLike(d, {{1, 5}, {7, 8}, {10, 15}, {20, 22}}); +} + +TEST_F(DisjointAllocationPoolTest, FailToExtract) { + DisjointAllocationPool a = Make({{1, 5}}); + DisjointAllocationPool b = a.AllocatePool(5); + CheckLooksLike(a, {{1, 5}}); + CHECK(b.IsEmpty()); +} + +TEST_F(DisjointAllocationPoolTest, FailToExtractExact) { + DisjointAllocationPool a = Make({{1, 5}, {10, 14}}); + DisjointAllocationPool b = a.Allocate(5); + CheckLooksLike(a, {{1, 5}, {10, 14}}); + CHECK(b.IsEmpty()); +} + +TEST_F(DisjointAllocationPoolTest, ExtractExact) { + DisjointAllocationPool a = Make({{1, 5}, {10, 15}}); + DisjointAllocationPool b = a.Allocate(5); + CheckLooksLike(a, {{1, 5}}); + CheckLooksLike(b, {{10, 15}}); +} + +TEST_F(DisjointAllocationPoolTest, Merging) { + DisjointAllocationPool a = Make({{10, 15}, {20, 25}}); + a.Merge(Make({{15, 20}})); + CheckLooksLike(a, {{10, 25}}); +} + +TEST_F(DisjointAllocationPoolTest, MergingMore) { + DisjointAllocationPool a = Make({{10, 15}, {20, 25}, {30, 35}}); + a.Merge(Make({{15, 20}, {25, 30}})); + CheckLooksLike(a, {{10, 35}}); +} + +TEST_F(DisjointAllocationPoolTest, MergingSkip) { + DisjointAllocationPool a = Make({{10, 15}, {20, 25}, {30, 35}}); + a.Merge(Make({{25, 30}})); + CheckLooksLike(a, {{10, 15}, {20, 35}}); +} + +TEST_F(DisjointAllocationPoolTest, MergingSkipLargerSrc) { + DisjointAllocationPool a = Make({{10, 15}, {20, 25}, {30, 35}}); + a.Merge(Make({{25, 30}, {35, 40}})); + CheckLooksLike(a, {{10, 15}, {20, 40}}); +} + +TEST_F(DisjointAllocationPoolTest, MergingSkipLargerSrcWithGap) { + DisjointAllocationPool a = Make({{10, 15}, {20, 25}, {30, 35}}); + a.Merge(Make({{25, 30}, {36, 40}})); + CheckLooksLike(a, {{10, 15}, {20, 35}, {36, 40}}); +} + +} // namespace wasm_heap_unittest +} // namespace wasm +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/unittests/wasm/wasm-macro-gen-unittest.cc b/deps/v8/test/unittests/wasm/wasm-macro-gen-unittest.cc index 63309db078..45a4c5a59b 100644 --- a/deps/v8/test/unittests/wasm/wasm-macro-gen-unittest.cc +++ b/deps/v8/test/unittests/wasm/wasm-macro-gen-unittest.cc @@ -309,6 +309,9 @@ TEST_F(WasmMacroGenTest, LoadsAndStoresWithOffset) { WASM_GET_LOCAL(0))); } } + +#undef EXPECT_SIZE + } // namespace wasm } // namespace internal } // namespace v8 diff --git a/deps/v8/test/unittests/wasm/wasm-opcodes-unittest.cc b/deps/v8/test/unittests/wasm/wasm-opcodes-unittest.cc index 4bb04c7152..12739ff44f 100644 --- a/deps/v8/test/unittests/wasm/wasm-opcodes-unittest.cc +++ b/deps/v8/test/unittests/wasm/wasm-opcodes-unittest.cc @@ -19,6 +19,7 @@ TEST_F(WasmOpcodesTest, EveryOpcodeHasAName) { } kValues[] = { #define DECLARE_ELEMENT(name, opcode, sig) {kExpr##name, "kExpr" #name}, FOREACH_OPCODE(DECLARE_ELEMENT)}; +#undef DECLARE_ELEMENT for (size_t i = 0; i < arraysize(kValues); i++) { const char* result = WasmOpcodes::OpcodeName(kValues[i].opcode); diff --git a/deps/v8/test/wasm-spec-tests/tests.tar.gz.sha1 b/deps/v8/test/wasm-spec-tests/tests.tar.gz.sha1 index 76c4ddc21f..240b11b803 100644 --- a/deps/v8/test/wasm-spec-tests/tests.tar.gz.sha1 +++ b/deps/v8/test/wasm-spec-tests/tests.tar.gz.sha1 @@ -1 +1 @@ -ca6a2bd223a88c489d9f5fbfb21bf4eb8700e62e
\ No newline at end of file +2c29039a7935576bb6d01f9b4b6c96b8861b5bbe
\ No newline at end of file diff --git a/deps/v8/test/wasm-spec-tests/wasm-spec-tests.status b/deps/v8/test/wasm-spec-tests/wasm-spec-tests.status index f0e4af7e79..c97ac33824 100644 --- a/deps/v8/test/wasm-spec-tests/wasm-spec-tests.status +++ b/deps/v8/test/wasm-spec-tests/wasm-spec-tests.status @@ -5,7 +5,6 @@ [ [ALWAYS, { #TODO(ahaas): Add additional stack checks on mips. - # Issue 6318: Stack checks for functions with huge stack frames fail on x64 and ia32 'tests/skip-stack-guard-page': [PASS, ['arch == mipsel or arch == mips64el or ((arch == ppc or arch == ppc64 or arch == s390 or arch == s390x) and simulator_run)', SKIP]], }], # ALWAYS diff --git a/deps/v8/test/webkit/js-continue-break-restrictions-expected.txt b/deps/v8/test/webkit/js-continue-break-restrictions-expected.txt index e42cf3dc37..5cf59d2346 100644 --- a/deps/v8/test/webkit/js-continue-break-restrictions-expected.txt +++ b/deps/v8/test/webkit/js-continue-break-restrictions-expected.txt @@ -42,17 +42,17 @@ PASS if (0) { L:A:{ continue; } } threw exception SyntaxError: Illegal continue PASS if(0){ L:for(;;) continue L; } is undefined. PASS if(0){ L:A:for(;;) continue L; } is undefined. PASS if(0){ A:L:for(;;) continue L; } is undefined. -PASS if(0){ A:for(;;) L:continue L; } threw exception SyntaxError: Illegal continue statement: 'L' does not denote an iteration statement. +PASS if(0){ A:for(;;) L:continue L; } threw exception SyntaxError: Undefined label 'L'. PASS if(0){ L:for(;;) A:continue L; } is undefined. PASS if(0){ L:do continue L; while(0); } is undefined. PASS if(0){ L:A:do continue L; while(0); } is undefined. PASS if(0){ A:L:do continue L; while(0);} is undefined. -PASS if(0){ A:do L:continue L; while(0); } threw exception SyntaxError: Illegal continue statement: 'L' does not denote an iteration statement. +PASS if(0){ A:do L:continue L; while(0); } threw exception SyntaxError: Undefined label 'L'. PASS if(0){ L:do A:continue L; while(0); } is undefined. PASS if(0){ L:while(0) continue L; } is undefined. PASS if(0){ L:A:while(0) continue L; } is undefined. PASS if(0){ A:L:while(0) continue L; } is undefined. -PASS if(0){ A:while(0) L:continue L; } threw exception SyntaxError: Illegal continue statement: 'L' does not denote an iteration statement. +PASS if(0){ A:while(0) L:continue L; } threw exception SyntaxError: Undefined label 'L'. PASS if(0){ L:while(0) A:continue L; } is undefined. PASS successfullyParsed is true diff --git a/deps/v8/test/webkit/webkit.status b/deps/v8/test/webkit/webkit.status index e8a24abd50..322454ba17 100644 --- a/deps/v8/test/webkit/webkit.status +++ b/deps/v8/test/webkit/webkit.status @@ -36,6 +36,10 @@ # Irregexp interpreter overflows stack. We should just not crash. 'fast/js/regexp-stack-overflow': [PASS, FAIL], }], # ALWAYS +['system == windows', { + # Exceeds call stack on windows after MSVS2017 switch. + 'fast/js/excessive-comma-usage': [SKIP], +}], # system == windows ['mode == debug', { # Too slow in debug mode. 'dfg-int-overflow-in-loop': [SKIP], |