diff options
Diffstat (limited to 'deps/v8/test/cctest')
87 files changed, 5473 insertions, 2470 deletions
diff --git a/deps/v8/test/cctest/BUILD.gn b/deps/v8/test/cctest/BUILD.gn index 32a766736f..d0934c9977 100644 --- a/deps/v8/test/cctest/BUILD.gn +++ b/deps/v8/test/cctest/BUILD.gn @@ -4,6 +4,13 @@ import("../../gni/v8.gni") +config("cctest_config") { + # Work around a bug in the gold linker. + if (use_gold && target_cpu == "x86") { + ldflags = [ "-Wl,--icf=none" ] + } +} + v8_executable("cctest") { testonly = true @@ -28,6 +35,7 @@ v8_executable("cctest") { configs = [ "../..:external_config", "../..:internal_config_base", + ":cctest_config", ] ldflags = [] @@ -188,6 +196,7 @@ v8_source_set("cctest_sources") { "test-conversions.cc", "test-cpu-profiler.cc", "test-date.cc", + "test-debug-helper.cc", "test-debug.cc", "test-decls.cc", "test-deoptimization.cc", @@ -313,11 +322,15 @@ v8_source_set("cctest_sources") { "test-javascript-arm64.cc", "test-js-arm64-variables.cc", "test-macro-assembler-arm64.cc", + "test-pointer-auth-arm64.cc", "test-poison-disasm-arm64.cc", "test-sync-primitives-arm64.cc", "test-utils-arm64.cc", "test-utils-arm64.h", ] + if (is_win) { + sources += [ "test-stack-unwinding-win64.cc" ] + } } else if (v8_current_cpu == "x86") { sources += [ ### gcmole(arch:ia32) ### "test-assembler-ia32.cc", @@ -356,7 +369,7 @@ v8_source_set("cctest_sources") { "test-macro-assembler-x64.cc", ] if (is_win) { - sources += [ "test-stack-unwinding-x64.cc" ] + sources += [ "test-stack-unwinding-win64.cc" ] } } else if (v8_current_cpu == "ppc" || v8_current_cpu == "ppc64") { sources += [ ### gcmole(arch:ppc) ### @@ -382,6 +395,7 @@ v8_source_set("cctest_sources") { "../..:v8_libbase", "../..:v8_libplatform", "../..:wasm_module_runner", + "../../tools/debug_helper:v8_debug_helper", "//build/win:default_exe_manifest", ] diff --git a/deps/v8/test/cctest/DEPS b/deps/v8/test/cctest/DEPS index 909e60372e..7373012870 100644 --- a/deps/v8/test/cctest/DEPS +++ b/deps/v8/test/cctest/DEPS @@ -1,5 +1,6 @@ include_rules = [ "+src", + "+tools", "+torque-generated", - "+perfetto/tracing.h" -] + "+perfetto", +]
\ No newline at end of file diff --git a/deps/v8/test/cctest/cctest.status b/deps/v8/test/cctest/cctest.status index 17d0096140..b1a7b5c101 100644 --- a/deps/v8/test/cctest/cctest.status +++ b/deps/v8/test/cctest/cctest.status @@ -518,6 +518,7 @@ 'test-regexp/MacroAssemblerNativeSimpleUC16': [SKIP], 'test-regexp/MacroAssemblerNativeSuccess': [SKIP], 'test-regexp/MacroAssemblerStackOverflow': [SKIP], + 'test-regexp/Graph': [SKIP], 'test-run-bytecode-graph-builder/*': [SKIP], 'test-run-calls-to-external-references/*': [SKIP], 'test-run-deopt/*': [SKIP], diff --git a/deps/v8/test/cctest/compiler/codegen-tester.h b/deps/v8/test/cctest/compiler/codegen-tester.h index 62db9445ea..210fe2cf1c 100644 --- a/deps/v8/test/cctest/compiler/codegen-tester.h +++ b/deps/v8/test/cctest/compiler/codegen-tester.h @@ -34,7 +34,7 @@ class RawMachineAssemblerTester : public HandleAndZoneScope, main_zone(), CSignature::New(main_zone(), MachineTypeForC<ReturnType>(), p...), - true), + CallDescriptor::kInitializeRootRegister), MachineType::PointerRepresentation(), InstructionSelector::SupportedMachineOperatorFlags(), InstructionSelector::AlignmentRequirements()) {} @@ -51,7 +51,7 @@ class RawMachineAssemblerTester : public HandleAndZoneScope, main_zone(), CSignature::New(main_zone(), MachineTypeForC<ReturnType>(), p...), - true), + CallDescriptor::kInitializeRootRegister), MachineType::PointerRepresentation(), InstructionSelector::SupportedMachineOperatorFlags(), InstructionSelector::AlignmentRequirements()), @@ -79,7 +79,7 @@ class RawMachineAssemblerTester : public HandleAndZoneScope, protected: Address Generate() override { if (code_.is_null()) { - Schedule* schedule = this->Export(); + Schedule* schedule = this->ExportForTest(); auto call_descriptor = this->call_descriptor(); Graph* graph = this->graph(); OptimizedCompilationInfo info(ArrayVector("testing"), main_zone(), kind_); diff --git a/deps/v8/test/cctest/compiler/serializer-tester.cc b/deps/v8/test/cctest/compiler/serializer-tester.cc index 2b56e07d24..338d1bcbfb 100644 --- a/deps/v8/test/cctest/compiler/serializer-tester.cc +++ b/deps/v8/test/cctest/compiler/serializer-tester.cc @@ -70,7 +70,11 @@ void CheckForSerializedInlinee(const char* source, int argc = 0, Handle<Object> g; CHECK(g_obj.ToHandle(&g)); + CHECK_WITH_MSG( + g->IsJSFunction(), + "The return value of the outer function must be a function too"); Handle<JSFunction> g_func = Handle<JSFunction>::cast(g); + SharedFunctionInfoRef g_sfi(tester.broker(), handle(g_func->shared(), tester.isolate())); FeedbackVectorRef g_fv(tester.broker(), @@ -288,6 +292,34 @@ TEST(MergeJumpTargetEnvironment) { "f(); return f;"); // Two calls to f to make g() megamorhpic. } +TEST(BoundFunctionTarget) { + CheckForSerializedInlinee( + "function apply(foo, arg) { return foo(arg); };" + "%EnsureFeedbackVectorForFunction(apply);" + "function test() {" + " const lambda = (a) => a;" + " %EnsureFeedbackVectorForFunction(lambda);" + " let bound = apply.bind(null, lambda).bind(null, 42);" + " %TurbofanStaticAssert(bound() == 42); return apply;" + "};" + "%EnsureFeedbackVectorForFunction(test);" + "test(); return test;"); +} + +TEST(BoundFunctionArguments) { + CheckForSerializedInlinee( + "function apply(foo, arg) { return foo(arg); };" + "%EnsureFeedbackVectorForFunction(apply);" + "function test() {" + " const lambda = (a) => a;" + " %EnsureFeedbackVectorForFunction(lambda);" + " let bound = apply.bind(null, lambda).bind(null, 42);" + " %TurbofanStaticAssert(bound() == 42); return lambda;" + "};" + "%EnsureFeedbackVectorForFunction(test);" + "test(); return test;"); +} + } // namespace compiler } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-code-assembler.cc b/deps/v8/test/cctest/compiler/test-code-assembler.cc index 375c6586f3..9e6318ee88 100644 --- a/deps/v8/test/cctest/compiler/test-code-assembler.cc +++ b/deps/v8/test/cctest/compiler/test-code-assembler.cc @@ -24,7 +24,7 @@ using Variable = CodeAssemblerVariable; Node* SmiTag(CodeAssembler& m, // NOLINT(runtime/references) Node* value) { int32_t constant_value; - if (m.ToInt32Constant(value, constant_value) && + if (m.ToInt32Constant(value, &constant_value) && Smi::IsValid(constant_value)) { return m.SmiConstant(Smi::FromInt(constant_value)); } @@ -89,7 +89,8 @@ TEST(SimpleCallRuntime1Arg) { Isolate* isolate(CcTest::InitIsolateOnce()); CodeAssemblerTester asm_tester(isolate); CodeAssembler m(asm_tester.state()); - Node* context = m.HeapConstant(Handle<Context>(isolate->native_context())); + TNode<Context> context = + m.HeapConstant(Handle<Context>(isolate->native_context())); Node* b = SmiTag(m, m.Int32Constant(0)); m.Return(m.CallRuntime(Runtime::kIsSmi, context, b)); FunctionTester ft(asm_tester.GenerateCode()); @@ -101,7 +102,8 @@ TEST(SimpleTailCallRuntime1Arg) { Isolate* isolate(CcTest::InitIsolateOnce()); CodeAssemblerTester asm_tester(isolate); CodeAssembler m(asm_tester.state()); - Node* context = m.HeapConstant(Handle<Context>(isolate->native_context())); + TNode<Context> context = + m.HeapConstant(Handle<Context>(isolate->native_context())); Node* b = SmiTag(m, m.Int32Constant(0)); m.TailCallRuntime(Runtime::kIsSmi, context, b); FunctionTester ft(asm_tester.GenerateCode()); @@ -113,7 +115,8 @@ TEST(SimpleCallRuntime2Arg) { Isolate* isolate(CcTest::InitIsolateOnce()); CodeAssemblerTester asm_tester(isolate); CodeAssembler m(asm_tester.state()); - Node* context = m.HeapConstant(Handle<Context>(isolate->native_context())); + TNode<Context> context = + m.HeapConstant(Handle<Context>(isolate->native_context())); Node* a = SmiTag(m, m.Int32Constant(2)); Node* b = SmiTag(m, m.Int32Constant(4)); m.Return(m.CallRuntime(Runtime::kAdd, context, a, b)); @@ -125,7 +128,8 @@ TEST(SimpleTailCallRuntime2Arg) { Isolate* isolate(CcTest::InitIsolateOnce()); CodeAssemblerTester asm_tester(isolate); CodeAssembler m(asm_tester.state()); - Node* context = m.HeapConstant(Handle<Context>(isolate->native_context())); + TNode<Context> context = + m.HeapConstant(Handle<Context>(isolate->native_context())); Node* a = SmiTag(m, m.Int32Constant(2)); Node* b = SmiTag(m, m.Int32Constant(4)); m.TailCallRuntime(Runtime::kAdd, context, a, b); @@ -225,7 +229,7 @@ TEST(VariableMerge1) { CodeAssembler m(asm_tester.state()); Variable var1(&m, MachineRepresentation::kTagged); Label l1(&m), l2(&m), merge(&m); - Node* temp = m.Int32Constant(0); + TNode<Int32T> temp = m.Int32Constant(0); var1.Bind(temp); m.Branch(m.Int32Constant(1), &l1, &l2); m.Bind(&l1); @@ -244,14 +248,14 @@ TEST(VariableMerge2) { CodeAssembler m(asm_tester.state()); Variable var1(&m, MachineRepresentation::kTagged); Label l1(&m), l2(&m), merge(&m); - Node* temp = m.Int32Constant(0); + TNode<Int32T> temp = m.Int32Constant(0); var1.Bind(temp); m.Branch(m.Int32Constant(1), &l1, &l2); m.Bind(&l1); CHECK_EQ(var1.value(), temp); m.Goto(&merge); m.Bind(&l2); - Node* temp2 = m.Int32Constant(2); + TNode<Int32T> temp2 = m.Int32Constant(2); var1.Bind(temp2); CHECK_EQ(var1.value(), temp2); m.Goto(&merge); @@ -266,7 +270,7 @@ TEST(VariableMerge3) { Variable var1(&m, MachineRepresentation::kTagged); Variable var2(&m, MachineRepresentation::kTagged); Label l1(&m), l2(&m), merge(&m); - Node* temp = m.Int32Constant(0); + TNode<Int32T> temp = m.Int32Constant(0); var1.Bind(temp); var2.Bind(temp); m.Branch(m.Int32Constant(1), &l1, &l2); @@ -274,7 +278,7 @@ TEST(VariableMerge3) { CHECK_EQ(var1.value(), temp); m.Goto(&merge); m.Bind(&l2); - Node* temp2 = m.Int32Constant(2); + TNode<Int32T> temp2 = m.Int32Constant(2); var1.Bind(temp2); CHECK_EQ(var1.value(), temp2); m.Goto(&merge); @@ -290,7 +294,7 @@ TEST(VariableMergeBindFirst) { CodeAssembler m(asm_tester.state()); Variable var1(&m, MachineRepresentation::kTagged); Label l1(&m), l2(&m), merge(&m, &var1), end(&m); - Node* temp = m.Int32Constant(0); + TNode<Int32T> temp = m.Int32Constant(0); var1.Bind(temp); m.Branch(m.Int32Constant(1), &l1, &l2); m.Bind(&l1); @@ -301,7 +305,7 @@ TEST(VariableMergeBindFirst) { CHECK_NOT_NULL(var1.value()); m.Goto(&end); m.Bind(&l2); - Node* temp2 = m.Int32Constant(2); + TNode<Int32T> temp2 = m.Int32Constant(2); var1.Bind(temp2); CHECK_EQ(var1.value(), temp2); m.Goto(&merge); @@ -318,7 +322,7 @@ TEST(VariableMergeSwitch) { Label l1(&m), l2(&m), default_label(&m); Label* labels[] = {&l1, &l2}; int32_t values[] = {1, 2}; - Node* temp1 = m.Int32Constant(0); + TNode<Smi> temp1 = m.SmiConstant(0); var1.Bind(temp1); m.Switch(m.Int32Constant(2), &default_label, values, labels, 2); m.Bind(&l1); @@ -326,7 +330,7 @@ TEST(VariableMergeSwitch) { m.Return(temp1); m.Bind(&l2); CHECK_EQ(temp1, var1.value()); - Node* temp2 = m.Int32Constant(7); + TNode<Smi> temp2 = m.SmiConstant(7); var1.Bind(temp2); m.Goto(&default_label); m.Bind(&default_label); @@ -374,24 +378,24 @@ TEST(TestToConstant) { int32_t value32; int64_t value64; Node* a = m.Int32Constant(5); - CHECK(m.ToInt32Constant(a, value32)); - CHECK(m.ToInt64Constant(a, value64)); + CHECK(m.ToInt32Constant(a, &value32)); + CHECK(m.ToInt64Constant(a, &value64)); a = m.Int64Constant(static_cast<int64_t>(1) << 32); - CHECK(!m.ToInt32Constant(a, value32)); - CHECK(m.ToInt64Constant(a, value64)); + CHECK(!m.ToInt32Constant(a, &value32)); + CHECK(m.ToInt64Constant(a, &value64)); a = m.Int64Constant(13); - CHECK(m.ToInt32Constant(a, value32)); - CHECK(m.ToInt64Constant(a, value64)); + CHECK(m.ToInt32Constant(a, &value32)); + CHECK(m.ToInt64Constant(a, &value64)); a = UndefinedConstant(m); - CHECK(!m.ToInt32Constant(a, value32)); - CHECK(!m.ToInt64Constant(a, value64)); + CHECK(!m.ToInt32Constant(a, &value32)); + CHECK(!m.ToInt64Constant(a, &value64)); a = UndefinedConstant(m); - CHECK(!m.ToInt32Constant(a, value32)); - CHECK(!m.ToInt64Constant(a, value64)); + CHECK(!m.ToInt32Constant(a, &value32)); + CHECK(!m.ToInt64Constant(a, &value64)); } TEST(DeferredCodePhiHints) { @@ -453,14 +457,15 @@ TEST(GotoIfException) { CodeAssemblerTester asm_tester(isolate, kNumParams); CodeAssembler m(asm_tester.state()); - Node* context = m.HeapConstant(Handle<Context>(isolate->native_context())); - Node* to_string_tag = + TNode<Context> context = + m.HeapConstant(Handle<Context>(isolate->native_context())); + TNode<Symbol> to_string_tag = m.HeapConstant(isolate->factory()->to_string_tag_symbol()); Variable exception(&m, MachineRepresentation::kTagged); Label exception_handler(&m); Callable to_string = Builtins::CallableFor(isolate, Builtins::kToString); - Node* string = m.CallStub(to_string, context, to_string_tag); + TNode<Object> string = m.CallStub(to_string, context, to_string_tag); m.GotoIfException(string, &exception_handler, &exception); m.Return(string); @@ -487,7 +492,8 @@ TEST(GotoIfExceptionMultiple) { CodeAssemblerTester asm_tester(isolate, kNumParams); CodeAssembler m(asm_tester.state()); - Node* context = m.HeapConstant(Handle<Context>(isolate->native_context())); + TNode<Context> context = + m.HeapConstant(Handle<Context>(isolate->native_context())); Node* first_value = m.Parameter(0); Node* second_value = m.Parameter(1); Node* third_value = m.Parameter(2); @@ -502,7 +508,7 @@ TEST(GotoIfExceptionMultiple) { // try { return ToString(param1) } catch (e) { ... } Callable to_string = Builtins::CallableFor(isolate, Builtins::kToString); - Node* string = m.CallStub(to_string, context, first_value); + TNode<Object> string = m.CallStub(to_string, context, first_value); m.GotoIfException(string, &exception_handler1, &error); m.Return(string); @@ -575,7 +581,8 @@ TEST(ExceptionHandler) { Label exception(&m, {&var}, Label::kDeferred); { CodeAssemblerScopedExceptionHandler handler(&m, &exception, &var); - Node* context = m.HeapConstant(Handle<Context>(isolate->native_context())); + TNode<Context> context = + m.HeapConstant(Handle<Context>(isolate->native_context())); m.CallRuntime(Runtime::kThrow, context, m.SmiConstant(2)); } m.Return(m.SmiConstant(1)); diff --git a/deps/v8/test/cctest/compiler/test-code-generator.cc b/deps/v8/test/cctest/compiler/test-code-generator.cc index 30cd7da7b5..74c50a4bfa 100644 --- a/deps/v8/test/cctest/compiler/test-code-generator.cc +++ b/deps/v8/test/cctest/compiler/test-code-generator.cc @@ -223,7 +223,7 @@ Handle<Code> BuildTeardownFunction(Isolate* isolate, TNode<FixedArray> vector = __ Cast(__ LoadFixedArrayElement(result_array, i)); for (int lane = 0; lane < 4; lane++) { - Node* lane_value = + TNode<Smi> lane_value = __ SmiFromInt32(tester.raw_assembler_for_testing()->AddNode( tester.raw_assembler_for_testing() ->machine() @@ -990,13 +990,14 @@ class CodeGeneratorTester { i++; } + static constexpr size_t kMaxUnoptimizedFrameHeight = 0; generator_ = new CodeGenerator( environment->main_zone(), &frame_, &linkage_, environment->instructions(), &info_, environment->main_isolate(), base::Optional<OsrHelper>(), kNoSourcePosition, nullptr, PoisoningMitigationLevel::kDontPoison, AssemblerOptions::Default(environment->main_isolate()), - Builtins::kNoBuiltinId); + Builtins::kNoBuiltinId, kMaxUnoptimizedFrameHeight); // Force a frame to be created. generator_->frame_access_state()->MarkHasFrame(true); diff --git a/deps/v8/test/cctest/compiler/test-instruction-scheduler.cc b/deps/v8/test/cctest/compiler/test-instruction-scheduler.cc index f80718e05e..7aa408f653 100644 --- a/deps/v8/test/cctest/compiler/test-instruction-scheduler.cc +++ b/deps/v8/test/cctest/compiler/test-instruction-scheduler.cc @@ -76,7 +76,7 @@ TEST(DeoptInMiddleOfBasicBlock) { // Dummy node for FlagsContinuation::ForDeoptimize (which won't accept // nullptr). Node* node = Node::New(zone, 0, nullptr, 0, nullptr, false); - VectorSlotPair feedback; + FeedbackSource feedback; FlagsContinuation cont = FlagsContinuation::ForDeoptimize( kEqual, DeoptimizeKind::kEager, DeoptimizeReason::kUnknown, feedback, node); 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 aef10b472d..cc2eddd1a0 100644 --- a/deps/v8/test/cctest/compiler/test-js-constant-cache.cc +++ b/deps/v8/test/cctest/compiler/test-js-constant-cache.cc @@ -4,6 +4,7 @@ #include "src/codegen/assembler.h" #include "src/compiler/js-graph.h" +#include "src/compiler/js-heap-broker.h" #include "src/compiler/node-properties.h" #include "src/heap/factory-inl.h" #include "test/cctest/cctest.h" @@ -35,7 +36,9 @@ class JSConstantCacheTester : public HandleAndZoneScope, JSConstantCacheTester() : JSCacheTesterHelper(main_zone()), JSGraph(main_isolate(), &main_graph_, &main_common_, &main_javascript_, - nullptr, &main_machine_) { + nullptr, &main_machine_), + canonical_(main_isolate()), + broker_(main_isolate(), main_zone(), false) { main_graph_.SetStart(main_graph_.NewNode(common()->Start(0))); main_graph_.SetEnd( main_graph_.NewNode(common()->End(1), main_graph_.start())); @@ -47,6 +50,11 @@ class JSConstantCacheTester : public HandleAndZoneScope, } Factory* factory() { return main_isolate()->factory(); } + JSHeapBroker* broker() { return &broker_; } + + private: + CanonicalHandleScope canonical_; + JSHeapBroker broker_; }; @@ -182,8 +190,8 @@ TEST(HeapNumbers) { Handle<Object> num = T.factory()->NewNumber(value); Handle<HeapNumber> heap = T.factory()->NewHeapNumber(value); Node* node1 = T.Constant(value); - Node* node2 = T.Constant(num); - Node* node3 = T.Constant(heap); + Node* node2 = T.Constant(ObjectRef(T.broker(), num)); + Node* node3 = T.Constant(ObjectRef(T.broker(), heap)); CHECK_EQ(node1, node2); CHECK_EQ(node1, node3); } @@ -193,12 +201,18 @@ TEST(HeapNumbers) { TEST(OddballHandle) { JSConstantCacheTester T; - CHECK_EQ(T.UndefinedConstant(), T.Constant(T.factory()->undefined_value())); - CHECK_EQ(T.TheHoleConstant(), T.Constant(T.factory()->the_hole_value())); - CHECK_EQ(T.TrueConstant(), T.Constant(T.factory()->true_value())); - CHECK_EQ(T.FalseConstant(), T.Constant(T.factory()->false_value())); - CHECK_EQ(T.NullConstant(), T.Constant(T.factory()->null_value())); - CHECK_EQ(T.NaNConstant(), T.Constant(T.factory()->nan_value())); + CHECK_EQ(T.UndefinedConstant(), + T.Constant(ObjectRef(T.broker(), T.factory()->undefined_value()))); + CHECK_EQ(T.TheHoleConstant(), + T.Constant(ObjectRef(T.broker(), T.factory()->the_hole_value()))); + CHECK_EQ(T.TrueConstant(), + T.Constant(ObjectRef(T.broker(), T.factory()->true_value()))); + CHECK_EQ(T.FalseConstant(), + T.Constant(ObjectRef(T.broker(), T.factory()->false_value()))); + CHECK_EQ(T.NullConstant(), + T.Constant(ObjectRef(T.broker(), T.factory()->null_value()))); + CHECK_EQ(T.NaNConstant(), + T.Constant(ObjectRef(T.broker(), T.factory()->nan_value()))); } diff --git a/deps/v8/test/cctest/compiler/test-js-context-specialization.cc b/deps/v8/test/cctest/compiler/test-js-context-specialization.cc index e6703dbbbe..1b136873b5 100644 --- a/deps/v8/test/cctest/compiler/test-js-context-specialization.cc +++ b/deps/v8/test/cctest/compiler/test-js-context-specialization.cc @@ -52,6 +52,8 @@ class ContextSpecializationTester : public HandleAndZoneScope { void CheckContextInputAndDepthChanges(Node* node, Node* expected_new_context, size_t expected_new_depth); + JSHeapBroker* broker() { return &js_heap_broker_; } + private: TickCounter tick_counter_; CanonicalHandleScope canonical_; @@ -126,8 +128,9 @@ TEST(ReduceJSLoadContext0) { const int slot = Context::NATIVE_CONTEXT_INDEX; native->set(slot, *expected); - Node* const_context = t.jsgraph()->Constant(native); - Node* deep_const_context = t.jsgraph()->Constant(subcontext2); + Node* const_context = t.jsgraph()->Constant(ObjectRef(t.broker(), native)); + Node* deep_const_context = + t.jsgraph()->Constant(ObjectRef(t.broker(), subcontext2)); Node* param_context = t.graph()->NewNode(t.common()->Parameter(0), start); { @@ -269,7 +272,8 @@ TEST(ReduceJSLoadContext2) { context_object0->set(slot_index, *slot_value0); context_object1->set(slot_index, *slot_value1); - Node* context0 = t.jsgraph()->Constant(context_object1); + Node* context0 = + t.jsgraph()->Constant(ObjectRef(t.broker(), context_object1)); Node* context1 = t.graph()->NewNode(create_function_context, context0, start, start); Node* context2 = @@ -423,8 +427,9 @@ TEST(ReduceJSStoreContext0) { const int slot = Context::NATIVE_CONTEXT_INDEX; native->set(slot, *expected); - Node* const_context = t.jsgraph()->Constant(native); - Node* deep_const_context = t.jsgraph()->Constant(subcontext2); + Node* const_context = t.jsgraph()->Constant(ObjectRef(t.broker(), native)); + Node* deep_const_context = + t.jsgraph()->Constant(ObjectRef(t.broker(), subcontext2)); Node* param_context = t.graph()->NewNode(t.common()->Parameter(0), start); { @@ -531,7 +536,8 @@ TEST(ReduceJSStoreContext2) { context_object0->set(slot_index, *slot_value0); context_object1->set(slot_index, *slot_value1); - Node* context0 = t.jsgraph()->Constant(context_object1); + Node* context0 = + t.jsgraph()->Constant(ObjectRef(t.broker(), context_object1)); Node* context1 = t.graph()->NewNode(create_function_context, context0, start, start); Node* context2 = diff --git a/deps/v8/test/cctest/compiler/test-multiple-return.cc b/deps/v8/test/cctest/compiler/test-multiple-return.cc index a34b1e14e5..c054e7654a 100644 --- a/deps/v8/test/cctest/compiler/test-multiple-return.cc +++ b/deps/v8/test/cctest/compiler/test-multiple-return.cc @@ -167,11 +167,11 @@ void TestReturnMultipleValues(MachineType type) { OptimizedCompilationInfo info(ArrayVector("testing"), handles.main_zone(), Code::WASM_FUNCTION); - Handle<Code> code = - Pipeline::GenerateCodeForTesting( - &info, handles.main_isolate(), desc, m.graph(), - AssemblerOptions::Default(handles.main_isolate()), m.Export()) - .ToHandleChecked(); + Handle<Code> code = Pipeline::GenerateCodeForTesting( + &info, handles.main_isolate(), desc, m.graph(), + AssemblerOptions::Default(handles.main_isolate()), + m.ExportForTest()) + .ToHandleChecked(); #ifdef ENABLE_DISASSEMBLER if (FLAG_print_code) { StdoutStream os; @@ -272,11 +272,11 @@ void ReturnLastValue(MachineType type) { OptimizedCompilationInfo info(ArrayVector("testing"), handles.main_zone(), Code::WASM_FUNCTION); - Handle<Code> code = - Pipeline::GenerateCodeForTesting( - &info, handles.main_isolate(), desc, m.graph(), - AssemblerOptions::Default(handles.main_isolate()), m.Export()) - .ToHandleChecked(); + Handle<Code> code = Pipeline::GenerateCodeForTesting( + &info, handles.main_isolate(), desc, m.graph(), + AssemblerOptions::Default(handles.main_isolate()), + m.ExportForTest()) + .ToHandleChecked(); std::shared_ptr<wasm::NativeModule> module = AllocateNativeModule( handles.main_isolate(), code->raw_instruction_size()); @@ -334,11 +334,11 @@ void ReturnSumOfReturns(MachineType type) { OptimizedCompilationInfo info(ArrayVector("testing"), handles.main_zone(), Code::WASM_FUNCTION); - Handle<Code> code = - Pipeline::GenerateCodeForTesting( - &info, handles.main_isolate(), desc, m.graph(), - AssemblerOptions::Default(handles.main_isolate()), m.Export()) - .ToHandleChecked(); + Handle<Code> code = Pipeline::GenerateCodeForTesting( + &info, handles.main_isolate(), desc, m.graph(), + AssemblerOptions::Default(handles.main_isolate()), + m.ExportForTest()) + .ToHandleChecked(); std::shared_ptr<wasm::NativeModule> module = AllocateNativeModule( handles.main_isolate(), code->raw_instruction_size()); diff --git a/deps/v8/test/cctest/compiler/test-representation-change.cc b/deps/v8/test/cctest/compiler/test-representation-change.cc index dac6f61932..d858448ef8 100644 --- a/deps/v8/test/cctest/compiler/test-representation-change.cc +++ b/deps/v8/test/cctest/compiler/test-representation-change.cc @@ -401,11 +401,11 @@ TEST(Word64) { CheckChange( IrOpcode::kCheckedInt64ToInt32, MachineRepresentation::kWord64, TypeCache::Get()->kSafeInteger, MachineRepresentation::kWord32, - UseInfo::CheckedSigned32AsWord32(kIdentifyZeros, VectorSlotPair())); + UseInfo::CheckedSigned32AsWord32(kIdentifyZeros, FeedbackSource())); CheckChange( IrOpcode::kCheckedUint64ToInt32, MachineRepresentation::kWord64, TypeCache::Get()->kPositiveSafeInteger, MachineRepresentation::kWord32, - UseInfo::CheckedSigned32AsWord32(kIdentifyZeros, VectorSlotPair())); + UseInfo::CheckedSigned32AsWord32(kIdentifyZeros, FeedbackSource())); CheckChange(IrOpcode::kChangeFloat64ToInt64, MachineRepresentation::kFloat64, Type::Signed32(), MachineRepresentation::kWord64); @@ -420,7 +420,7 @@ TEST(Word64) { CheckChange( IrOpcode::kCheckedFloat64ToInt64, MachineRepresentation::kFloat64, Type::Number(), MachineRepresentation::kWord64, - UseInfo::CheckedSigned64AsWord64(kIdentifyZeros, VectorSlotPair())); + UseInfo::CheckedSigned64AsWord64(kIdentifyZeros, FeedbackSource())); CheckChange(IrOpcode::kChangeInt64ToFloat64, MachineRepresentation::kWord64, Type::Signed32(), MachineRepresentation::kFloat64); @@ -449,7 +449,7 @@ TEST(Word64) { IrOpcode::kChangeFloat32ToFloat64, IrOpcode::kCheckedFloat64ToInt64, MachineRepresentation::kFloat32, Type::Number(), MachineRepresentation::kWord64, - UseInfo::CheckedSigned64AsWord64(kIdentifyZeros, VectorSlotPair())); + UseInfo::CheckedSigned64AsWord64(kIdentifyZeros, FeedbackSource())); CheckTwoChanges(IrOpcode::kChangeInt64ToFloat64, IrOpcode::kTruncateFloat64ToFloat32, @@ -470,11 +470,11 @@ TEST(Word64) { CheckChange( IrOpcode::kCheckedTaggedToInt64, MachineRepresentation::kTagged, Type::Number(), MachineRepresentation::kWord64, - UseInfo::CheckedSigned64AsWord64(kIdentifyZeros, VectorSlotPair())); + UseInfo::CheckedSigned64AsWord64(kIdentifyZeros, FeedbackSource())); CheckChange( IrOpcode::kCheckedTaggedToInt64, MachineRepresentation::kTaggedPointer, Type::Number(), MachineRepresentation::kWord64, - UseInfo::CheckedSigned64AsWord64(kIdentifyZeros, VectorSlotPair())); + UseInfo::CheckedSigned64AsWord64(kIdentifyZeros, FeedbackSource())); CheckTwoChanges(IrOpcode::kTruncateInt64ToInt32, IrOpcode::kChangeInt31ToTaggedSigned, @@ -507,12 +507,12 @@ TEST(Word64) { CheckChange(IrOpcode::kCheckedInt64ToTaggedSigned, MachineRepresentation::kWord64, TypeCache::Get()->kSafeInteger, MachineRepresentation::kTaggedSigned, - UseInfo::CheckedSignedSmallAsTaggedSigned(VectorSlotPair())); + UseInfo::CheckedSignedSmallAsTaggedSigned(FeedbackSource())); CheckChange(IrOpcode::kCheckedUint64ToTaggedSigned, MachineRepresentation::kWord64, TypeCache::Get()->kPositiveSafeInteger, MachineRepresentation::kTaggedSigned, - UseInfo::CheckedSignedSmallAsTaggedSigned(VectorSlotPair())); + UseInfo::CheckedSignedSmallAsTaggedSigned(FeedbackSource())); CheckTwoChanges( IrOpcode::kChangeInt64ToFloat64, IrOpcode::kChangeFloat64ToTaggedPointer, @@ -630,7 +630,7 @@ TEST(SignednessInWord32) { CheckChange(IrOpcode::kCheckedTruncateTaggedToWord32, MachineRepresentation::kTagged, Type::NonInternal(), MachineRepresentation::kWord32, - UseInfo::CheckedNumberOrOddballAsWord32(VectorSlotPair())); + UseInfo::CheckedNumberOrOddballAsWord32(FeedbackSource())); CheckTwoChanges(IrOpcode::kChangeInt32ToFloat64, IrOpcode::kTruncateFloat64ToFloat32, @@ -644,7 +644,7 @@ TEST(SignednessInWord32) { CheckChange( IrOpcode::kCheckedUint32ToInt32, MachineRepresentation::kWord32, Type::Unsigned32(), - UseInfo::CheckedSigned32AsWord32(kIdentifyZeros, VectorSlotPair())); + UseInfo::CheckedSigned32AsWord32(kIdentifyZeros, FeedbackSource())); } TEST(CompressedAndTagged) { @@ -698,19 +698,19 @@ static void TestMinusZeroCheck(IrOpcode::Value expected, Type from_type) { CheckChange( expected, MachineRepresentation::kFloat64, from_type, - UseInfo::CheckedSignedSmallAsWord32(kDistinguishZeros, VectorSlotPair())); + UseInfo::CheckedSignedSmallAsWord32(kDistinguishZeros, FeedbackSource())); CheckChange( expected, MachineRepresentation::kFloat64, from_type, - UseInfo::CheckedSignedSmallAsWord32(kIdentifyZeros, VectorSlotPair())); + UseInfo::CheckedSignedSmallAsWord32(kIdentifyZeros, FeedbackSource())); CheckChange( expected, MachineRepresentation::kFloat64, from_type, - UseInfo::CheckedSigned32AsWord32(kDistinguishZeros, VectorSlotPair())); + UseInfo::CheckedSigned32AsWord32(kDistinguishZeros, FeedbackSource())); CheckChange( expected, MachineRepresentation::kFloat64, from_type, - UseInfo::CheckedSigned32AsWord32(kDistinguishZeros, VectorSlotPair())); + UseInfo::CheckedSigned32AsWord32(kDistinguishZeros, FeedbackSource())); } TEST(MinusZeroCheck) { 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 eed6cf1e59..026e8307ae 100644 --- a/deps/v8/test/cctest/compiler/test-run-native-calls.cc +++ b/deps/v8/test/cctest/compiler/test-run-native-calls.cc @@ -439,7 +439,7 @@ class Computer { Graph graph(&zone); RawMachineAssembler raw(isolate, &graph, desc); build(desc, raw); - inner = CompileGraph("Compute", desc, &graph, raw.Export()); + inner = CompileGraph("Compute", desc, &graph, raw.ExportForTest()); } CSignatureOf<int32_t> csig; @@ -466,8 +466,8 @@ class Computer { Node* store = io.StoreOutput(raw, call); USE(store); raw.Return(raw.Int32Constant(seed)); - wrapper = - CompileGraph("Compute-wrapper-const", cdesc, &graph, raw.Export()); + wrapper = CompileGraph("Compute-wrapper-const", cdesc, &graph, + raw.ExportForTest()); } CodeRunner<int32_t> runnable(isolate, wrapper, &csig); @@ -501,7 +501,8 @@ class Computer { Node* store = io.StoreOutput(raw, call); USE(store); raw.Return(raw.Int32Constant(seed)); - wrapper = CompileGraph("Compute-wrapper", cdesc, &graph, raw.Export()); + wrapper = + CompileGraph("Compute-wrapper", cdesc, &graph, raw.ExportForTest()); } CodeRunner<int32_t> runnable(isolate, wrapper, &csig); @@ -576,7 +577,7 @@ static void CopyTwentyInt32(CallDescriptor* desc) { kNoWriteBarrier); } raw.Return(raw.Int32Constant(42)); - inner = CompileGraph("CopyTwentyInt32", desc, &graph, raw.Export()); + inner = CompileGraph("CopyTwentyInt32", desc, &graph, raw.ExportForTest()); } CSignatureOf<int32_t> csig; @@ -599,8 +600,8 @@ static void CopyTwentyInt32(CallDescriptor* desc) { Node* call = raw.CallN(desc, input_count, inputs); raw.Return(call); - wrapper = - CompileGraph("CopyTwentyInt32-wrapper", cdesc, &graph, raw.Export()); + wrapper = CompileGraph("CopyTwentyInt32-wrapper", cdesc, &graph, + raw.ExportForTest()); } CodeRunner<int32_t> runnable(isolate, wrapper, &csig); @@ -962,7 +963,8 @@ static void Build_Select_With_Call( Graph graph(&zone); RawMachineAssembler raw(isolate, &graph, desc); raw.Return(raw.Parameter(which)); - inner = CompileGraph("Select-indirection", desc, &graph, raw.Export()); + inner = + CompileGraph("Select-indirection", desc, &graph, raw.ExportForTest()); CHECK(!inner.is_null()); CHECK(inner->IsCode()); } @@ -1058,7 +1060,7 @@ void MixedParamTest(int start) { Graph graph(&zone); RawMachineAssembler raw(isolate, &graph, desc); raw.Return(raw.Parameter(which)); - select = CompileGraph("Compute", desc, &graph, raw.Export()); + select = CompileGraph("Compute", desc, &graph, raw.ExportForTest()); } { @@ -1117,7 +1119,7 @@ void MixedParamTest(int start) { expected_ret = static_cast<int32_t>(constant); raw.Return(raw.Int32Constant(expected_ret)); wrapper = CompileGraph("Select-mixed-wrapper-const", cdesc, &graph, - raw.Export()); + raw.ExportForTest()); } CodeRunner<int32_t> runnable(isolate, wrapper, &csig); @@ -1176,7 +1178,7 @@ void TestStackSlot(MachineType slot_type, T expected) { g.Store(slot_type.representation(), g.Parameter(11), g.Parameter(10), WriteBarrierKind::kNoWriteBarrier); g.Return(g.Parameter(9)); - inner = CompileGraph("Compute", desc, &graph, g.Export()); + inner = CompileGraph("Compute", desc, &graph, g.ExportForTest()); // Create function f with a stack slot which calls the inner function g. BufferedRawMachineAssemblerTester<T> f(slot_type); diff --git a/deps/v8/test/cctest/compiler/test-run-retpoline.cc b/deps/v8/test/cctest/compiler/test-run-retpoline.cc index be329e1b00..32569eaaee 100644 --- a/deps/v8/test/cctest/compiler/test-run-retpoline.cc +++ b/deps/v8/test/cctest/compiler/test-run-retpoline.cc @@ -27,7 +27,8 @@ Handle<Code> BuildCallee(Isolate* isolate, CallDescriptor* call_descriptor) { int param_count = static_cast<int>(call_descriptor->StackParameterCount()); Node* sum = __ IntPtrConstant(0); for (int i = 0; i < param_count; ++i) { - Node* product = __ IntPtrMul(__ Parameter(i), __ IntPtrConstant(i + 1)); + TNode<IntPtrT> product = + __ Signed(__ IntPtrMul(__ Parameter(i), __ IntPtrConstant(i + 1))); sum = __ IntPtrAdd(sum, product); } __ Return(sum); diff --git a/deps/v8/test/cctest/compiler/test-run-tail-calls.cc b/deps/v8/test/cctest/compiler/test-run-tail-calls.cc index 1562befb9d..ed8a099090 100644 --- a/deps/v8/test/cctest/compiler/test-run-tail-calls.cc +++ b/deps/v8/test/cctest/compiler/test-run-tail-calls.cc @@ -28,8 +28,9 @@ Handle<Code> BuildCallee(Isolate* isolate, CallDescriptor* call_descriptor) { int param_count = static_cast<int>(call_descriptor->StackParameterCount()); Node* sum = __ IntPtrConstant(0); for (int i = 0; i < param_count; ++i) { - Node* product = __ IntPtrMul(__ Parameter(i), __ IntPtrConstant(i + 1)); - sum = __ IntPtrAdd(sum, product); + TNode<WordT> product = + __ IntPtrMul(__ Parameter(i), __ IntPtrConstant(i + 1)); + sum = __ Signed(__ IntPtrAdd(sum, product)); } __ Return(sum); return tester.GenerateCodeCloseAndEscape(); diff --git a/deps/v8/test/cctest/heap/heap-tester.h b/deps/v8/test/cctest/heap/heap-tester.h index 14a4eb3cd9..6f6cfb46b5 100644 --- a/deps/v8/test/cctest/heap/heap-tester.h +++ b/deps/v8/test/cctest/heap/heap-tester.h @@ -19,6 +19,10 @@ V(CompactionSpaceDivideSinglePage) \ V(InvalidatedSlotsAfterTrimming) \ V(InvalidatedSlotsAllInvalidatedRanges) \ + V(InvalidatedSlotsCleanupEachObject) \ + V(InvalidatedSlotsCleanupFull) \ + V(InvalidatedSlotsCleanupRightTrim) \ + V(InvalidatedSlotsCleanupOverlapRight) \ V(InvalidatedSlotsEvacuationCandidate) \ V(InvalidatedSlotsNoInvalidatedRanges) \ V(InvalidatedSlotsResetObjectRegression) \ diff --git a/deps/v8/test/cctest/heap/test-embedder-tracing.cc b/deps/v8/test/cctest/heap/test-embedder-tracing.cc index 2d0833e1a3..28553266ff 100644 --- a/deps/v8/test/cctest/heap/test-embedder-tracing.cc +++ b/deps/v8/test/cctest/heap/test-embedder-tracing.cc @@ -16,6 +16,13 @@ #include "test/cctest/heap/heap-utils.h" namespace v8 { + +// See test below: TracedGlobalNoDestructor. +template <> +struct TracedGlobalTrait<v8::TracedGlobal<v8::Value>> { + static constexpr bool kRequiresExplicitDestruction = false; +}; + namespace internal { namespace heap { @@ -346,6 +353,85 @@ TEST(TracedGlobalInStdVector) { CHECK(vec[0].IsEmpty()); } +TEST(TracedGlobalCopyWithDestructor) { + ManualGCScope manual_gc; + CcTest::InitializeVM(); + v8::Isolate* isolate = CcTest::isolate(); + v8::HandleScope scope(isolate); + i::GlobalHandles* global_handles = CcTest::i_isolate()->global_handles(); + + static_assert(TracedGlobalTrait< + v8::TracedGlobal<v8::Object>>::kRequiresExplicitDestruction, + "destructor expected"); + + const size_t initial_count = global_handles->handles_count(); + v8::TracedGlobal<v8::Object> global1; + { + v8::HandleScope scope(isolate); + global1.Reset(isolate, v8::Object::New(isolate)); + } + v8::TracedGlobal<v8::Object> global2(global1); + v8::TracedGlobal<v8::Object> global3; + global3 = global2; + CHECK_EQ(initial_count + 3, global_handles->handles_count()); + CHECK(!global1.IsEmpty()); + CHECK_EQ(global1, global2); + CHECK_EQ(global2, global3); + { + v8::HandleScope scope(isolate); + auto tmp = v8::Local<v8::Object>::New(isolate, global3); + CHECK(!tmp.IsEmpty()); + InvokeMarkSweep(); + } + CHECK_EQ(initial_count + 3, global_handles->handles_count()); + CHECK(!global1.IsEmpty()); + CHECK_EQ(global1, global2); + CHECK_EQ(global2, global3); + InvokeMarkSweep(); + CHECK_EQ(initial_count, global_handles->handles_count()); + CHECK(global1.IsEmpty()); + CHECK_EQ(global1, global2); + CHECK_EQ(global2, global3); +} + +TEST(TracedGlobalCopyNoDestructor) { + ManualGCScope manual_gc; + CcTest::InitializeVM(); + v8::Isolate* isolate = CcTest::isolate(); + v8::HandleScope scope(isolate); + i::GlobalHandles* global_handles = CcTest::i_isolate()->global_handles(); + + static_assert(!TracedGlobalTrait< + v8::TracedGlobal<v8::Value>>::kRequiresExplicitDestruction, + "no destructor expected"); + + const size_t initial_count = global_handles->handles_count(); + v8::TracedGlobal<v8::Value> global1; + { + v8::HandleScope scope(isolate); + global1.Reset(isolate, v8::Object::New(isolate)); + } + v8::TracedGlobal<v8::Value> global2(global1); + v8::TracedGlobal<v8::Value> global3; + global3 = global2; + CHECK_EQ(initial_count + 3, global_handles->handles_count()); + CHECK(!global1.IsEmpty()); + CHECK_EQ(global1, global2); + CHECK_EQ(global2, global3); + { + v8::HandleScope scope(isolate); + auto tmp = v8::Local<v8::Value>::New(isolate, global3); + CHECK(!tmp.IsEmpty()); + InvokeMarkSweep(); + } + CHECK_EQ(initial_count + 3, global_handles->handles_count()); + CHECK(!global1.IsEmpty()); + CHECK_EQ(global1, global2); + CHECK_EQ(global2, global3); + InvokeMarkSweep(); + CHECK_EQ(initial_count, global_handles->handles_count()); +} + TEST(TracedGlobalInStdUnorderedMap) { ManualGCScope manual_gc; CcTest::InitializeVM(); @@ -560,6 +646,218 @@ TEST(TracePrologueCallingIntoV8WriteBarrier) { std::move(global)); heap::TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); SimulateIncrementalMarking(CcTest::i_isolate()->heap()); + // Finish GC to avoid removing the tracer while GC is running which may end up + // in an infinite loop because of unprocessed objects. + heap::InvokeMarkSweep(); +} + +TEST(TracedGlobalWithDestructor) { + ManualGCScope manual_gc; + CcTest::InitializeVM(); + v8::Isolate* isolate = CcTest::isolate(); + v8::HandleScope scope(isolate); + TestEmbedderHeapTracer tracer; + heap::TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); + i::GlobalHandles* global_handles = CcTest::i_isolate()->global_handles(); + + const size_t initial_count = global_handles->handles_count(); + auto* traced = new v8::TracedGlobal<v8::Object>(); + { + v8::HandleScope scope(isolate); + v8::Local<v8::Object> object(ConstructTraceableJSApiObject( + isolate->GetCurrentContext(), nullptr, nullptr)); + CHECK(traced->IsEmpty()); + *traced = v8::TracedGlobal<v8::Object>(isolate, object); + CHECK(!traced->IsEmpty()); + CHECK_EQ(initial_count + 1, global_handles->handles_count()); + } + static_assert(TracedGlobalTrait< + v8::TracedGlobal<v8::Object>>::kRequiresExplicitDestruction, + "destructor expected"); + delete traced; + CHECK_EQ(initial_count, global_handles->handles_count()); + // GC should not need to clear the handle. + heap::InvokeMarkSweep(); + CHECK_EQ(initial_count, global_handles->handles_count()); +} + +TEST(TracedGlobalNoDestructor) { + ManualGCScope manual_gc; + CcTest::InitializeVM(); + v8::Isolate* isolate = CcTest::isolate(); + v8::HandleScope scope(isolate); + TestEmbedderHeapTracer tracer; + heap::TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); + i::GlobalHandles* global_handles = CcTest::i_isolate()->global_handles(); + + const size_t initial_count = global_handles->handles_count(); + char* memory = new char[sizeof(v8::TracedGlobal<v8::Value>)]; + auto* traced = new (memory) v8::TracedGlobal<v8::Value>(); + { + v8::HandleScope scope(isolate); + v8::Local<v8::Value> object(ConstructTraceableJSApiObject( + isolate->GetCurrentContext(), nullptr, nullptr)); + CHECK(traced->IsEmpty()); + *traced = v8::TracedGlobal<v8::Value>(isolate, object); + CHECK(!traced->IsEmpty()); + CHECK_EQ(initial_count + 1, global_handles->handles_count()); + } + static_assert(!TracedGlobalTrait< + v8::TracedGlobal<v8::Value>>::kRequiresExplicitDestruction, + "no destructor expected"); + traced->~TracedGlobal<v8::Value>(); + CHECK_EQ(initial_count + 1, global_handles->handles_count()); + // GC should clear the handle. + heap::InvokeMarkSweep(); + CHECK_EQ(initial_count, global_handles->handles_count()); + delete[] memory; +} + +namespace { + +class EmptyEmbedderHeapTracer : public v8::EmbedderHeapTracer { + public: + void RegisterV8References( + const std::vector<std::pair<void*, void*>>& embedder_fields) final {} + + bool AdvanceTracing(double deadline_in_ms) final { return true; } + bool IsTracingDone() final { return true; } + void TracePrologue(EmbedderHeapTracer::TraceFlags) final {} + void TraceEpilogue() final {} + void EnterFinalPause(EmbedderStackState) final {} +}; + +// EmbedderHeapTracer that can optimize Scavenger handling when used with +// TraceGlobal handles that have destructors. +class EmbedderHeapTracerDestructorNonTracingClearing final + : public EmptyEmbedderHeapTracer { + public: + explicit EmbedderHeapTracerDestructorNonTracingClearing( + uint16_t class_id_to_optimize) + : class_id_to_optimize_(class_id_to_optimize) {} + + bool IsRootForNonTracingGC(const v8::TracedGlobal<v8::Value>& handle) final { + return handle.WrapperClassId() != class_id_to_optimize_; + } + + void ResetHandleInNonTracingGC( + const v8::TracedGlobal<v8::Value>& handle) final { + // Not called when used with handles that have destructors. + CHECK(false); + } + + private: + uint16_t class_id_to_optimize_; +}; + +// EmbedderHeapTracer that can optimize Scavenger handling when used with +// TraceGlobal handles without destructors. +class EmbedderHeapTracerNoDestructorNonTracingClearing final + : public EmptyEmbedderHeapTracer { + public: + explicit EmbedderHeapTracerNoDestructorNonTracingClearing( + uint16_t class_id_to_optimize) + : class_id_to_optimize_(class_id_to_optimize) {} + + bool IsRootForNonTracingGC(const v8::TracedGlobal<v8::Value>& handle) final { + return handle.WrapperClassId() != class_id_to_optimize_; + } + + void ResetHandleInNonTracingGC( + const v8::TracedGlobal<v8::Value>& handle) final { + if (handle.WrapperClassId() != class_id_to_optimize_) return; + + // Convention (for test): Objects that are optimized have their first field + // set as a back pointer. + TracedGlobal<v8::Value>* original_handle = + reinterpret_cast<TracedGlobal<v8::Value>*>( + v8::Object::GetAlignedPointerFromInternalField( + handle.As<v8::Object>(), 0)); + original_handle->Reset(); + } + + private: + uint16_t class_id_to_optimize_; +}; + +template <typename T> +void SetupOptimizedAndNonOptimizedHandle( + v8::Isolate* isolate, uint16_t optimized_class_id, + v8::TracedGlobal<T>* optimized_handle, + v8::TracedGlobal<T>* non_optimized_handle) { + v8::HandleScope scope(isolate); + + v8::Local<v8::Object> optimized_object(ConstructTraceableJSApiObject( + isolate->GetCurrentContext(), optimized_handle, nullptr)); + CHECK(optimized_handle->IsEmpty()); + *optimized_handle = v8::TracedGlobal<T>(isolate, optimized_object); + CHECK(!optimized_handle->IsEmpty()); + optimized_handle->SetWrapperClassId(optimized_class_id); + + v8::Local<v8::Object> non_optimized_object(ConstructTraceableJSApiObject( + isolate->GetCurrentContext(), nullptr, nullptr)); + CHECK(non_optimized_handle->IsEmpty()); + *non_optimized_handle = v8::TracedGlobal<T>(isolate, non_optimized_object); + CHECK(!non_optimized_handle->IsEmpty()); +} + +} // namespace + +TEST(TracedGlobalDestructorReclaimedOnScavenge) { + ManualGCScope manual_gc; + CcTest::InitializeVM(); + v8::Isolate* isolate = CcTest::isolate(); + v8::HandleScope scope(isolate); + constexpr uint16_t kClassIdToOptimize = 17; + EmbedderHeapTracerDestructorNonTracingClearing tracer(kClassIdToOptimize); + heap::TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); + i::GlobalHandles* global_handles = CcTest::i_isolate()->global_handles(); + + static_assert(TracedGlobalTrait< + v8::TracedGlobal<v8::Object>>::kRequiresExplicitDestruction, + "destructor expected"); + const size_t initial_count = global_handles->handles_count(); + auto* optimized_handle = new v8::TracedGlobal<v8::Object>(); + auto* non_optimized_handle = new v8::TracedGlobal<v8::Object>(); + SetupOptimizedAndNonOptimizedHandle(isolate, kClassIdToOptimize, + optimized_handle, non_optimized_handle); + CHECK_EQ(initial_count + 2, global_handles->handles_count()); + heap::InvokeScavenge(); + CHECK_EQ(initial_count + 1, global_handles->handles_count()); + CHECK(optimized_handle->IsEmpty()); + delete optimized_handle; + CHECK(!non_optimized_handle->IsEmpty()); + delete non_optimized_handle; + CHECK_EQ(initial_count, global_handles->handles_count()); +} + +TEST(TracedGlobalNoDestructorReclaimedOnScavenge) { + ManualGCScope manual_gc; + CcTest::InitializeVM(); + v8::Isolate* isolate = CcTest::isolate(); + v8::HandleScope scope(isolate); + constexpr uint16_t kClassIdToOptimize = 23; + EmbedderHeapTracerNoDestructorNonTracingClearing tracer(kClassIdToOptimize); + heap::TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); + i::GlobalHandles* global_handles = CcTest::i_isolate()->global_handles(); + + static_assert(!TracedGlobalTrait< + v8::TracedGlobal<v8::Value>>::kRequiresExplicitDestruction, + "no destructor expected"); + const size_t initial_count = global_handles->handles_count(); + auto* optimized_handle = new v8::TracedGlobal<v8::Value>(); + auto* non_optimized_handle = new v8::TracedGlobal<v8::Value>(); + SetupOptimizedAndNonOptimizedHandle(isolate, kClassIdToOptimize, + optimized_handle, non_optimized_handle); + CHECK_EQ(initial_count + 2, global_handles->handles_count()); + heap::InvokeScavenge(); + CHECK_EQ(initial_count + 1, global_handles->handles_count()); + CHECK(optimized_handle->IsEmpty()); + delete optimized_handle; + CHECK(!non_optimized_handle->IsEmpty()); + non_optimized_handle->Reset(); + delete non_optimized_handle; + CHECK_EQ(initial_count, global_handles->handles_count()); } } // namespace heap diff --git a/deps/v8/test/cctest/heap/test-heap.cc b/deps/v8/test/cctest/heap/test-heap.cc index e4dbee2210..fd17c0f063 100644 --- a/deps/v8/test/cctest/heap/test-heap.cc +++ b/deps/v8/test/cctest/heap/test-heap.cc @@ -1799,36 +1799,6 @@ TEST(HeapNumberAlignment) { } } -TEST(MutableHeapNumberAlignment) { - CcTest::InitializeVM(); - Isolate* isolate = CcTest::i_isolate(); - Factory* factory = isolate->factory(); - Heap* heap = isolate->heap(); - HandleScope sc(isolate); - - const auto required_alignment = - HeapObject::RequiredAlignment(*factory->mutable_heap_number_map()); - const int maximum_misalignment = - Heap::GetMaximumFillToAlign(required_alignment); - - for (int offset = 0; offset <= maximum_misalignment; offset += kTaggedSize) { - AlignNewSpace(required_alignment, offset); - Handle<Object> number_new = factory->NewMutableHeapNumber(1.000123); - CHECK(number_new->IsMutableHeapNumber()); - CHECK(Heap::InYoungGeneration(*number_new)); - CHECK_EQ(0, Heap::GetFillToAlign(HeapObject::cast(*number_new).address(), - required_alignment)); - - AlignOldSpace(required_alignment, offset); - Handle<Object> number_old = - factory->NewMutableHeapNumber(1.000321, AllocationType::kOld); - CHECK(number_old->IsMutableHeapNumber()); - CHECK(heap->InOldSpace(*number_old)); - CHECK_EQ(0, Heap::GetFillToAlign(HeapObject::cast(*number_old).address(), - required_alignment)); - } -} - TEST(TestSizeOfObjectsVsHeapObjectIteratorPrecision) { CcTest::InitializeVM(); HeapObjectIterator iterator(CcTest::heap()); diff --git a/deps/v8/test/cctest/heap/test-invalidated-slots.cc b/deps/v8/test/cctest/heap/test-invalidated-slots.cc index c88cf1f3ba..af42503f86 100644 --- a/deps/v8/test/cctest/heap/test-invalidated-slots.cc +++ b/deps/v8/test/cctest/heap/test-invalidated-slots.cc @@ -44,7 +44,7 @@ Page* HeapTester::AllocateByteArraysOnPage( CHECK_EQ(page, Page::FromHeapObject(byte_array)); } } - CHECK_NULL(page->invalidated_slots()); + CHECK_NULL(page->invalidated_slots<OLD_TO_OLD>()); return page; } @@ -53,7 +53,7 @@ HEAP_TEST(InvalidatedSlotsNoInvalidatedRanges) { Heap* heap = CcTest::heap(); std::vector<ByteArray> byte_arrays; Page* page = AllocateByteArraysOnPage(heap, &byte_arrays); - InvalidatedSlotsFilter filter(page); + InvalidatedSlotsFilter filter = InvalidatedSlotsFilter::OldToOld(page); for (ByteArray byte_array : byte_arrays) { Address start = byte_array.address() + ByteArray::kHeaderSize; Address end = byte_array.address() + byte_array.Size(); @@ -70,10 +70,10 @@ HEAP_TEST(InvalidatedSlotsSomeInvalidatedRanges) { Page* page = AllocateByteArraysOnPage(heap, &byte_arrays); // Register every second byte arrays as invalidated. for (size_t i = 0; i < byte_arrays.size(); i += 2) { - page->RegisterObjectWithInvalidatedSlots(byte_arrays[i], - byte_arrays[i].Size()); + page->RegisterObjectWithInvalidatedSlots<OLD_TO_OLD>(byte_arrays[i], + byte_arrays[i].Size()); } - InvalidatedSlotsFilter filter(page); + InvalidatedSlotsFilter filter = InvalidatedSlotsFilter::OldToOld(page); for (size_t i = 0; i < byte_arrays.size(); i++) { ByteArray byte_array = byte_arrays[i]; Address start = byte_array.address() + ByteArray::kHeaderSize; @@ -95,10 +95,10 @@ HEAP_TEST(InvalidatedSlotsAllInvalidatedRanges) { Page* page = AllocateByteArraysOnPage(heap, &byte_arrays); // Register the all byte arrays as invalidated. for (size_t i = 0; i < byte_arrays.size(); i++) { - page->RegisterObjectWithInvalidatedSlots(byte_arrays[i], - byte_arrays[i].Size()); + page->RegisterObjectWithInvalidatedSlots<OLD_TO_OLD>(byte_arrays[i], + byte_arrays[i].Size()); } - InvalidatedSlotsFilter filter(page); + InvalidatedSlotsFilter filter = InvalidatedSlotsFilter::OldToOld(page); for (size_t i = 0; i < byte_arrays.size(); i++) { ByteArray byte_array = byte_arrays[i]; Address start = byte_array.address() + ByteArray::kHeaderSize; @@ -117,12 +117,12 @@ HEAP_TEST(InvalidatedSlotsAfterTrimming) { Page* page = AllocateByteArraysOnPage(heap, &byte_arrays); // Register the all byte arrays as invalidated. for (size_t i = 0; i < byte_arrays.size(); i++) { - page->RegisterObjectWithInvalidatedSlots(byte_arrays[i], - byte_arrays[i].Size()); + page->RegisterObjectWithInvalidatedSlots<OLD_TO_OLD>(byte_arrays[i], + byte_arrays[i].Size()); } // Trim byte arrays and check that the slots outside the byte arrays are // considered invalid if the old space page was swept. - InvalidatedSlotsFilter filter(page); + InvalidatedSlotsFilter filter = InvalidatedSlotsFilter::OldToOld(page); for (size_t i = 0; i < byte_arrays.size(); i++) { ByteArray byte_array = byte_arrays[i]; Address start = byte_array.address() + ByteArray::kHeaderSize; @@ -145,11 +145,11 @@ HEAP_TEST(InvalidatedSlotsEvacuationCandidate) { // This should be no-op because the page is marked as evacuation // candidate. for (size_t i = 0; i < byte_arrays.size(); i++) { - page->RegisterObjectWithInvalidatedSlots(byte_arrays[i], - byte_arrays[i].Size()); + page->RegisterObjectWithInvalidatedSlots<OLD_TO_OLD>(byte_arrays[i], + byte_arrays[i].Size()); } // All slots must still be valid. - InvalidatedSlotsFilter filter(page); + InvalidatedSlotsFilter filter = InvalidatedSlotsFilter::OldToOld(page); for (size_t i = 0; i < byte_arrays.size(); i++) { ByteArray byte_array = byte_arrays[i]; Address start = byte_array.address() + ByteArray::kHeaderSize; @@ -169,11 +169,11 @@ HEAP_TEST(InvalidatedSlotsResetObjectRegression) { heap->RightTrimFixedArray(byte_arrays[0], byte_arrays[0].length() - 8); // Register the all byte arrays as invalidated. for (size_t i = 0; i < byte_arrays.size(); i++) { - page->RegisterObjectWithInvalidatedSlots(byte_arrays[i], - byte_arrays[i].Size()); + page->RegisterObjectWithInvalidatedSlots<OLD_TO_OLD>(byte_arrays[i], + byte_arrays[i].Size()); } // All slots must still be invalid. - InvalidatedSlotsFilter filter(page); + InvalidatedSlotsFilter filter = InvalidatedSlotsFilter::OldToOld(page); for (size_t i = 0; i < byte_arrays.size(); i++) { ByteArray byte_array = byte_arrays[i]; Address start = byte_array.address() + ByteArray::kHeaderSize; @@ -351,6 +351,78 @@ HEAP_TEST(InvalidatedSlotsFastToSlow) { CcTest::CollectGarbage(i::OLD_SPACE); } +HEAP_TEST(InvalidatedSlotsCleanupFull) { + ManualGCScope manual_gc_scope; + CcTest::InitializeVM(); + Heap* heap = CcTest::heap(); + std::vector<ByteArray> byte_arrays; + Page* page = AllocateByteArraysOnPage(heap, &byte_arrays); + // Register all byte arrays as invalidated. + for (size_t i = 0; i < byte_arrays.size(); i++) { + page->RegisterObjectWithInvalidatedSlots<OLD_TO_NEW>(byte_arrays[i], + byte_arrays[i].Size()); + } + + // Mark full page as free + InvalidatedSlotsCleanup cleanup = InvalidatedSlotsCleanup::OldToNew(page); + cleanup.Free(page->area_start(), page->area_end()); + + // After cleanup there should be no invalidated objects on page left + CHECK(page->invalidated_slots<OLD_TO_NEW>()->empty()); +} + +HEAP_TEST(InvalidatedSlotsCleanupEachObject) { + ManualGCScope manual_gc_scope; + CcTest::InitializeVM(); + Heap* heap = CcTest::heap(); + std::vector<ByteArray> byte_arrays; + Page* page = AllocateByteArraysOnPage(heap, &byte_arrays); + // Register all byte arrays as invalidated. + for (size_t i = 0; i < byte_arrays.size(); i++) { + page->RegisterObjectWithInvalidatedSlots<OLD_TO_NEW>(byte_arrays[i], + byte_arrays[i].Size()); + } + + // Mark each object as free on page + InvalidatedSlotsCleanup cleanup = InvalidatedSlotsCleanup::OldToNew(page); + + for (size_t i = 0; i < byte_arrays.size(); i++) { + Address free_start = byte_arrays[i].address(); + Address free_end = free_start + byte_arrays[i].Size(); + cleanup.Free(free_start, free_end); + } + + // After cleanup there should be no invalidated objects on page left + CHECK(page->invalidated_slots<OLD_TO_NEW>()->empty()); +} + +HEAP_TEST(InvalidatedSlotsCleanupRightTrim) { + ManualGCScope manual_gc_scope; + CcTest::InitializeVM(); + Heap* heap = CcTest::heap(); + std::vector<ByteArray> byte_arrays; + Page* page = AllocateByteArraysOnPage(heap, &byte_arrays); + + CHECK_GT(byte_arrays.size(), 1); + ByteArray& invalidated = byte_arrays[1]; + int invalidated_size = invalidated.Size(); + + heap->RightTrimFixedArray(invalidated, invalidated.length() - 8); + page->RegisterObjectWithInvalidatedSlots<OLD_TO_NEW>(invalidated, + invalidated_size); + + // Free memory at end of invalidated object + InvalidatedSlotsCleanup cleanup = InvalidatedSlotsCleanup::OldToNew(page); + Address free_start = invalidated.address() + invalidated.Size(); + cleanup.Free(free_start, page->area_end()); + + // After cleanup the invalidated object should be smaller + InvalidatedSlots* invalidated_slots = page->invalidated_slots<OLD_TO_NEW>(); + CHECK_GE((*invalidated_slots)[HeapObject::FromAddress(invalidated.address())], + invalidated.Size()); + CHECK_EQ(invalidated_slots->size(), 1); +} + } // namespace heap } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/ArrayLiterals.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/ArrayLiterals.golden index 9392d60181..d6097e938d 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/ArrayLiterals.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/ArrayLiterals.golden @@ -141,9 +141,9 @@ handlers: [ snippet: " var a = [ 1, 2 ]; return [ 0, ...a ]; " -frame size: 8 +frame size: 7 parameter count: 1 -bytecode array length: 84 +bytecode array length: 80 bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(37), @@ -152,22 +152,21 @@ bytecodes: [ B(Star), R(2), B(LdaConstant), U8(2), /* 67 S> */ B(Star), R(1), - B(LdaNamedProperty), R(0), U8(3), U8(2), + B(GetIterator), R(0), U8(2), B(Star), R(6), B(CallProperty0), R(6), R(0), U8(4), - B(Mov), R(0), R(5), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), B(Star), R(4), - B(LdaNamedProperty), R(4), U8(4), U8(6), + B(LdaNamedProperty), R(4), U8(3), U8(6), B(Star), R(3), B(CallProperty0), R(3), R(4), U8(15), - B(Star), R(7), + B(Star), R(5), B(JumpIfJSReceiver), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(7), U8(1), - B(LdaNamedProperty), R(7), U8(5), U8(17), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(5), U8(1), + B(LdaNamedProperty), R(5), U8(4), U8(17), B(JumpIfToBooleanTrue), U8(19), - B(LdaNamedProperty), R(7), U8(6), U8(8), + B(LdaNamedProperty), R(5), U8(5), U8(8), B(StaInArrayLiteral), R(2), R(1), U8(13), B(Ldar), R(1), B(Inc), U8(12), @@ -180,7 +179,6 @@ constant pool: [ ARRAY_BOILERPLATE_DESCRIPTION_TYPE, ARRAY_BOILERPLATE_DESCRIPTION_TYPE, Smi [1], - SYMBOL_TYPE, ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/AsyncGenerators.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/AsyncGenerators.golden index ce579699d8..1dbb999371 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/AsyncGenerators.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/AsyncGenerators.golden @@ -212,9 +212,9 @@ snippet: " async function* f() { for (let x of [42]) yield x } f(); " -frame size: 21 +frame size: 19 parameter count: 1 -bytecode array length: 372 +bytecode array length: 369 bytecodes: [ B(SwitchOnGeneratorState), R(0), U8(0), U8(2), B(Mov), R(closure), R(4), @@ -235,103 +235,102 @@ bytecodes: [ B(LdaSmi), I8(1), B(Star), R(4), B(Mov), R(8), R(5), - B(JumpConstant), U8(16), + B(JumpConstant), U8(15), /* 36 S> */ B(CreateArrayLiteral), U8(4), U8(0), U8(37), B(Star), R(10), - B(LdaNamedProperty), R(10), U8(5), U8(1), + B(GetIterator), R(10), U8(1), B(Star), R(11), B(CallProperty0), R(11), R(10), U8(3), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), B(Star), R(9), - B(LdaNamedProperty), R(9), U8(6), U8(5), + B(LdaNamedProperty), R(9), U8(5), U8(5), B(Star), R(8), B(LdaFalse), - B(Star), R(12), - B(Mov), R(context), R(15), + B(Star), R(10), + B(Mov), R(context), R(13), B(LdaTrue), - B(Star), R(12), + B(Star), R(10), /* 31 S> */ B(CallProperty0), R(8), R(9), U8(7), - B(Star), R(16), + B(Star), R(14), B(JumpIfJSReceiver), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(16), U8(1), - B(LdaNamedProperty), R(16), U8(7), U8(9), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(14), U8(1), + B(LdaNamedProperty), R(14), U8(6), U8(9), B(JumpIfToBooleanTrue), U8(67), - B(LdaNamedProperty), R(16), U8(8), U8(11), - B(Star), R(16), + B(LdaNamedProperty), R(14), U8(7), U8(11), + B(Star), R(14), B(LdaFalse), - B(Star), R(12), - B(Mov), R(16), R(1), + B(Star), R(10), + B(Mov), R(14), R(1), /* 22 E> */ B(StackCheck), /* 31 S> */ B(Mov), R(1), R(3), /* 42 S> */ B(LdaFalse), - B(Star), R(19), - B(Mov), R(0), R(17), - B(Mov), R(3), R(18), - B(InvokeIntrinsic), U8(Runtime::k_AsyncGeneratorYield), R(17), U8(3), - /* 42 E> */ B(SuspendGenerator), R(0), R(0), U8(17), U8(1), - B(ResumeGenerator), R(0), R(0), U8(17), B(Star), R(17), + B(Mov), R(0), R(15), + B(Mov), R(3), R(16), + B(InvokeIntrinsic), U8(Runtime::k_AsyncGeneratorYield), R(15), U8(3), + /* 42 E> */ B(SuspendGenerator), R(0), R(0), U8(15), U8(1), + B(ResumeGenerator), R(0), R(0), U8(15), + B(Star), R(15), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1), - B(SwitchOnSmiNoFeedback), U8(9), U8(2), I8(0), - B(Ldar), R(17), + B(SwitchOnSmiNoFeedback), U8(8), U8(2), I8(0), + B(Ldar), R(15), /* 42 E> */ B(Throw), B(LdaSmi), I8(1), - B(Star), R(13), - B(Mov), R(17), R(14), + B(Star), R(11), + B(Mov), R(15), R(12), B(Jump), U8(20), - B(Ldar), R(17), + B(Ldar), R(15), B(JumpLoop), U8(84), I8(0), B(LdaSmi), I8(-1), - B(Star), R(14), - B(Star), R(13), + B(Star), R(12), + B(Star), R(11), B(Jump), U8(7), - B(Star), R(14), + B(Star), R(12), B(LdaZero), - B(Star), R(13), + B(Star), R(11), B(LdaTheHole), B(SetPendingMessage), + B(Star), R(13), + B(Ldar), R(10), + B(JumpIfToBooleanTrue), U8(58), + B(LdaNamedProperty), R(9), U8(10), U8(13), B(Star), R(15), - B(Ldar), R(12), - B(JumpIfToBooleanTrue), U8(60), - B(LdaNamedProperty), R(9), U8(11), U8(13), - B(Star), R(17), - B(JumpIfUndefined), U8(52), - B(JumpIfNull), U8(50), - B(Mov), R(context), R(18), + B(JumpIfUndefinedOrNull), U8(50), + B(Mov), R(context), R(16), B(TestTypeOf), U8(6), B(JumpIfTrue), U8(18), B(Wide), B(LdaSmi), I16(159), - B(Star), R(19), - B(LdaConstant), U8(12), - B(Star), R(20), - B(CallRuntime), U16(Runtime::kNewTypeError), R(19), U8(2), + B(Star), R(17), + B(LdaConstant), U8(11), + B(Star), R(18), + B(CallRuntime), U16(Runtime::kNewTypeError), R(17), U8(2), B(Throw), - B(CallProperty0), R(17), R(9), U8(15), + B(CallProperty0), R(15), R(9), U8(15), B(JumpIfJSReceiver), U8(21), - B(Star), R(19), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(19), U8(1), + B(Star), R(17), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(17), U8(1), B(Jump), U8(12), - B(Star), R(18), + B(Star), R(16), B(LdaZero), - B(TestReferenceEqual), R(13), + B(TestReferenceEqual), R(11), B(JumpIfTrue), U8(5), - B(Ldar), R(18), + B(Ldar), R(16), B(ReThrow), - B(Ldar), R(15), - B(SetPendingMessage), B(Ldar), R(13), - B(SwitchOnSmiNoFeedback), U8(13), U8(2), I8(0), + B(SetPendingMessage), + B(Ldar), R(11), + B(SwitchOnSmiNoFeedback), U8(12), U8(2), I8(0), B(Jump), U8(14), - B(Ldar), R(14), + B(Ldar), R(12), B(ReThrow), B(LdaSmi), I8(1), B(Star), R(4), - B(Mov), R(14), R(5), + B(Mov), R(12), R(5), B(Jump), U8(51), B(Jump), U8(36), B(Star), R(8), - B(CreateCatchContext), R(8), U8(15), + B(CreateCatchContext), R(8), U8(14), B(Star), R(7), B(LdaTheHole), B(SetPendingMessage), @@ -360,7 +359,7 @@ bytecodes: [ B(Ldar), R(6), B(SetPendingMessage), B(Ldar), R(4), - B(SwitchOnSmiNoFeedback), U8(17), U8(3), I8(0), + B(SwitchOnSmiNoFeedback), U8(16), U8(3), I8(0), B(Jump), U8(22), B(Ldar), R(5), B(ReThrow), @@ -377,11 +376,10 @@ bytecodes: [ ] constant pool: [ Smi [30], - Smi [149], + Smi [148], Smi [16], Smi [7], ARRAY_BOILERPLATE_DESCRIPTION_TYPE, - SYMBOL_TYPE, ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], @@ -392,16 +390,16 @@ constant pool: [ Smi [6], Smi [9], SCOPE_INFO_TYPE, - Smi [277], + Smi [274], Smi [6], Smi [9], Smi [23], ] handlers: [ - [20, 318, 326], - [23, 282, 284], - [93, 180, 188], - [214, 247, 249], + [20, 315, 323], + [23, 279, 281], + [92, 179, 187], + [211, 244, 246], ] --- @@ -410,9 +408,9 @@ snippet: " async function* f() { yield* g() } f(); " -frame size: 19 +frame size: 17 parameter count: 1 -bytecode array length: 475 +bytecode array length: 466 bytecodes: [ B(SwitchOnGeneratorState), R(0), U8(0), U8(5), B(Mov), R(closure), R(1), @@ -433,44 +431,69 @@ bytecodes: [ B(LdaSmi), I8(1), B(Star), R(1), B(Mov), R(5), R(2), - B(JumpConstant), U8(18), + B(JumpConstant), U8(17), /* 49 S> */ B(LdaGlobal), U8(7), U8(0), B(Star), R(9), /* 56 E> */ B(CallUndefinedReceiver0), R(9), U8(2), B(Star), R(10), B(LdaNamedProperty), R(10), U8(8), U8(4), - B(JumpIfUndefined), U8(17), - B(JumpIfNull), U8(15), + B(JumpIfUndefinedOrNull), U8(15), B(Star), R(11), B(CallProperty0), R(11), R(10), U8(6), - B(JumpIfJSReceiver), U8(23), + B(JumpIfJSReceiver), U8(22), B(CallRuntime), U16(Runtime::kThrowSymbolAsyncIteratorInvalid), R(0), U8(0), - B(LdaNamedProperty), R(10), U8(9), U8(8), + B(GetIterator), R(10), U8(8), B(Star), R(11), B(CallProperty0), R(11), R(10), U8(10), B(Star), R(11), B(InvokeIntrinsic), U8(Runtime::k_CreateAsyncFromSyncIterator), R(11), U8(1), B(Star), R(7), - B(LdaNamedProperty), R(7), U8(10), U8(12), + B(LdaNamedProperty), R(7), U8(9), U8(12), B(Star), R(9), B(LdaUndefined), B(Star), R(8), B(LdaZero), B(Star), R(6), B(Ldar), R(6), - B(SwitchOnSmiNoFeedback), U8(11), U8(2), I8(1), + B(SwitchOnSmiNoFeedback), U8(10), U8(2), I8(1), B(CallProperty1), R(9), R(7), R(8), U8(14), - B(Jump), U8(146), - B(LdaNamedProperty), R(7), U8(13), U8(16), - B(JumpIfUndefined), U8(13), - B(JumpIfNull), U8(11), + B(Jump), U8(140), + B(LdaNamedProperty), R(7), U8(12), U8(16), + B(JumpIfUndefinedOrNull), U8(11), + B(Star), R(10), + B(CallProperty1), R(10), R(7), R(8), U8(18), + B(Jump), U8(125), + B(Mov), R(0), R(10), + B(Mov), R(8), R(11), + B(InvokeIntrinsic), U8(Runtime::k_AsyncGeneratorAwaitUncaught), R(10), U8(2), + /* 49 E> */ B(SuspendGenerator), R(0), R(0), U8(10), U8(1), + B(ResumeGenerator), R(0), R(0), U8(10), + B(Star), R(10), + B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1), + B(Star), R(11), + B(LdaZero), + B(TestReferenceEqual), R(11), + B(JumpIfTrue), U8(5), + B(Ldar), R(10), + B(ReThrow), + B(LdaSmi), I8(1), + B(Star), R(1), + B(Mov), R(10), R(2), + B(Jump), U8(241), + B(LdaNamedProperty), R(7), U8(13), U8(20), + B(JumpIfUndefinedOrNull), U8(11), B(Star), R(12), - B(CallProperty1), R(12), R(7), R(8), U8(18), - B(Jump), U8(129), + B(CallProperty1), R(12), R(7), R(8), U8(22), + B(Jump), U8(66), + B(LdaNamedProperty), R(7), U8(12), U8(24), + B(JumpIfUndefinedOrNull), U8(55), + B(Star), R(12), + B(CallProperty0), R(12), R(7), U8(26), + B(Jump), U8(2), + B(Star), R(13), B(Mov), R(0), R(12), - B(Mov), R(8), R(13), B(InvokeIntrinsic), U8(Runtime::k_AsyncGeneratorAwaitUncaught), R(12), U8(2), - /* 49 E> */ B(SuspendGenerator), R(0), R(0), U8(12), U8(1), + /* 49 E> */ B(SuspendGenerator), R(0), R(0), U8(12), U8(2), B(ResumeGenerator), R(0), R(0), U8(12), B(Star), R(12), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1), @@ -480,72 +503,43 @@ bytecodes: [ B(JumpIfTrue), U8(5), B(Ldar), R(12), B(ReThrow), - B(LdaSmi), I8(1), - B(Star), R(1), - B(Mov), R(12), R(2), - B(Jump), U8(245), - B(LdaNamedProperty), R(7), U8(14), U8(20), - B(JumpIfUndefined), U8(13), - B(JumpIfNull), U8(11), - B(Star), R(14), - B(CallProperty1), R(14), R(7), R(8), U8(22), - B(Jump), U8(68), - B(LdaNamedProperty), R(7), U8(13), U8(24), - B(JumpIfUndefined), U8(57), - B(JumpIfNull), U8(55), - B(Star), R(14), - B(CallProperty0), R(14), R(7), U8(26), - B(Jump), U8(2), - B(Star), R(15), - B(Mov), R(0), R(14), - B(InvokeIntrinsic), U8(Runtime::k_AsyncGeneratorAwaitUncaught), R(14), U8(2), - /* 49 E> */ B(SuspendGenerator), R(0), R(0), U8(14), U8(2), - B(ResumeGenerator), R(0), R(0), U8(14), - B(Star), R(14), - B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1), - B(Star), R(15), - B(LdaZero), - B(TestReferenceEqual), R(15), - B(JumpIfTrue), U8(5), - B(Ldar), R(14), - B(ReThrow), - B(Ldar), R(14), + B(Ldar), R(12), B(JumpIfJSReceiver), U8(9), - B(Star), R(16), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(16), U8(1), - B(CallRuntime), U16(Runtime::kThrowThrowMethodMissing), R(0), U8(0), - B(Star), R(15), - B(Mov), R(0), R(14), - B(InvokeIntrinsic), U8(Runtime::k_AsyncGeneratorAwaitUncaught), R(14), U8(2), - /* 49 E> */ B(SuspendGenerator), R(0), R(0), U8(14), U8(3), - B(ResumeGenerator), R(0), R(0), U8(14), B(Star), R(14), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(14), U8(1), + B(CallRuntime), U16(Runtime::kThrowThrowMethodMissing), R(0), U8(0), + B(Star), R(13), + B(Mov), R(0), R(12), + B(InvokeIntrinsic), U8(Runtime::k_AsyncGeneratorAwaitUncaught), R(12), U8(2), + /* 49 E> */ B(SuspendGenerator), R(0), R(0), U8(12), U8(3), + B(ResumeGenerator), R(0), R(0), U8(12), + B(Star), R(12), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1), - B(Star), R(15), + B(Star), R(13), B(LdaZero), - B(TestReferenceEqual), R(15), + B(TestReferenceEqual), R(13), B(JumpIfTrue), U8(5), - B(Ldar), R(14), + B(Ldar), R(12), B(ReThrow), - B(Ldar), R(14), - B(Mov), R(14), R(5), + B(Ldar), R(12), + B(Mov), R(12), R(5), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(5), U8(1), - B(LdaNamedProperty), R(5), U8(15), U8(28), + B(LdaNamedProperty), R(5), U8(14), U8(28), B(JumpIfToBooleanTrue), U8(38), - B(LdaNamedProperty), R(5), U8(16), U8(30), - B(Star), R(17), + B(LdaNamedProperty), R(5), U8(15), U8(30), + B(Star), R(15), B(LdaFalse), - B(Star), R(18), - B(Mov), R(0), R(16), - B(InvokeIntrinsic), U8(Runtime::k_AsyncGeneratorYield), R(16), U8(3), - /* 49 E> */ B(SuspendGenerator), R(0), R(0), U8(16), U8(4), - B(ResumeGenerator), R(0), R(0), U8(16), + B(Star), R(16), + B(Mov), R(0), R(14), + B(InvokeIntrinsic), U8(Runtime::k_AsyncGeneratorYield), R(14), U8(3), + /* 49 E> */ B(SuspendGenerator), R(0), R(0), U8(14), U8(4), + B(ResumeGenerator), R(0), R(0), U8(14), B(Star), R(8), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1), B(Star), R(6), - B(JumpLoop), U8(242), I8(0), - B(LdaNamedProperty), R(5), U8(16), U8(32), + B(JumpLoop), U8(236), I8(0), + B(LdaNamedProperty), R(5), U8(15), U8(32), B(Star), R(7), B(LdaSmi), I8(1), B(TestReferenceEqual), R(6), @@ -557,7 +551,7 @@ bytecodes: [ B(Ldar), R(7), B(Jump), U8(36), B(Star), R(5), - B(CreateCatchContext), R(5), U8(17), + B(CreateCatchContext), R(5), U8(16), B(Star), R(4), B(LdaTheHole), B(SetPendingMessage), @@ -586,7 +580,7 @@ bytecodes: [ B(Ldar), R(3), B(SetPendingMessage), B(Ldar), R(1), - B(SwitchOnSmiNoFeedback), U8(19), U8(3), I8(0), + B(SwitchOnSmiNoFeedback), U8(18), U8(3), I8(0), B(Jump), U8(22), B(Ldar), R(2), B(ReThrow), @@ -603,30 +597,29 @@ bytecodes: [ ] constant pool: [ Smi [30], - Smi [162], - Smi [238], - Smi [288], - Smi [347], + Smi [157], + Smi [229], + Smi [279], + Smi [338], Smi [16], Smi [7], ONE_BYTE_INTERNALIZED_STRING_TYPE ["g"], SYMBOL_TYPE, - SYMBOL_TYPE, ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], Smi [11], - Smi [72], + Smi [70], ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["throw"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], SCOPE_INFO_TYPE, - Smi [380], + Smi [371], Smi [6], Smi [9], Smi [23], ] handlers: [ - [20, 421, 429], - [23, 383, 387], + [20, 412, 420], + [23, 374, 378], ] diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/CallAndSpread.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/CallAndSpread.golden index 33bd5434b4..963cbee018 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/CallAndSpread.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/CallAndSpread.golden @@ -65,9 +65,9 @@ handlers: [ snippet: " Math.max(0, ...[1, 2, 3], 4); " -frame size: 10 +frame size: 9 parameter count: 1 -bytecode array length: 107 +bytecode array length: 106 bytecodes: [ /* 30 E> */ B(StackCheck), /* 34 S> */ B(LdaGlobal), U8(0), U8(0), @@ -80,22 +80,22 @@ bytecodes: [ B(Star), R(3), /* 49 S> */ B(CreateArrayLiteral), U8(4), U8(5), U8(37), B(Star), R(7), - B(LdaNamedProperty), R(7), U8(5), U8(6), + B(GetIterator), R(7), U8(6), B(Star), R(8), B(CallProperty0), R(8), R(7), U8(8), B(Mov), R(0), R(2), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), B(Star), R(6), - B(LdaNamedProperty), R(6), U8(6), U8(10), + B(LdaNamedProperty), R(6), U8(5), U8(10), B(Star), R(5), B(CallProperty0), R(5), R(6), U8(19), - B(Star), R(9), + B(Star), R(7), B(JumpIfJSReceiver), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(9), U8(1), - B(LdaNamedProperty), R(9), U8(7), U8(21), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(7), U8(1), + B(LdaNamedProperty), R(7), U8(6), U8(21), B(JumpIfToBooleanTrue), U8(19), - B(LdaNamedProperty), R(9), U8(8), U8(12), + B(LdaNamedProperty), R(7), U8(7), U8(12), B(StaInArrayLiteral), R(4), R(3), U8(17), B(Ldar), R(3), B(Inc), U8(16), @@ -114,7 +114,6 @@ constant pool: [ ARRAY_BOILERPLATE_DESCRIPTION_TYPE, Smi [1], ARRAY_BOILERPLATE_DESCRIPTION_TYPE, - SYMBOL_TYPE, ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/DestructuringAssignment.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/DestructuringAssignment.golden index 2d44b972a0..e26b79a9fb 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/DestructuringAssignment.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/DestructuringAssignment.golden @@ -10,93 +10,90 @@ snippet: " var x, a = [0,1,2,3]; [x] = a; " -frame size: 16 +frame size: 14 parameter count: 1 -bytecode array length: 178 +bytecode array length: 172 bytecodes: [ /* 30 E> */ B(StackCheck), /* 45 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(37), B(Star), R(1), - /* 60 S> */ B(LdaNamedProperty), R(1), U8(1), U8(1), + /* 60 S> */ B(GetIterator), R(1), U8(1), B(Star), R(6), B(CallProperty0), R(6), R(1), U8(3), - B(Mov), R(1), R(5), B(Mov), R(1), R(2), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), B(Star), R(4), - B(LdaNamedProperty), R(4), U8(2), U8(5), + B(LdaNamedProperty), R(4), U8(1), U8(5), B(Star), R(3), B(LdaFalse), - B(Star), R(7), - B(Mov), R(context), R(10), - /* 57 S> */ B(Ldar), R(7), + B(Star), R(5), + B(Mov), R(context), R(8), + /* 57 S> */ B(Ldar), R(5), B(JumpIfToBooleanTrue), U8(37), B(LdaTrue), - B(Star), R(7), + B(Star), R(5), B(CallProperty0), R(3), R(4), U8(11), - B(Star), R(11), + B(Star), R(9), B(JumpIfJSReceiver), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(11), U8(1), - B(LdaNamedProperty), R(11), U8(3), U8(9), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(9), U8(1), + B(LdaNamedProperty), R(9), U8(2), U8(9), B(JumpIfToBooleanTrue), U8(15), - B(LdaNamedProperty), R(11), U8(4), U8(7), - B(Star), R(11), + B(LdaNamedProperty), R(9), U8(3), U8(7), + B(Star), R(9), B(LdaFalse), - B(Star), R(7), - B(Ldar), R(11), + B(Star), R(5), + B(Ldar), R(9), B(Jump), U8(3), B(LdaUndefined), B(Star), R(0), B(LdaSmi), I8(-1), - B(Star), R(9), - B(Star), R(8), + B(Star), R(7), + B(Star), R(6), B(Jump), U8(7), - B(Star), R(9), + B(Star), R(7), B(LdaZero), - B(Star), R(8), + B(Star), R(6), B(LdaTheHole), B(SetPendingMessage), + B(Star), R(8), + B(Ldar), R(5), + B(JumpIfToBooleanTrue), U8(58), + B(LdaNamedProperty), R(4), U8(4), U8(13), B(Star), R(10), - B(Ldar), R(7), - B(JumpIfToBooleanTrue), U8(60), - B(LdaNamedProperty), R(4), U8(5), U8(13), - B(Star), R(12), - B(JumpIfUndefined), U8(52), - B(JumpIfNull), U8(50), - B(Mov), R(context), R(13), + B(JumpIfUndefinedOrNull), U8(50), + B(Mov), R(context), R(11), B(TestTypeOf), U8(6), B(JumpIfTrue), U8(18), B(Wide), B(LdaSmi), I16(159), - B(Star), R(14), - B(LdaConstant), U8(6), - B(Star), R(15), - B(CallRuntime), U16(Runtime::kNewTypeError), R(14), U8(2), + B(Star), R(12), + B(LdaConstant), U8(5), + B(Star), R(13), + B(CallRuntime), U16(Runtime::kNewTypeError), R(12), U8(2), B(Throw), - B(CallProperty0), R(12), R(4), U8(15), + B(CallProperty0), R(10), R(4), U8(15), B(JumpIfJSReceiver), U8(21), - B(Star), R(14), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(14), U8(1), + B(Star), R(12), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(12), U8(1), B(Jump), U8(12), - B(Star), R(13), + B(Star), R(11), B(LdaZero), - B(TestReferenceEqual), R(8), + B(TestReferenceEqual), R(6), B(JumpIfTrue), U8(5), - B(Ldar), R(13), + B(Ldar), R(11), B(ReThrow), - B(Ldar), R(10), + B(Ldar), R(8), B(SetPendingMessage), B(LdaZero), - B(TestReferenceEqual), R(8), + B(TestReferenceEqual), R(6), B(JumpIfFalse), U8(5), - B(Ldar), R(9), + B(Ldar), R(7), B(ReThrow), B(LdaUndefined), /* 65 S> */ B(Return), ] constant pool: [ ARRAY_BOILERPLATE_DESCRIPTION_TYPE, - SYMBOL_TYPE, ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], @@ -104,8 +101,8 @@ constant pool: [ ONE_BYTE_INTERNALIZED_STRING_TYPE [""], ] handlers: [ - [44, 86, 94], - [120, 153, 155], + [40, 82, 90], + [114, 147, 149], ] --- @@ -113,127 +110,124 @@ snippet: " var x, y, a = [0,1,2,3]; [,x,...y] = a; " -frame size: 17 +frame size: 15 parameter count: 1 -bytecode array length: 264 +bytecode array length: 258 bytecodes: [ /* 30 E> */ B(StackCheck), /* 48 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(37), B(Star), R(2), - /* 69 S> */ B(LdaNamedProperty), R(2), U8(1), U8(1), + /* 69 S> */ B(GetIterator), R(2), U8(1), B(Star), R(7), B(CallProperty0), R(7), R(2), U8(3), - B(Mov), R(2), R(6), B(Mov), R(2), R(3), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), B(Star), R(5), - B(LdaNamedProperty), R(5), U8(2), U8(5), + B(LdaNamedProperty), R(5), U8(1), U8(5), B(Star), R(4), B(LdaFalse), - B(Star), R(8), - B(Mov), R(context), R(11), - B(Ldar), R(8), + B(Star), R(6), + B(Mov), R(context), R(9), + B(Ldar), R(6), B(JumpIfToBooleanTrue), U8(35), B(LdaTrue), - B(Star), R(8), + B(Star), R(6), B(CallProperty0), R(4), R(5), U8(11), - B(Star), R(12), + B(Star), R(10), B(JumpIfJSReceiver), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(12), U8(1), - B(LdaNamedProperty), R(12), U8(3), U8(9), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(10), U8(1), + B(LdaNamedProperty), R(10), U8(2), U8(9), B(JumpIfToBooleanTrue), U8(13), - B(LdaNamedProperty), R(12), U8(4), U8(7), - B(Star), R(12), + B(LdaNamedProperty), R(10), U8(3), U8(7), + B(Star), R(10), B(LdaFalse), - B(Star), R(8), - B(Ldar), R(12), - /* 61 S> */ B(Ldar), R(8), + B(Star), R(6), + B(Ldar), R(10), + /* 61 S> */ B(Ldar), R(6), B(JumpIfToBooleanTrue), U8(37), B(LdaTrue), - B(Star), R(8), + B(Star), R(6), B(CallProperty0), R(4), R(5), U8(13), - B(Star), R(12), + B(Star), R(10), B(JumpIfJSReceiver), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(12), U8(1), - B(LdaNamedProperty), R(12), U8(3), U8(9), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(10), U8(1), + B(LdaNamedProperty), R(10), U8(2), U8(9), B(JumpIfToBooleanTrue), U8(15), - B(LdaNamedProperty), R(12), U8(4), U8(7), - B(Star), R(12), + B(LdaNamedProperty), R(10), U8(3), U8(7), + B(Star), R(10), B(LdaFalse), - B(Star), R(8), - B(Ldar), R(12), + B(Star), R(6), + B(Ldar), R(10), B(Jump), U8(3), B(LdaUndefined), B(Star), R(0), /* 63 S> */ B(CreateEmptyArrayLiteral), U8(15), - B(Star), R(13), + B(Star), R(11), B(LdaZero), - B(Star), R(14), + B(Star), R(12), B(LdaTrue), - B(Star), R(8), + B(Star), R(6), B(CallProperty0), R(4), R(5), U8(19), - B(Star), R(12), + B(Star), R(10), B(JumpIfJSReceiver), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(12), U8(1), - B(LdaNamedProperty), R(12), U8(3), U8(21), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(10), U8(1), + B(LdaNamedProperty), R(10), U8(2), U8(21), B(JumpIfToBooleanTrue), U8(19), - B(LdaNamedProperty), R(12), U8(4), U8(7), - B(StaInArrayLiteral), R(13), R(14), U8(16), - B(Ldar), R(14), + B(LdaNamedProperty), R(10), U8(3), U8(7), + B(StaInArrayLiteral), R(11), R(12), U8(16), + B(Ldar), R(12), B(Inc), U8(18), - B(Star), R(14), + B(Star), R(12), B(JumpLoop), U8(33), I8(0), - B(Mov), R(13), R(1), + B(Mov), R(11), R(1), B(LdaSmi), I8(-1), - B(Star), R(10), - B(Star), R(9), + B(Star), R(8), + B(Star), R(7), B(Jump), U8(7), - B(Star), R(10), + B(Star), R(8), B(LdaZero), - B(Star), R(9), + B(Star), R(7), B(LdaTheHole), B(SetPendingMessage), + B(Star), R(9), + B(Ldar), R(6), + B(JumpIfToBooleanTrue), U8(58), + B(LdaNamedProperty), R(5), U8(4), U8(23), B(Star), R(11), - B(Ldar), R(8), - B(JumpIfToBooleanTrue), U8(60), - B(LdaNamedProperty), R(5), U8(5), U8(23), - B(Star), R(13), - B(JumpIfUndefined), U8(52), - B(JumpIfNull), U8(50), - B(Mov), R(context), R(14), + B(JumpIfUndefinedOrNull), U8(50), + B(Mov), R(context), R(12), B(TestTypeOf), U8(6), B(JumpIfTrue), U8(18), B(Wide), B(LdaSmi), I16(159), - B(Star), R(15), - B(LdaConstant), U8(6), - B(Star), R(16), - B(CallRuntime), U16(Runtime::kNewTypeError), R(15), U8(2), + B(Star), R(13), + B(LdaConstant), U8(5), + B(Star), R(14), + B(CallRuntime), U16(Runtime::kNewTypeError), R(13), U8(2), B(Throw), - B(CallProperty0), R(13), R(5), U8(25), + B(CallProperty0), R(11), R(5), U8(25), B(JumpIfJSReceiver), U8(21), - B(Star), R(15), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(15), U8(1), + B(Star), R(13), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(13), U8(1), B(Jump), U8(12), - B(Star), R(14), + B(Star), R(12), B(LdaZero), - B(TestReferenceEqual), R(9), + B(TestReferenceEqual), R(7), B(JumpIfTrue), U8(5), - B(Ldar), R(14), + B(Ldar), R(12), B(ReThrow), - B(Ldar), R(11), + B(Ldar), R(9), B(SetPendingMessage), B(LdaZero), - B(TestReferenceEqual), R(9), + B(TestReferenceEqual), R(7), B(JumpIfFalse), U8(5), - B(Ldar), R(10), + B(Ldar), R(8), B(ReThrow), B(LdaUndefined), /* 74 S> */ B(Return), ] constant pool: [ ARRAY_BOILERPLATE_DESCRIPTION_TYPE, - SYMBOL_TYPE, ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], @@ -241,8 +235,8 @@ constant pool: [ ONE_BYTE_INTERNALIZED_STRING_TYPE [""], ] handlers: [ - [44, 172, 180], - [206, 239, 241], + [40, 168, 176], + [200, 233, 235], ] --- @@ -250,114 +244,111 @@ snippet: " var x={}, y, a = [0]; [x.foo,y=4] = a; " -frame size: 18 +frame size: 16 parameter count: 1 -bytecode array length: 229 +bytecode array length: 223 bytecodes: [ /* 30 E> */ B(StackCheck), /* 40 S> */ B(CreateEmptyObjectLiteral), B(Star), R(0), /* 51 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(37), B(Star), R(2), - /* 68 S> */ B(LdaNamedProperty), R(2), U8(1), U8(1), + /* 68 S> */ B(GetIterator), R(2), U8(1), B(Star), R(7), B(CallProperty0), R(7), R(2), U8(3), - B(Mov), R(2), R(6), B(Mov), R(2), R(3), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), B(Star), R(5), - B(LdaNamedProperty), R(5), U8(2), U8(5), + B(LdaNamedProperty), R(5), U8(1), U8(5), B(Star), R(4), B(LdaFalse), - B(Star), R(8), - B(Mov), R(context), R(11), - /* 59 S> */ B(Ldar), R(8), - B(Mov), R(0), R(13), + B(Star), R(6), + B(Mov), R(context), R(9), + /* 59 S> */ B(Ldar), R(6), + B(Mov), R(0), R(11), B(JumpIfToBooleanTrue), U8(37), B(LdaTrue), - B(Star), R(8), + B(Star), R(6), B(CallProperty0), R(4), R(5), U8(11), - B(Star), R(12), + B(Star), R(10), B(JumpIfJSReceiver), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(12), U8(1), - B(LdaNamedProperty), R(12), U8(3), U8(9), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(10), U8(1), + B(LdaNamedProperty), R(10), U8(2), U8(9), B(JumpIfToBooleanTrue), U8(15), - B(LdaNamedProperty), R(12), U8(4), U8(7), - B(Star), R(12), + B(LdaNamedProperty), R(10), U8(3), U8(7), + B(Star), R(10), B(LdaFalse), - B(Star), R(8), - B(Ldar), R(12), + B(Star), R(6), + B(Ldar), R(10), B(Jump), U8(3), B(LdaUndefined), - B(StaNamedProperty), R(13), U8(5), U8(13), - /* 63 S> */ B(Ldar), R(8), + B(StaNamedProperty), R(11), U8(4), U8(13), + /* 63 S> */ B(Ldar), R(6), B(JumpIfToBooleanTrue), U8(37), B(LdaTrue), - B(Star), R(8), + B(Star), R(6), B(CallProperty0), R(4), R(5), U8(15), - B(Star), R(12), + B(Star), R(10), B(JumpIfJSReceiver), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(12), U8(1), - B(LdaNamedProperty), R(12), U8(3), U8(9), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(10), U8(1), + B(LdaNamedProperty), R(10), U8(2), U8(9), B(JumpIfToBooleanTrue), U8(15), - B(LdaNamedProperty), R(12), U8(4), U8(7), - B(Star), R(12), + B(LdaNamedProperty), R(10), U8(3), U8(7), + B(Star), R(10), B(LdaFalse), - B(Star), R(8), - B(Ldar), R(12), + B(Star), R(6), + B(Ldar), R(10), B(JumpIfNotUndefined), U8(4), B(LdaSmi), I8(4), B(Star), R(1), B(LdaSmi), I8(-1), - B(Star), R(10), - B(Star), R(9), + B(Star), R(8), + B(Star), R(7), B(Jump), U8(7), - B(Star), R(10), + B(Star), R(8), B(LdaZero), - B(Star), R(9), + B(Star), R(7), B(LdaTheHole), B(SetPendingMessage), - B(Star), R(11), - B(Ldar), R(8), - B(JumpIfToBooleanTrue), U8(60), - B(LdaNamedProperty), R(5), U8(6), U8(17), - B(Star), R(14), - B(JumpIfUndefined), U8(52), - B(JumpIfNull), U8(50), - B(Mov), R(context), R(15), + B(Star), R(9), + B(Ldar), R(6), + B(JumpIfToBooleanTrue), U8(58), + B(LdaNamedProperty), R(5), U8(5), U8(17), + B(Star), R(12), + B(JumpIfUndefinedOrNull), U8(50), + B(Mov), R(context), R(13), B(TestTypeOf), U8(6), B(JumpIfTrue), U8(18), B(Wide), B(LdaSmi), I16(159), - B(Star), R(16), - B(LdaConstant), U8(7), - B(Star), R(17), - B(CallRuntime), U16(Runtime::kNewTypeError), R(16), U8(2), + B(Star), R(14), + B(LdaConstant), U8(6), + B(Star), R(15), + B(CallRuntime), U16(Runtime::kNewTypeError), R(14), U8(2), B(Throw), - B(CallProperty0), R(14), R(5), U8(19), + B(CallProperty0), R(12), R(5), U8(19), B(JumpIfJSReceiver), U8(21), - B(Star), R(16), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(16), U8(1), + B(Star), R(14), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(14), U8(1), B(Jump), U8(12), - B(Star), R(15), + B(Star), R(13), B(LdaZero), - B(TestReferenceEqual), R(9), + B(TestReferenceEqual), R(7), B(JumpIfTrue), U8(5), - B(Ldar), R(15), + B(Ldar), R(13), B(ReThrow), - B(Ldar), R(11), + B(Ldar), R(9), B(SetPendingMessage), B(LdaZero), - B(TestReferenceEqual), R(9), + B(TestReferenceEqual), R(7), B(JumpIfFalse), U8(5), - B(Ldar), R(10), + B(Ldar), R(8), B(ReThrow), B(LdaUndefined), /* 73 S> */ B(Return), ] constant pool: [ ARRAY_BOILERPLATE_DESCRIPTION_TYPE, - SYMBOL_TYPE, ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], @@ -366,8 +357,8 @@ constant pool: [ ONE_BYTE_INTERNALIZED_STRING_TYPE [""], ] handlers: [ - [47, 137, 145], - [171, 204, 206], + [43, 133, 141], + [165, 198, 200], ] --- @@ -375,18 +366,14 @@ snippet: " var x, a = {x:1}; ({x} = a); " -frame size: 3 +frame size: 2 parameter count: 1 -bytecode array length: 26 +bytecode array length: 15 bytecodes: [ /* 30 E> */ B(StackCheck), /* 45 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(41), B(Star), R(1), - /* 52 S> */ B(JumpIfNull), U8(4), - B(JumpIfNotUndefined), U8(7), - /* 53 E> */ B(CallRuntime), U16(Runtime::kThrowPatternAssignmentNonCoercible), R(0), U8(0), - B(Star), R(2), - /* 54 S> */ B(LdaNamedProperty), R(2), U8(1), U8(1), + /* 54 S> */ B(LdaNamedProperty), R(1), U8(1), U8(1), B(Star), R(0), B(LdaUndefined), /* 63 S> */ B(Return), @@ -403,20 +390,16 @@ snippet: " var x={}, a = {y:1}; ({y:x.foo} = a); " -frame size: 3 +frame size: 2 parameter count: 1 -bytecode array length: 31 +bytecode array length: 20 bytecodes: [ /* 30 E> */ B(StackCheck), /* 40 S> */ B(CreateEmptyObjectLiteral), B(Star), R(0), /* 48 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(41), B(Star), R(1), - /* 55 S> */ B(JumpIfNull), U8(4), - B(JumpIfNotUndefined), U8(7), - /* 56 E> */ B(CallRuntime), U16(Runtime::kThrowPatternAssignmentNonCoercible), R(0), U8(0), - /* 61 S> */ B(Star), R(2), - B(LdaNamedProperty), R(2), U8(1), U8(1), + /* 61 S> */ B(LdaNamedProperty), R(1), U8(1), U8(1), B(StaNamedProperty), R(0), U8(2), U8(3), B(LdaUndefined), /* 72 S> */ B(Return), @@ -436,18 +419,15 @@ snippet: " " frame size: 4 parameter count: 1 -bytecode array length: 41 +bytecode array length: 33 bytecodes: [ /* 30 E> */ B(StackCheck), /* 45 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(41), B(Star), R(1), - /* 62 S> */ B(JumpIfNull), U8(4), - B(JumpIfNotUndefined), U8(7), - /* 63 E> */ B(CallRuntime), U16(Runtime::kThrowPatternAssignmentNonCoercible), R(0), U8(0), - B(Star), R(2), /* 64 S> */ B(LdaConstant), U8(1), B(Star), R(3), - B(LdaNamedProperty), R(2), U8(1), U8(1), + B(LdaNamedProperty), R(1), U8(1), U8(1), + B(Mov), R(1), R(2), B(JumpIfNotUndefined), U8(3), B(LdaZero), B(Star), R(0), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/ForAwaitOf.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/ForAwaitOf.golden index 1cafe42d28..f60e591040 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/ForAwaitOf.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/ForAwaitOf.golden @@ -14,9 +14,9 @@ snippet: " } f(); " -frame size: 21 +frame size: 19 parameter count: 1 -bytecode array length: 325 +bytecode array length: 320 bytecodes: [ B(SwitchOnGeneratorState), R(0), U8(0), U8(2), B(Mov), R(closure), R(4), @@ -28,110 +28,108 @@ bytecodes: [ /* 43 S> */ B(CreateArrayLiteral), U8(2), U8(0), U8(37), B(Star), R(7), B(LdaNamedProperty), R(7), U8(3), U8(1), - B(JumpIfUndefined), U8(17), - B(JumpIfNull), U8(15), + B(JumpIfUndefinedOrNull), U8(15), B(Star), R(8), B(CallProperty0), R(8), R(7), U8(3), - B(JumpIfJSReceiver), U8(23), + B(JumpIfJSReceiver), U8(22), B(CallRuntime), U16(Runtime::kThrowSymbolAsyncIteratorInvalid), R(0), U8(0), - B(LdaNamedProperty), R(7), U8(4), U8(5), + B(GetIterator), R(7), U8(5), B(Star), R(8), B(CallProperty0), R(8), R(7), U8(7), B(Star), R(8), B(InvokeIntrinsic), U8(Runtime::k_CreateAsyncFromSyncIterator), R(8), U8(1), B(Star), R(6), - B(LdaNamedProperty), R(6), U8(5), U8(9), + B(LdaNamedProperty), R(6), U8(4), U8(9), B(Star), R(5), B(LdaFalse), - B(Star), R(9), - B(Mov), R(context), R(12), + B(Star), R(7), + B(Mov), R(context), R(10), B(LdaTrue), - B(Star), R(9), + B(Star), R(7), /* 38 S> */ B(CallProperty0), R(5), R(6), U8(11), - B(Star), R(15), - B(Mov), R(0), R(14), - B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionAwaitUncaught), R(14), U8(2), - B(SuspendGenerator), R(0), R(0), U8(14), U8(0), - B(ResumeGenerator), R(0), R(0), U8(14), - B(Star), R(14), + B(Star), R(13), + B(Mov), R(0), R(12), + B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionAwaitUncaught), R(12), U8(2), + B(SuspendGenerator), R(0), R(0), U8(12), U8(0), + B(ResumeGenerator), R(0), R(0), U8(12), + B(Star), R(12), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1), - B(Star), R(15), + B(Star), R(13), B(LdaZero), - B(TestReferenceEqual), R(15), + B(TestReferenceEqual), R(13), B(JumpIfTrue), U8(5), - B(Ldar), R(14), + B(Ldar), R(12), B(ReThrow), - B(Ldar), R(14), - B(Mov), R(14), R(13), + B(Ldar), R(12), + B(Mov), R(12), R(11), B(JumpIfJSReceiver), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(13), U8(1), - B(LdaNamedProperty), R(13), U8(6), U8(13), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(11), U8(1), + B(LdaNamedProperty), R(11), U8(5), U8(13), B(JumpIfToBooleanTrue), U8(23), - B(LdaNamedProperty), R(13), U8(7), U8(15), - B(Star), R(13), + B(LdaNamedProperty), R(11), U8(6), U8(15), + B(Star), R(11), B(LdaFalse), - B(Star), R(9), - B(Mov), R(13), R(1), + B(Star), R(7), + B(Mov), R(11), R(1), /* 23 E> */ B(StackCheck), /* 38 S> */ B(Mov), R(1), R(3), - B(Ldar), R(13), + B(Ldar), R(11), B(JumpLoop), U8(77), I8(0), B(LdaSmi), I8(-1), - B(Star), R(11), - B(Star), R(10), + B(Star), R(9), + B(Star), R(8), B(Jump), U8(7), - B(Star), R(11), + B(Star), R(9), B(LdaZero), - B(Star), R(10), + B(Star), R(8), B(LdaTheHole), /* 38 E> */ B(SetPendingMessage), - B(Star), R(12), - B(Ldar), R(9), - B(JumpIfToBooleanTrue), U8(96), - B(LdaNamedProperty), R(6), U8(8), U8(17), - B(Star), R(16), - B(JumpIfUndefined), U8(88), - B(JumpIfNull), U8(86), - B(Mov), R(context), R(17), + B(Star), R(10), + B(Ldar), R(7), + B(JumpIfToBooleanTrue), U8(94), + B(LdaNamedProperty), R(6), U8(7), U8(17), + B(Star), R(14), + B(JumpIfUndefinedOrNull), U8(86), + B(Mov), R(context), R(15), B(TestTypeOf), U8(6), B(JumpIfTrue), U8(18), B(Wide), B(LdaSmi), I16(159), - B(Star), R(18), - B(LdaConstant), U8(9), - B(Star), R(19), - B(CallRuntime), U16(Runtime::kNewTypeError), R(18), U8(2), + B(Star), R(16), + B(LdaConstant), U8(8), + B(Star), R(17), + B(CallRuntime), U16(Runtime::kNewTypeError), R(16), U8(2), B(Throw), - B(CallProperty0), R(16), R(6), U8(19), - B(Star), R(19), - B(Mov), R(0), R(18), - B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionAwaitUncaught), R(18), U8(2), - B(SuspendGenerator), R(0), R(0), U8(18), U8(1), - B(ResumeGenerator), R(0), R(0), U8(18), - B(Star), R(18), + B(CallProperty0), R(14), R(6), U8(19), + B(Star), R(17), + B(Mov), R(0), R(16), + B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionAwaitUncaught), R(16), U8(2), + B(SuspendGenerator), R(0), R(0), U8(16), U8(1), + B(ResumeGenerator), R(0), R(0), U8(16), + B(Star), R(16), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1), - B(Star), R(19), + B(Star), R(17), B(LdaZero), - B(TestReferenceEqual), R(19), + B(TestReferenceEqual), R(17), B(JumpIfTrue), U8(5), - B(Ldar), R(18), + B(Ldar), R(16), B(ReThrow), - B(Ldar), R(18), + B(Ldar), R(16), B(JumpIfJSReceiver), U8(21), - B(Star), R(20), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(20), U8(1), + B(Star), R(18), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(18), U8(1), B(Jump), U8(12), - B(Star), R(17), + B(Star), R(15), B(LdaZero), - B(TestReferenceEqual), R(10), + B(TestReferenceEqual), R(8), B(JumpIfTrue), U8(5), - B(Ldar), R(17), + B(Ldar), R(15), B(ReThrow), - B(Ldar), R(12), + B(Ldar), R(10), B(SetPendingMessage), B(LdaZero), - B(TestReferenceEqual), R(10), + B(TestReferenceEqual), R(8), B(JumpIfFalse), U8(5), - B(Ldar), R(11), + B(Ldar), R(9), B(ReThrow), B(LdaUndefined), B(Star), R(6), @@ -141,7 +139,7 @@ bytecodes: [ B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionResolve), R(5), U8(3), /* 57 S> */ B(Return), B(Star), R(5), - B(CreateCatchContext), R(5), U8(10), + B(CreateCatchContext), R(5), U8(9), B(Star), R(4), B(LdaTheHole), B(SetPendingMessage), @@ -156,11 +154,10 @@ bytecodes: [ /* 57 S> */ B(Return), ] constant pool: [ - Smi [98], - Smi [229], + Smi [95], + Smi [224], ARRAY_BOILERPLATE_DESCRIPTION_TYPE, SYMBOL_TYPE, - SYMBOL_TYPE, ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], @@ -169,9 +166,9 @@ constant pool: [ SCOPE_INFO_TYPE, ] handlers: [ - [20, 297, 297], - [77, 157, 165], - [191, 260, 262], + [20, 292, 292], + [74, 154, 162], + [186, 255, 257], ] --- @@ -181,9 +178,9 @@ snippet: " } f(); " -frame size: 21 +frame size: 19 parameter count: 1 -bytecode array length: 346 +bytecode array length: 341 bytecodes: [ B(SwitchOnGeneratorState), R(0), U8(0), U8(2), B(Mov), R(closure), R(4), @@ -195,118 +192,116 @@ bytecodes: [ /* 43 S> */ B(CreateArrayLiteral), U8(2), U8(0), U8(37), B(Star), R(7), B(LdaNamedProperty), R(7), U8(3), U8(1), - B(JumpIfUndefined), U8(17), - B(JumpIfNull), U8(15), + B(JumpIfUndefinedOrNull), U8(15), B(Star), R(8), B(CallProperty0), R(8), R(7), U8(3), - B(JumpIfJSReceiver), U8(23), + B(JumpIfJSReceiver), U8(22), B(CallRuntime), U16(Runtime::kThrowSymbolAsyncIteratorInvalid), R(0), U8(0), - B(LdaNamedProperty), R(7), U8(4), U8(5), + B(GetIterator), R(7), U8(5), B(Star), R(8), B(CallProperty0), R(8), R(7), U8(7), B(Star), R(8), B(InvokeIntrinsic), U8(Runtime::k_CreateAsyncFromSyncIterator), R(8), U8(1), B(Star), R(6), - B(LdaNamedProperty), R(6), U8(5), U8(9), + B(LdaNamedProperty), R(6), U8(4), U8(9), B(Star), R(5), B(LdaFalse), - B(Star), R(9), - B(Mov), R(context), R(12), + B(Star), R(7), + B(Mov), R(context), R(10), B(LdaTrue), - B(Star), R(9), + B(Star), R(7), /* 38 S> */ B(CallProperty0), R(5), R(6), U8(11), - B(Star), R(15), - B(Mov), R(0), R(14), - B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionAwaitUncaught), R(14), U8(2), - B(SuspendGenerator), R(0), R(0), U8(14), U8(0), - B(ResumeGenerator), R(0), R(0), U8(14), - B(Star), R(14), + B(Star), R(13), + B(Mov), R(0), R(12), + B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionAwaitUncaught), R(12), U8(2), + B(SuspendGenerator), R(0), R(0), U8(12), U8(0), + B(ResumeGenerator), R(0), R(0), U8(12), + B(Star), R(12), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1), - B(Star), R(15), + B(Star), R(13), B(LdaZero), - B(TestReferenceEqual), R(15), + B(TestReferenceEqual), R(13), B(JumpIfTrue), U8(5), - B(Ldar), R(14), + B(Ldar), R(12), B(ReThrow), - B(Ldar), R(14), - B(Mov), R(14), R(13), + B(Ldar), R(12), + B(Mov), R(12), R(11), B(JumpIfJSReceiver), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(13), U8(1), - B(LdaNamedProperty), R(13), U8(6), U8(13), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(11), U8(1), + B(LdaNamedProperty), R(11), U8(5), U8(13), B(JumpIfToBooleanTrue), U8(27), - B(LdaNamedProperty), R(13), U8(7), U8(15), - B(Star), R(13), + B(LdaNamedProperty), R(11), U8(6), U8(15), + B(Star), R(11), B(LdaFalse), - B(Star), R(9), - B(Mov), R(13), R(1), + B(Star), R(7), + B(Mov), R(11), R(1), /* 23 E> */ B(StackCheck), /* 38 S> */ B(Mov), R(1), R(3), /* 56 S> */ B(LdaSmi), I8(1), - B(Mov), R(13), R(11), - B(Star), R(10), + B(Mov), R(11), R(9), + B(Star), R(8), B(Jump), U8(15), B(LdaSmi), I8(-1), - B(Star), R(11), - B(Star), R(10), + B(Star), R(9), + B(Star), R(8), B(Jump), U8(7), - B(Star), R(11), + B(Star), R(9), B(LdaZero), - B(Star), R(10), + B(Star), R(8), B(LdaTheHole), B(SetPendingMessage), - B(Star), R(12), - B(Ldar), R(9), - B(JumpIfToBooleanTrue), U8(96), - B(LdaNamedProperty), R(6), U8(8), U8(17), - B(Star), R(16), - B(JumpIfUndefined), U8(88), - B(JumpIfNull), U8(86), - B(Mov), R(context), R(17), + B(Star), R(10), + B(Ldar), R(7), + B(JumpIfToBooleanTrue), U8(94), + B(LdaNamedProperty), R(6), U8(7), U8(17), + B(Star), R(14), + B(JumpIfUndefinedOrNull), U8(86), + B(Mov), R(context), R(15), B(TestTypeOf), U8(6), B(JumpIfTrue), U8(18), B(Wide), B(LdaSmi), I16(159), - B(Star), R(18), - B(LdaConstant), U8(9), - B(Star), R(19), - B(CallRuntime), U16(Runtime::kNewTypeError), R(18), U8(2), + B(Star), R(16), + B(LdaConstant), U8(8), + B(Star), R(17), + B(CallRuntime), U16(Runtime::kNewTypeError), R(16), U8(2), B(Throw), - B(CallProperty0), R(16), R(6), U8(19), - B(Star), R(19), - B(Mov), R(0), R(18), - B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionAwaitUncaught), R(18), U8(2), - B(SuspendGenerator), R(0), R(0), U8(18), U8(1), - B(ResumeGenerator), R(0), R(0), U8(18), - B(Star), R(18), + B(CallProperty0), R(14), R(6), U8(19), + B(Star), R(17), + B(Mov), R(0), R(16), + B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionAwaitUncaught), R(16), U8(2), + B(SuspendGenerator), R(0), R(0), U8(16), U8(1), + B(ResumeGenerator), R(0), R(0), U8(16), + B(Star), R(16), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1), - B(Star), R(19), + B(Star), R(17), B(LdaZero), - B(TestReferenceEqual), R(19), + B(TestReferenceEqual), R(17), B(JumpIfTrue), U8(5), - B(Ldar), R(18), + B(Ldar), R(16), B(ReThrow), - B(Ldar), R(18), + B(Ldar), R(16), B(JumpIfJSReceiver), U8(21), - B(Star), R(20), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(20), U8(1), + B(Star), R(18), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(18), U8(1), B(Jump), U8(12), - B(Star), R(17), + B(Star), R(15), B(LdaZero), - B(TestReferenceEqual), R(10), + B(TestReferenceEqual), R(8), B(JumpIfTrue), U8(5), - B(Ldar), R(17), + B(Ldar), R(15), B(ReThrow), - B(Ldar), R(12), - B(SetPendingMessage), B(Ldar), R(10), - B(SwitchOnSmiNoFeedback), U8(10), U8(2), I8(0), + B(SetPendingMessage), + B(Ldar), R(8), + B(SwitchOnSmiNoFeedback), U8(9), U8(2), I8(0), B(Jump), U8(19), - B(Ldar), R(11), + B(Ldar), R(9), B(ReThrow), B(LdaTrue), - B(Star), R(18), - B(Mov), R(0), R(16), - B(Mov), R(11), R(17), - B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionResolve), R(16), U8(3), + B(Star), R(16), + B(Mov), R(0), R(14), + B(Mov), R(9), R(15), + B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionResolve), R(14), U8(3), /* 68 S> */ B(Return), B(LdaUndefined), B(Star), R(6), @@ -316,7 +311,7 @@ bytecodes: [ B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionResolve), R(5), U8(3), /* 68 S> */ B(Return), B(Star), R(5), - B(CreateCatchContext), R(5), U8(12), + B(CreateCatchContext), R(5), U8(11), B(Star), R(4), B(LdaTheHole), B(SetPendingMessage), @@ -331,11 +326,10 @@ bytecodes: [ /* 68 S> */ B(Return), ] constant pool: [ - Smi [98], - Smi [233], + Smi [95], + Smi [228], ARRAY_BOILERPLATE_DESCRIPTION_TYPE, SYMBOL_TYPE, - SYMBOL_TYPE, ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], @@ -346,9 +340,9 @@ constant pool: [ SCOPE_INFO_TYPE, ] handlers: [ - [20, 318, 318], - [77, 161, 169], - [195, 264, 266], + [20, 313, 313], + [74, 158, 166], + [190, 259, 261], ] --- @@ -361,9 +355,9 @@ snippet: " } f(); " -frame size: 21 +frame size: 19 parameter count: 1 -bytecode array length: 341 +bytecode array length: 336 bytecodes: [ B(SwitchOnGeneratorState), R(0), U8(0), U8(2), B(Mov), R(closure), R(4), @@ -375,50 +369,49 @@ bytecodes: [ /* 43 S> */ B(CreateArrayLiteral), U8(2), U8(0), U8(37), B(Star), R(7), B(LdaNamedProperty), R(7), U8(3), U8(1), - B(JumpIfUndefined), U8(17), - B(JumpIfNull), U8(15), + B(JumpIfUndefinedOrNull), U8(15), B(Star), R(8), B(CallProperty0), R(8), R(7), U8(3), - B(JumpIfJSReceiver), U8(23), + B(JumpIfJSReceiver), U8(22), B(CallRuntime), U16(Runtime::kThrowSymbolAsyncIteratorInvalid), R(0), U8(0), - B(LdaNamedProperty), R(7), U8(4), U8(5), + B(GetIterator), R(7), U8(5), B(Star), R(8), B(CallProperty0), R(8), R(7), U8(7), B(Star), R(8), B(InvokeIntrinsic), U8(Runtime::k_CreateAsyncFromSyncIterator), R(8), U8(1), B(Star), R(6), - B(LdaNamedProperty), R(6), U8(5), U8(9), + B(LdaNamedProperty), R(6), U8(4), U8(9), B(Star), R(5), B(LdaFalse), - B(Star), R(9), - B(Mov), R(context), R(12), + B(Star), R(7), + B(Mov), R(context), R(10), B(LdaTrue), - B(Star), R(9), + B(Star), R(7), /* 38 S> */ B(CallProperty0), R(5), R(6), U8(11), - B(Star), R(15), - B(Mov), R(0), R(14), - B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionAwaitUncaught), R(14), U8(2), - B(SuspendGenerator), R(0), R(0), U8(14), U8(0), - B(ResumeGenerator), R(0), R(0), U8(14), - B(Star), R(14), + B(Star), R(13), + B(Mov), R(0), R(12), + B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionAwaitUncaught), R(12), U8(2), + B(SuspendGenerator), R(0), R(0), U8(12), U8(0), + B(ResumeGenerator), R(0), R(0), U8(12), + B(Star), R(12), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1), - B(Star), R(15), + B(Star), R(13), B(LdaZero), - B(TestReferenceEqual), R(15), + B(TestReferenceEqual), R(13), B(JumpIfTrue), U8(5), - B(Ldar), R(14), + B(Ldar), R(12), B(ReThrow), - B(Ldar), R(14), - B(Mov), R(14), R(13), + B(Ldar), R(12), + B(Mov), R(12), R(11), B(JumpIfJSReceiver), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(13), U8(1), - B(LdaNamedProperty), R(13), U8(6), U8(13), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(11), U8(1), + B(LdaNamedProperty), R(11), U8(5), U8(13), B(JumpIfToBooleanTrue), U8(39), - B(LdaNamedProperty), R(13), U8(7), U8(15), - B(Star), R(13), + B(LdaNamedProperty), R(11), U8(6), U8(15), + B(Star), R(11), B(LdaFalse), - B(Star), R(9), - B(Mov), R(13), R(1), + B(Star), R(7), + B(Mov), R(11), R(1), /* 23 E> */ B(StackCheck), /* 38 S> */ B(Mov), R(1), R(3), /* 63 S> */ B(LdaSmi), I8(10), @@ -431,61 +424,60 @@ bytecodes: [ /* 103 S> */ B(Jump), U8(5), B(JumpLoop), U8(93), I8(0), B(LdaSmi), I8(-1), - B(Star), R(11), - B(Star), R(10), + B(Star), R(9), + B(Star), R(8), B(Jump), U8(7), - B(Star), R(11), + B(Star), R(9), B(LdaZero), - B(Star), R(10), + B(Star), R(8), B(LdaTheHole), B(SetPendingMessage), - B(Star), R(12), - B(Ldar), R(9), - B(JumpIfToBooleanTrue), U8(96), - B(LdaNamedProperty), R(6), U8(8), U8(19), - B(Star), R(16), - B(JumpIfUndefined), U8(88), - B(JumpIfNull), U8(86), - B(Mov), R(context), R(17), + B(Star), R(10), + B(Ldar), R(7), + B(JumpIfToBooleanTrue), U8(94), + B(LdaNamedProperty), R(6), U8(7), U8(19), + B(Star), R(14), + B(JumpIfUndefinedOrNull), U8(86), + B(Mov), R(context), R(15), B(TestTypeOf), U8(6), B(JumpIfTrue), U8(18), B(Wide), B(LdaSmi), I16(159), - B(Star), R(18), - B(LdaConstant), U8(9), - B(Star), R(19), - B(CallRuntime), U16(Runtime::kNewTypeError), R(18), U8(2), + B(Star), R(16), + B(LdaConstant), U8(8), + B(Star), R(17), + B(CallRuntime), U16(Runtime::kNewTypeError), R(16), U8(2), B(Throw), - B(CallProperty0), R(16), R(6), U8(21), - B(Star), R(19), - B(Mov), R(0), R(18), - B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionAwaitUncaught), R(18), U8(2), - B(SuspendGenerator), R(0), R(0), U8(18), U8(1), - B(ResumeGenerator), R(0), R(0), U8(18), - B(Star), R(18), + B(CallProperty0), R(14), R(6), U8(21), + B(Star), R(17), + B(Mov), R(0), R(16), + B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionAwaitUncaught), R(16), U8(2), + B(SuspendGenerator), R(0), R(0), U8(16), U8(1), + B(ResumeGenerator), R(0), R(0), U8(16), + B(Star), R(16), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1), - B(Star), R(19), + B(Star), R(17), B(LdaZero), - B(TestReferenceEqual), R(19), + B(TestReferenceEqual), R(17), B(JumpIfTrue), U8(5), - B(Ldar), R(18), + B(Ldar), R(16), B(ReThrow), - B(Ldar), R(18), + B(Ldar), R(16), B(JumpIfJSReceiver), U8(21), - B(Star), R(20), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(20), U8(1), + B(Star), R(18), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(18), U8(1), B(Jump), U8(12), - B(Star), R(17), + B(Star), R(15), B(LdaZero), - B(TestReferenceEqual), R(10), + B(TestReferenceEqual), R(8), B(JumpIfTrue), U8(5), - B(Ldar), R(17), + B(Ldar), R(15), B(ReThrow), - B(Ldar), R(12), + B(Ldar), R(10), B(SetPendingMessage), B(LdaZero), - B(TestReferenceEqual), R(10), + B(TestReferenceEqual), R(8), B(JumpIfFalse), U8(5), - B(Ldar), R(11), + B(Ldar), R(9), B(ReThrow), B(LdaUndefined), B(Star), R(6), @@ -495,7 +487,7 @@ bytecodes: [ B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionResolve), R(5), U8(3), /* 114 S> */ B(Return), B(Star), R(5), - B(CreateCatchContext), R(5), U8(10), + B(CreateCatchContext), R(5), U8(9), B(Star), R(4), B(LdaTheHole), B(SetPendingMessage), @@ -510,11 +502,10 @@ bytecodes: [ /* 114 S> */ B(Return), ] constant pool: [ - Smi [98], - Smi [245], + Smi [95], + Smi [240], ARRAY_BOILERPLATE_DESCRIPTION_TYPE, SYMBOL_TYPE, - SYMBOL_TYPE, ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], @@ -523,9 +514,9 @@ constant pool: [ SCOPE_INFO_TYPE, ] handlers: [ - [20, 313, 313], - [77, 173, 181], - [207, 276, 278], + [20, 308, 308], + [74, 170, 178], + [202, 271, 273], ] --- @@ -536,9 +527,9 @@ snippet: " } f(); " -frame size: 17 +frame size: 15 parameter count: 1 -bytecode array length: 261 +bytecode array length: 258 bytecodes: [ B(Mov), R(closure), R(2), B(Mov), R(this), R(3), @@ -550,86 +541,85 @@ bytecodes: [ B(Star), R(1), /* 68 S> */ B(CreateArrayLiteral), U8(1), U8(1), U8(37), B(Star), R(5), - B(LdaNamedProperty), R(5), U8(2), U8(2), + B(GetIterator), R(5), U8(2), B(Star), R(6), B(CallProperty0), R(6), R(5), U8(4), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), B(Star), R(4), - B(LdaNamedProperty), R(4), U8(3), U8(6), + B(LdaNamedProperty), R(4), U8(2), U8(6), B(Star), R(3), B(LdaFalse), - B(Star), R(7), - B(Mov), R(context), R(10), + B(Star), R(5), + B(Mov), R(context), R(8), B(LdaTrue), - B(Star), R(7), + B(Star), R(5), /* 59 S> */ B(CallProperty0), R(3), R(4), U8(8), - B(Star), R(11), + B(Star), R(9), B(JumpIfJSReceiver), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(11), U8(1), - B(LdaNamedProperty), R(11), U8(4), U8(10), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(9), U8(1), + B(LdaNamedProperty), R(9), U8(3), U8(10), B(JumpIfToBooleanTrue), U8(33), - B(LdaNamedProperty), R(11), U8(5), U8(12), - B(Star), R(11), + B(LdaNamedProperty), R(9), U8(4), U8(12), + B(Star), R(9), B(LdaFalse), - B(Star), R(7), - B(Ldar), R(11), - /* 58 E> */ B(StaNamedProperty), R(1), U8(6), U8(14), + B(Star), R(5), + B(Ldar), R(9), + /* 58 E> */ B(StaNamedProperty), R(1), U8(5), U8(14), /* 53 E> */ B(StackCheck), - /* 87 S> */ B(LdaNamedProperty), R(1), U8(6), U8(16), - B(Star), R(9), + /* 87 S> */ B(LdaNamedProperty), R(1), U8(5), U8(16), + B(Star), R(7), B(LdaSmi), I8(1), - B(Star), R(8), - B(Mov), R(1), R(12), + B(Star), R(6), + B(Mov), R(1), R(10), B(Jump), U8(15), B(LdaSmi), I8(-1), - B(Star), R(9), - B(Star), R(8), + B(Star), R(7), + B(Star), R(6), B(Jump), U8(7), - B(Star), R(9), + B(Star), R(7), B(LdaZero), - B(Star), R(8), + B(Star), R(6), B(LdaTheHole), B(SetPendingMessage), - B(Star), R(10), - B(Ldar), R(7), - B(JumpIfToBooleanTrue), U8(60), - B(LdaNamedProperty), R(4), U8(7), U8(18), - B(Star), R(13), - B(JumpIfUndefined), U8(52), - B(JumpIfNull), U8(50), - B(Mov), R(context), R(14), + B(Star), R(8), + B(Ldar), R(5), + B(JumpIfToBooleanTrue), U8(58), + B(LdaNamedProperty), R(4), U8(6), U8(18), + B(Star), R(11), + B(JumpIfUndefinedOrNull), U8(50), + B(Mov), R(context), R(12), B(TestTypeOf), U8(6), B(JumpIfTrue), U8(18), B(Wide), B(LdaSmi), I16(159), - B(Star), R(15), - B(LdaConstant), U8(8), - B(Star), R(16), - B(CallRuntime), U16(Runtime::kNewTypeError), R(15), U8(2), + B(Star), R(13), + B(LdaConstant), U8(7), + B(Star), R(14), + B(CallRuntime), U16(Runtime::kNewTypeError), R(13), U8(2), B(Throw), - B(CallProperty0), R(13), R(4), U8(20), + B(CallProperty0), R(11), R(4), U8(20), B(JumpIfJSReceiver), U8(21), - B(Star), R(15), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(15), U8(1), + B(Star), R(13), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(13), U8(1), B(Jump), U8(12), - B(Star), R(14), + B(Star), R(12), B(LdaZero), - B(TestReferenceEqual), R(8), + B(TestReferenceEqual), R(6), B(JumpIfTrue), U8(5), - B(Ldar), R(14), + B(Ldar), R(12), B(ReThrow), - B(Ldar), R(10), - B(SetPendingMessage), B(Ldar), R(8), - B(SwitchOnSmiNoFeedback), U8(9), U8(2), I8(0), + B(SetPendingMessage), + B(Ldar), R(6), + B(SwitchOnSmiNoFeedback), U8(8), U8(2), I8(0), B(Jump), U8(19), - B(Ldar), R(9), + B(Ldar), R(7), B(ReThrow), B(LdaFalse), - B(Star), R(15), - B(Mov), R(0), R(13), - B(Mov), R(9), R(14), - B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionResolve), R(13), U8(3), + B(Star), R(13), + B(Mov), R(0), R(11), + B(Mov), R(7), R(12), + B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionResolve), R(11), U8(3), /* 96 S> */ B(Return), B(LdaUndefined), B(Star), R(4), @@ -639,7 +629,7 @@ bytecodes: [ B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionResolve), R(3), U8(3), /* 96 S> */ B(Return), B(Star), R(3), - B(CreateCatchContext), R(3), U8(11), + B(CreateCatchContext), R(3), U8(10), B(Star), R(2), B(LdaTheHole), B(SetPendingMessage), @@ -656,7 +646,6 @@ bytecodes: [ constant pool: [ OBJECT_BOILERPLATE_DESCRIPTION_TYPE, ARRAY_BOILERPLATE_DESCRIPTION_TYPE, - SYMBOL_TYPE, ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], @@ -668,8 +657,8 @@ constant pool: [ SCOPE_INFO_TYPE, ] handlers: [ - [16, 233, 233], - [59, 112, 120], - [146, 179, 181], + [16, 230, 230], + [58, 111, 119], + [143, 176, 178], ] diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/ForIn.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/ForIn.golden index 8c24e461cd..fe1defeefb 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/ForIn.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/ForIn.golden @@ -63,13 +63,12 @@ snippet: " " frame size: 8 parameter count: 1 -bytecode array length: 46 +bytecode array length: 44 bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaConstant), U8(0), B(Star), R(0), - /* 68 S> */ B(JumpIfUndefined), U8(39), - B(JumpIfNull), U8(37), + /* 68 S> */ B(JumpIfUndefinedOrNull), U8(37), B(ToObject), R(3), B(ForInEnumerate), R(3), B(ForInPrepare), R(4), U8(0), @@ -102,14 +101,13 @@ snippet: " " frame size: 9 parameter count: 1 -bytecode array length: 58 +bytecode array length: 56 bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaZero), B(Star), R(0), /* 59 S> */ B(CreateArrayLiteral), U8(0), U8(1), U8(37), - B(JumpIfUndefined), U8(48), - B(JumpIfNull), U8(46), + B(JumpIfUndefinedOrNull), U8(46), B(ToObject), R(3), B(ForInEnumerate), R(3), B(ForInPrepare), R(4), U8(0), @@ -148,14 +146,13 @@ snippet: " " frame size: 7 parameter count: 1 -bytecode array length: 85 +bytecode array length: 83 bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(41), B(Star), R(0), /* 77 S> */ B(CreateArrayLiteral), U8(1), U8(2), U8(37), - B(JumpIfUndefined), U8(72), - B(JumpIfNull), U8(70), + B(JumpIfUndefinedOrNull), U8(70), B(ToObject), R(1), B(ForInEnumerate), R(1), B(ForInPrepare), R(2), U8(1), @@ -202,14 +199,13 @@ snippet: " " frame size: 9 parameter count: 1 -bytecode array length: 64 +bytecode array length: 62 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(2), U8(37), - B(JumpIfUndefined), U8(51), - B(JumpIfNull), U8(49), + B(JumpIfUndefinedOrNull), U8(49), B(ToObject), R(1), B(ForInEnumerate), R(1), B(ForInPrepare), R(2), U8(1), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOf.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOf.golden index 17e1d59343..1557e8d2a8 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOf.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOf.golden @@ -9,90 +9,88 @@ wrap: yes snippet: " for (var p of [0, 1, 2]) {} " -frame size: 15 +frame size: 13 parameter count: 1 -bytecode array length: 173 +bytecode array length: 170 bytecodes: [ /* 30 E> */ B(StackCheck), /* 48 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(37), B(Star), R(4), - B(LdaNamedProperty), R(4), U8(1), U8(1), + B(GetIterator), R(4), U8(1), B(Star), R(5), B(CallProperty0), R(5), R(4), U8(3), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), B(Star), R(3), - B(LdaNamedProperty), R(3), U8(2), U8(5), + B(LdaNamedProperty), R(3), U8(1), U8(5), B(Star), R(2), B(LdaFalse), - B(Star), R(6), - B(Mov), R(context), R(9), + B(Star), R(4), + B(Mov), R(context), R(7), B(LdaTrue), - B(Star), R(6), + B(Star), R(4), /* 43 S> */ B(CallProperty0), R(2), R(3), U8(7), - B(Star), R(10), + B(Star), R(8), B(JumpIfJSReceiver), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(10), U8(1), - B(LdaNamedProperty), R(10), U8(3), U8(9), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(8), U8(1), + B(LdaNamedProperty), R(8), U8(2), U8(9), B(JumpIfToBooleanTrue), U8(23), - B(LdaNamedProperty), R(10), U8(4), U8(11), - B(Star), R(10), + B(LdaNamedProperty), R(8), U8(3), U8(11), + B(Star), R(8), B(LdaFalse), - B(Star), R(6), - B(Mov), R(10), R(1), + B(Star), R(4), + B(Mov), R(8), R(1), /* 34 E> */ B(StackCheck), /* 43 S> */ B(Mov), R(1), R(0), - B(Ldar), R(10), + B(Ldar), R(8), B(JumpLoop), U8(40), I8(0), B(LdaSmi), I8(-1), - B(Star), R(8), - B(Star), R(7), + B(Star), R(6), + B(Star), R(5), B(Jump), U8(7), - B(Star), R(8), + B(Star), R(6), B(LdaZero), - B(Star), R(7), + B(Star), R(5), B(LdaTheHole), /* 43 E> */ B(SetPendingMessage), + B(Star), R(7), + B(Ldar), R(4), + B(JumpIfToBooleanTrue), U8(58), + B(LdaNamedProperty), R(3), U8(4), U8(13), B(Star), R(9), - B(Ldar), R(6), - B(JumpIfToBooleanTrue), U8(60), - B(LdaNamedProperty), R(3), U8(5), U8(13), - B(Star), R(11), - B(JumpIfUndefined), U8(52), - B(JumpIfNull), U8(50), - B(Mov), R(context), R(12), + B(JumpIfUndefinedOrNull), U8(50), + B(Mov), R(context), R(10), B(TestTypeOf), U8(6), B(JumpIfTrue), U8(18), B(Wide), B(LdaSmi), I16(159), - B(Star), R(13), - B(LdaConstant), U8(6), - B(Star), R(14), - B(CallRuntime), U16(Runtime::kNewTypeError), R(13), U8(2), + B(Star), R(11), + B(LdaConstant), U8(5), + B(Star), R(12), + B(CallRuntime), U16(Runtime::kNewTypeError), R(11), U8(2), B(Throw), - B(CallProperty0), R(11), R(3), U8(15), + B(CallProperty0), R(9), R(3), U8(15), B(JumpIfJSReceiver), U8(21), - B(Star), R(13), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(13), U8(1), + B(Star), R(11), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(11), U8(1), B(Jump), U8(12), - B(Star), R(12), + B(Star), R(10), B(LdaZero), - B(TestReferenceEqual), R(7), + B(TestReferenceEqual), R(5), B(JumpIfTrue), U8(5), - B(Ldar), R(12), + B(Ldar), R(10), B(ReThrow), - B(Ldar), R(9), + B(Ldar), R(7), B(SetPendingMessage), B(LdaZero), - B(TestReferenceEqual), R(7), + B(TestReferenceEqual), R(5), B(JumpIfFalse), U8(5), - B(Ldar), R(8), + B(Ldar), R(6), B(ReThrow), B(LdaUndefined), /* 62 S> */ B(Return), ] constant pool: [ ARRAY_BOILERPLATE_DESCRIPTION_TYPE, - SYMBOL_TYPE, ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], @@ -100,8 +98,8 @@ constant pool: [ ONE_BYTE_INTERNALIZED_STRING_TYPE [""], ] handlers: [ - [38, 81, 89], - [115, 148, 150], + [37, 80, 88], + [112, 145, 147], ] --- @@ -109,95 +107,92 @@ snippet: " var x = 'potatoes'; for (var p of x) { return p; } " -frame size: 16 +frame size: 14 parameter count: 1 -bytecode array length: 184 +bytecode array length: 178 bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaConstant), U8(0), B(Star), R(0), - /* 68 S> */ B(LdaNamedProperty), R(0), U8(1), U8(0), + /* 68 S> */ B(GetIterator), R(0), U8(0), B(Star), R(6), B(CallProperty0), R(6), R(0), U8(2), - B(Mov), R(0), R(5), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), B(Star), R(4), - B(LdaNamedProperty), R(4), U8(2), U8(4), + B(LdaNamedProperty), R(4), U8(1), U8(4), B(Star), R(3), B(LdaFalse), - B(Star), R(7), - B(Mov), R(context), R(10), + B(Star), R(5), + B(Mov), R(context), R(8), B(LdaTrue), - B(Star), R(7), + B(Star), R(5), /* 63 S> */ B(CallProperty0), R(3), R(4), U8(6), - B(Star), R(11), + B(Star), R(9), B(JumpIfJSReceiver), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(11), U8(1), - B(LdaNamedProperty), R(11), U8(3), U8(8), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(9), U8(1), + B(LdaNamedProperty), R(9), U8(2), U8(8), B(JumpIfToBooleanTrue), U8(27), - B(LdaNamedProperty), R(11), U8(4), U8(10), - B(Star), R(11), + B(LdaNamedProperty), R(9), U8(3), U8(10), + B(Star), R(9), B(LdaFalse), - B(Star), R(7), - B(Mov), R(11), R(2), + B(Star), R(5), + B(Mov), R(9), R(2), /* 54 E> */ B(StackCheck), /* 63 S> */ B(Mov), R(2), R(1), /* 73 S> */ B(LdaSmi), I8(1), - B(Mov), R(11), R(9), - B(Star), R(8), + B(Mov), R(9), R(7), + B(Star), R(6), B(Jump), U8(15), B(LdaSmi), I8(-1), - B(Star), R(9), - B(Star), R(8), + B(Star), R(7), + B(Star), R(6), B(Jump), U8(7), - B(Star), R(9), + B(Star), R(7), B(LdaZero), - B(Star), R(8), + B(Star), R(6), B(LdaTheHole), B(SetPendingMessage), + B(Star), R(8), + B(Ldar), R(5), + B(JumpIfToBooleanTrue), U8(58), + B(LdaNamedProperty), R(4), U8(4), U8(12), B(Star), R(10), - B(Ldar), R(7), - B(JumpIfToBooleanTrue), U8(60), - B(LdaNamedProperty), R(4), U8(5), U8(12), - B(Star), R(12), - B(JumpIfUndefined), U8(52), - B(JumpIfNull), U8(50), - B(Mov), R(context), R(13), + B(JumpIfUndefinedOrNull), U8(50), + B(Mov), R(context), R(11), B(TestTypeOf), U8(6), B(JumpIfTrue), U8(18), B(Wide), B(LdaSmi), I16(159), - B(Star), R(14), - B(LdaConstant), U8(6), - B(Star), R(15), - B(CallRuntime), U16(Runtime::kNewTypeError), R(14), U8(2), + B(Star), R(12), + B(LdaConstant), U8(5), + B(Star), R(13), + B(CallRuntime), U16(Runtime::kNewTypeError), R(12), U8(2), B(Throw), - B(CallProperty0), R(12), R(4), U8(14), + B(CallProperty0), R(10), R(4), U8(14), B(JumpIfJSReceiver), U8(21), - B(Star), R(14), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(14), U8(1), + B(Star), R(12), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(12), U8(1), B(Jump), U8(12), - B(Star), R(13), + B(Star), R(11), B(LdaZero), - B(TestReferenceEqual), R(8), + B(TestReferenceEqual), R(6), B(JumpIfTrue), U8(5), - B(Ldar), R(13), + B(Ldar), R(11), B(ReThrow), - B(Ldar), R(10), - B(SetPendingMessage), B(Ldar), R(8), - B(SwitchOnSmiNoFeedback), U8(7), U8(2), I8(0), + B(SetPendingMessage), + B(Ldar), R(6), + B(SwitchOnSmiNoFeedback), U8(6), U8(2), I8(0), B(Jump), U8(8), - B(Ldar), R(9), + B(Ldar), R(7), B(ReThrow), - B(Ldar), R(9), + B(Ldar), R(7), /* 85 S> */ B(Return), B(LdaUndefined), /* 85 S> */ B(Return), ] constant pool: [ ONE_BYTE_INTERNALIZED_STRING_TYPE ["potatoes"], - SYMBOL_TYPE, ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], @@ -207,8 +202,8 @@ constant pool: [ Smi [9], ] handlers: [ - [39, 86, 94], - [120, 153, 155], + [35, 82, 90], + [114, 147, 149], ] --- @@ -218,37 +213,37 @@ snippet: " if (x == 20) break; } " -frame size: 15 +frame size: 13 parameter count: 1 -bytecode array length: 189 +bytecode array length: 186 bytecodes: [ /* 30 E> */ B(StackCheck), /* 48 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(37), B(Star), R(4), - B(LdaNamedProperty), R(4), U8(1), U8(1), + B(GetIterator), R(4), U8(1), B(Star), R(5), B(CallProperty0), R(5), R(4), U8(3), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), B(Star), R(3), - B(LdaNamedProperty), R(3), U8(2), U8(5), + B(LdaNamedProperty), R(3), U8(1), U8(5), B(Star), R(2), B(LdaFalse), - B(Star), R(6), - B(Mov), R(context), R(9), + B(Star), R(4), + B(Mov), R(context), R(7), B(LdaTrue), - B(Star), R(6), + B(Star), R(4), /* 43 S> */ B(CallProperty0), R(2), R(3), U8(7), - B(Star), R(10), + B(Star), R(8), B(JumpIfJSReceiver), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(10), U8(1), - B(LdaNamedProperty), R(10), U8(3), U8(9), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(8), U8(1), + B(LdaNamedProperty), R(8), U8(2), U8(9), B(JumpIfToBooleanTrue), U8(39), - B(LdaNamedProperty), R(10), U8(4), U8(11), - B(Star), R(10), + B(LdaNamedProperty), R(8), U8(3), U8(11), + B(Star), R(8), B(LdaFalse), - B(Star), R(6), - B(Mov), R(10), R(1), + B(Star), R(4), + B(Mov), R(8), R(1), /* 34 E> */ B(StackCheck), /* 43 S> */ B(Mov), R(1), R(0), /* 66 S> */ B(LdaSmi), I8(10), @@ -261,54 +256,52 @@ bytecodes: [ /* 104 S> */ B(Jump), U8(5), B(JumpLoop), U8(56), I8(0), B(LdaSmi), I8(-1), - B(Star), R(8), - B(Star), R(7), + B(Star), R(6), + B(Star), R(5), B(Jump), U8(7), - B(Star), R(8), + B(Star), R(6), B(LdaZero), - B(Star), R(7), + B(Star), R(5), B(LdaTheHole), B(SetPendingMessage), + B(Star), R(7), + B(Ldar), R(4), + B(JumpIfToBooleanTrue), U8(58), + B(LdaNamedProperty), R(3), U8(4), U8(15), B(Star), R(9), - B(Ldar), R(6), - B(JumpIfToBooleanTrue), U8(60), - B(LdaNamedProperty), R(3), U8(5), U8(15), - B(Star), R(11), - B(JumpIfUndefined), U8(52), - B(JumpIfNull), U8(50), - B(Mov), R(context), R(12), + B(JumpIfUndefinedOrNull), U8(50), + B(Mov), R(context), R(10), B(TestTypeOf), U8(6), B(JumpIfTrue), U8(18), B(Wide), B(LdaSmi), I16(159), - B(Star), R(13), - B(LdaConstant), U8(6), - B(Star), R(14), - B(CallRuntime), U16(Runtime::kNewTypeError), R(13), U8(2), + B(Star), R(11), + B(LdaConstant), U8(5), + B(Star), R(12), + B(CallRuntime), U16(Runtime::kNewTypeError), R(11), U8(2), B(Throw), - B(CallProperty0), R(11), R(3), U8(17), + B(CallProperty0), R(9), R(3), U8(17), B(JumpIfJSReceiver), U8(21), - B(Star), R(13), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(13), U8(1), + B(Star), R(11), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(11), U8(1), B(Jump), U8(12), - B(Star), R(12), + B(Star), R(10), B(LdaZero), - B(TestReferenceEqual), R(7), + B(TestReferenceEqual), R(5), B(JumpIfTrue), U8(5), - B(Ldar), R(12), + B(Ldar), R(10), B(ReThrow), - B(Ldar), R(9), + B(Ldar), R(7), B(SetPendingMessage), B(LdaZero), - B(TestReferenceEqual), R(7), + B(TestReferenceEqual), R(5), B(JumpIfFalse), U8(5), - B(Ldar), R(8), + B(Ldar), R(6), B(ReThrow), B(LdaUndefined), /* 113 S> */ B(Return), ] constant pool: [ ARRAY_BOILERPLATE_DESCRIPTION_TYPE, - SYMBOL_TYPE, ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], @@ -316,8 +309,8 @@ constant pool: [ ONE_BYTE_INTERNALIZED_STRING_TYPE [""], ] handlers: [ - [38, 97, 105], - [131, 164, 166], + [37, 96, 104], + [128, 161, 163], ] --- @@ -325,91 +318,90 @@ snippet: " var x = { 'a': 1, 'b': 2 }; for (x['a'] of [1,2,3]) { return x['a']; } " -frame size: 15 +frame size: 13 parameter count: 1 -bytecode array length: 195 +bytecode array length: 192 bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(41), B(Star), R(0), /* 77 S> */ B(CreateArrayLiteral), U8(1), U8(1), U8(37), B(Star), R(3), - B(LdaNamedProperty), R(3), U8(2), U8(2), + B(GetIterator), R(3), U8(2), B(Star), R(4), B(CallProperty0), R(4), R(3), U8(4), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), B(Star), R(2), - B(LdaNamedProperty), R(2), U8(3), U8(6), + B(LdaNamedProperty), R(2), U8(2), U8(6), B(Star), R(1), B(LdaFalse), - B(Star), R(5), - B(Mov), R(context), R(8), + B(Star), R(3), + B(Mov), R(context), R(6), B(LdaTrue), - B(Star), R(5), + B(Star), R(3), /* 68 S> */ B(CallProperty0), R(1), R(2), U8(8), - B(Star), R(9), + B(Star), R(7), B(JumpIfJSReceiver), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(9), U8(1), - B(LdaNamedProperty), R(9), U8(4), U8(10), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(7), U8(1), + B(LdaNamedProperty), R(7), U8(3), U8(10), B(JumpIfToBooleanTrue), U8(33), - B(LdaNamedProperty), R(9), U8(5), U8(12), - B(Star), R(9), + B(LdaNamedProperty), R(7), U8(4), U8(12), + B(Star), R(7), B(LdaFalse), - B(Star), R(5), - B(Ldar), R(9), - /* 67 E> */ B(StaNamedProperty), R(0), U8(6), U8(14), + B(Star), R(3), + B(Ldar), R(7), + /* 67 E> */ B(StaNamedProperty), R(0), U8(5), U8(14), /* 62 E> */ B(StackCheck), - /* 96 S> */ B(LdaNamedProperty), R(0), U8(6), U8(16), - B(Star), R(7), + /* 96 S> */ B(LdaNamedProperty), R(0), U8(5), U8(16), + B(Star), R(5), B(LdaSmi), I8(1), - B(Star), R(6), - B(Mov), R(0), R(10), + B(Star), R(4), + B(Mov), R(0), R(8), B(Jump), U8(15), B(LdaSmi), I8(-1), - B(Star), R(7), - B(Star), R(6), + B(Star), R(5), + B(Star), R(4), B(Jump), U8(7), - B(Star), R(7), + B(Star), R(5), B(LdaZero), - B(Star), R(6), + B(Star), R(4), B(LdaTheHole), B(SetPendingMessage), - B(Star), R(8), - B(Ldar), R(5), - B(JumpIfToBooleanTrue), U8(60), - B(LdaNamedProperty), R(2), U8(7), U8(18), - B(Star), R(11), - B(JumpIfUndefined), U8(52), - B(JumpIfNull), U8(50), - B(Mov), R(context), R(12), + B(Star), R(6), + B(Ldar), R(3), + B(JumpIfToBooleanTrue), U8(58), + B(LdaNamedProperty), R(2), U8(6), U8(18), + B(Star), R(9), + B(JumpIfUndefinedOrNull), U8(50), + B(Mov), R(context), R(10), B(TestTypeOf), U8(6), B(JumpIfTrue), U8(18), B(Wide), B(LdaSmi), I16(159), - B(Star), R(13), - B(LdaConstant), U8(8), - B(Star), R(14), - B(CallRuntime), U16(Runtime::kNewTypeError), R(13), U8(2), + B(Star), R(11), + B(LdaConstant), U8(7), + B(Star), R(12), + B(CallRuntime), U16(Runtime::kNewTypeError), R(11), U8(2), B(Throw), - B(CallProperty0), R(11), R(2), U8(20), + B(CallProperty0), R(9), R(2), U8(20), B(JumpIfJSReceiver), U8(21), - B(Star), R(13), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(13), U8(1), + B(Star), R(11), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(11), U8(1), B(Jump), U8(12), - B(Star), R(12), + B(Star), R(10), B(LdaZero), - B(TestReferenceEqual), R(6), + B(TestReferenceEqual), R(4), B(JumpIfTrue), U8(5), - B(Ldar), R(12), + B(Ldar), R(10), B(ReThrow), - B(Ldar), R(8), - B(SetPendingMessage), B(Ldar), R(6), - B(SwitchOnSmiNoFeedback), U8(9), U8(2), I8(0), + B(SetPendingMessage), + B(Ldar), R(4), + B(SwitchOnSmiNoFeedback), U8(8), U8(2), I8(0), B(Jump), U8(8), - B(Ldar), R(7), + B(Ldar), R(5), B(ReThrow), - B(Ldar), R(7), + B(Ldar), R(5), /* 105 S> */ B(Return), B(LdaUndefined), /* 105 S> */ B(Return), @@ -417,7 +409,6 @@ bytecodes: [ constant pool: [ OBJECT_BOILERPLATE_DESCRIPTION_TYPE, ARRAY_BOILERPLATE_DESCRIPTION_TYPE, - SYMBOL_TYPE, ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], @@ -428,7 +419,7 @@ constant pool: [ Smi [9], ] handlers: [ - [44, 97, 105], - [131, 164, 166], + [43, 96, 104], + [128, 161, 163], ] diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOfLoop.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOfLoop.golden index 1b10e1bf6e..f50891172e 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOfLoop.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOfLoop.golden @@ -13,89 +13,86 @@ snippet: " } f([1, 2, 3]); " -frame size: 17 +frame size: 15 parameter count: 2 -bytecode array length: 173 +bytecode array length: 167 bytecodes: [ /* 10 E> */ B(StackCheck), - /* 34 S> */ B(LdaNamedProperty), R(arg0), U8(0), U8(0), + /* 34 S> */ B(GetIterator), R(arg0), U8(0), B(Star), R(7), B(CallProperty0), R(7), R(arg0), U8(2), - B(Mov), R(arg0), R(6), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), B(Star), R(5), - B(LdaNamedProperty), R(5), U8(1), U8(4), + B(LdaNamedProperty), R(5), U8(0), U8(4), B(Star), R(4), B(LdaFalse), - B(Star), R(8), - B(Mov), R(context), R(11), + B(Star), R(6), + B(Mov), R(context), R(9), B(LdaTrue), - B(Star), R(8), + B(Star), R(6), /* 29 S> */ B(CallProperty0), R(4), R(5), U8(6), - B(Star), R(12), + B(Star), R(10), B(JumpIfJSReceiver), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(12), U8(1), - B(LdaNamedProperty), R(12), U8(2), U8(8), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(10), U8(1), + B(LdaNamedProperty), R(10), U8(1), U8(8), B(JumpIfToBooleanTrue), U8(26), - B(LdaNamedProperty), R(12), U8(3), U8(10), - B(Star), R(12), + B(LdaNamedProperty), R(10), U8(2), U8(10), + B(Star), R(10), B(LdaFalse), - B(Star), R(8), - B(Mov), R(12), R(0), + B(Star), R(6), + B(Mov), R(10), R(0), /* 20 E> */ B(StackCheck), /* 29 S> */ B(Mov), R(0), R(2), /* 49 S> */ B(Mov), R(2), R(3), - B(Ldar), R(12), + B(Ldar), R(10), B(JumpLoop), U8(43), I8(0), B(LdaSmi), I8(-1), - B(Star), R(10), - B(Star), R(9), + B(Star), R(8), + B(Star), R(7), B(Jump), U8(7), - B(Star), R(10), + B(Star), R(8), B(LdaZero), - B(Star), R(9), + B(Star), R(7), B(LdaTheHole), /* 49 E> */ B(SetPendingMessage), + B(Star), R(9), + B(Ldar), R(6), + B(JumpIfToBooleanTrue), U8(58), + B(LdaNamedProperty), R(5), U8(3), U8(12), B(Star), R(11), - B(Ldar), R(8), - B(JumpIfToBooleanTrue), U8(60), - B(LdaNamedProperty), R(5), U8(4), U8(12), - B(Star), R(13), - B(JumpIfUndefined), U8(52), - B(JumpIfNull), U8(50), - B(Mov), R(context), R(14), + B(JumpIfUndefinedOrNull), U8(50), + B(Mov), R(context), R(12), B(TestTypeOf), U8(6), B(JumpIfTrue), U8(18), B(Wide), B(LdaSmi), I16(159), - B(Star), R(15), - B(LdaConstant), U8(5), - B(Star), R(16), - B(CallRuntime), U16(Runtime::kNewTypeError), R(15), U8(2), + B(Star), R(13), + B(LdaConstant), U8(4), + B(Star), R(14), + B(CallRuntime), U16(Runtime::kNewTypeError), R(13), U8(2), B(Throw), - B(CallProperty0), R(13), R(5), U8(14), + B(CallProperty0), R(11), R(5), U8(14), B(JumpIfJSReceiver), U8(21), - B(Star), R(15), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(15), U8(1), + B(Star), R(13), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(13), U8(1), B(Jump), U8(12), - B(Star), R(14), + B(Star), R(12), B(LdaZero), - B(TestReferenceEqual), R(9), + B(TestReferenceEqual), R(7), B(JumpIfTrue), U8(5), - B(Ldar), R(14), + B(Ldar), R(12), B(ReThrow), - B(Ldar), R(11), + B(Ldar), R(9), B(SetPendingMessage), B(LdaZero), - B(TestReferenceEqual), R(9), + B(TestReferenceEqual), R(7), B(JumpIfFalse), U8(5), - B(Ldar), R(10), + B(Ldar), R(8), B(ReThrow), B(LdaUndefined), /* 54 S> */ B(Return), ] constant pool: [ - SYMBOL_TYPE, ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], @@ -103,8 +100,8 @@ constant pool: [ ONE_BYTE_INTERNALIZED_STRING_TYPE [""], ] handlers: [ - [35, 81, 89], - [115, 148, 150], + [31, 77, 85], + [109, 142, 144], ] --- @@ -114,9 +111,9 @@ snippet: " } f([1, 2, 3]); " -frame size: 22 +frame size: 20 parameter count: 2 -bytecode array length: 254 +bytecode array length: 251 bytecodes: [ B(CreateFunctionContext), U8(0), U8(4), B(PushContext), R(2), @@ -135,98 +132,97 @@ bytecodes: [ B(StaCurrentContextSlot), U8(4), /* 34 S> */ B(LdaContextSlot), R(3), U8(4), U8(0), B(Star), R(6), - B(LdaNamedProperty), R(6), U8(2), U8(0), + B(GetIterator), R(6), U8(0), B(Star), R(7), B(CallProperty0), R(7), R(6), U8(2), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), B(Star), R(5), - B(LdaNamedProperty), R(5), U8(3), U8(4), + B(LdaNamedProperty), R(5), U8(2), U8(4), B(Star), R(4), B(LdaFalse), - B(Star), R(8), - B(Mov), R(context), R(11), + B(Star), R(6), + B(Mov), R(context), R(9), B(LdaTrue), - B(Star), R(8), + B(Star), R(6), /* 29 S> */ B(CallProperty0), R(4), R(5), U8(6), - B(Star), R(12), + B(Star), R(10), B(JumpIfJSReceiver), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(12), U8(1), - B(LdaNamedProperty), R(12), U8(4), U8(8), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(10), U8(1), + B(LdaNamedProperty), R(10), U8(3), U8(8), B(JumpIfToBooleanTrue), U8(75), - B(LdaNamedProperty), R(12), U8(5), U8(10), - B(Star), R(12), + B(LdaNamedProperty), R(10), U8(4), U8(10), + B(Star), R(10), B(LdaFalse), - B(Star), R(8), - B(Mov), R(12), R(0), + B(Star), R(6), + B(Mov), R(10), R(0), /* 20 E> */ B(StackCheck), - B(CreateBlockContext), U8(6), - B(PushContext), R(13), + B(CreateBlockContext), U8(5), + B(PushContext), R(11), B(LdaTheHole), B(StaCurrentContextSlot), U8(4), /* 29 S> */ B(Ldar), R(0), /* 29 E> */ B(StaCurrentContextSlot), U8(4), - /* 41 S> */ B(LdaLookupGlobalSlot), U8(7), U8(12), U8(3), - B(Star), R(14), - B(LdaConstant), U8(8), - B(Star), R(15), + /* 41 S> */ B(LdaLookupGlobalSlot), U8(6), U8(12), U8(3), + B(Star), R(12), + B(LdaConstant), U8(7), + B(Star), R(13), B(LdaZero), - B(Star), R(19), + B(Star), R(17), B(LdaSmi), I8(37), - B(Star), R(20), + B(Star), R(18), B(LdaSmi), I8(41), - B(Star), R(21), - B(Mov), R(14), R(16), - B(Mov), R(15), R(17), - B(Mov), R(closure), R(18), - B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(16), U8(6), - B(Star), R(14), - /* 41 E> */ B(CallUndefinedReceiver1), R(14), R(15), U8(14), - B(PopContext), R(13), - B(Mov), R(0), R(12), + B(Star), R(19), + B(Mov), R(12), R(14), + B(Mov), R(13), R(15), + B(Mov), R(closure), R(16), + B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(14), U8(6), + B(Star), R(12), + /* 41 E> */ B(CallUndefinedReceiver1), R(12), R(13), U8(14), + B(PopContext), R(11), + B(Mov), R(0), R(10), B(JumpLoop), U8(92), I8(0), B(LdaSmi), I8(-1), - B(Star), R(10), - B(Star), R(9), + B(Star), R(8), + B(Star), R(7), B(Jump), U8(7), - B(Star), R(10), + B(Star), R(8), B(LdaZero), - B(Star), R(9), + B(Star), R(7), B(LdaTheHole), B(SetPendingMessage), - B(Star), R(11), - B(Ldar), R(8), - B(JumpIfToBooleanTrue), U8(60), - B(LdaNamedProperty), R(5), U8(9), U8(16), - B(Star), R(14), - B(JumpIfUndefined), U8(52), - B(JumpIfNull), U8(50), - B(Mov), R(context), R(15), + B(Star), R(9), + B(Ldar), R(6), + B(JumpIfToBooleanTrue), U8(58), + B(LdaNamedProperty), R(5), U8(8), U8(16), + B(Star), R(12), + B(JumpIfUndefinedOrNull), U8(50), + B(Mov), R(context), R(13), B(TestTypeOf), U8(6), B(JumpIfTrue), U8(18), B(Wide), B(LdaSmi), I16(159), - B(Star), R(16), - B(LdaConstant), U8(10), - B(Star), R(17), - B(CallRuntime), U16(Runtime::kNewTypeError), R(16), U8(2), + B(Star), R(14), + B(LdaConstant), U8(9), + B(Star), R(15), + B(CallRuntime), U16(Runtime::kNewTypeError), R(14), U8(2), B(Throw), - B(CallProperty0), R(14), R(5), U8(18), + B(CallProperty0), R(12), R(5), U8(18), B(JumpIfJSReceiver), U8(21), - B(Star), R(16), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(16), U8(1), + B(Star), R(14), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(14), U8(1), B(Jump), U8(12), - B(Star), R(15), + B(Star), R(13), B(LdaZero), - B(TestReferenceEqual), R(9), + B(TestReferenceEqual), R(7), B(JumpIfTrue), U8(5), - B(Ldar), R(15), + B(Ldar), R(13), B(ReThrow), - B(Ldar), R(11), + B(Ldar), R(9), B(SetPendingMessage), B(LdaZero), - B(TestReferenceEqual), R(9), + B(TestReferenceEqual), R(7), B(JumpIfFalse), U8(5), - B(Ldar), R(10), + B(Ldar), R(8), B(ReThrow), B(PopContext), R(3), B(LdaUndefined), @@ -235,7 +231,6 @@ bytecodes: [ constant pool: [ SCOPE_INFO_TYPE, SCOPE_INFO_TYPE, - SYMBOL_TYPE, ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], @@ -246,8 +241,8 @@ constant pool: [ ONE_BYTE_INTERNALIZED_STRING_TYPE [""], ] handlers: [ - [65, 160, 168], - [194, 227, 229], + [64, 159, 167], + [191, 224, 226], ] --- @@ -257,97 +252,94 @@ snippet: " } f([1, 2, 3]); " -frame size: 16 +frame size: 14 parameter count: 2 -bytecode array length: 190 +bytecode array length: 184 bytecodes: [ /* 10 E> */ B(StackCheck), - /* 34 S> */ B(LdaNamedProperty), R(arg0), U8(0), U8(0), + /* 34 S> */ B(GetIterator), R(arg0), U8(0), B(Star), R(5), B(CallProperty0), R(5), R(arg0), U8(2), - B(Mov), R(arg0), R(4), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), B(Star), R(3), - B(LdaNamedProperty), R(3), U8(1), U8(4), + B(LdaNamedProperty), R(3), U8(0), U8(4), B(Star), R(2), B(LdaFalse), - B(Star), R(6), - B(Mov), R(context), R(9), + B(Star), R(4), + B(Mov), R(context), R(7), B(LdaTrue), - B(Star), R(6), + B(Star), R(4), /* 29 S> */ B(CallProperty0), R(2), R(3), U8(6), - B(Star), R(10), + B(Star), R(8), B(JumpIfJSReceiver), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(10), U8(1), - B(LdaNamedProperty), R(10), U8(2), U8(8), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(8), U8(1), + B(LdaNamedProperty), R(8), U8(1), U8(8), B(JumpIfToBooleanTrue), U8(43), - B(LdaNamedProperty), R(10), U8(3), U8(10), - B(Star), R(10), + B(LdaNamedProperty), R(8), U8(2), U8(10), + B(Star), R(8), B(LdaFalse), - B(Star), R(6), - B(Mov), R(10), R(0), + B(Star), R(4), + B(Mov), R(8), R(0), /* 20 E> */ B(StackCheck), - B(CreateBlockContext), U8(4), - B(PushContext), R(11), + B(CreateBlockContext), U8(3), + B(PushContext), R(9), B(LdaTheHole), B(StaCurrentContextSlot), U8(4), /* 29 S> */ B(Ldar), R(0), /* 29 E> */ B(StaCurrentContextSlot), U8(4), - /* 41 S> */ B(CreateClosure), U8(5), U8(0), U8(2), - B(Star), R(12), - /* 67 E> */ B(CallUndefinedReceiver0), R(12), U8(12), - B(PopContext), R(11), - B(Mov), R(0), R(10), + /* 41 S> */ B(CreateClosure), U8(4), U8(0), U8(2), + B(Star), R(10), + /* 67 E> */ B(CallUndefinedReceiver0), R(10), U8(12), + B(PopContext), R(9), + B(Mov), R(0), R(8), B(JumpLoop), U8(60), I8(0), B(LdaSmi), I8(-1), - B(Star), R(8), - B(Star), R(7), + B(Star), R(6), + B(Star), R(5), B(Jump), U8(7), - B(Star), R(8), + B(Star), R(6), B(LdaZero), - B(Star), R(7), + B(Star), R(5), B(LdaTheHole), B(SetPendingMessage), - B(Star), R(9), - B(Ldar), R(6), - B(JumpIfToBooleanTrue), U8(60), - B(LdaNamedProperty), R(3), U8(6), U8(14), - B(Star), R(12), - B(JumpIfUndefined), U8(52), - B(JumpIfNull), U8(50), - B(Mov), R(context), R(13), + B(Star), R(7), + B(Ldar), R(4), + B(JumpIfToBooleanTrue), U8(58), + B(LdaNamedProperty), R(3), U8(5), U8(14), + B(Star), R(10), + B(JumpIfUndefinedOrNull), U8(50), + B(Mov), R(context), R(11), B(TestTypeOf), U8(6), B(JumpIfTrue), U8(18), B(Wide), B(LdaSmi), I16(159), - B(Star), R(14), - B(LdaConstant), U8(7), - B(Star), R(15), - B(CallRuntime), U16(Runtime::kNewTypeError), R(14), U8(2), + B(Star), R(12), + B(LdaConstant), U8(6), + B(Star), R(13), + B(CallRuntime), U16(Runtime::kNewTypeError), R(12), U8(2), B(Throw), - B(CallProperty0), R(12), R(3), U8(16), + B(CallProperty0), R(10), R(3), U8(16), B(JumpIfJSReceiver), U8(21), - B(Star), R(14), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(14), U8(1), + B(Star), R(12), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(12), U8(1), B(Jump), U8(12), - B(Star), R(13), + B(Star), R(11), B(LdaZero), - B(TestReferenceEqual), R(7), + B(TestReferenceEqual), R(5), B(JumpIfTrue), U8(5), - B(Ldar), R(13), + B(Ldar), R(11), B(ReThrow), - B(Ldar), R(9), + B(Ldar), R(7), B(SetPendingMessage), B(LdaZero), - B(TestReferenceEqual), R(7), + B(TestReferenceEqual), R(5), B(JumpIfFalse), U8(5), - B(Ldar), R(8), + B(Ldar), R(6), B(ReThrow), B(LdaUndefined), /* 73 S> */ B(Return), ] constant pool: [ - SYMBOL_TYPE, ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], @@ -357,8 +349,8 @@ constant pool: [ ONE_BYTE_INTERNALIZED_STRING_TYPE [""], ] handlers: [ - [35, 98, 106], - [132, 165, 167], + [31, 94, 102], + [126, 159, 161], ] --- @@ -368,98 +360,90 @@ snippet: " } f([{ x: 0, y: 3 }, { x: 1, y: 9 }, { x: -12, y: 17 }]); " -frame size: 19 +frame size: 17 parameter count: 2 -bytecode array length: 197 +bytecode array length: 178 bytecodes: [ /* 10 E> */ B(StackCheck), - /* 41 S> */ B(LdaNamedProperty), R(arg0), U8(0), U8(0), + /* 41 S> */ B(GetIterator), R(arg0), U8(0), B(Star), R(9), B(CallProperty0), R(9), R(arg0), U8(2), - B(Mov), R(arg0), R(8), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), B(Star), R(7), - B(LdaNamedProperty), R(7), U8(1), U8(4), + B(LdaNamedProperty), R(7), U8(0), U8(4), B(Star), R(6), B(LdaFalse), - B(Star), R(10), - B(Mov), R(context), R(13), + B(Star), R(8), + B(Mov), R(context), R(11), B(LdaTrue), - B(Star), R(10), + B(Star), R(8), /* 36 S> */ B(CallProperty0), R(6), R(7), U8(6), - B(Star), R(14), + B(Star), R(12), B(JumpIfJSReceiver), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(14), U8(1), - B(LdaNamedProperty), R(14), U8(2), U8(8), - B(JumpIfToBooleanTrue), U8(50), - B(LdaNamedProperty), R(14), U8(3), U8(10), - B(Star), R(14), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(12), U8(1), + B(LdaNamedProperty), R(12), U8(1), U8(8), + B(JumpIfToBooleanTrue), U8(37), + B(LdaNamedProperty), R(12), U8(2), U8(10), + B(Star), R(12), B(LdaFalse), - B(Star), R(10), - B(Mov), R(14), R(0), + B(Star), R(8), + B(Mov), R(12), R(0), /* 20 E> */ B(StackCheck), - /* 36 S> */ B(Ldar), R(14), - B(JumpIfNull), U8(4), - B(JumpIfNotUndefined), U8(7), - /* 29 E> */ B(CallRuntime), U16(Runtime::kThrowPatternAssignmentNonCoercible), R(0), U8(0), - B(Star), R(15), - /* 31 S> */ B(LdaNamedProperty), R(15), U8(4), U8(12), + /* 31 S> */ B(LdaNamedProperty), R(0), U8(3), U8(12), B(Star), R(3), - /* 34 S> */ B(LdaNamedProperty), R(15), U8(5), U8(14), + /* 34 S> */ B(LdaNamedProperty), R(0), U8(4), U8(14), B(Star), R(4), /* 56 S> */ B(Ldar), R(4), /* 58 E> */ B(Add), R(3), U8(16), B(Star), R(5), - B(JumpLoop), U8(67), I8(0), + B(JumpLoop), U8(54), I8(0), B(LdaSmi), I8(-1), - B(Star), R(12), - B(Star), R(11), + B(Star), R(10), + B(Star), R(9), B(Jump), U8(7), - B(Star), R(12), + B(Star), R(10), B(LdaZero), - B(Star), R(11), + B(Star), R(9), B(LdaTheHole), /* 56 E> */ B(SetPendingMessage), + B(Star), R(11), + B(Ldar), R(8), + B(JumpIfToBooleanTrue), U8(58), + B(LdaNamedProperty), R(7), U8(5), U8(17), B(Star), R(13), - B(Ldar), R(10), - B(JumpIfToBooleanTrue), U8(60), - B(LdaNamedProperty), R(7), U8(6), U8(17), - B(Star), R(15), - B(JumpIfUndefined), U8(52), - B(JumpIfNull), U8(50), - B(Mov), R(context), R(16), + B(JumpIfUndefinedOrNull), U8(50), + B(Mov), R(context), R(14), B(TestTypeOf), U8(6), B(JumpIfTrue), U8(18), B(Wide), B(LdaSmi), I16(159), - B(Star), R(17), - B(LdaConstant), U8(7), - B(Star), R(18), - B(CallRuntime), U16(Runtime::kNewTypeError), R(17), U8(2), + B(Star), R(15), + B(LdaConstant), U8(6), + B(Star), R(16), + B(CallRuntime), U16(Runtime::kNewTypeError), R(15), U8(2), B(Throw), - B(CallProperty0), R(15), R(7), U8(19), + B(CallProperty0), R(13), R(7), U8(19), B(JumpIfJSReceiver), U8(21), - B(Star), R(17), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(17), U8(1), + B(Star), R(15), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(15), U8(1), B(Jump), U8(12), - B(Star), R(16), + B(Star), R(14), B(LdaZero), - B(TestReferenceEqual), R(11), + B(TestReferenceEqual), R(9), B(JumpIfTrue), U8(5), - B(Ldar), R(16), + B(Ldar), R(14), B(ReThrow), - B(Ldar), R(13), + B(Ldar), R(11), B(SetPendingMessage), B(LdaZero), - B(TestReferenceEqual), R(11), + B(TestReferenceEqual), R(9), B(JumpIfFalse), U8(5), - B(Ldar), R(12), + B(Ldar), R(10), B(ReThrow), B(LdaUndefined), /* 65 S> */ B(Return), ] constant pool: [ - SYMBOL_TYPE, ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], @@ -469,8 +453,8 @@ constant pool: [ ONE_BYTE_INTERNALIZED_STRING_TYPE [""], ] handlers: [ - [35, 105, 113], - [139, 172, 174], + [31, 88, 96], + [120, 153, 155], ] --- @@ -480,9 +464,9 @@ snippet: " } f([1, 2, 3]); " -frame size: 18 +frame size: 16 parameter count: 2 -bytecode array length: 214 +bytecode array length: 208 bytecodes: [ B(SwitchOnGeneratorState), R(0), U8(0), U8(1), B(Mov), R(closure), R(5), @@ -499,78 +483,76 @@ bytecodes: [ /* 11 E> */ B(Throw), B(Ldar), R(5), /* 55 S> */ B(Return), - /* 35 S> */ B(LdaNamedProperty), R(arg0), U8(3), U8(0), + /* 35 S> */ B(GetIterator), R(arg0), U8(0), B(Star), R(8), B(CallProperty0), R(8), R(arg0), U8(2), - B(Mov), R(arg0), R(7), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), B(Star), R(6), - B(LdaNamedProperty), R(6), U8(4), U8(4), + B(LdaNamedProperty), R(6), U8(3), U8(4), B(Star), R(5), B(LdaFalse), - B(Star), R(9), - B(Mov), R(context), R(12), + B(Star), R(7), + B(Mov), R(context), R(10), B(LdaTrue), - B(Star), R(9), + B(Star), R(7), /* 30 S> */ B(CallProperty0), R(5), R(6), U8(6), - B(Star), R(13), + B(Star), R(11), B(JumpIfJSReceiver), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(13), U8(1), - B(LdaNamedProperty), R(13), U8(5), U8(8), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(11), U8(1), + B(LdaNamedProperty), R(11), U8(4), U8(8), B(JumpIfToBooleanTrue), U8(26), - B(LdaNamedProperty), R(13), U8(6), U8(10), - B(Star), R(13), + B(LdaNamedProperty), R(11), U8(5), U8(10), + B(Star), R(11), B(LdaFalse), - B(Star), R(9), - B(Mov), R(13), R(1), + B(Star), R(7), + B(Mov), R(11), R(1), /* 21 E> */ B(StackCheck), /* 30 S> */ B(Mov), R(1), R(3), /* 50 S> */ B(Mov), R(3), R(4), - B(Ldar), R(13), + B(Ldar), R(11), B(JumpLoop), U8(43), I8(0), B(LdaSmi), I8(-1), - B(Star), R(11), - B(Star), R(10), + B(Star), R(9), + B(Star), R(8), B(Jump), U8(7), - B(Star), R(11), + B(Star), R(9), B(LdaZero), - B(Star), R(10), + B(Star), R(8), B(LdaTheHole), /* 50 E> */ B(SetPendingMessage), + B(Star), R(10), + B(Ldar), R(7), + B(JumpIfToBooleanTrue), U8(58), + B(LdaNamedProperty), R(6), U8(6), U8(12), B(Star), R(12), - B(Ldar), R(9), - B(JumpIfToBooleanTrue), U8(60), - B(LdaNamedProperty), R(6), U8(7), U8(12), - B(Star), R(14), - B(JumpIfUndefined), U8(52), - B(JumpIfNull), U8(50), - B(Mov), R(context), R(15), + B(JumpIfUndefinedOrNull), U8(50), + B(Mov), R(context), R(13), B(TestTypeOf), U8(6), B(JumpIfTrue), U8(18), B(Wide), B(LdaSmi), I16(159), - B(Star), R(16), - B(LdaConstant), U8(8), - B(Star), R(17), - B(CallRuntime), U16(Runtime::kNewTypeError), R(16), U8(2), + B(Star), R(14), + B(LdaConstant), U8(7), + B(Star), R(15), + B(CallRuntime), U16(Runtime::kNewTypeError), R(14), U8(2), B(Throw), - B(CallProperty0), R(14), R(6), U8(14), + B(CallProperty0), R(12), R(6), U8(14), B(JumpIfJSReceiver), U8(21), - B(Star), R(16), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(16), U8(1), + B(Star), R(14), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(14), U8(1), B(Jump), U8(12), - B(Star), R(15), + B(Star), R(13), B(LdaZero), - B(TestReferenceEqual), R(10), + B(TestReferenceEqual), R(8), B(JumpIfTrue), U8(5), - B(Ldar), R(15), + B(Ldar), R(13), B(ReThrow), - B(Ldar), R(12), + B(Ldar), R(10), B(SetPendingMessage), B(LdaZero), - B(TestReferenceEqual), R(10), + B(TestReferenceEqual), R(8), B(JumpIfFalse), U8(5), - B(Ldar), R(11), + B(Ldar), R(9), B(ReThrow), B(LdaUndefined), /* 55 S> */ B(Return), @@ -579,7 +561,6 @@ constant pool: [ Smi [22], Smi [10], Smi [7], - SYMBOL_TYPE, ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], @@ -587,8 +568,8 @@ constant pool: [ ONE_BYTE_INTERNALIZED_STRING_TYPE [""], ] handlers: [ - [76, 122, 130], - [156, 189, 191], + [72, 118, 126], + [150, 183, 185], ] --- @@ -598,9 +579,9 @@ snippet: " } f([1, 2, 3]); " -frame size: 17 +frame size: 15 parameter count: 2 -bytecode array length: 258 +bytecode array length: 252 bytecodes: [ B(SwitchOnGeneratorState), R(0), U8(0), U8(2), B(Mov), R(closure), R(4), @@ -617,104 +598,101 @@ bytecodes: [ /* 11 E> */ B(Throw), B(Ldar), R(4), /* 49 S> */ B(Return), - /* 35 S> */ B(LdaNamedProperty), R(arg0), U8(4), U8(0), + /* 35 S> */ B(GetIterator), R(arg0), U8(0), B(Star), R(7), B(CallProperty0), R(7), R(arg0), U8(2), - B(Mov), R(arg0), R(6), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), B(Star), R(5), - B(LdaNamedProperty), R(5), U8(5), U8(4), + B(LdaNamedProperty), R(5), U8(4), U8(4), B(Star), R(4), B(LdaFalse), - B(Star), R(8), - B(Mov), R(context), R(11), + B(Star), R(6), + B(Mov), R(context), R(9), B(LdaTrue), - B(Star), R(8), + B(Star), R(6), /* 30 S> */ B(CallProperty0), R(4), R(5), U8(6), - B(Star), R(12), + B(Star), R(10), B(JumpIfJSReceiver), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(12), U8(1), - B(LdaNamedProperty), R(12), U8(6), U8(8), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(10), U8(1), + B(LdaNamedProperty), R(10), U8(5), U8(8), B(JumpIfToBooleanTrue), U8(64), - B(LdaNamedProperty), R(12), U8(7), U8(10), - B(Star), R(12), + B(LdaNamedProperty), R(10), U8(6), U8(10), + B(Star), R(10), B(LdaFalse), - B(Star), R(8), - B(Mov), R(12), R(1), + B(Star), R(6), + B(Mov), R(10), R(1), /* 21 E> */ B(StackCheck), /* 30 S> */ B(Mov), R(1), R(3), /* 40 S> */ B(LdaFalse), - B(Star), R(14), - B(Mov), R(3), R(13), - B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(13), U8(2), - /* 40 E> */ B(SuspendGenerator), R(0), R(0), U8(13), U8(1), - B(ResumeGenerator), R(0), R(0), U8(13), - B(Star), R(13), + B(Star), R(12), + B(Mov), R(3), R(11), + B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(11), U8(2), + /* 40 E> */ B(SuspendGenerator), R(0), R(0), U8(11), U8(1), + B(ResumeGenerator), R(0), R(0), U8(11), + B(Star), R(11), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1), - B(SwitchOnSmiNoFeedback), U8(8), U8(2), I8(0), - B(Ldar), R(13), + B(SwitchOnSmiNoFeedback), U8(7), U8(2), I8(0), + B(Ldar), R(11), /* 40 E> */ B(Throw), B(LdaSmi), I8(1), - B(Star), R(9), - B(Mov), R(13), R(10), + B(Star), R(7), + B(Mov), R(11), R(8), B(Jump), U8(20), - B(Ldar), R(13), + B(Ldar), R(11), B(JumpLoop), U8(81), I8(0), B(LdaSmi), I8(-1), - B(Star), R(10), - B(Star), R(9), + B(Star), R(8), + B(Star), R(7), B(Jump), U8(7), - B(Star), R(10), + B(Star), R(8), B(LdaZero), - B(Star), R(9), + B(Star), R(7), B(LdaTheHole), B(SetPendingMessage), + B(Star), R(9), + B(Ldar), R(6), + B(JumpIfToBooleanTrue), U8(58), + B(LdaNamedProperty), R(5), U8(9), U8(12), B(Star), R(11), - B(Ldar), R(8), - B(JumpIfToBooleanTrue), U8(60), - B(LdaNamedProperty), R(5), U8(10), U8(12), - B(Star), R(13), - B(JumpIfUndefined), U8(52), - B(JumpIfNull), U8(50), - B(Mov), R(context), R(14), + B(JumpIfUndefinedOrNull), U8(50), + B(Mov), R(context), R(12), B(TestTypeOf), U8(6), B(JumpIfTrue), U8(18), B(Wide), B(LdaSmi), I16(159), - B(Star), R(15), - B(LdaConstant), U8(11), - B(Star), R(16), - B(CallRuntime), U16(Runtime::kNewTypeError), R(15), U8(2), + B(Star), R(13), + B(LdaConstant), U8(10), + B(Star), R(14), + B(CallRuntime), U16(Runtime::kNewTypeError), R(13), U8(2), B(Throw), - B(CallProperty0), R(13), R(5), U8(14), + B(CallProperty0), R(11), R(5), U8(14), B(JumpIfJSReceiver), U8(21), - B(Star), R(15), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(15), U8(1), + B(Star), R(13), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(13), U8(1), B(Jump), U8(12), - B(Star), R(14), + B(Star), R(12), B(LdaZero), - B(TestReferenceEqual), R(9), + B(TestReferenceEqual), R(7), B(JumpIfTrue), U8(5), - B(Ldar), R(14), + B(Ldar), R(12), B(ReThrow), - B(Ldar), R(11), - B(SetPendingMessage), B(Ldar), R(9), - B(SwitchOnSmiNoFeedback), U8(12), U8(2), I8(0), + B(SetPendingMessage), + B(Ldar), R(7), + B(SwitchOnSmiNoFeedback), U8(11), U8(2), I8(0), B(Jump), U8(8), - B(Ldar), R(10), + B(Ldar), R(8), B(ReThrow), - B(Ldar), R(10), + B(Ldar), R(8), /* 49 S> */ B(Return), B(LdaUndefined), /* 49 S> */ B(Return), ] constant pool: [ Smi [22], - Smi [129], + Smi [125], Smi [10], Smi [7], - SYMBOL_TYPE, ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], @@ -726,8 +704,8 @@ constant pool: [ Smi [9], ] handlers: [ - [76, 160, 168], - [194, 227, 229], + [72, 156, 164], + [188, 221, 223], ] --- @@ -737,9 +715,9 @@ snippet: " } f([1, 2, 3]); " -frame size: 19 +frame size: 17 parameter count: 2 -bytecode array length: 228 +bytecode array length: 222 bytecodes: [ B(Mov), R(closure), R(5), B(Mov), R(this), R(6), @@ -747,78 +725,76 @@ bytecodes: [ B(Star), R(0), /* 16 E> */ B(StackCheck), B(Mov), R(context), R(5), - /* 40 S> */ B(LdaNamedProperty), R(arg0), U8(0), U8(0), + /* 40 S> */ B(GetIterator), R(arg0), U8(0), B(Star), R(9), B(CallProperty0), R(9), R(arg0), U8(2), - B(Mov), R(arg0), R(8), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), B(Star), R(7), - B(LdaNamedProperty), R(7), U8(1), U8(4), + B(LdaNamedProperty), R(7), U8(0), U8(4), B(Star), R(6), B(LdaFalse), - B(Star), R(10), - B(Mov), R(context), R(13), + B(Star), R(8), + B(Mov), R(context), R(11), B(LdaTrue), - B(Star), R(10), + B(Star), R(8), /* 35 S> */ B(CallProperty0), R(6), R(7), U8(6), - B(Star), R(14), + B(Star), R(12), B(JumpIfJSReceiver), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(14), U8(1), - B(LdaNamedProperty), R(14), U8(2), U8(8), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(12), U8(1), + B(LdaNamedProperty), R(12), U8(1), U8(8), B(JumpIfToBooleanTrue), U8(26), - B(LdaNamedProperty), R(14), U8(3), U8(10), - B(Star), R(14), + B(LdaNamedProperty), R(12), U8(2), U8(10), + B(Star), R(12), B(LdaFalse), - B(Star), R(10), - B(Mov), R(14), R(1), + B(Star), R(8), + B(Mov), R(12), R(1), /* 26 E> */ B(StackCheck), /* 35 S> */ B(Mov), R(1), R(3), /* 55 S> */ B(Mov), R(3), R(4), - B(Ldar), R(14), + B(Ldar), R(12), B(JumpLoop), U8(43), I8(0), B(LdaSmi), I8(-1), - B(Star), R(12), - B(Star), R(11), + B(Star), R(10), + B(Star), R(9), B(Jump), U8(7), - B(Star), R(12), + B(Star), R(10), B(LdaZero), - B(Star), R(11), + B(Star), R(9), B(LdaTheHole), /* 55 E> */ B(SetPendingMessage), + B(Star), R(11), + B(Ldar), R(8), + B(JumpIfToBooleanTrue), U8(58), + B(LdaNamedProperty), R(7), U8(3), U8(12), B(Star), R(13), - B(Ldar), R(10), - B(JumpIfToBooleanTrue), U8(60), - B(LdaNamedProperty), R(7), U8(4), U8(12), - B(Star), R(15), - B(JumpIfUndefined), U8(52), - B(JumpIfNull), U8(50), - B(Mov), R(context), R(16), + B(JumpIfUndefinedOrNull), U8(50), + B(Mov), R(context), R(14), B(TestTypeOf), U8(6), B(JumpIfTrue), U8(18), B(Wide), B(LdaSmi), I16(159), - B(Star), R(17), - B(LdaConstant), U8(5), - B(Star), R(18), - B(CallRuntime), U16(Runtime::kNewTypeError), R(17), U8(2), + B(Star), R(15), + B(LdaConstant), U8(4), + B(Star), R(16), + B(CallRuntime), U16(Runtime::kNewTypeError), R(15), U8(2), B(Throw), - B(CallProperty0), R(15), R(7), U8(14), + B(CallProperty0), R(13), R(7), U8(14), B(JumpIfJSReceiver), U8(21), - B(Star), R(17), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(17), U8(1), + B(Star), R(15), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(15), U8(1), B(Jump), U8(12), - B(Star), R(16), + B(Star), R(14), B(LdaZero), - B(TestReferenceEqual), R(11), + B(TestReferenceEqual), R(9), B(JumpIfTrue), U8(5), - B(Ldar), R(16), + B(Ldar), R(14), B(ReThrow), - B(Ldar), R(13), + B(Ldar), R(11), B(SetPendingMessage), B(LdaZero), - B(TestReferenceEqual), R(11), + B(TestReferenceEqual), R(9), B(JumpIfFalse), U8(5), - B(Ldar), R(12), + B(Ldar), R(10), B(ReThrow), B(LdaUndefined), B(Star), R(7), @@ -828,7 +804,7 @@ bytecodes: [ B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionResolve), R(6), U8(3), /* 60 S> */ B(Return), B(Star), R(6), - B(CreateCatchContext), R(6), U8(6), + B(CreateCatchContext), R(6), U8(5), B(Star), R(5), B(LdaTheHole), B(SetPendingMessage), @@ -843,7 +819,6 @@ bytecodes: [ /* 60 S> */ B(Return), ] constant pool: [ - SYMBOL_TYPE, ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], @@ -852,9 +827,9 @@ constant pool: [ SCOPE_INFO_TYPE, ] handlers: [ - [16, 200, 200], - [50, 96, 104], - [130, 163, 165], + [16, 194, 194], + [46, 92, 100], + [124, 157, 159], ] --- @@ -864,9 +839,9 @@ snippet: " } f([1, 2, 3]); " -frame size: 18 +frame size: 16 parameter count: 2 -bytecode array length: 264 +bytecode array length: 258 bytecodes: [ B(SwitchOnGeneratorState), R(0), U8(0), U8(1), B(Mov), R(closure), R(4), @@ -875,90 +850,88 @@ bytecodes: [ B(Star), R(0), /* 16 E> */ B(StackCheck), B(Mov), R(context), R(4), - /* 40 S> */ B(LdaNamedProperty), R(arg0), U8(1), U8(0), + /* 40 S> */ B(GetIterator), R(arg0), U8(0), B(Star), R(8), B(CallProperty0), R(8), R(arg0), U8(2), - B(Mov), R(arg0), R(7), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), B(Star), R(6), - B(LdaNamedProperty), R(6), U8(2), U8(4), + B(LdaNamedProperty), R(6), U8(1), U8(4), B(Star), R(5), B(LdaFalse), - B(Star), R(9), - B(Mov), R(context), R(12), + B(Star), R(7), + B(Mov), R(context), R(10), B(LdaTrue), - B(Star), R(9), + B(Star), R(7), /* 35 S> */ B(CallProperty0), R(5), R(6), U8(6), - B(Star), R(13), + B(Star), R(11), B(JumpIfJSReceiver), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(13), U8(1), - B(LdaNamedProperty), R(13), U8(3), U8(8), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(11), U8(1), + B(LdaNamedProperty), R(11), U8(2), U8(8), B(JumpIfToBooleanTrue), U8(58), - B(LdaNamedProperty), R(13), U8(4), U8(10), - B(Star), R(13), + B(LdaNamedProperty), R(11), U8(3), U8(10), + B(Star), R(11), B(LdaFalse), - B(Star), R(9), - B(Mov), R(13), R(1), + B(Star), R(7), + B(Mov), R(11), R(1), /* 26 E> */ B(StackCheck), /* 35 S> */ B(Mov), R(1), R(3), - /* 45 S> */ B(Mov), R(0), R(14), - B(Mov), R(3), R(15), - B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionAwaitUncaught), R(14), U8(2), - /* 45 E> */ B(SuspendGenerator), R(0), R(0), U8(14), U8(0), - B(ResumeGenerator), R(0), R(0), U8(14), - B(Star), R(14), + /* 45 S> */ B(Mov), R(0), R(12), + B(Mov), R(3), R(13), + B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionAwaitUncaught), R(12), U8(2), + /* 45 E> */ B(SuspendGenerator), R(0), R(0), U8(12), U8(0), + B(ResumeGenerator), R(0), R(0), U8(12), + B(Star), R(12), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1), - B(Star), R(15), + B(Star), R(13), B(LdaZero), - B(TestReferenceEqual), R(15), + B(TestReferenceEqual), R(13), B(JumpIfTrue), U8(5), - B(Ldar), R(14), + B(Ldar), R(12), B(ReThrow), - B(Ldar), R(14), + B(Ldar), R(12), B(JumpLoop), U8(75), I8(0), B(LdaSmi), I8(-1), - B(Star), R(11), - B(Star), R(10), + B(Star), R(9), + B(Star), R(8), B(Jump), U8(7), - B(Star), R(11), + B(Star), R(9), B(LdaZero), - B(Star), R(10), + B(Star), R(8), B(LdaTheHole), B(SetPendingMessage), + B(Star), R(10), + B(Ldar), R(7), + B(JumpIfToBooleanTrue), U8(58), + B(LdaNamedProperty), R(6), U8(4), U8(12), B(Star), R(12), - B(Ldar), R(9), - B(JumpIfToBooleanTrue), U8(60), - B(LdaNamedProperty), R(6), U8(5), U8(12), - B(Star), R(14), - B(JumpIfUndefined), U8(52), - B(JumpIfNull), U8(50), - B(Mov), R(context), R(15), + B(JumpIfUndefinedOrNull), U8(50), + B(Mov), R(context), R(13), B(TestTypeOf), U8(6), B(JumpIfTrue), U8(18), B(Wide), B(LdaSmi), I16(159), - B(Star), R(16), - B(LdaConstant), U8(6), - B(Star), R(17), - B(CallRuntime), U16(Runtime::kNewTypeError), R(16), U8(2), + B(Star), R(14), + B(LdaConstant), U8(5), + B(Star), R(15), + B(CallRuntime), U16(Runtime::kNewTypeError), R(14), U8(2), B(Throw), - B(CallProperty0), R(14), R(6), U8(14), + B(CallProperty0), R(12), R(6), U8(14), B(JumpIfJSReceiver), U8(21), - B(Star), R(16), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(16), U8(1), + B(Star), R(14), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(14), U8(1), B(Jump), U8(12), - B(Star), R(15), + B(Star), R(13), B(LdaZero), - B(TestReferenceEqual), R(10), + B(TestReferenceEqual), R(8), B(JumpIfTrue), U8(5), - B(Ldar), R(15), + B(Ldar), R(13), B(ReThrow), - B(Ldar), R(12), + B(Ldar), R(10), B(SetPendingMessage), B(LdaZero), - B(TestReferenceEqual), R(10), + B(TestReferenceEqual), R(8), B(JumpIfFalse), U8(5), - B(Ldar), R(11), + B(Ldar), R(9), B(ReThrow), B(LdaUndefined), B(Star), R(6), @@ -968,7 +941,7 @@ bytecodes: [ B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionResolve), R(5), U8(3), /* 54 S> */ B(Return), B(Star), R(5), - B(CreateCatchContext), R(5), U8(7), + B(CreateCatchContext), R(5), U8(6), B(Star), R(4), B(LdaTheHole), B(SetPendingMessage), @@ -983,8 +956,7 @@ bytecodes: [ /* 54 S> */ B(Return), ] constant pool: [ - Smi [107], - SYMBOL_TYPE, + Smi [103], ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], @@ -993,8 +965,8 @@ constant pool: [ SCOPE_INFO_TYPE, ] handlers: [ - [20, 236, 236], - [54, 132, 140], - [166, 199, 201], + [20, 230, 230], + [50, 128, 136], + [160, 193, 195], ] diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/Generators.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/Generators.golden index bfbd05cd31..157b58d81d 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/Generators.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/Generators.golden @@ -98,9 +98,9 @@ snippet: " function* f() { for (let x of [42]) yield x } f(); " -frame size: 17 +frame size: 15 parameter count: 1 -bytecode array length: 261 +bytecode array length: 258 bytecodes: [ B(SwitchOnGeneratorState), R(0), U8(0), U8(2), B(Mov), R(closure), R(4), @@ -119,104 +119,102 @@ bytecodes: [ /* 44 S> */ B(Return), /* 30 S> */ B(CreateArrayLiteral), U8(4), U8(0), U8(37), B(Star), R(6), - B(LdaNamedProperty), R(6), U8(5), U8(1), + B(GetIterator), R(6), U8(1), B(Star), R(7), B(CallProperty0), R(7), R(6), U8(3), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), B(Star), R(5), - B(LdaNamedProperty), R(5), U8(6), U8(5), + B(LdaNamedProperty), R(5), U8(5), U8(5), B(Star), R(4), B(LdaFalse), - B(Star), R(8), - B(Mov), R(context), R(11), + B(Star), R(6), + B(Mov), R(context), R(9), B(LdaTrue), - B(Star), R(8), + B(Star), R(6), /* 25 S> */ B(CallProperty0), R(4), R(5), U8(7), - B(Star), R(12), + B(Star), R(10), B(JumpIfJSReceiver), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(12), U8(1), - B(LdaNamedProperty), R(12), U8(7), U8(9), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(10), U8(1), + B(LdaNamedProperty), R(10), U8(6), U8(9), B(JumpIfToBooleanTrue), U8(64), - B(LdaNamedProperty), R(12), U8(8), U8(11), - B(Star), R(12), + B(LdaNamedProperty), R(10), U8(7), U8(11), + B(Star), R(10), B(LdaFalse), - B(Star), R(8), - B(Mov), R(12), R(1), + B(Star), R(6), + B(Mov), R(10), R(1), /* 16 E> */ B(StackCheck), /* 25 S> */ B(Mov), R(1), R(3), /* 36 S> */ B(LdaFalse), - B(Star), R(14), - B(Mov), R(3), R(13), - B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(13), U8(2), - /* 36 E> */ B(SuspendGenerator), R(0), R(0), U8(13), U8(1), - B(ResumeGenerator), R(0), R(0), U8(13), - B(Star), R(13), + B(Star), R(12), + B(Mov), R(3), R(11), + B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(11), U8(2), + /* 36 E> */ B(SuspendGenerator), R(0), R(0), U8(11), U8(1), + B(ResumeGenerator), R(0), R(0), U8(11), + B(Star), R(11), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1), - B(SwitchOnSmiNoFeedback), U8(9), U8(2), I8(0), - B(Ldar), R(13), + B(SwitchOnSmiNoFeedback), U8(8), U8(2), I8(0), + B(Ldar), R(11), /* 36 E> */ B(Throw), B(LdaSmi), I8(1), - B(Star), R(9), - B(Mov), R(13), R(10), + B(Star), R(7), + B(Mov), R(11), R(8), B(Jump), U8(20), - B(Ldar), R(13), + B(Ldar), R(11), B(JumpLoop), U8(81), I8(0), B(LdaSmi), I8(-1), - B(Star), R(10), - B(Star), R(9), + B(Star), R(8), + B(Star), R(7), B(Jump), U8(7), - B(Star), R(10), + B(Star), R(8), B(LdaZero), - B(Star), R(9), + B(Star), R(7), B(LdaTheHole), B(SetPendingMessage), + B(Star), R(9), + B(Ldar), R(6), + B(JumpIfToBooleanTrue), U8(58), + B(LdaNamedProperty), R(5), U8(10), U8(13), B(Star), R(11), - B(Ldar), R(8), - B(JumpIfToBooleanTrue), U8(60), - B(LdaNamedProperty), R(5), U8(11), U8(13), - B(Star), R(13), - B(JumpIfUndefined), U8(52), - B(JumpIfNull), U8(50), - B(Mov), R(context), R(14), + B(JumpIfUndefinedOrNull), U8(50), + B(Mov), R(context), R(12), B(TestTypeOf), U8(6), B(JumpIfTrue), U8(18), B(Wide), B(LdaSmi), I16(159), - B(Star), R(15), - B(LdaConstant), U8(12), - B(Star), R(16), - B(CallRuntime), U16(Runtime::kNewTypeError), R(15), U8(2), + B(Star), R(13), + B(LdaConstant), U8(11), + B(Star), R(14), + B(CallRuntime), U16(Runtime::kNewTypeError), R(13), U8(2), B(Throw), - B(CallProperty0), R(13), R(5), U8(15), + B(CallProperty0), R(11), R(5), U8(15), B(JumpIfJSReceiver), U8(21), - B(Star), R(15), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(15), U8(1), + B(Star), R(13), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(13), U8(1), B(Jump), U8(12), - B(Star), R(14), + B(Star), R(12), B(LdaZero), - B(TestReferenceEqual), R(9), + B(TestReferenceEqual), R(7), B(JumpIfTrue), U8(5), - B(Ldar), R(14), + B(Ldar), R(12), B(ReThrow), - B(Ldar), R(11), - B(SetPendingMessage), B(Ldar), R(9), - B(SwitchOnSmiNoFeedback), U8(13), U8(2), I8(0), + B(SetPendingMessage), + B(Ldar), R(7), + B(SwitchOnSmiNoFeedback), U8(12), U8(2), I8(0), B(Jump), U8(8), - B(Ldar), R(10), + B(Ldar), R(8), B(ReThrow), - B(Ldar), R(10), + B(Ldar), R(8), /* 44 S> */ B(Return), B(LdaUndefined), /* 44 S> */ B(Return), ] constant pool: [ Smi [22], - Smi [132], + Smi [131], Smi [10], Smi [7], ARRAY_BOILERPLATE_DESCRIPTION_TYPE, - SYMBOL_TYPE, ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], @@ -228,8 +226,8 @@ constant pool: [ Smi [9], ] handlers: [ - [79, 163, 171], - [197, 230, 232], + [78, 162, 170], + [194, 227, 229], ] --- @@ -238,9 +236,9 @@ snippet: " function* f() { yield* g() } f(); " -frame size: 9 +frame size: 8 parameter count: 1 -bytecode array length: 217 +bytecode array length: 210 bytecodes: [ B(SwitchOnGeneratorState), R(0), U8(0), U8(2), B(Mov), R(closure), R(1), @@ -261,59 +259,56 @@ bytecodes: [ B(Star), R(5), /* 50 E> */ B(CallUndefinedReceiver0), R(5), U8(2), B(Star), R(6), - B(LdaNamedProperty), R(6), U8(5), U8(4), + B(GetIterator), R(6), U8(4), B(Star), R(7), B(CallProperty0), R(7), R(6), U8(6), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), B(Star), R(3), - B(LdaNamedProperty), R(3), U8(6), U8(8), + B(LdaNamedProperty), R(3), U8(5), U8(8), B(Star), R(5), B(LdaUndefined), B(Star), R(4), B(LdaZero), B(Star), R(2), B(Ldar), R(2), - B(SwitchOnSmiNoFeedback), U8(7), U8(2), I8(1), + B(SwitchOnSmiNoFeedback), U8(6), U8(2), I8(1), B(CallProperty1), R(5), R(3), R(4), U8(10), - B(Jump), U8(69), - B(LdaNamedProperty), R(3), U8(9), U8(12), - B(JumpIfUndefined), U8(13), - B(JumpIfNull), U8(11), - B(Star), R(8), - B(CallProperty1), R(8), R(3), R(4), U8(14), - B(Jump), U8(52), + B(Jump), U8(63), + B(LdaNamedProperty), R(3), U8(8), U8(12), + B(JumpIfUndefinedOrNull), U8(11), + B(Star), R(6), + B(CallProperty1), R(6), R(3), R(4), U8(14), + B(Jump), U8(48), B(Ldar), R(4), /* 54 S> */ B(Return), - B(LdaNamedProperty), R(3), U8(10), U8(16), - B(JumpIfUndefined), U8(13), - B(JumpIfNull), U8(11), - B(Star), R(8), - B(CallProperty1), R(8), R(3), R(4), U8(18), - B(Jump), U8(32), - B(LdaNamedProperty), R(3), U8(9), U8(20), - B(JumpIfUndefined), U8(21), - B(JumpIfNull), U8(19), - B(Star), R(8), - B(CallProperty0), R(8), R(3), U8(22), + B(LdaNamedProperty), R(3), U8(9), U8(16), + B(JumpIfUndefinedOrNull), U8(11), + B(Star), R(6), + B(CallProperty1), R(6), R(3), R(4), U8(18), + B(Jump), U8(30), + B(LdaNamedProperty), R(3), U8(8), U8(20), + B(JumpIfUndefinedOrNull), U8(19), + B(Star), R(6), + B(CallProperty0), R(6), R(3), U8(22), B(Jump), U8(2), B(JumpIfJSReceiver), U8(9), - B(Star), R(8), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(8), U8(1), + B(Star), R(6), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(6), U8(1), B(CallRuntime), U16(Runtime::kThrowThrowMethodMissing), R(0), U8(0), B(Star), R(1), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(1), U8(1), - B(LdaNamedProperty), R(1), U8(11), U8(24), + B(LdaNamedProperty), R(1), U8(10), U8(24), B(JumpIfToBooleanTrue), U8(24), B(Ldar), R(1), - /* 43 E> */ B(SuspendGenerator), R(0), R(0), U8(8), U8(1), - B(ResumeGenerator), R(0), R(0), U8(8), + /* 43 E> */ B(SuspendGenerator), R(0), R(0), U8(6), U8(1), + B(ResumeGenerator), R(0), R(0), U8(6), B(Star), R(4), B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1), B(Star), R(2), - B(JumpLoop), U8(114), I8(0), - B(LdaNamedProperty), R(1), U8(12), U8(26), + B(JumpLoop), U8(108), I8(0), + B(LdaNamedProperty), R(1), U8(11), U8(26), B(Star), R(3), B(LdaSmi), I8(1), B(TestReferenceEqual), R(2), @@ -325,14 +320,13 @@ bytecodes: [ ] constant pool: [ Smi [22], - Smi [185], + Smi [178], Smi [10], Smi [7], ONE_BYTE_INTERNALIZED_STRING_TYPE ["g"], - SYMBOL_TYPE, ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], Smi [11], - Smi [31], + Smi [29], ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["throw"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/NewAndSpread.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/NewAndSpread.golden index ed15f99fc9..dce8d7ac8c 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/NewAndSpread.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/NewAndSpread.golden @@ -92,9 +92,9 @@ snippet: " class A { constructor(...args) { this.args = args; } } new A(0, ...[1, 2, 3], 4); " -frame size: 10 +frame size: 9 parameter count: 1 -bytecode array length: 131 +bytecode array length: 130 bytecodes: [ /* 30 E> */ B(StackCheck), B(CreateBlockContext), U8(0), @@ -117,22 +117,22 @@ bytecodes: [ B(Star), R(3), /* 101 S> */ B(CreateArrayLiteral), U8(5), U8(1), U8(37), B(Star), R(7), - B(LdaNamedProperty), R(7), U8(6), U8(2), + B(GetIterator), R(7), U8(2), B(Star), R(8), B(CallProperty0), R(8), R(7), U8(4), B(Mov), R(5), R(2), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), B(Star), R(6), - B(LdaNamedProperty), R(6), U8(7), U8(6), + B(LdaNamedProperty), R(6), U8(6), U8(6), B(Star), R(5), B(CallProperty0), R(5), R(6), U8(15), - B(Star), R(9), + B(Star), R(7), B(JumpIfJSReceiver), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(9), U8(1), - B(LdaNamedProperty), R(9), U8(8), U8(17), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(7), U8(1), + B(LdaNamedProperty), R(7), U8(7), U8(17), B(JumpIfToBooleanTrue), U8(19), - B(LdaNamedProperty), R(9), U8(9), U8(8), + B(LdaNamedProperty), R(7), U8(8), U8(8), B(StaInArrayLiteral), R(4), R(3), U8(13), B(Ldar), R(3), B(Inc), U8(12), @@ -152,7 +152,6 @@ constant pool: [ ARRAY_BOILERPLATE_DESCRIPTION_TYPE, Smi [1], ARRAY_BOILERPLATE_DESCRIPTION_TYPE, - SYMBOL_TYPE, ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/PrivateAccessorAccess.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/PrivateAccessorAccess.golden new file mode 100644 index 0000000000..6fc00999a5 --- /dev/null +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/PrivateAccessorAccess.golden @@ -0,0 +1,192 @@ +# +# Autogenerated by generate-bytecode-expectations. +# + +--- +wrap: no +test function name: test +private methods: yes + +--- +snippet: " + class A { + get #a() { return 1; } + set #a(val) { } + + constructor() { + this.#a++; + this.#a = 1; + return this.#a; + } + } + var test = A; + new test; +" +frame size: 6 +parameter count: 1 +bytecode array length: 95 +bytecodes: [ + /* 67 E> */ B(StackCheck), + B(LdaCurrentContextSlot), U8(5), + B(Star), R(1), + B(Mov), R(this), R(0), + B(CallRuntime), U16(Runtime::kAddPrivateBrand), R(0), U8(2), + /* 76 S> */ B(LdaCurrentContextSlot), U8(4), + B(Star), R(3), + B(LdaCurrentContextSlot), U8(5), + /* 81 E> */ B(LdaKeyedProperty), R(this), U8(0), + B(CallRuntime), U16(Runtime::kLoadPrivateGetter), R(3), U8(1), + B(Star), R(4), + B(CallProperty0), R(4), R(this), U8(2), + B(Inc), U8(4), + B(Star), R(4), + /* 83 E> */ B(CallRuntime), U16(Runtime::kLoadPrivateSetter), R(3), U8(1), + B(Star), R(5), + B(CallProperty1), R(5), R(this), R(4), U8(5), + /* 91 S> */ B(LdaSmi), I8(1), + B(Star), R(2), + B(LdaCurrentContextSlot), U8(4), + B(Star), R(4), + B(LdaCurrentContextSlot), U8(5), + /* 96 E> */ B(LdaKeyedProperty), R(this), U8(7), + B(CallRuntime), U16(Runtime::kLoadPrivateSetter), R(4), U8(1), + B(Star), R(5), + B(CallProperty1), R(5), R(this), R(2), U8(9), + /* 108 S> */ B(LdaCurrentContextSlot), U8(4), + B(Star), R(3), + B(LdaCurrentContextSlot), U8(5), + /* 120 E> */ B(LdaKeyedProperty), R(this), U8(11), + B(CallRuntime), U16(Runtime::kLoadPrivateGetter), R(3), U8(1), + B(Star), R(4), + B(CallProperty0), R(4), R(this), U8(13), + /* 123 S> */ B(Return), +] +constant pool: [ +] +handlers: [ +] + +--- +snippet: " + class B { + get #b() { return 1; } + constructor() { this.#b++; } + } + var test = B; + new test; +" +frame size: 4 +parameter count: 1 +bytecode array length: 29 +bytecodes: [ + /* 48 E> */ B(StackCheck), + B(LdaCurrentContextSlot), U8(5), + B(Star), R(1), + B(Mov), R(this), R(0), + B(CallRuntime), U16(Runtime::kAddPrivateBrand), R(0), U8(2), + /* 53 S> */ B(Wide), B(LdaSmi), I16(263), + B(Star), R(2), + B(LdaConstant), U8(0), + B(Star), R(3), + B(CallRuntime), U16(Runtime::kNewTypeError), R(2), U8(2), + B(Throw), +] +constant pool: [ + ONE_BYTE_INTERNALIZED_STRING_TYPE ["#b"], +] +handlers: [ +] + +--- +snippet: " + class C { + set #c(val) { } + constructor() { this.#c++; } + } + var test = C; + new test; +" +frame size: 4 +parameter count: 1 +bytecode array length: 29 +bytecodes: [ + /* 41 E> */ B(StackCheck), + B(LdaCurrentContextSlot), U8(5), + B(Star), R(1), + B(Mov), R(this), R(0), + B(CallRuntime), U16(Runtime::kAddPrivateBrand), R(0), U8(2), + /* 46 S> */ B(Wide), B(LdaSmi), I16(262), + B(Star), R(2), + B(LdaConstant), U8(0), + B(Star), R(3), + B(CallRuntime), U16(Runtime::kNewTypeError), R(2), U8(2), + B(Throw), +] +constant pool: [ + ONE_BYTE_INTERNALIZED_STRING_TYPE ["#c"], +] +handlers: [ +] + +--- +snippet: " + class D { + get #d() { return 1; } + constructor() { this.#d = 1; } + } + var test = D; + new test; +" +frame size: 4 +parameter count: 1 +bytecode array length: 29 +bytecodes: [ + /* 48 E> */ B(StackCheck), + B(LdaCurrentContextSlot), U8(5), + B(Star), R(1), + B(Mov), R(this), R(0), + B(CallRuntime), U16(Runtime::kAddPrivateBrand), R(0), U8(2), + /* 53 S> */ B(Wide), B(LdaSmi), I16(263), + B(Star), R(2), + B(LdaConstant), U8(0), + B(Star), R(3), + /* 61 E> */ B(CallRuntime), U16(Runtime::kNewTypeError), R(2), U8(2), + B(Throw), +] +constant pool: [ + ONE_BYTE_INTERNALIZED_STRING_TYPE ["#d"], +] +handlers: [ +] + +--- +snippet: " + class E { + set #e(val) { } + constructor() { this.#e; } + } + var test = E; + new test; +" +frame size: 5 +parameter count: 1 +bytecode array length: 29 +bytecodes: [ + /* 41 E> */ B(StackCheck), + B(LdaCurrentContextSlot), U8(5), + B(Star), R(1), + B(Mov), R(this), R(0), + B(CallRuntime), U16(Runtime::kAddPrivateBrand), R(0), U8(2), + /* 46 S> */ B(Wide), B(LdaSmi), I16(262), + B(Star), R(3), + B(LdaConstant), U8(0), + B(Star), R(4), + B(CallRuntime), U16(Runtime::kNewTypeError), R(3), U8(2), + B(Throw), +] +constant pool: [ + ONE_BYTE_INTERNALIZED_STRING_TYPE ["#e"], +] +handlers: [ +] + diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/PrivateAccessorDeclaration.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/PrivateAccessorDeclaration.golden new file mode 100644 index 0000000000..aceee552b5 --- /dev/null +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/PrivateAccessorDeclaration.golden @@ -0,0 +1,398 @@ +# +# Autogenerated by generate-bytecode-expectations. +# + +--- +wrap: yes +private methods: yes + +--- +snippet: " + { + class A { + get #a() { return 1; } + set #a(val) { } + } + } +" +frame size: 8 +parameter count: 1 +bytecode array length: 68 +bytecodes: [ + /* 30 E> */ B(StackCheck), + B(CreateBlockContext), U8(0), + B(PushContext), R(2), + B(LdaTheHole), + B(Star), R(6), + B(CreateClosure), U8(2), U8(0), U8(2), + B(Star), R(3), + B(LdaConstant), U8(1), + B(Star), R(4), + B(Mov), R(3), R(5), + B(CallRuntime), U16(Runtime::kDefineClass), R(4), U8(3), + B(Star), R(4), + B(Mov), R(5), R(1), + B(LdaConstant), U8(3), + B(Star), R(5), + B(CallRuntime), U16(Runtime::kCreatePrivateNameSymbol), R(5), U8(1), + B(StaCurrentContextSlot), U8(5), + B(CreateClosure), U8(4), U8(1), U8(2), + B(Star), R(6), + B(CreateClosure), U8(5), U8(2), U8(2), + B(Star), R(7), + B(CallRuntime), U16(Runtime::kCreatePrivateAccessors), R(6), U8(2), + B(StaCurrentContextSlot), U8(4), + B(PopContext), R(2), + B(Mov), R(1), R(0), + B(LdaUndefined), + /* 101 S> */ B(Return), +] +constant pool: [ + SCOPE_INFO_TYPE, + FIXED_ARRAY_TYPE, + SHARED_FUNCTION_INFO_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["A"], + SHARED_FUNCTION_INFO_TYPE, + SHARED_FUNCTION_INFO_TYPE, +] +handlers: [ +] + +--- +snippet: " + { + class B { + get #b() { return 1; } + } + } +" +frame size: 8 +parameter count: 1 +bytecode array length: 65 +bytecodes: [ + /* 30 E> */ B(StackCheck), + B(CreateBlockContext), U8(0), + B(PushContext), R(2), + B(LdaTheHole), + B(Star), R(6), + B(CreateClosure), U8(2), U8(0), U8(2), + B(Star), R(3), + B(LdaConstant), U8(1), + B(Star), R(4), + B(Mov), R(3), R(5), + B(CallRuntime), U16(Runtime::kDefineClass), R(4), U8(3), + B(Star), R(4), + B(Mov), R(5), R(1), + B(LdaConstant), U8(3), + B(Star), R(5), + B(CallRuntime), U16(Runtime::kCreatePrivateNameSymbol), R(5), U8(1), + B(StaCurrentContextSlot), U8(5), + B(CreateClosure), U8(4), U8(1), U8(2), + B(Star), R(6), + B(LdaNull), + B(Star), R(7), + B(CallRuntime), U16(Runtime::kCreatePrivateAccessors), R(6), U8(2), + B(StaCurrentContextSlot), U8(4), + B(PopContext), R(2), + B(Mov), R(1), R(0), + B(LdaUndefined), + /* 81 S> */ B(Return), +] +constant pool: [ + SCOPE_INFO_TYPE, + FIXED_ARRAY_TYPE, + SHARED_FUNCTION_INFO_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["B"], + SHARED_FUNCTION_INFO_TYPE, +] +handlers: [ +] + +--- +snippet: " + { + class C { + set #c(val) { } + } + } +" +frame size: 8 +parameter count: 1 +bytecode array length: 65 +bytecodes: [ + /* 30 E> */ B(StackCheck), + B(CreateBlockContext), U8(0), + B(PushContext), R(2), + B(LdaTheHole), + B(Star), R(6), + B(CreateClosure), U8(2), U8(0), U8(2), + B(Star), R(3), + B(LdaConstant), U8(1), + B(Star), R(4), + B(Mov), R(3), R(5), + B(CallRuntime), U16(Runtime::kDefineClass), R(4), U8(3), + B(Star), R(4), + B(Mov), R(5), R(1), + B(LdaConstant), U8(3), + B(Star), R(5), + B(CallRuntime), U16(Runtime::kCreatePrivateNameSymbol), R(5), U8(1), + B(StaCurrentContextSlot), U8(5), + B(LdaNull), + B(Star), R(6), + B(CreateClosure), U8(4), U8(1), U8(2), + B(Star), R(7), + B(CallRuntime), U16(Runtime::kCreatePrivateAccessors), R(6), U8(2), + B(StaCurrentContextSlot), U8(4), + B(PopContext), R(2), + B(Mov), R(1), R(0), + B(LdaUndefined), + /* 74 S> */ B(Return), +] +constant pool: [ + SCOPE_INFO_TYPE, + FIXED_ARRAY_TYPE, + SHARED_FUNCTION_INFO_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["C"], + SHARED_FUNCTION_INFO_TYPE, +] +handlers: [ +] + +--- +snippet: " + { + class D { + get #d() { return 1; } + set #d(val) { } + } + + class E extends D { + get #e() { return 2; } + set #e(val) { } + } + } +" +frame size: 10 +parameter count: 1 +bytecode array length: 133 +bytecodes: [ + /* 30 E> */ B(StackCheck), + B(CreateBlockContext), U8(0), + B(PushContext), R(4), + B(LdaTheHole), + B(Star), R(8), + B(CreateClosure), U8(2), U8(0), U8(2), + B(Star), R(5), + B(LdaConstant), U8(1), + B(Star), R(6), + B(Mov), R(5), R(7), + B(CallRuntime), U16(Runtime::kDefineClass), R(6), U8(3), + B(Star), R(6), + B(Mov), R(7), R(3), + B(LdaConstant), U8(3), + B(Star), R(7), + B(CallRuntime), U16(Runtime::kCreatePrivateNameSymbol), R(7), U8(1), + B(StaCurrentContextSlot), U8(5), + B(CreateClosure), U8(4), U8(1), U8(2), + B(Star), R(8), + B(CreateClosure), U8(5), U8(2), U8(2), + B(Star), R(9), + B(CallRuntime), U16(Runtime::kCreatePrivateAccessors), R(8), U8(2), + B(StaCurrentContextSlot), U8(4), + B(PopContext), R(4), + B(Mov), R(3), R(0), + /* 38 E> */ B(CreateBlockContext), U8(6), + B(PushContext), R(4), + /* 118 E> */ B(CreateClosure), U8(8), U8(3), U8(2), + B(Star), R(5), + B(LdaConstant), U8(7), + B(Star), R(6), + B(Mov), R(5), R(7), + B(Mov), R(3), R(8), + B(CallRuntime), U16(Runtime::kDefineClass), R(6), U8(3), + B(Star), R(6), + B(Mov), R(7), R(2), + B(LdaConstant), U8(9), + B(Star), R(7), + B(CallRuntime), U16(Runtime::kCreatePrivateNameSymbol), R(7), U8(1), + B(StaCurrentContextSlot), U8(5), + B(CreateClosure), U8(10), U8(4), U8(2), + B(Star), R(8), + B(CreateClosure), U8(11), U8(5), U8(2), + B(Star), R(9), + B(CallRuntime), U16(Runtime::kCreatePrivateAccessors), R(8), U8(2), + B(StaCurrentContextSlot), U8(4), + B(PopContext), R(4), + B(Mov), R(2), R(1), + B(LdaUndefined), + /* 175 S> */ B(Return), +] +constant pool: [ + SCOPE_INFO_TYPE, + FIXED_ARRAY_TYPE, + SHARED_FUNCTION_INFO_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["D"], + SHARED_FUNCTION_INFO_TYPE, + SHARED_FUNCTION_INFO_TYPE, + SCOPE_INFO_TYPE, + FIXED_ARRAY_TYPE, + SHARED_FUNCTION_INFO_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["E"], + SHARED_FUNCTION_INFO_TYPE, + SHARED_FUNCTION_INFO_TYPE, +] +handlers: [ +] + +--- +snippet: " + { + class A { foo() {} } + class C extends A { + get #a() { return super.foo; } + } + new C(); + } +" +frame size: 10 +parameter count: 1 +bytecode array length: 119 +bytecodes: [ + /* 30 E> */ B(StackCheck), + B(CreateBlockContext), U8(0), + B(PushContext), R(4), + B(LdaTheHole), + B(Star), R(8), + B(CreateClosure), U8(2), U8(0), U8(2), + B(Star), R(5), + B(LdaConstant), U8(1), + B(Star), R(6), + B(CreateClosure), U8(3), U8(1), U8(2), + B(Star), R(9), + B(Mov), R(5), R(7), + B(CallRuntime), U16(Runtime::kDefineClass), R(6), U8(4), + B(Star), R(6), + B(Mov), R(7), R(3), + B(PopContext), R(4), + B(Mov), R(3), R(0), + /* 38 E> */ B(CreateBlockContext), U8(4), + B(PushContext), R(4), + /* 77 E> */ B(CreateClosure), U8(6), U8(2), U8(2), + B(Star), R(5), + B(LdaConstant), U8(5), + B(Star), R(6), + B(Mov), R(5), R(7), + B(Mov), R(3), R(8), + B(CallRuntime), U16(Runtime::kDefineClass), R(6), U8(3), + B(Star), R(6), + B(Mov), R(7), R(2), + B(LdaConstant), U8(7), + B(Star), R(7), + B(CallRuntime), U16(Runtime::kCreatePrivateNameSymbol), R(7), U8(1), + B(StaCurrentContextSlot), U8(5), + B(CreateClosure), U8(8), U8(3), U8(2), + B(Star), R(8), + B(Ldar), R(6), + B(StaNamedProperty), R(8), U8(9), U8(0), + B(LdaNull), + B(Star), R(9), + B(CallRuntime), U16(Runtime::kCreatePrivateAccessors), R(8), U8(2), + B(StaCurrentContextSlot), U8(4), + B(PopContext), R(4), + B(Mov), R(2), R(1), + /* 122 S> */ B(Ldar), R(1), + /* 122 E> */ B(Construct), R(1), R(0), U8(0), U8(2), + B(LdaUndefined), + /* 133 S> */ B(Return), +] +constant pool: [ + SCOPE_INFO_TYPE, + FIXED_ARRAY_TYPE, + SHARED_FUNCTION_INFO_TYPE, + SHARED_FUNCTION_INFO_TYPE, + SCOPE_INFO_TYPE, + FIXED_ARRAY_TYPE, + SHARED_FUNCTION_INFO_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["C"], + SHARED_FUNCTION_INFO_TYPE, + SYMBOL_TYPE, +] +handlers: [ +] + +--- +snippet: " + { + class A { foo(val) {} } + class C extends A { + set #a(val) { super.foo(val); } + } + new C(); + } +" +frame size: 10 +parameter count: 1 +bytecode array length: 119 +bytecodes: [ + /* 30 E> */ B(StackCheck), + B(CreateBlockContext), U8(0), + B(PushContext), R(4), + B(LdaTheHole), + B(Star), R(8), + B(CreateClosure), U8(2), U8(0), U8(2), + B(Star), R(5), + B(LdaConstant), U8(1), + B(Star), R(6), + B(CreateClosure), U8(3), U8(1), U8(2), + B(Star), R(9), + B(Mov), R(5), R(7), + B(CallRuntime), U16(Runtime::kDefineClass), R(6), U8(4), + B(Star), R(6), + B(Mov), R(7), R(3), + B(PopContext), R(4), + B(Mov), R(3), R(0), + /* 38 E> */ B(CreateBlockContext), U8(4), + B(PushContext), R(4), + /* 80 E> */ B(CreateClosure), U8(6), U8(2), U8(2), + B(Star), R(5), + B(LdaConstant), U8(5), + B(Star), R(6), + B(Mov), R(5), R(7), + B(Mov), R(3), R(8), + B(CallRuntime), U16(Runtime::kDefineClass), R(6), U8(3), + B(Star), R(6), + B(Mov), R(7), R(2), + B(LdaConstant), U8(7), + B(Star), R(7), + B(CallRuntime), U16(Runtime::kCreatePrivateNameSymbol), R(7), U8(1), + B(StaCurrentContextSlot), U8(5), + B(LdaNull), + B(Star), R(8), + B(CreateClosure), U8(8), U8(3), U8(2), + B(Star), R(9), + B(Ldar), R(6), + B(StaNamedProperty), R(9), U8(9), U8(0), + B(CallRuntime), U16(Runtime::kCreatePrivateAccessors), R(8), U8(2), + B(StaCurrentContextSlot), U8(4), + B(PopContext), R(4), + B(Mov), R(2), R(1), + /* 126 S> */ B(Ldar), R(1), + /* 126 E> */ B(Construct), R(1), R(0), U8(0), U8(2), + B(LdaUndefined), + /* 137 S> */ B(Return), +] +constant pool: [ + SCOPE_INFO_TYPE, + FIXED_ARRAY_TYPE, + SHARED_FUNCTION_INFO_TYPE, + SHARED_FUNCTION_INFO_TYPE, + SCOPE_INFO_TYPE, + FIXED_ARRAY_TYPE, + SHARED_FUNCTION_INFO_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["C"], + SHARED_FUNCTION_INFO_TYPE, + SYMBOL_TYPE, +] +handlers: [ +] + diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/PrivateMethodAccess.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/PrivateMethodAccess.golden new file mode 100644 index 0000000000..d41b342187 --- /dev/null +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/PrivateMethodAccess.golden @@ -0,0 +1,104 @@ +# +# Autogenerated by generate-bytecode-expectations. +# + +--- +wrap: no +test function name: test +private methods: yes + +--- +snippet: " + class A { + #a() { return 1; } + constructor() { return this.#a(); } + } + + var test = A; + new A; +" +frame size: 3 +parameter count: 1 +bytecode array length: 28 +bytecodes: [ + /* 44 E> */ B(StackCheck), + B(LdaCurrentContextSlot), U8(5), + B(Star), R(1), + B(Mov), R(this), R(0), + B(CallRuntime), U16(Runtime::kAddPrivateBrand), R(0), U8(2), + /* 49 S> */ B(LdaCurrentContextSlot), U8(5), + /* 61 E> */ B(LdaKeyedProperty), R(this), U8(0), + B(LdaCurrentContextSlot), U8(4), + B(Star), R(2), + /* 63 E> */ B(CallAnyReceiver), R(2), R(this), U8(1), U8(2), + /* 66 S> */ B(Return), +] +constant pool: [ +] +handlers: [ +] + +--- +snippet: " + class B { + #b() { return 1; } + constructor() { this.#b = 1; } + } + + var test = B; + new test; +" +frame size: 4 +parameter count: 1 +bytecode array length: 29 +bytecodes: [ + /* 44 E> */ B(StackCheck), + B(LdaCurrentContextSlot), U8(5), + B(Star), R(1), + B(Mov), R(this), R(0), + B(CallRuntime), U16(Runtime::kAddPrivateBrand), R(0), U8(2), + /* 49 S> */ B(Wide), B(LdaSmi), I16(261), + B(Star), R(2), + B(LdaConstant), U8(0), + B(Star), R(3), + /* 57 E> */ B(CallRuntime), U16(Runtime::kNewTypeError), R(2), U8(2), + B(Throw), +] +constant pool: [ + ONE_BYTE_INTERNALIZED_STRING_TYPE ["#b"], +] +handlers: [ +] + +--- +snippet: " + class C { + #c() { return 1; } + constructor() { this.#c++; } + } + + var test = C; + new test; +" +frame size: 4 +parameter count: 1 +bytecode array length: 29 +bytecodes: [ + /* 44 E> */ B(StackCheck), + B(LdaCurrentContextSlot), U8(5), + B(Star), R(1), + B(Mov), R(this), R(0), + B(CallRuntime), U16(Runtime::kAddPrivateBrand), R(0), U8(2), + /* 49 S> */ B(Wide), B(LdaSmi), I16(261), + B(Star), R(2), + B(LdaConstant), U8(0), + B(Star), R(3), + B(CallRuntime), U16(Runtime::kNewTypeError), R(2), U8(2), + B(Throw), +] +constant pool: [ + ONE_BYTE_INTERNALIZED_STRING_TYPE ["#c"], +] +handlers: [ +] + diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/PrivateMethodDeclaration.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/PrivateMethodDeclaration.golden new file mode 100644 index 0000000000..d1aab34fda --- /dev/null +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/PrivateMethodDeclaration.golden @@ -0,0 +1,198 @@ +# +# Autogenerated by generate-bytecode-expectations. +# + +--- +wrap: yes +private methods: yes + +--- +snippet: " + { + class A { + #a() { return 1; } + } + } +" +frame size: 7 +parameter count: 1 +bytecode array length: 55 +bytecodes: [ + /* 30 E> */ B(StackCheck), + B(CreateBlockContext), U8(0), + B(PushContext), R(2), + B(LdaTheHole), + B(Star), R(6), + B(CreateClosure), U8(2), U8(0), U8(2), + B(Star), R(3), + B(LdaConstant), U8(1), + B(Star), R(4), + B(CreateClosure), U8(3), U8(1), U8(2), + B(StaCurrentContextSlot), U8(4), + B(Mov), R(3), R(5), + B(CallRuntime), U16(Runtime::kDefineClass), R(4), U8(3), + B(Star), R(4), + B(Mov), R(5), R(1), + B(LdaConstant), U8(4), + B(Star), R(5), + B(CallRuntime), U16(Runtime::kCreatePrivateNameSymbol), R(5), U8(1), + B(StaCurrentContextSlot), U8(5), + B(PopContext), R(2), + B(Mov), R(1), R(0), + B(LdaUndefined), + /* 77 S> */ B(Return), +] +constant pool: [ + SCOPE_INFO_TYPE, + FIXED_ARRAY_TYPE, + SHARED_FUNCTION_INFO_TYPE, + SHARED_FUNCTION_INFO_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["A"], +] +handlers: [ +] + +--- +snippet: " + { + class D { + #d() { return 1; } + } + class E extends D { + #e() { return 2; } + } + } +" +frame size: 9 +parameter count: 1 +bytecode array length: 107 +bytecodes: [ + /* 30 E> */ B(StackCheck), + B(CreateBlockContext), U8(0), + B(PushContext), R(4), + B(LdaTheHole), + B(Star), R(8), + B(CreateClosure), U8(2), U8(0), U8(2), + B(Star), R(5), + B(LdaConstant), U8(1), + B(Star), R(6), + B(CreateClosure), U8(3), U8(1), U8(2), + B(StaCurrentContextSlot), U8(4), + B(Mov), R(5), R(7), + B(CallRuntime), U16(Runtime::kDefineClass), R(6), U8(3), + B(Star), R(6), + B(Mov), R(7), R(3), + B(LdaConstant), U8(4), + B(Star), R(7), + B(CallRuntime), U16(Runtime::kCreatePrivateNameSymbol), R(7), U8(1), + B(StaCurrentContextSlot), U8(5), + B(PopContext), R(4), + B(Mov), R(3), R(0), + /* 38 E> */ B(CreateBlockContext), U8(5), + B(PushContext), R(4), + /* 93 E> */ B(CreateClosure), U8(7), U8(2), U8(2), + B(Star), R(5), + B(LdaConstant), U8(6), + B(Star), R(6), + B(CreateClosure), U8(8), U8(3), U8(2), + B(StaCurrentContextSlot), U8(4), + B(Mov), R(5), R(7), + B(Mov), R(3), R(8), + B(CallRuntime), U16(Runtime::kDefineClass), R(6), U8(3), + B(Star), R(6), + B(Mov), R(7), R(2), + B(LdaConstant), U8(9), + B(Star), R(7), + B(CallRuntime), U16(Runtime::kCreatePrivateNameSymbol), R(7), U8(1), + B(StaCurrentContextSlot), U8(5), + B(PopContext), R(4), + B(Mov), R(2), R(1), + B(LdaUndefined), + /* 126 S> */ B(Return), +] +constant pool: [ + SCOPE_INFO_TYPE, + FIXED_ARRAY_TYPE, + SHARED_FUNCTION_INFO_TYPE, + SHARED_FUNCTION_INFO_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["D"], + SCOPE_INFO_TYPE, + FIXED_ARRAY_TYPE, + SHARED_FUNCTION_INFO_TYPE, + SHARED_FUNCTION_INFO_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["E"], +] +handlers: [ +] + +--- +snippet: " + { + class A { foo() {} } + class C extends A { + #m() { return super.foo; } + } + } +" +frame size: 10 +parameter count: 1 +bytecode array length: 106 +bytecodes: [ + /* 30 E> */ B(StackCheck), + B(CreateBlockContext), U8(0), + B(PushContext), R(4), + B(LdaTheHole), + B(Star), R(8), + B(CreateClosure), U8(2), U8(0), U8(2), + B(Star), R(5), + B(LdaConstant), U8(1), + B(Star), R(6), + B(CreateClosure), U8(3), U8(1), U8(2), + B(Star), R(9), + B(Mov), R(5), R(7), + B(CallRuntime), U16(Runtime::kDefineClass), R(6), U8(4), + B(Star), R(6), + B(Mov), R(7), R(3), + B(PopContext), R(4), + B(Mov), R(3), R(0), + /* 38 E> */ B(CreateBlockContext), U8(4), + B(PushContext), R(4), + /* 77 E> */ B(CreateClosure), U8(6), U8(2), U8(2), + B(Star), R(5), + B(LdaConstant), U8(5), + B(Star), R(6), + B(CreateClosure), U8(7), U8(3), U8(2), + B(StaCurrentContextSlot), U8(4), + B(Mov), R(5), R(7), + B(Mov), R(3), R(8), + B(CallRuntime), U16(Runtime::kDefineClass), R(6), U8(3), + B(Star), R(6), + B(Mov), R(7), R(2), + B(LdaConstant), U8(8), + B(Star), R(7), + B(CallRuntime), U16(Runtime::kCreatePrivateNameSymbol), R(7), U8(1), + B(StaCurrentContextSlot), U8(5), + B(LdaCurrentContextSlot), U8(4), + B(Star), R(8), + B(Ldar), R(6), + B(StaNamedProperty), R(8), U8(9), U8(0), + B(PopContext), R(4), + B(Mov), R(2), R(1), + B(LdaUndefined), + /* 118 S> */ B(Return), +] +constant pool: [ + SCOPE_INFO_TYPE, + FIXED_ARRAY_TYPE, + SHARED_FUNCTION_INFO_TYPE, + SHARED_FUNCTION_INFO_TYPE, + SCOPE_INFO_TYPE, + FIXED_ARRAY_TYPE, + SHARED_FUNCTION_INFO_TYPE, + SHARED_FUNCTION_INFO_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["C"], + SYMBOL_TYPE, +] +handlers: [ +] + diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/PrivateMethods.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/PrivateMethods.golden deleted file mode 100644 index 5821a20069..0000000000 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/PrivateMethods.golden +++ /dev/null @@ -1,160 +0,0 @@ -# -# Autogenerated by generate-bytecode-expectations. -# - ---- -wrap: yes -private methods: yes - ---- -snippet: " - { - class A { - #a() { return 1; } - callA() { return this.#a(); } - } - - const a = new A; - a.callA(); - } -" -frame size: 9 -parameter count: 1 -bytecode array length: 80 -bytecodes: [ - /* 30 E> */ B(StackCheck), - B(CreateBlockContext), U8(0), - B(PushContext), R(3), - B(LdaTheHole), - B(Star), R(7), - B(CreateClosure), U8(2), U8(0), U8(2), - B(Star), R(4), - B(LdaConstant), U8(1), - B(Star), R(5), - B(CreateClosure), U8(3), U8(1), U8(2), - B(StaCurrentContextSlot), U8(4), - B(CreateClosure), U8(4), U8(2), U8(2), - B(Star), R(8), - B(Mov), R(4), R(6), - B(CallRuntime), U16(Runtime::kDefineClass), R(5), U8(4), - B(Star), R(5), - B(Mov), R(6), R(2), - B(LdaConstant), U8(5), - B(Star), R(6), - B(CallRuntime), U16(Runtime::kCreatePrivateNameSymbol), R(6), U8(1), - B(StaCurrentContextSlot), U8(5), - B(PopContext), R(3), - B(Mov), R(2), R(0), - /* 122 S> */ B(Ldar), R(0), - /* 122 E> */ B(Construct), R(0), R(0), U8(0), U8(0), - B(Star), R(1), - /* 133 S> */ B(LdaNamedProperty), R(1), U8(6), U8(2), - B(Star), R(3), - /* 133 E> */ B(CallProperty0), R(3), R(1), U8(4), - B(LdaUndefined), - /* 144 S> */ B(Return), -] -constant pool: [ - SCOPE_INFO_TYPE, - FIXED_ARRAY_TYPE, - SHARED_FUNCTION_INFO_TYPE, - SHARED_FUNCTION_INFO_TYPE, - SHARED_FUNCTION_INFO_TYPE, - ONE_BYTE_INTERNALIZED_STRING_TYPE ["A"], - ONE_BYTE_INTERNALIZED_STRING_TYPE ["callA"], -] -handlers: [ -] - ---- -snippet: " - { - class D { - #d() { return 1; } - callD() { return this.#d(); } - } - - class E extends D { - #e() { return 2; } - callE() { return this.callD() + this.#e(); } - } - - const e = new E; - e.callE(); - } -" -frame size: 11 -parameter count: 1 -bytecode array length: 138 -bytecodes: [ - /* 30 E> */ B(StackCheck), - B(CreateBlockContext), U8(0), - B(PushContext), R(5), - B(LdaTheHole), - B(Star), R(9), - B(CreateClosure), U8(2), U8(0), U8(2), - B(Star), R(6), - B(LdaConstant), U8(1), - B(Star), R(7), - B(CreateClosure), U8(3), U8(1), U8(2), - B(StaCurrentContextSlot), U8(4), - B(CreateClosure), U8(4), U8(2), U8(2), - B(Star), R(10), - B(Mov), R(6), R(8), - B(CallRuntime), U16(Runtime::kDefineClass), R(7), U8(4), - B(Star), R(7), - B(Mov), R(8), R(4), - B(LdaConstant), U8(5), - B(Star), R(8), - B(CallRuntime), U16(Runtime::kCreatePrivateNameSymbol), R(8), U8(1), - B(StaCurrentContextSlot), U8(5), - B(PopContext), R(5), - B(Mov), R(4), R(0), - /* 38 E> */ B(CreateBlockContext), U8(6), - B(PushContext), R(5), - /* 128 E> */ B(CreateClosure), U8(8), U8(3), U8(2), - B(Star), R(6), - B(LdaConstant), U8(7), - B(Star), R(7), - B(CreateClosure), U8(9), U8(4), U8(2), - B(StaCurrentContextSlot), U8(4), - B(CreateClosure), U8(10), U8(5), U8(2), - B(Star), R(10), - B(Mov), R(6), R(8), - B(Mov), R(4), R(9), - B(CallRuntime), U16(Runtime::kDefineClass), R(7), U8(4), - B(Star), R(7), - B(Mov), R(8), R(3), - B(LdaConstant), U8(11), - B(Star), R(8), - B(CallRuntime), U16(Runtime::kCreatePrivateNameSymbol), R(8), U8(1), - B(StaCurrentContextSlot), U8(5), - B(PopContext), R(5), - B(Mov), R(3), R(1), - /* 221 S> */ B(Ldar), R(1), - /* 221 E> */ B(Construct), R(1), R(0), U8(0), U8(0), - B(Star), R(2), - /* 232 S> */ B(LdaNamedProperty), R(2), U8(12), U8(2), - B(Star), R(5), - /* 232 E> */ B(CallProperty0), R(5), R(2), U8(4), - B(LdaUndefined), - /* 243 S> */ B(Return), -] -constant pool: [ - SCOPE_INFO_TYPE, - FIXED_ARRAY_TYPE, - SHARED_FUNCTION_INFO_TYPE, - SHARED_FUNCTION_INFO_TYPE, - SHARED_FUNCTION_INFO_TYPE, - ONE_BYTE_INTERNALIZED_STRING_TYPE ["D"], - SCOPE_INFO_TYPE, - FIXED_ARRAY_TYPE, - SHARED_FUNCTION_INFO_TYPE, - SHARED_FUNCTION_INFO_TYPE, - SHARED_FUNCTION_INFO_TYPE, - ONE_BYTE_INTERNALIZED_STRING_TYPE ["E"], - ONE_BYTE_INTERNALIZED_STRING_TYPE ["callE"], -] -handlers: [ -] - diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/StandardForLoop.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/StandardForLoop.golden index 9cb5a6b01c..1a4ad60629 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/StandardForLoop.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/StandardForLoop.golden @@ -220,13 +220,10 @@ snippet: " " frame size: 4 parameter count: 1 -bytecode array length: 53 +bytecode array length: 44 bytecodes: [ /* 10 E> */ B(StackCheck), /* 37 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(41), - B(JumpIfNull), U8(4), - B(JumpIfNotUndefined), U8(7), - /* 26 E> */ B(CallRuntime), U16(Runtime::kThrowPatternAssignmentNonCoercible), R(0), U8(0), B(Star), R(3), /* 28 S> */ B(LdaNamedProperty), R(3), U8(1), U8(1), B(Star), R(0), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/SuperCallAndSpread.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/SuperCallAndSpread.golden index 74849d1c85..e3eed68138 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/SuperCallAndSpread.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/SuperCallAndSpread.golden @@ -91,9 +91,9 @@ snippet: " test = new B(1, 2, 3).constructor; })(); " -frame size: 13 +frame size: 12 parameter count: 1 -bytecode array length: 128 +bytecode array length: 124 bytecodes: [ B(CreateRestParameter), B(Star), R(3), @@ -111,23 +111,22 @@ bytecodes: [ B(Ldar), R(6), B(Inc), U8(3), /* 152 S> */ B(Star), R(6), - B(LdaNamedProperty), R(3), U8(0), U8(4), + B(GetIterator), R(3), U8(4), B(Star), R(11), B(CallProperty0), R(11), R(3), U8(6), - B(Mov), R(3), R(10), B(Mov), R(1), R(4), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), B(Star), R(9), - B(LdaNamedProperty), R(9), U8(1), U8(8), + B(LdaNamedProperty), R(9), U8(0), U8(8), B(Star), R(8), B(CallProperty0), R(8), R(9), U8(14), - B(Star), R(12), + B(Star), R(10), B(JumpIfJSReceiver), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(12), U8(1), - B(LdaNamedProperty), R(12), U8(2), U8(16), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(10), U8(1), + B(LdaNamedProperty), R(10), U8(1), U8(16), B(JumpIfToBooleanTrue), U8(19), - B(LdaNamedProperty), R(12), U8(3), U8(10), + B(LdaNamedProperty), R(10), U8(2), U8(10), B(StaInArrayLiteral), R(7), R(6), U8(1), B(Ldar), R(6), B(Inc), U8(3), @@ -147,7 +146,6 @@ bytecodes: [ /* 162 S> */ B(Return), ] constant pool: [ - SYMBOL_TYPE, ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/WideRegisters.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/WideRegisters.golden index 19a09ba49c..066d6e9f03 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/WideRegisters.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/WideRegisters.golden @@ -2655,7 +2655,7 @@ snippet: " " frame size: 163 parameter count: 1 -bytecode array length: 626 +bytecode array length: 624 bytecodes: [ /* 30 E> */ B(StackCheck), /* 43 S> */ B(LdaZero), @@ -2977,8 +2977,7 @@ bytecodes: [ /* 2146 S> */ B(LdaZero), B(Star), R(1), /* 2162 S> */ B(Ldar), R(0), - B(JumpIfUndefined), U8(74), - B(JumpIfNull), U8(72), + B(JumpIfUndefinedOrNull), U8(72), B(Wide), B(ToObject), R16(157), B(Wide), B(ForInEnumerate), R16(157), B(Wide), B(ForInPrepare), R16(158), U16(0), diff --git a/deps/v8/test/cctest/interpreter/test-bytecode-generator.cc b/deps/v8/test/cctest/interpreter/test-bytecode-generator.cc index e1601d4642..fda02933aa 100644 --- a/deps/v8/test/cctest/interpreter/test-bytecode-generator.cc +++ b/deps/v8/test/cctest/interpreter/test-bytecode-generator.cc @@ -2758,7 +2758,7 @@ TEST(PrivateClassFields) { LoadGolden("PrivateClassFields.golden"))); } -TEST(PrivateMethods) { +TEST(PrivateMethodDeclaration) { bool old_methods_flag = i::FLAG_harmony_private_methods; i::FLAG_harmony_private_methods = true; InitializedIgnitionHandleScope scope; @@ -2768,30 +2768,179 @@ TEST(PrivateMethods) { "{\n" " class A {\n" " #a() { return 1; }\n" - " callA() { return this.#a(); }\n" " }\n" - "\n" - " const a = new A;\n" - " a.callA();\n" "}\n", "{\n" " class D {\n" " #d() { return 1; }\n" - " callD() { return this.#d(); }\n" " }\n" - "\n" " class E extends D {\n" " #e() { return 2; }\n" - " callE() { return this.callD() + this.#e(); }\n" + " }\n" + "}\n", + + "{\n" + " class A { foo() {} }\n" + " class C extends A {\n" + " #m() { return super.foo; }\n" + " }\n" + "}\n"}; + + CHECK(CompareTexts(BuildActual(printer, snippets), + LoadGolden("PrivateMethodDeclaration.golden"))); + i::FLAG_harmony_private_methods = old_methods_flag; +} + +TEST(PrivateMethodAccess) { + bool old_methods_flag = i::FLAG_harmony_private_methods; + i::FLAG_harmony_private_methods = true; + InitializedIgnitionHandleScope scope; + BytecodeExpectationsPrinter printer(CcTest::isolate()); + printer.set_wrap(false); + printer.set_test_function_name("test"); + + const char* snippets[] = { + "class A {\n" + " #a() { return 1; }\n" + " constructor() { return this.#a(); }\n" + "}\n" + "\n" + "var test = A;\n" + "new A;\n", + + "class B {\n" + " #b() { return 1; }\n" + " constructor() { this.#b = 1; }\n" + "}\n" + "\n" + "var test = B;\n" + "new test;\n", + + "class C {\n" + " #c() { return 1; }\n" + " constructor() { this.#c++; }\n" + "}\n" + "\n" + "var test = C;\n" + "new test;\n"}; + + CHECK(CompareTexts(BuildActual(printer, snippets), + LoadGolden("PrivateMethodAccess.golden"))); + i::FLAG_harmony_private_methods = old_methods_flag; +} + +TEST(PrivateAccessorAccess) { + bool old_methods_flag = i::FLAG_harmony_private_methods; + i::FLAG_harmony_private_methods = true; + InitializedIgnitionHandleScope scope; + BytecodeExpectationsPrinter printer(CcTest::isolate()); + printer.set_wrap(false); + printer.set_test_function_name("test"); + + const char* snippets[] = { + "class A {\n" + " get #a() { return 1; }\n" + " set #a(val) { }\n" + "\n" + " constructor() {\n" + " this.#a++;\n" + " this.#a = 1;\n" + " return this.#a;\n" + " }\n" + "}\n" + "var test = A;\n" + "new test;\n", + + "class B {\n" + " get #b() { return 1; }\n" + " constructor() { this.#b++; }\n" + "}\n" + "var test = B;\n" + "new test;\n", + + "class C {\n" + " set #c(val) { }\n" + " constructor() { this.#c++; }\n" + "}\n" + "var test = C;\n" + "new test;\n", + + "class D {\n" + " get #d() { return 1; }\n" + " constructor() { this.#d = 1; }\n" + "}\n" + "var test = D;\n" + "new test;\n", + + "class E {\n" + " set #e(val) { }\n" + " constructor() { this.#e; }\n" + "}\n" + "var test = E;\n" + "new test;\n"}; + + CHECK(CompareTexts(BuildActual(printer, snippets), + LoadGolden("PrivateAccessorAccess.golden"))); + i::FLAG_harmony_private_methods = old_methods_flag; +} + +TEST(PrivateAccessorDeclaration) { + bool old_methods_flag = i::FLAG_harmony_private_methods; + i::FLAG_harmony_private_methods = true; + InitializedIgnitionHandleScope scope; + BytecodeExpectationsPrinter printer(CcTest::isolate()); + + const char* snippets[] = { + "{\n" + " class A {\n" + " get #a() { return 1; }\n" + " set #a(val) { }\n" + " }\n" + "}\n", + + "{\n" + " class B {\n" + " get #b() { return 1; }\n" + " }\n" + "}\n", + + "{\n" + " class C {\n" + " set #c(val) { }\n" + " }\n" + "}\n", + + "{\n" + " class D {\n" + " get #d() { return 1; }\n" + " set #d(val) { }\n" " }\n" "\n" - " const e = new E;\n" - " e.callE();\n" + " class E extends D {\n" + " get #e() { return 2; }\n" + " set #e(val) { }\n" + " }\n" + "}\n", + + "{\n" + " class A { foo() {} }\n" + " class C extends A {\n" + " get #a() { return super.foo; }\n" + " }\n" + " new C();\n" + "}\n", + + "{\n" + " class A { foo(val) {} }\n" + " class C extends A {\n" + " set #a(val) { super.foo(val); }\n" + " }\n" + " new C();\n" "}\n"}; CHECK(CompareTexts(BuildActual(printer, snippets), - LoadGolden("PrivateMethods.golden"))); + LoadGolden("PrivateAccessorDeclaration.golden"))); i::FLAG_harmony_private_methods = old_methods_flag; } diff --git a/deps/v8/test/cctest/libplatform/test-tracing.cc b/deps/v8/test/cctest/libplatform/test-tracing.cc index d20dfff652..a98445be97 100644 --- a/deps/v8/test/cctest/libplatform/test-tracing.cc +++ b/deps/v8/test/cctest/libplatform/test-tracing.cc @@ -23,14 +23,10 @@ class TestDataSource : public perfetto::DataSource<TestDataSource> { public: void OnSetup(const SetupArgs&) override {} - void OnStart(const StartArgs&) override { started_.Signal(); } + void OnStart(const StartArgs&) override {} void OnStop(const StopArgs&) override {} - - static v8::base::Semaphore started_; }; -v8::base::Semaphore TestDataSource::started_{0}; - PERFETTO_DEFINE_DATA_SOURCE_STATIC_MEMBERS(TestDataSource); #endif // V8_USE_PERFETTO @@ -625,8 +621,6 @@ TEST(Perfetto) { TRACE_EVENT1("v8", "test2", "arg1", uint64_arg); TRACE_EVENT2("v8", "test3", "arg1", uint64_arg, "arg2", str_arg); } - TRACE_EVENT_INSTANT0("v8", "final event not captured", - TRACE_EVENT_SCOPE_THREAD); harness.StopTracing(); @@ -688,8 +682,6 @@ TEST(Categories) { TRACE_EVENT0("cat", "v8.Test2"); TRACE_EVENT0("v8", "v8.Test3"); } - TRACE_EVENT_INSTANT0("v8", "final event not captured", - TRACE_EVENT_SCOPE_THREAD); harness.StopTracing(); @@ -765,8 +757,6 @@ TEST(MultipleArgsAndCopy) { std::move(trace_event_arg), "a2", new ConvertableToTraceFormatMock(123)); } - TRACE_EVENT_INSTANT0("v8", "final event not captured", - TRACE_EVENT_SCOPE_THREAD); harness.StopTracing(); @@ -894,8 +884,6 @@ TEST(JsonIntegrationTest) { TRACE_EVENT1("v8", "v8.Test.3", "3", inf_num); TRACE_EVENT1("v8", "v8.Test.4", "4", neg_inf_num); } - TRACE_EVENT_INSTANT0("v8", "final event not captured", - TRACE_EVENT_SCOPE_THREAD); harness.StopTracing(); std::string json = harness.perfetto_json_stream(); @@ -922,8 +910,7 @@ TEST(TracingPerfetto) { auto tracing_session_ = perfetto::Tracing::NewTrace(perfetto::BackendType::kInProcessBackend); tracing_session_->Setup(perfetto_trace_config); - tracing_session_->Start(); - TestDataSource::started_.Wait(); + tracing_session_->StartBlocking(); for (int i = 0; i < 15; i++) { TestDataSource::Trace([&](TestDataSource::TraceContext ctx) { @@ -938,10 +925,7 @@ TEST(TracingPerfetto) { trace_event->set_thread_timestamp(123); }); } - v8::base::Semaphore stopped_{0}; - tracing_session_->SetOnStopCallback([&stopped_]() { stopped_.Signal(); }); - tracing_session_->Stop(); - stopped_.Wait(); + tracing_session_->StopBlocking(); std::ostringstream perfetto_json_stream_; @@ -957,6 +941,40 @@ TEST(TracingPerfetto) { CHECK_GT(perfetto_json_stream_.str().length(), 0); } +TEST(StartAndStopRepeated) { + for (int i = 0; i < 3; i++) { + ::perfetto::TraceConfig perfetto_trace_config; + perfetto_trace_config.add_buffers()->set_size_kb(4096); + auto* ds_config = + perfetto_trace_config.add_data_sources()->mutable_config(); + ds_config->set_name("v8.trace_events"); + + perfetto::DataSourceDescriptor dsd; + dsd.set_name("v8.trace_events"); + TestDataSource::Register(dsd); + + auto tracing_session_ = + perfetto::Tracing::NewTrace(perfetto::BackendType::kInProcessBackend); + tracing_session_->Setup(perfetto_trace_config); + tracing_session_->StartBlocking(); + + for (int i = 0; i < 15; i++) { + TestDataSource::Trace([&](TestDataSource::TraceContext ctx) { + auto packet = ctx.NewTracePacket(); + auto* trace_event_bundle = packet->set_chrome_events(); + auto* trace_event = trace_event_bundle->add_trace_events(); + + trace_event->set_phase('c'); + trace_event->set_thread_id(v8::base::OS::GetCurrentThreadId()); + trace_event->set_timestamp(123); + trace_event->set_process_id(v8::base::OS::GetCurrentProcessId()); + trace_event->set_thread_timestamp(123); + }); + } + tracing_session_->StopBlocking(); + } +} + #endif // V8_USE_PERFETTO } // namespace tracing diff --git a/deps/v8/test/cctest/parsing/test-scanner-streams.cc b/deps/v8/test/cctest/parsing/test-scanner-streams.cc index 39d95897d6..35b7048bb0 100644 --- a/deps/v8/test/cctest/parsing/test-scanner-streams.cc +++ b/deps/v8/test/cctest/parsing/test-scanner-streams.cc @@ -776,6 +776,43 @@ TEST(RelocatingCharacterStream) { CHECK_EQ('d', two_byte_string_stream->Advance()); } +TEST(RelocatingUnbufferedCharacterStream) { + ManualGCScope manual_gc_scope; + CcTest::InitializeVM(); + i::Isolate* i_isolate = CcTest::i_isolate(); + v8::HandleScope scope(CcTest::isolate()); + + const char16_t* string = u"abc\u2603"; + int length = static_cast<int>(std::char_traits<char16_t>::length(string)); + std::unique_ptr<i::uc16[]> uc16_buffer(new i::uc16[length]); + for (int i = 0; i < length; i++) { + uc16_buffer[i] = string[i]; + } + i::Vector<const i::uc16> two_byte_vector(uc16_buffer.get(), length); + i::Handle<i::String> two_byte_string = + i_isolate->factory() + ->NewStringFromTwoByte(two_byte_vector, i::AllocationType::kYoung) + .ToHandleChecked(); + std::unique_ptr<i::Utf16CharacterStream> two_byte_string_stream( + i::ScannerStream::For(i_isolate, two_byte_string, 0, length)); + + // Seek to offset 2 so that the buffer_pos_ is not zero initially. + two_byte_string_stream->Seek(2); + CHECK_EQ('c', two_byte_string_stream->Advance()); + CHECK_EQ(size_t{3}, two_byte_string_stream->pos()); + + i::String raw = *two_byte_string; + i_isolate->heap()->CollectGarbage(i::NEW_SPACE, + i::GarbageCollectionReason::kUnknown); + // GC moved the string and buffer was updated to the correct location. + CHECK_NE(raw, *two_byte_string); + + // Check that we correctly moved based on buffer_pos_, not based on a position + // of zero. + CHECK_EQ(u'\u2603', two_byte_string_stream->Advance()); + CHECK_EQ(size_t{4}, two_byte_string_stream->pos()); +} + TEST(CloneCharacterStreams) { v8::HandleScope handles(CcTest::isolate()); v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); diff --git a/deps/v8/test/cctest/test-accessor-assembler.cc b/deps/v8/test/cctest/test-accessor-assembler.cc index 20a2bc2d80..c88c85b586 100644 --- a/deps/v8/test/cctest/test-accessor-assembler.cc +++ b/deps/v8/test/cctest/test-accessor-assembler.cc @@ -18,6 +18,7 @@ namespace internal { using compiler::CodeAssemblerTester; using compiler::FunctionTester; using compiler::Node; +using compiler::TNode; namespace { @@ -129,8 +130,9 @@ TEST(TryProbeStubCache) { { Node* receiver = m.Parameter(0); - Node* name = m.Parameter(1); - Node* expected_handler = m.Parameter(2); + TNode<Object> name = m.CAST(m.Parameter(1)); + TNode<MaybeObject> expected_handler = + m.UncheckedCast<MaybeObject>(m.Parameter(2)); Label passed(&m), failed(&m); @@ -140,12 +142,11 @@ TEST(TryProbeStubCache) { m.TryProbeStubCache(&stub_cache, receiver, name, &if_handler, &var_handler, &if_miss); m.BIND(&if_handler); - m.Branch(m.WordEqual(expected_handler, - m.BitcastMaybeObjectToWord(var_handler.value())), - &passed, &failed); + m.Branch(m.TaggedEqual(expected_handler, var_handler.value()), &passed, + &failed); m.BIND(&if_miss); - m.Branch(m.WordEqual(expected_handler, m.IntPtrConstant(0)), &passed, + m.Branch(m.TaggedEqual(expected_handler, m.SmiConstant(0)), &passed, &failed); m.BIND(&passed); diff --git a/deps/v8/test/cctest/test-api-stack-traces.cc b/deps/v8/test/cctest/test-api-stack-traces.cc index bceba18c4a..26941793c6 100644 --- a/deps/v8/test/cctest/test-api-stack-traces.cc +++ b/deps/v8/test/cctest/test-api-stack-traces.cc @@ -250,31 +250,31 @@ static void AnalyzeStackInNativeCode( v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace( args.GetIsolate(), 5, v8::StackTrace::kOverview); CHECK_EQ(3, stackTrace->GetFrameCount()); - checkStackFrame(nullptr, "function.name", 3, 1, true, false, + checkStackFrame(nullptr, "function.name", 1, 1, true, false, stackTrace->GetFrame(isolate, 0)); } else if (testGroup == kDisplayName) { v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace( args.GetIsolate(), 5, v8::StackTrace::kOverview); CHECK_EQ(3, stackTrace->GetFrameCount()); - checkStackFrame(nullptr, "function.displayName", 3, 1, true, false, + checkStackFrame(nullptr, "function.displayName", 1, 1, true, false, stackTrace->GetFrame(isolate, 0)); } else if (testGroup == kFunctionNameAndDisplayName) { v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace( args.GetIsolate(), 5, v8::StackTrace::kOverview); CHECK_EQ(3, stackTrace->GetFrameCount()); - checkStackFrame(nullptr, "function.displayName", 3, 1, true, false, + checkStackFrame(nullptr, "function.displayName", 1, 1, true, false, stackTrace->GetFrame(isolate, 0)); } else if (testGroup == kDisplayNameIsNotString) { v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace( args.GetIsolate(), 5, v8::StackTrace::kOverview); CHECK_EQ(3, stackTrace->GetFrameCount()); - checkStackFrame(nullptr, "function.name", 3, 1, true, false, + checkStackFrame(nullptr, "function.name", 1, 1, true, false, stackTrace->GetFrame(isolate, 0)); } else if (testGroup == kFunctionNameIsNotString) { v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace( args.GetIsolate(), 5, v8::StackTrace::kOverview); CHECK_EQ(3, stackTrace->GetFrameCount()); - checkStackFrame(nullptr, "", 3, 1, true, false, + checkStackFrame(nullptr, "", 1, 1, true, false, stackTrace->GetFrame(isolate, 0)); } } diff --git a/deps/v8/test/cctest/test-api.cc b/deps/v8/test/cctest/test-api.cc index 73bea08d08..1a670a9b10 100644 --- a/deps/v8/test/cctest/test-api.cc +++ b/deps/v8/test/cctest/test-api.cc @@ -12975,7 +12975,7 @@ void ApiTestFuzzer::SetUp(PartOfTest part) { RegisterThreadedTest::nth(i)->fuzzer_ = new ApiTestFuzzer(i + start); } for (int i = 0; i < active_tests_; i++) { - RegisterThreadedTest::nth(i)->fuzzer_->Start(); + CHECK(RegisterThreadedTest::nth(i)->fuzzer_->Start()); } } @@ -18386,8 +18386,8 @@ TEST(MultipleIsolatesOnIndividualThreads) { IsolateThread thread2(12); // Compute some fibonacci numbers on 3 threads in 3 isolates. - thread1.Start(); - thread2.Start(); + CHECK(thread1.Start()); + CHECK(thread2.Start()); int result1 = CalcFibonacci(CcTest::isolate(), 21); int result2 = CalcFibonacci(CcTest::isolate(), 12); @@ -18481,7 +18481,7 @@ class InitDefaultIsolateThread : public v8::base::Thread { static void InitializeTestHelper(InitDefaultIsolateThread::TestCase testCase) { InitDefaultIsolateThread thread(testCase); - thread.Start(); + CHECK(thread.Start()); thread.Join(); CHECK(thread.result()); } @@ -19953,6 +19953,71 @@ TEST(ScopedMicrotasks) { env->GetIsolate()->SetMicrotasksPolicy(v8::MicrotasksPolicy::kScoped); { v8::MicrotasksScope scope1(env->GetIsolate(), + v8::MicrotasksScope::kRunMicrotasks); + env->GetIsolate()->EnqueueMicrotask( + Function::New(env.local(), MicrotaskOne).ToLocalChecked()); + CompileRun("var ext1Calls = 0;"); + } + { + v8::MicrotasksScope scope1(env->GetIsolate(), + v8::MicrotasksScope::kRunMicrotasks); + ExpectInt32("ext1Calls", 1); + } + { + v8::MicrotasksScope scope1(env->GetIsolate(), + v8::MicrotasksScope::kRunMicrotasks); + env->GetIsolate()->EnqueueMicrotask( + Function::New(env.local(), MicrotaskOne).ToLocalChecked()); + CompileRun("throw new Error()"); + } + { + v8::MicrotasksScope scope1(env->GetIsolate(), + v8::MicrotasksScope::kRunMicrotasks); + ExpectInt32("ext1Calls", 2); + } + { + v8::MicrotasksScope scope1(env->GetIsolate(), + v8::MicrotasksScope::kRunMicrotasks); + env->GetIsolate()->EnqueueMicrotask( + Function::New(env.local(), MicrotaskOne).ToLocalChecked()); + v8::TryCatch try_catch(env->GetIsolate()); + CompileRun("throw new Error()"); + } + { + v8::MicrotasksScope scope1(env->GetIsolate(), + v8::MicrotasksScope::kRunMicrotasks); + ExpectInt32("ext1Calls", 3); + } + { + v8::MicrotasksScope scope1(env->GetIsolate(), + v8::MicrotasksScope::kRunMicrotasks); + env->GetIsolate()->EnqueueMicrotask( + Function::New(env.local(), MicrotaskOne).ToLocalChecked()); + env->GetIsolate()->TerminateExecution(); + { + v8::MicrotasksScope scope2(env->GetIsolate(), + v8::MicrotasksScope::kRunMicrotasks); + env->GetIsolate()->EnqueueMicrotask( + Function::New(env.local(), MicrotaskOne).ToLocalChecked()); + } + } + env->GetIsolate()->CancelTerminateExecution(); + { + v8::MicrotasksScope scope1(env->GetIsolate(), + v8::MicrotasksScope::kRunMicrotasks); + ExpectInt32("ext1Calls", 3); + env->GetIsolate()->EnqueueMicrotask( + Function::New(env.local(), MicrotaskOne).ToLocalChecked()); + } + { + v8::MicrotasksScope scope1(env->GetIsolate(), + v8::MicrotasksScope::kRunMicrotasks); + + ExpectInt32("ext1Calls", 4); + } + + { + v8::MicrotasksScope scope1(env->GetIsolate(), v8::MicrotasksScope::kDoNotRunMicrotasks); env->GetIsolate()->EnqueueMicrotask( Function::New(env.local(), MicrotaskOne).ToLocalChecked()); @@ -20746,7 +20811,7 @@ class ThreadInterruptTest { void RunTest() { InterruptThread i_thread(this); - i_thread.Start(); + CHECK(i_thread.Start()); sem_.Wait(); CHECK_EQ(kExpectedValue, sem_value_); @@ -21009,7 +21074,7 @@ class RegExpInterruptTest { v8::HandleScope handle_scope(isolate_); i_thread.SetTestBody(test_body_fn); - i_thread.Start(); + CHECK(i_thread.Start()); TestBody(); @@ -21213,7 +21278,7 @@ class RequestInterruptTestBaseWithSimpleInterrupt public: RequestInterruptTestBaseWithSimpleInterrupt() : i_thread(this) { } - void StartInterruptThread() override { i_thread.Start(); } + void StartInterruptThread() override { CHECK(i_thread.Start()); } private: class InterruptThread : public v8::base::Thread { @@ -21444,7 +21509,7 @@ class RequestMultipleInterrupts : public RequestInterruptTestBase { public: RequestMultipleInterrupts() : i_thread(this), counter_(0) {} - void StartInterruptThread() override { i_thread.Start(); } + void StartInterruptThread() override { CHECK(i_thread.Start()); } void TestBody() override { Local<Function> func = Function::New(env_.local(), ShouldContinueCallback, @@ -24851,7 +24916,7 @@ TEST(FutexInterruption) { FutexInterruptionThread timeout_thread(isolate); v8::TryCatch try_catch(CcTest::isolate()); - timeout_thread.Start(); + CHECK(timeout_thread.Start()); CompileRun( "var ab = new SharedArrayBuffer(4);" @@ -25268,7 +25333,7 @@ TEST(MemoryPressure) { LocalContext env; MemoryPressureThread memory_pressure_thread( isolate, v8::MemoryPressureLevel::kCritical); - memory_pressure_thread.Start(); + CHECK(memory_pressure_thread.Start()); memory_pressure_thread.Join(); // This should trigger GC. CHECK_EQ(0, counter.NumberOfWeakCalls()); @@ -26080,7 +26145,7 @@ void AtomicsWaitCallbackForTesting( break; case AtomicsWaitCallbackAction::StopFromThreadAndThrow: info->stop_thread = v8::base::make_unique<StopAtomicsWaitThread>(info); - info->stop_thread->Start(); + CHECK(info->stop_thread->Start()); break; case AtomicsWaitCallbackAction::KeepWaiting: break; diff --git a/deps/v8/test/cctest/test-assembler-arm64.cc b/deps/v8/test/cctest/test-assembler-arm64.cc index 1f6b732808..4fdf30ef64 100644 --- a/deps/v8/test/cctest/test-assembler-arm64.cc +++ b/deps/v8/test/cctest/test-assembler-arm64.cc @@ -234,6 +234,15 @@ static void InitializeVM() { #define CHECK_FULL_HEAP_OBJECT_IN_REGISTER(expected, result) \ CHECK(Equal64(expected->ptr(), &core, result)) +#define CHECK_NOT_ZERO_AND_NOT_EQUAL_64(reg0, reg1) \ + { \ + int64_t value0 = core.xreg(reg0.code()); \ + int64_t value1 = core.xreg(reg1.code()); \ + CHECK_NE(0, value0); \ + CHECK_NE(0, value1); \ + CHECK_NE(value0, value1); \ + } + #define CHECK_EQUAL_FP64(expected, result) \ CHECK(EqualFP64(expected, &core, result)) @@ -1982,75 +1991,142 @@ TEST(test_branch) { CHECK_EQUAL_64(0, x3); } +namespace { +// Generate a block of code that, when hit, always jumps to `landing_pad`. +void GenerateLandingNops(MacroAssembler* masm, int n, Label* landing_pad) { + for (int i = 0; i < (n - 1); i++) { + if (i % 100 == 0) { + masm->B(landing_pad); + } else { + masm->Nop(); + } + } + masm->B(landing_pad); +} +} // namespace + TEST(far_branch_backward) { INIT_V8(); - // Test that the MacroAssembler correctly resolves backward branches to labels - // that are outside the immediate range of branch instructions. - int max_range = - std::max(Instruction::ImmBranchRange(TestBranchType), - std::max(Instruction::ImmBranchRange(CompareBranchType), - Instruction::ImmBranchRange(CondBranchType))); + ImmBranchType branch_types[] = {TestBranchType, CompareBranchType, + CondBranchType}; - SETUP_SIZE(max_range + 1000 * kInstrSize); + for (ImmBranchType type : branch_types) { + int range = Instruction::ImmBranchRange(type); - START(); + SETUP_SIZE(range + 1000 * kInstrSize); - Label done, fail; - Label test_tbz, test_cbz, test_bcond; - Label success_tbz, success_cbz, success_bcond; + START(); - __ Mov(x0, 0); - __ Mov(x1, 1); - __ Mov(x10, 0); + Label done, fail; + Label near, far, in_range, out_of_range; - __ B(&test_tbz); - __ Bind(&success_tbz); - __ Orr(x0, x0, 1 << 0); - __ B(&test_cbz); - __ Bind(&success_cbz); - __ Orr(x0, x0, 1 << 1); - __ B(&test_bcond); - __ Bind(&success_bcond); - __ Orr(x0, x0, 1 << 2); + __ Mov(x0, 0); + __ Mov(x1, 1); + __ Mov(x10, 0); - __ B(&done); + __ B(&near); + __ Bind(&in_range); + __ Orr(x0, x0, 1 << 0); - // Generate enough code to overflow the immediate range of the three types of - // branches below. - for (int i = 0; i < max_range / kInstrSize + 1; ++i) { - if (i % 100 == 0) { - // If we do land in this code, we do not want to execute so many nops - // before reaching the end of test (especially if tracing is activated). - __ B(&fail); - } else { - __ Nop(); - } - } - __ B(&fail); + __ B(&far); + __ Bind(&out_of_range); + __ Orr(x0, x0, 1 << 1); - __ Bind(&test_tbz); - __ Tbz(x10, 7, &success_tbz); - __ Bind(&test_cbz); - __ Cbz(x10, &success_cbz); - __ Bind(&test_bcond); - __ Cmp(x10, 0); - __ B(eq, &success_bcond); + __ B(&done); - // For each out-of-range branch instructions, at least two instructions should - // have been generated. - CHECK_GE(7 * kInstrSize, __ SizeOfCodeGeneratedSince(&test_tbz)); + // We use a slack and an approximate budget instead of checking precisely + // when the branch limit is hit, since veneers and literal pool can mess + // with our calculation of where the limit is. + // In this test, we want to make sure we support backwards branches and the + // range is more-or-less correct. It's not a big deal if the macro-assembler + // got the range a little wrong, as long as it's not far off which could + // affect performance. + + int budget = + (range - static_cast<int>(__ SizeOfCodeGeneratedSince(&in_range))) / + kInstrSize; + + const int kSlack = 100; + + // Generate enough code so that the next branch will be in range but we are + // close to the limit. + GenerateLandingNops(&masm, budget - kSlack, &fail); + + __ Bind(&near); + switch (type) { + case TestBranchType: + __ Tbz(x10, 3, &in_range); + // This should be: + // TBZ <in_range> + CHECK_EQ(1 * kInstrSize, __ SizeOfCodeGeneratedSince(&near)); + break; + case CompareBranchType: + __ Cbz(x10, &in_range); + // This should be: + // CBZ <in_range> + CHECK_EQ(1 * kInstrSize, __ SizeOfCodeGeneratedSince(&near)); + break; + case CondBranchType: + __ Cmp(x10, 0); + __ B(eq, &in_range); + // This should be: + // CMP + // B.EQ <in_range> + CHECK_EQ(2 * kInstrSize, __ SizeOfCodeGeneratedSince(&near)); + break; + default: + UNREACHABLE(); + break; + } - __ Bind(&fail); - __ Mov(x1, 0); - __ Bind(&done); + // Now go past the limit so that branches are now out of range. + GenerateLandingNops(&masm, kSlack * 2, &fail); + + __ Bind(&far); + switch (type) { + case TestBranchType: + __ Tbz(x10, 5, &out_of_range); + // This should be: + // TBNZ <skip> + // B <out_of_range> + // skip: + CHECK_EQ(2 * kInstrSize, __ SizeOfCodeGeneratedSince(&far)); + break; + case CompareBranchType: + __ Cbz(x10, &out_of_range); + // This should be: + // CBNZ <skip> + // B <out_of_range> + // skip: + CHECK_EQ(2 * kInstrSize, __ SizeOfCodeGeneratedSince(&far)); + break; + case CondBranchType: + __ Cmp(x10, 0); + __ B(eq, &out_of_range); + // This should be: + // CMP + // B.NE <skip> + // B <out_of_range> + // skip: + CHECK_EQ(3 * kInstrSize, __ SizeOfCodeGeneratedSince(&far)); + break; + default: + UNREACHABLE(); + break; + } - END(); + __ Bind(&fail); + __ Mov(x1, 0); + __ Bind(&done); - RUN(); + END(); - CHECK_EQUAL_64(0x7, x0); - CHECK_EQUAL_64(0x1, x1); + RUN(); + + CHECK_EQUAL_64(0x3, x0); + CHECK_EQUAL_64(1, x1); + } } TEST(far_branch_simple_veneer) { @@ -2177,18 +2253,7 @@ TEST(far_branch_veneer_link_chain) { // Generate enough code to overflow the immediate range of the three types of // branches below. - for (int i = 0; i < max_range / kInstrSize + 1; ++i) { - if (i % 100 == 0) { - // If we do land in this code, we do not want to execute so many nops - // before reaching the end of test (especially if tracing is activated). - // Also, the branches give the MacroAssembler the opportunity to emit the - // veneers. - __ B(&fail); - } else { - __ Nop(); - } - } - __ B(&fail); + GenerateLandingNops(&masm, (max_range / kInstrSize) + 1, &fail); __ Bind(&success_tbz); __ Orr(x0, x0, 1 << 0); @@ -2219,7 +2284,58 @@ TEST(far_branch_veneer_broken_link_chain) { // a branch from the link chain of a label and the two links on each side of // the removed branch cannot be linked together (out of range). // - // We test with tbz because it has a small range. + // We want to generate the following code, we test with tbz because it has a + // small range: + // + // ~~~ + // 1: B <far> + // : + // : + // : + // 2: TBZ <far> -------. + // : | + // : | out of range + // : | + // 3: TBZ <far> | + // | | + // | in range | + // V | + // far: <-' + // ~~~ + // + // If we say that the range of TBZ is 3 lines on this graph, then we can get + // into a situation where the link chain gets broken. When emitting the two + // TBZ instructions, we are in range of the previous branch in the chain so + // we'll generate a TBZ and not a TBNZ+B sequence that can encode a bigger + // range. + // + // However, the first TBZ (2), is out of range of the far label so a veneer + // will be generated after the second TBZ (3). And this will result in a + // broken chain because we can no longer link from (3) back to (1). + // + // ~~~ + // 1: B <far> <-. + // : + // : out of range + // : + // 2: TBZ <veneer> : + // : + // : + // : + // 3: TBZ <far> ----' + // + // B <skip> + // veneer: + // B <far> + // skip: + // + // far: + // ~~~ + // + // This test makes sure the MacroAssembler is able to resolve this case by, + // for instance, resolving (1) early and making it jump to <veneer> instead of + // <far>. + int max_range = Instruction::ImmBranchRange(TestBranchType); int inter_range = max_range / 2 + max_range / 10; @@ -2240,44 +2356,42 @@ TEST(far_branch_veneer_broken_link_chain) { __ Mov(x0, 1); __ B(&far_target); - for (int i = 0; i < inter_range / kInstrSize; ++i) { - if (i % 100 == 0) { - // Do not allow generating veneers. They should not be needed. - __ b(&fail); - } else { - __ Nop(); - } - } + GenerateLandingNops(&masm, inter_range / kInstrSize, &fail); // Will need a veneer to point to reach the target. __ Bind(&test_2); __ Mov(x0, 2); - __ Tbz(x10, 7, &far_target); - - for (int i = 0; i < inter_range / kInstrSize; ++i) { - if (i % 100 == 0) { - // Do not allow generating veneers. They should not be needed. - __ b(&fail); - } else { - __ Nop(); - } + { + Label tbz; + __ Bind(&tbz); + __ Tbz(x10, 7, &far_target); + // This should be a single TBZ since the previous link is in range at this + // point. + CHECK_EQ(1 * kInstrSize, __ SizeOfCodeGeneratedSince(&tbz)); } + GenerateLandingNops(&masm, inter_range / kInstrSize, &fail); + // Does not need a veneer to reach the target, but the initial branch // instruction is out of range. __ Bind(&test_3); __ Mov(x0, 3); - __ Tbz(x10, 7, &far_target); - - for (int i = 0; i < inter_range / kInstrSize; ++i) { - if (i % 100 == 0) { - // Allow generating veneers. - __ B(&fail); - } else { - __ Nop(); - } + { + Label tbz; + __ Bind(&tbz); + __ Tbz(x10, 7, &far_target); + // This should be a single TBZ since the previous link is in range at this + // point. + CHECK_EQ(1 * kInstrSize, __ SizeOfCodeGeneratedSince(&tbz)); } + // A veneer will be generated for the first TBZ, which will then remove the + // label from the chain and break it because the second TBZ is out of range of + // the first branch. + // The MacroAssembler should be able to cope with this. + + GenerateLandingNops(&masm, inter_range / kInstrSize, &fail); + __ B(&fail); __ Bind(&far_target); @@ -11478,6 +11592,79 @@ TEST(system_msr) { CHECK_EQUAL_64(0, x10); } +TEST(system_pauth_a) { + SETUP(); + START(); + + // Exclude x16 and x17 from the scratch register list so we can use + // Pac/Autia1716 safely. + UseScratchRegisterScope temps(&masm); + temps.Exclude(x16, x17); + temps.Include(x10, x11); + + // Backup stack pointer. + __ Mov(x20, sp); + + // Modifiers + __ Mov(x16, 0x477d469dec0b8768); + __ Mov(sp, 0x477d469dec0b8760); + + // Generate PACs using the 3 system instructions. + __ Mov(x17, 0x0000000012345678); + __ Pacia1716(); + __ Mov(x0, x17); + + __ Mov(lr, 0x0000000012345678); + __ Paciasp(); + __ Mov(x2, lr); + + // Authenticate the pointers above. + __ Mov(x17, x0); + __ Autia1716(); + __ Mov(x3, x17); + + __ Mov(lr, x2); + __ Autiasp(); + __ Mov(x5, lr); + + // Attempt to authenticate incorrect pointers. + __ Mov(x17, x2); + __ Autia1716(); + __ Mov(x6, x17); + + __ Mov(lr, x0); + __ Autiasp(); + __ Mov(x8, lr); + + // Restore stack pointer. + __ Mov(sp, x20); + + // Mask out just the PAC code bits. + __ And(x0, x0, 0x007f000000000000); + __ And(x2, x2, 0x007f000000000000); + + END(); + +// TODO(all): test on real hardware when available +#ifdef USE_SIMULATOR + RUN(); + + // Check PAC codes have been generated and aren't equal. + // NOTE: with a different ComputePAC implementation, there may be a collision. + CHECK_NE(0, core.xreg(2)); + CHECK_NOT_ZERO_AND_NOT_EQUAL_64(x0, x2); + + // Pointers correctly authenticated. + CHECK_EQUAL_64(0x0000000012345678, x3); + CHECK_EQUAL_64(0x0000000012345678, x5); + + // Pointers corrupted after failing to authenticate. + CHECK_EQUAL_64(0x0020000012345678, x6); + CHECK_EQUAL_64(0x0020000012345678, x8); + +#endif // USE_SIMULATOR +} + TEST(system) { INIT_V8(); SETUP(); @@ -14703,6 +14890,7 @@ TEST(internal_reference_linked) { #undef CHECK_EQUAL_FP32 #undef CHECK_EQUAL_64 #undef CHECK_FULL_HEAP_OBJECT_IN_REGISTER +#undef CHECK_NOT_ZERO_AND_NOT_EQUAL_64 #undef CHECK_EQUAL_FP64 #undef CHECK_EQUAL_128 #undef CHECK_CONSTANT_POOL_SIZE diff --git a/deps/v8/test/cctest/test-circular-queue.cc b/deps/v8/test/cctest/test-circular-queue.cc index 7b0475ff80..5525540d2b 100644 --- a/deps/v8/test/cctest/test-circular-queue.cc +++ b/deps/v8/test/cctest/test-circular-queue.cc @@ -148,7 +148,7 @@ TEST(SamplingCircularQueueMultithreading) { ProducerThread producer3(&scq, kRecordsPerChunk, 20, &semaphore); CHECK(!scq.Peek()); - producer1.Start(); + CHECK(producer1.Start()); semaphore.Wait(); for (Record i = 1; i < 1 + kRecordsPerChunk; ++i) { Record* rec = reinterpret_cast<Record*>(scq.Peek()); @@ -160,7 +160,7 @@ TEST(SamplingCircularQueueMultithreading) { } CHECK(!scq.Peek()); - producer2.Start(); + CHECK(producer2.Start()); semaphore.Wait(); for (Record i = 10; i < 10 + kRecordsPerChunk; ++i) { Record* rec = reinterpret_cast<Record*>(scq.Peek()); @@ -172,7 +172,7 @@ TEST(SamplingCircularQueueMultithreading) { } CHECK(!scq.Peek()); - producer3.Start(); + CHECK(producer3.Start()); semaphore.Wait(); for (Record i = 20; i < 20 + kRecordsPerChunk; ++i) { Record* rec = reinterpret_cast<Record*>(scq.Peek()); diff --git a/deps/v8/test/cctest/test-code-stub-assembler.cc b/deps/v8/test/cctest/test-code-stub-assembler.cc index e7fc946675..3a4f11e126 100644 --- a/deps/v8/test/cctest/test-code-stub-assembler.cc +++ b/deps/v8/test/cctest/test-code-stub-assembler.cc @@ -53,9 +53,9 @@ Handle<String> MakeName(const char* str, int suffix) { return MakeString(buffer.begin()); } -int sum9(int a0, int a1, int a2, int a3, int a4, int a5, int a6, int a7, - int a8) { - return a0 + a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8; +int sum10(int a0, int a1, int a2, int a3, int a4, int a5, int a6, int a7, + int a8, int a9) { + return a0 + a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9; } static int sum3(int a0, int a1, int a2) { return a0 + a1 + a2; } @@ -70,8 +70,8 @@ TEST(CallCFunction) { CodeStubAssembler m(asm_tester.state()); { - Node* const fun_constant = m.ExternalConstant( - ExternalReference::Create(reinterpret_cast<Address>(sum9))); + TNode<ExternalReference> const fun_constant = m.ExternalConstant( + ExternalReference::Create(reinterpret_cast<Address>(sum10))); MachineType type_intptr = MachineType::IntPtr(); @@ -85,14 +85,15 @@ TEST(CallCFunction) { std::make_pair(type_intptr, m.IntPtrConstant(5)), std::make_pair(type_intptr, m.IntPtrConstant(6)), std::make_pair(type_intptr, m.IntPtrConstant(7)), - std::make_pair(type_intptr, m.IntPtrConstant(8))); + std::make_pair(type_intptr, m.IntPtrConstant(8)), + std::make_pair(type_intptr, m.IntPtrConstant(9))); m.Return(m.SmiTag(result)); } FunctionTester ft(asm_tester.GenerateCode(), kNumParams); Handle<Object> result = ft.Call().ToHandleChecked(); - CHECK_EQ(36, Handle<Smi>::cast(result)->value()); + CHECK_EQ(45, Handle<Smi>::cast(result)->value()); } TEST(CallCFunctionWithCallerSavedRegisters) { @@ -103,7 +104,7 @@ TEST(CallCFunctionWithCallerSavedRegisters) { CodeStubAssembler m(asm_tester.state()); { - Node* const fun_constant = m.ExternalConstant( + TNode<ExternalReference> const fun_constant = m.ExternalConstant( ExternalReference::Create(reinterpret_cast<Address>(sum3))); MachineType type_intptr = MachineType::IntPtr(); @@ -311,7 +312,7 @@ TEST(DecodeWordFromWord32) { CodeAssemblerTester asm_tester(isolate); CodeStubAssembler m(asm_tester.state()); - class TestBitField : public BitField<unsigned, 3, 3> {}; + using TestBitField = BitField<unsigned, 3, 3>; m.Return(m.SmiTag( m.Signed(m.DecodeWordFromWord32<TestBitField>(m.Int32Constant(0x2F))))); FunctionTester ft(asm_tester.GenerateCode()); @@ -430,35 +431,38 @@ TEST(TryToName) { enum Result { kKeyIsIndex, kKeyIsUnique, kBailout }; { Node* key = m.Parameter(0); - Node* expected_result = m.Parameter(1); - Node* expected_arg = m.Parameter(2); + TNode<MaybeObject> expected_result = + m.UncheckedCast<MaybeObject>(m.Parameter(1)); + TNode<Object> expected_arg = m.CAST(m.Parameter(2)); Label passed(&m), failed(&m); Label if_keyisindex(&m), if_keyisunique(&m), if_bailout(&m); { - Variable var_index(&m, MachineType::PointerRepresentation()); - Variable var_unique(&m, MachineRepresentation::kTagged); + TYPED_VARIABLE_DEF(IntPtrT, var_index, &m); + TYPED_VARIABLE_DEF(Object, var_unique, &m); m.TryToName(key, &if_keyisindex, &var_index, &if_keyisunique, &var_unique, &if_bailout); m.BIND(&if_keyisindex); - m.GotoIfNot(m.WordEqual(expected_result, - m.SmiConstant(Smi::FromInt(kKeyIsIndex))), + m.GotoIfNot(m.TaggedEqual(expected_result, + m.SmiConstant(Smi::FromInt(kKeyIsIndex))), &failed); - m.Branch(m.WordEqual(m.SmiUntag(expected_arg), var_index.value()), - &passed, &failed); + m.Branch( + m.IntPtrEqual(m.SmiUntag(m.CAST(expected_arg)), var_index.value()), + &passed, &failed); m.BIND(&if_keyisunique); - m.GotoIfNot(m.WordEqual(expected_result, - m.SmiConstant(Smi::FromInt(kKeyIsUnique))), + m.GotoIfNot(m.TaggedEqual(expected_result, + m.SmiConstant(Smi::FromInt(kKeyIsUnique))), &failed); - m.Branch(m.WordEqual(expected_arg, var_unique.value()), &passed, &failed); + m.Branch(m.TaggedEqual(expected_arg, var_unique.value()), &passed, + &failed); } m.BIND(&if_bailout); m.Branch( - m.WordEqual(expected_result, m.SmiConstant(Smi::FromInt(kBailout))), + m.TaggedEqual(expected_result, m.SmiConstant(Smi::FromInt(kBailout))), &passed, &failed); m.BIND(&passed); @@ -653,7 +657,7 @@ void TestNameDictionaryLookup() { &var_name_index, &if_not_found); m.BIND(&if_found); m.GotoIfNot( - m.WordEqual(expected_result, m.SmiConstant(Smi::FromInt(kFound))), + m.TaggedEqual(expected_result, m.SmiConstant(Smi::FromInt(kFound))), &failed); m.Branch( m.WordEqual(m.SmiUntag(m.CAST(expected_arg)), var_name_index.value()), @@ -661,7 +665,7 @@ void TestNameDictionaryLookup() { m.BIND(&if_not_found); m.Branch( - m.WordEqual(expected_result, m.SmiConstant(Smi::FromInt(kNotFound))), + m.TaggedEqual(expected_result, m.SmiConstant(Smi::FromInt(kNotFound))), &passed, &failed); m.BIND(&passed); @@ -756,14 +760,14 @@ TEST(NumberDictionaryLookup) { &if_not_found); m.BIND(&if_found); m.GotoIfNot( - m.WordEqual(expected_result, m.SmiConstant(Smi::FromInt(kFound))), + m.TaggedEqual(expected_result, m.SmiConstant(Smi::FromInt(kFound))), &failed); m.Branch(m.WordEqual(m.SmiUntag(m.CAST(expected_arg)), var_entry.value()), &passed, &failed); m.BIND(&if_not_found); m.Branch( - m.WordEqual(expected_result, m.SmiConstant(Smi::FromInt(kNotFound))), + m.TaggedEqual(expected_result, m.SmiConstant(Smi::FromInt(kNotFound))), &passed, &failed); m.BIND(&passed); @@ -847,12 +851,12 @@ TEST(TransitionLookup) { &if_not_found); BIND(&if_found); - GotoIfNot(WordEqual(expected_result, SmiConstant(kFound)), &failed); - Branch(WordEqual(expected_arg, SmiTag(var_transition_index.value())), + GotoIfNot(TaggedEqual(expected_result, SmiConstant(kFound)), &failed); + Branch(TaggedEqual(expected_arg, SmiTag(var_transition_index.value())), &passed, &failed); BIND(&if_not_found); - Branch(WordEqual(expected_result, SmiConstant(kNotFound)), &passed, + Branch(TaggedEqual(expected_result, SmiConstant(kNotFound)), &passed, &failed); BIND(&passed); @@ -1010,29 +1014,31 @@ TEST(TryHasOwnProperty) { { Node* object = m.Parameter(0); Node* unique_name = m.Parameter(1); - Node* expected_result = m.Parameter(2); + TNode<MaybeObject> expected_result = + m.UncheckedCast<MaybeObject>(m.Parameter(2)); Label passed(&m), failed(&m); Label if_found(&m), if_not_found(&m), if_bailout(&m); - Node* map = m.LoadMap(object); - Node* instance_type = m.LoadMapInstanceType(map); + TNode<Map> map = m.LoadMap(object); + TNode<Uint16T> instance_type = m.LoadMapInstanceType(map); m.TryHasOwnProperty(object, map, instance_type, unique_name, &if_found, &if_not_found, &if_bailout); m.BIND(&if_found); - m.Branch(m.WordEqual(expected_result, m.SmiConstant(Smi::FromInt(kFound))), - &passed, &failed); + m.Branch( + m.TaggedEqual(expected_result, m.SmiConstant(Smi::FromInt(kFound))), + &passed, &failed); m.BIND(&if_not_found); m.Branch( - m.WordEqual(expected_result, m.SmiConstant(Smi::FromInt(kNotFound))), + m.TaggedEqual(expected_result, m.SmiConstant(Smi::FromInt(kNotFound))), &passed, &failed); m.BIND(&if_bailout); m.Branch( - m.WordEqual(expected_result, m.SmiConstant(Smi::FromInt(kBailout))), + m.TaggedEqual(expected_result, m.SmiConstant(Smi::FromInt(kBailout))), &passed, &failed); m.BIND(&passed); @@ -1207,8 +1213,8 @@ TEST(TryGetOwnProperty) { Variable var_value(&m, MachineRepresentation::kTagged); Label if_found(&m), if_not_found(&m), if_bailout(&m); - Node* map = m.LoadMap(object); - Node* instance_type = m.LoadMapInstanceType(map); + TNode<Map> map = m.LoadMap(object); + TNode<Uint16T> instance_type = m.LoadMapInstanceType(map); m.TryGetOwnProperty(context, object, object, map, instance_type, unique_name, &if_found, &var_value, &if_not_found, @@ -1421,34 +1427,37 @@ TEST(TryLookupElement) { enum Result { kFound, kAbsent, kNotFound, kBailout }; { Node* object = m.Parameter(0); - Node* index = m.SmiUntag(m.Parameter(1)); - Node* expected_result = m.Parameter(2); + TNode<IntPtrT> index = m.SmiUntag(m.Parameter(1)); + TNode<MaybeObject> expected_result = + m.UncheckedCast<MaybeObject>(m.Parameter(2)); Label passed(&m), failed(&m); Label if_found(&m), if_not_found(&m), if_bailout(&m), if_absent(&m); - Node* map = m.LoadMap(object); - Node* instance_type = m.LoadMapInstanceType(map); + TNode<Map> map = m.LoadMap(object); + TNode<Uint16T> instance_type = m.LoadMapInstanceType(map); m.TryLookupElement(object, map, instance_type, index, &if_found, &if_absent, &if_not_found, &if_bailout); m.BIND(&if_found); - m.Branch(m.WordEqual(expected_result, m.SmiConstant(Smi::FromInt(kFound))), - &passed, &failed); + m.Branch( + m.TaggedEqual(expected_result, m.SmiConstant(Smi::FromInt(kFound))), + &passed, &failed); m.BIND(&if_absent); - m.Branch(m.WordEqual(expected_result, m.SmiConstant(Smi::FromInt(kAbsent))), - &passed, &failed); + m.Branch( + m.TaggedEqual(expected_result, m.SmiConstant(Smi::FromInt(kAbsent))), + &passed, &failed); m.BIND(&if_not_found); m.Branch( - m.WordEqual(expected_result, m.SmiConstant(Smi::FromInt(kNotFound))), + m.TaggedEqual(expected_result, m.SmiConstant(Smi::FromInt(kNotFound))), &passed, &failed); m.BIND(&if_bailout); m.Branch( - m.WordEqual(expected_result, m.SmiConstant(Smi::FromInt(kBailout))), + m.TaggedEqual(expected_result, m.SmiConstant(Smi::FromInt(kBailout))), &passed, &failed); m.BIND(&passed); @@ -1600,19 +1609,19 @@ TEST(TryLookupElement) { CHECK_NOT_FOUND(object, 42); } -// TODO(ishell): uncomment once NO_ELEMENTS kind is supported. -// { -// Handle<Map> map = Map::Create(isolate, 0); -// map->set_elements_kind(NO_ELEMENTS); -// Handle<JSObject> object = factory->NewJSObjectFromMap(map); -// CHECK_EQ(NO_ELEMENTS, object->map()->elements_kind()); -// -// CHECK_NOT_FOUND(object, 0); -// CHECK_NOT_FOUND(object, 1); -// CHECK_NOT_FOUND(object, 7); -// CHECK_NOT_FOUND(object, 13); -// CHECK_NOT_FOUND(object, 42); -// } + // TODO(ishell): uncomment once NO_ELEMENTS kind is supported. + // { + // Handle<Map> map = Map::Create(isolate, 0); + // map->set_elements_kind(NO_ELEMENTS); + // Handle<JSObject> object = factory->NewJSObjectFromMap(map); + // CHECK_EQ(NO_ELEMENTS, object->map()->elements_kind()); + // + // CHECK_NOT_FOUND(object, 0); + // CHECK_NOT_FOUND(object, 1); + // CHECK_NOT_FOUND(object, 7); + // CHECK_NOT_FOUND(object, 13); + // CHECK_NOT_FOUND(object, 42); + // } #undef CHECK_FOUND #undef CHECK_NOT_FOUND @@ -1652,7 +1661,8 @@ TEST(AllocateJSObjectFromMap) { Node* properties = m.Parameter(1); Node* elements = m.Parameter(2); - Node* result = m.AllocateJSObjectFromMap(map, properties, elements); + TNode<JSObject> result = + m.AllocateJSObjectFromMap(map, properties, elements); CodeStubAssembler::Label done(&m); m.GotoIfNot(m.IsJSArrayMap(map), &done); @@ -1722,7 +1732,8 @@ TEST(AllocateNameDictionary) { { Node* capacity = m.Parameter(0); - Node* result = m.AllocateNameDictionary(m.SmiUntag(capacity)); + TNode<NameDictionary> result = + m.AllocateNameDictionary(m.SmiUntag(capacity)); m.Return(result); } @@ -1931,11 +1942,11 @@ TEST(Arguments) { CodeStubArguments arguments(&m, m.IntPtrConstant(3)); CSA_ASSERT( - &m, m.WordEqual(arguments.AtIndex(0), m.SmiConstant(Smi::FromInt(12)))); + &m, m.TaggedEqual(arguments.AtIndex(0), m.SmiConstant(Smi::FromInt(12)))); CSA_ASSERT( - &m, m.WordEqual(arguments.AtIndex(1), m.SmiConstant(Smi::FromInt(13)))); + &m, m.TaggedEqual(arguments.AtIndex(1), m.SmiConstant(Smi::FromInt(13)))); CSA_ASSERT( - &m, m.WordEqual(arguments.AtIndex(2), m.SmiConstant(Smi::FromInt(14)))); + &m, m.TaggedEqual(arguments.AtIndex(2), m.SmiConstant(Smi::FromInt(14)))); arguments.PopAndReturn(arguments.GetReceiver()); @@ -1959,17 +1970,17 @@ TEST(ArgumentsWithSmiConstantIndices) { CodeStubAssembler::SMI_PARAMETERS); CSA_ASSERT(&m, - m.WordEqual(arguments.AtIndex(m.SmiConstant(0), - CodeStubAssembler::SMI_PARAMETERS), - m.SmiConstant(Smi::FromInt(12)))); + m.TaggedEqual(arguments.AtIndex(m.SmiConstant(0), + CodeStubAssembler::SMI_PARAMETERS), + m.SmiConstant(Smi::FromInt(12)))); CSA_ASSERT(&m, - m.WordEqual(arguments.AtIndex(m.SmiConstant(1), - CodeStubAssembler::SMI_PARAMETERS), - m.SmiConstant(Smi::FromInt(13)))); + m.TaggedEqual(arguments.AtIndex(m.SmiConstant(1), + CodeStubAssembler::SMI_PARAMETERS), + m.SmiConstant(Smi::FromInt(13)))); CSA_ASSERT(&m, - m.WordEqual(arguments.AtIndex(m.SmiConstant(2), - CodeStubAssembler::SMI_PARAMETERS), - m.SmiConstant(Smi::FromInt(14)))); + m.TaggedEqual(arguments.AtIndex(m.SmiConstant(2), + CodeStubAssembler::SMI_PARAMETERS), + m.SmiConstant(Smi::FromInt(14)))); arguments.PopAndReturn(arguments.GetReceiver()); @@ -2012,17 +2023,17 @@ TEST(ArgumentsWithSmiIndices) { CodeStubAssembler::SMI_PARAMETERS); CSA_ASSERT(&m, - m.WordEqual(arguments.AtIndex(NonConstantSmi(&m, 0), - CodeStubAssembler::SMI_PARAMETERS), - m.SmiConstant(Smi::FromInt(12)))); + m.TaggedEqual(arguments.AtIndex(NonConstantSmi(&m, 0), + CodeStubAssembler::SMI_PARAMETERS), + m.SmiConstant(Smi::FromInt(12)))); CSA_ASSERT(&m, - m.WordEqual(arguments.AtIndex(NonConstantSmi(&m, 1), - CodeStubAssembler::SMI_PARAMETERS), - m.SmiConstant(Smi::FromInt(13)))); + m.TaggedEqual(arguments.AtIndex(NonConstantSmi(&m, 1), + CodeStubAssembler::SMI_PARAMETERS), + m.SmiConstant(Smi::FromInt(13)))); CSA_ASSERT(&m, - m.WordEqual(arguments.AtIndex(NonConstantSmi(&m, 2), - CodeStubAssembler::SMI_PARAMETERS), - m.SmiConstant(Smi::FromInt(14)))); + m.TaggedEqual(arguments.AtIndex(NonConstantSmi(&m, 2), + CodeStubAssembler::SMI_PARAMETERS), + m.SmiConstant(Smi::FromInt(14)))); arguments.PopAndReturn(arguments.GetReceiver()); @@ -2368,7 +2379,7 @@ TEST(CreatePromiseResolvingFunctionsContext) { PromiseBuiltinsAssembler m(asm_tester.state()); Node* const context = m.Parameter(kNumParams + 2); - Node* const native_context = m.LoadNativeContext(context); + TNode<NativeContext> const native_context = m.LoadNativeContext(context); Node* const promise = m.AllocateAndInitJSPromise(context, m.UndefinedConstant()); Node* const promise_context = m.CreatePromiseResolvingFunctionsContext( @@ -2396,13 +2407,13 @@ TEST(CreatePromiseResolvingFunctions) { PromiseBuiltinsAssembler m(asm_tester.state()); Node* const context = m.Parameter(kNumParams + 2); - Node* const native_context = m.LoadNativeContext(context); + TNode<NativeContext> const native_context = m.LoadNativeContext(context); Node* const promise = m.AllocateAndInitJSPromise(context, m.UndefinedConstant()); Node *resolve, *reject; std::tie(resolve, reject) = m.CreatePromiseResolvingFunctions( promise, m.BooleanConstant(false), native_context); - Node* const kSize = m.IntPtrConstant(2); + TNode<IntPtrT> const kSize = m.IntPtrConstant(2); TNode<FixedArray> const arr = m.Cast(m.AllocateFixedArray(PACKED_ELEMENTS, kSize)); m.StoreFixedArrayElement(arr, 0, resolve); @@ -2486,15 +2497,15 @@ TEST(AllocateFunctionWithMapAndContext) { PromiseBuiltinsAssembler m(asm_tester.state()); Node* const context = m.Parameter(kNumParams + 2); - Node* const native_context = m.LoadNativeContext(context); + TNode<NativeContext> const native_context = m.LoadNativeContext(context); Node* const promise = m.AllocateAndInitJSPromise(context, m.UndefinedConstant()); Node* promise_context = m.CreatePromiseResolvingFunctionsContext( promise, m.BooleanConstant(false), native_context); - Node* resolve_info = m.LoadContextElement( + TNode<Object> resolve_info = m.LoadContextElement( native_context, Context::PROMISE_CAPABILITY_DEFAULT_RESOLVE_SHARED_FUN_INDEX); - Node* const map = m.LoadContextElement( + TNode<Object> const map = m.LoadContextElement( native_context, Context::STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX); Node* const resolve = m.AllocateFunctionWithMapAndContext(map, resolve_info, promise_context); @@ -2524,9 +2535,9 @@ TEST(CreatePromiseGetCapabilitiesExecutorContext) { PromiseBuiltinsAssembler m(asm_tester.state()); Node* const context = m.Parameter(kNumParams + 2); - Node* const native_context = m.LoadNativeContext(context); + TNode<NativeContext> const native_context = m.LoadNativeContext(context); - Node* const map = m.LoadRoot(RootIndex::kPromiseCapabilityMap); + TNode<Map> const map = m.PromiseCapabilityMapConstant(); Node* const capability = m.AllocateStruct(map); m.StoreObjectFieldNoWriteBarrier( capability, PromiseCapability::kPromiseOffset, m.UndefinedConstant()); @@ -2560,12 +2571,12 @@ TEST(NewPromiseCapability) { PromiseBuiltinsAssembler m(asm_tester.state()); Node* const context = m.Parameter(kNumParams + 2); - Node* const native_context = m.LoadNativeContext(context); - Node* const promise_constructor = + TNode<NativeContext> const native_context = m.LoadNativeContext(context); + TNode<Object> const promise_constructor = m.LoadContextElement(native_context, Context::PROMISE_FUNCTION_INDEX); - Node* const debug_event = m.TrueConstant(); - Node* const capability = + TNode<Oddball> const debug_event = m.TrueConstant(); + TNode<Object> const capability = m.CallBuiltin(Builtins::kNewPromiseCapability, context, promise_constructor, debug_event); m.Return(capability); @@ -2608,9 +2619,9 @@ TEST(NewPromiseCapability) { Node* const context = m.Parameter(kNumParams + 2); Node* const constructor = m.Parameter(1); - Node* const debug_event = m.TrueConstant(); - Node* const capability = m.CallBuiltin(Builtins::kNewPromiseCapability, - context, constructor, debug_event); + TNode<Oddball> const debug_event = m.TrueConstant(); + TNode<Object> const capability = m.CallBuiltin( + Builtins::kNewPromiseCapability, context, constructor, debug_event); m.Return(capability); FunctionTester ft(asm_tester.GenerateCode(), kNumParams); @@ -2674,12 +2685,13 @@ TEST(DirectMemoryTest8BitWord32Immediate) { const int element_count = 8; Label bad(&m); - Node* buffer_node = m.IntPtrConstant(reinterpret_cast<intptr_t>(buffer)); + TNode<IntPtrT> buffer_node = + m.IntPtrConstant(reinterpret_cast<intptr_t>(buffer)); for (size_t i = 0; i < element_count; ++i) { for (size_t j = 0; j < element_count; ++j) { Node* loaded = m.LoadBufferObject(buffer_node, static_cast<int>(i), MachineType::Uint8()); - Node* masked = m.Word32And(loaded, m.Int32Constant(buffer[j])); + TNode<Word32T> masked = m.Word32And(loaded, m.Int32Constant(buffer[j])); if ((buffer[j] & buffer[i]) != 0) { m.GotoIf(m.Word32Equal(masked, m.Int32Constant(0)), &bad); } else { @@ -2706,13 +2718,14 @@ TEST(DirectMemoryTest16BitWord32Immediate) { const int element_count = 8; Label bad(&m); - Node* buffer_node = m.IntPtrConstant(reinterpret_cast<intptr_t>(buffer)); + TNode<IntPtrT> buffer_node = + m.IntPtrConstant(reinterpret_cast<intptr_t>(buffer)); for (size_t i = 0; i < element_count; ++i) { for (size_t j = 0; j < element_count; ++j) { Node* loaded = m.LoadBufferObject(buffer_node, static_cast<int>(i * sizeof(int16_t)), MachineType::Uint16()); - Node* masked = m.Word32And(loaded, m.Int32Constant(buffer[j])); + TNode<Word32T> masked = m.Word32And(loaded, m.Int32Constant(buffer[j])); if ((buffer[j] & buffer[i]) != 0) { m.GotoIf(m.Word32Equal(masked, m.Int32Constant(0)), &bad); } else { @@ -2740,7 +2753,8 @@ TEST(DirectMemoryTest8BitWord32) { Label bad(&m); Node* constants[element_count]; - Node* buffer_node = m.IntPtrConstant(reinterpret_cast<intptr_t>(buffer)); + TNode<IntPtrT> buffer_node = + m.IntPtrConstant(reinterpret_cast<intptr_t>(buffer)); for (size_t i = 0; i < element_count; ++i) { constants[i] = m.LoadBufferObject(buffer_node, static_cast<int>(i), MachineType::Uint8()); @@ -2750,7 +2764,7 @@ TEST(DirectMemoryTest8BitWord32) { for (size_t j = 0; j < element_count; ++j) { Node* loaded = m.LoadBufferObject(buffer_node, static_cast<int>(i), MachineType::Uint8()); - Node* masked = m.Word32And(loaded, constants[j]); + TNode<Word32T> masked = m.Word32And(loaded, constants[j]); if ((buffer[j] & buffer[i]) != 0) { m.GotoIf(m.Word32Equal(masked, m.Int32Constant(0)), &bad); } else { @@ -2785,20 +2799,22 @@ TEST(DirectMemoryTest16BitWord32) { Label bad(&m); Node* constants[element_count]; - Node* buffer_node1 = m.IntPtrConstant(reinterpret_cast<intptr_t>(buffer)); + TNode<IntPtrT> buffer_node1 = + m.IntPtrConstant(reinterpret_cast<intptr_t>(buffer)); for (size_t i = 0; i < element_count; ++i) { constants[i] = m.LoadBufferObject(buffer_node1, static_cast<int>(i * sizeof(int16_t)), MachineType::Uint16()); } - Node* buffer_node2 = m.IntPtrConstant(reinterpret_cast<intptr_t>(buffer)); + TNode<IntPtrT> buffer_node2 = + m.IntPtrConstant(reinterpret_cast<intptr_t>(buffer)); for (size_t i = 0; i < element_count; ++i) { for (size_t j = 0; j < element_count; ++j) { Node* loaded = m.LoadBufferObject(buffer_node1, static_cast<int>(i * sizeof(int16_t)), MachineType::Uint16()); - Node* masked = m.Word32And(loaded, constants[j]); + TNode<Word32T> masked = m.Word32And(loaded, constants[j]); if ((buffer[j] & buffer[i]) != 0) { m.GotoIf(m.Word32Equal(masked, m.Int32Constant(0)), &bad); } else { @@ -2841,8 +2857,8 @@ TEST(LoadJSArrayElementsMap) { { CodeStubAssembler m(asm_tester.state()); Node* context = m.Parameter(kNumParams + 2); - Node* native_context = m.LoadNativeContext(context); - Node* kind = m.SmiToInt32(m.Parameter(0)); + TNode<NativeContext> native_context = m.LoadNativeContext(context); + TNode<Int32T> kind = m.SmiToInt32(m.Parameter(0)); m.Return(m.LoadJSArrayElementsMap(kind, native_context)); } @@ -3288,8 +3304,8 @@ TEST(ExtractFixedArraySimpleIntPtrParameters) { CodeAssemblerTester asm_tester(isolate, kNumParams); { CodeStubAssembler m(asm_tester.state()); - Node* p1_untagged = m.SmiUntag(m.Parameter(1)); - Node* p2_untagged = m.SmiUntag(m.Parameter(2)); + TNode<IntPtrT> p1_untagged = m.SmiUntag(m.Parameter(1)); + TNode<IntPtrT> p2_untagged = m.SmiUntag(m.Parameter(2)); m.Return(m.ExtractFixedArray(m.Parameter(0), p1_untagged, p2_untagged)); } FunctionTester ft(asm_tester.GenerateCode(), kNumParams); @@ -3334,8 +3350,9 @@ TEST(SingleInputPhiElimination) { Label end_label(&m, {&temp1, &temp2}); temp1.Bind(m.Parameter(1)); temp2.Bind(m.Parameter(1)); - m.Branch(m.WordEqual(m.Parameter(0), m.Parameter(1)), &end_label, - &temp_label); + m.Branch(m.TaggedEqual(m.UncheckedCast<Object>(m.Parameter(0)), + m.UncheckedCast<Object>(m.Parameter(1))), + &end_label, &temp_label); temp1.Bind(m.Parameter(2)); temp2.Bind(m.Parameter(2)); m.BIND(&temp_label); @@ -3486,7 +3503,7 @@ TEST(TestCallBuiltinInlineTrampoline) { Node* str = m.Parameter(0); Node* context = m.Parameter(kNumParams + kContextOffset); - Node* index = m.SmiConstant(2); + TNode<Smi> index = m.SmiConstant(2); m.Return(m.CallStub(Builtins::CallableFor(isolate, Builtins::kStringRepeat), context, str, index)); @@ -3511,7 +3528,7 @@ TEST(TestCallBuiltinIndirectLoad) { Node* str = m.Parameter(0); Node* context = m.Parameter(kNumParams + kContextOffset); - Node* index = m.SmiConstant(2); + TNode<Smi> index = m.SmiConstant(2); m.Return(m.CallStub(Builtins::CallableFor(isolate, Builtins::kStringRepeat), context, str, index)); diff --git a/deps/v8/test/cctest/test-conversions.cc b/deps/v8/test/cctest/test-conversions.cc index 1ddd463795..2bf07888af 100644 --- a/deps/v8/test/cctest/test-conversions.cc +++ b/deps/v8/test/cctest/test-conversions.cc @@ -312,11 +312,10 @@ TEST(ExponentNumberStr) { CHECK_EQ(1e-106, StringToDouble(".000001e-100", NO_FLAGS)); } - -class OneBit1: public BitField<uint32_t, 0, 1> {}; -class OneBit2: public BitField<uint32_t, 7, 1> {}; -class EightBit1: public BitField<uint32_t, 0, 8> {}; -class EightBit2: public BitField<uint32_t, 13, 8> {}; +using OneBit1 = BitField<uint32_t, 0, 1>; +using OneBit2 = BitField<uint32_t, 7, 1>; +using EightBit1 = BitField<uint32_t, 0, 8>; +using EightBit2 = BitField<uint32_t, 13, 8>; TEST(BitField) { uint32_t x; @@ -351,9 +350,8 @@ TEST(BitField) { CHECK(!EightBit2::is_valid(256)); } - -class UpperBits: public BitField64<int, 61, 3> {}; -class MiddleBits: public BitField64<int, 31, 2> {}; +using UpperBits = BitField64<int, 61, 3>; +using MiddleBits = BitField64<int, 31, 2>; TEST(BitField64) { uint64_t x; diff --git a/deps/v8/test/cctest/test-cpu-profiler.cc b/deps/v8/test/cctest/test-cpu-profiler.cc index 4b9ee4629f..6d0ee0e512 100644 --- a/deps/v8/test/cctest/test-cpu-profiler.cc +++ b/deps/v8/test/cctest/test-cpu-profiler.cc @@ -37,6 +37,7 @@ #include "src/base/platform/platform.h" #include "src/codegen/source-position-table.h" #include "src/deoptimizer/deoptimizer.h" +#include "src/heap/spaces.h" #include "src/libplatform/default-platform.h" #include "src/logging/log.h" #include "src/objects/objects-inl.h" @@ -45,11 +46,18 @@ #include "src/profiler/tracing-cpu-profiler.h" #include "src/utils/utils.h" #include "test/cctest/cctest.h" +#include "test/cctest/heap/heap-utils.h" #include "test/cctest/profiler-extension.h" #include "include/libplatform/v8-tracing.h" +#include "src/libplatform/tracing/trace-event-listener.h" #include "src/tracing/trace-event.h" +#ifdef V8_USE_PERFETTO +#include "perfetto/trace/chrome/chrome_trace_event.pb.h" +#include "perfetto/trace/trace.pb.h" +#endif + namespace v8 { namespace internal { namespace test_cpu_profiler { @@ -79,12 +87,13 @@ static const char* reason(const i::DeoptimizeReason reason) { TEST(StartStop) { i::Isolate* isolate = CcTest::i_isolate(); CpuProfilesCollection profiles(isolate); - ProfileGenerator generator(&profiles); + ProfilerCodeObserver code_observer(isolate); + ProfileGenerator generator(&profiles, code_observer.code_map()); std::unique_ptr<ProfilerEventsProcessor> processor( - new SamplingEventsProcessor(isolate, &generator, + new SamplingEventsProcessor(isolate, &generator, &code_observer, v8::base::TimeDelta::FromMicroseconds(100), true)); - processor->Start(); + CHECK(processor->Start()); processor->StopSynchronously(); } @@ -163,10 +172,13 @@ TEST(CodeEvents) { i::AbstractCode moved_code = CreateCode(&env); CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate); - ProfileGenerator* generator = new ProfileGenerator(profiles); + ProfilerCodeObserver code_observer(isolate); + ProfileGenerator* generator = + new ProfileGenerator(profiles, code_observer.code_map()); ProfilerEventsProcessor* processor = new SamplingEventsProcessor( - isolate, generator, v8::base::TimeDelta::FromMicroseconds(100), true); - processor->Start(); + isolate, generator, &code_observer, + v8::base::TimeDelta::FromMicroseconds(100), true); + CHECK(processor->Start()); ProfilerListener profiler_listener(isolate, processor); isolate->logger()->AddCodeEventListener(&profiler_listener); @@ -222,13 +234,16 @@ TEST(TickEvents) { i::AbstractCode frame3_code = CreateCode(&env); CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate); - ProfileGenerator* generator = new ProfileGenerator(profiles); + ProfilerCodeObserver code_observer(isolate); + ProfileGenerator* generator = + new ProfileGenerator(profiles, code_observer.code_map()); ProfilerEventsProcessor* processor = new SamplingEventsProcessor( - CcTest::i_isolate(), generator, + CcTest::i_isolate(), generator, &code_observer, v8::base::TimeDelta::FromMicroseconds(100), true); - CpuProfiler profiler(isolate, kDebugNaming, profiles, generator, processor); + CpuProfiler profiler(isolate, kDebugNaming, kLazyLogging, profiles, generator, + processor); profiles->StartProfiling(""); - processor->Start(); + CHECK(processor->Start()); ProfilerListener profiler_listener(isolate, processor); isolate->logger()->AddCodeEventListener(&profiler_listener); @@ -291,13 +306,16 @@ TEST(Issue1398) { i::AbstractCode code = CreateCode(&env); CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate); - ProfileGenerator* generator = new ProfileGenerator(profiles); + ProfilerCodeObserver code_observer(isolate); + ProfileGenerator* generator = + new ProfileGenerator(profiles, code_observer.code_map()); ProfilerEventsProcessor* processor = new SamplingEventsProcessor( - CcTest::i_isolate(), generator, + CcTest::i_isolate(), generator, &code_observer, v8::base::TimeDelta::FromMicroseconds(100), true); - CpuProfiler profiler(isolate, kDebugNaming, profiles, generator, processor); + CpuProfiler profiler(isolate, kDebugNaming, kLazyLogging, profiles, generator, + processor); profiles->StartProfiling(""); - processor->Start(); + CHECK(processor->Start()); ProfilerListener profiler_listener(isolate, processor); profiler_listener.CodeCreateEvent(i::Logger::BUILTIN_TAG, code, "bbb"); @@ -305,7 +323,7 @@ TEST(Issue1398) { v8::internal::TickSample sample; sample.pc = reinterpret_cast<void*>(code.InstructionStart()); sample.tos = nullptr; - sample.frames_count = v8::TickSample::kMaxFramesCount; + sample.frames_count = TickSample::kMaxFramesCount; for (unsigned i = 0; i < sample.frames_count; ++i) { sample.stack[i] = reinterpret_cast<void*>(code.InstructionStart()); } @@ -323,7 +341,7 @@ TEST(Issue1398) { ++actual_depth; } - CHECK_EQ(1 + v8::TickSample::kMaxFramesCount, actual_depth); // +1 for PC. + CHECK_EQ(1 + TickSample::kMaxFramesCount, actual_depth); // +1 for PC. } TEST(DeleteAllCpuProfiles) { @@ -440,7 +458,8 @@ class ProfilerHelper { v8::Local<v8::Function> function, v8::Local<v8::Value> argv[], int argc, unsigned min_js_samples = 0, unsigned min_external_samples = 0, ProfilingMode mode = ProfilingMode::kLeafNodeLineNumbers, - unsigned max_samples = CpuProfilingOptions::kNoSampleLimit); + unsigned max_samples = v8::CpuProfilingOptions::kNoSampleLimit, + v8::Local<v8::Context> context = v8::Local<v8::Context>()); v8::CpuProfiler* profiler() { return profiler_; } @@ -453,11 +472,12 @@ v8::CpuProfile* ProfilerHelper::Run(v8::Local<v8::Function> function, v8::Local<v8::Value> argv[], int argc, unsigned min_js_samples, unsigned min_external_samples, - ProfilingMode mode, unsigned max_samples) { + ProfilingMode mode, unsigned max_samples, + v8::Local<v8::Context> context) { v8::Local<v8::String> profile_name = v8_str("my_profile"); profiler_->SetSamplingInterval(100); - profiler_->StartProfiling(profile_name, {mode, max_samples}); + profiler_->StartProfiling(profile_name, {mode, max_samples, 0, context}); v8::internal::CpuProfiler* iprofiler = reinterpret_cast<v8::internal::CpuProfiler*>(profiler_); @@ -465,6 +485,7 @@ v8::CpuProfile* ProfilerHelper::Run(v8::Local<v8::Function> function, reinterpret_cast<i::SamplingEventsProcessor*>(iprofiler->processor()) ->sampler(); sampler->StartCountingSamples(); + do { function->Call(context_, context_->Global(), argc, argv).ToLocalChecked(); } while (sampler->js_sample_count() < min_js_samples || @@ -1154,18 +1175,21 @@ static void TickLines(bool optimize) { CHECK_NE(code_address, kNullAddress); CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate); - ProfileGenerator* generator = new ProfileGenerator(profiles); + ProfilerCodeObserver code_observer(isolate); + ProfileGenerator* generator = + new ProfileGenerator(profiles, code_observer.code_map()); ProfilerEventsProcessor* processor = new SamplingEventsProcessor( - CcTest::i_isolate(), generator, + CcTest::i_isolate(), generator, &code_observer, v8::base::TimeDelta::FromMicroseconds(100), true); - CpuProfiler profiler(isolate, kDebugNaming, profiles, generator, processor); + CpuProfiler profiler(isolate, kDebugNaming, kLazyLogging, profiles, generator, + processor); profiles->StartProfiling(""); // TODO(delphick): Stop using the CpuProfiler internals here: This forces // LogCompiledFunctions so that source positions are collected everywhere. // This would normally happen automatically with CpuProfiler::StartProfiling // but doesn't because it's constructed with a generator and a processor. isolate->logger()->LogCompiledFunctions(); - processor->Start(); + CHECK(processor->Start()); ProfilerListener profiler_listener(isolate, processor); // Enqueue code creation events. @@ -1806,7 +1830,7 @@ TEST(Inlining2) { v8::Local<v8::String> profile_name = v8_str("inlining"); profiler->StartProfiling( profile_name, - CpuProfilingOptions{v8::CpuProfilingMode::kCallerLineNumbers}); + v8::CpuProfilingOptions{v8::CpuProfilingMode::kCallerLineNumbers}); v8::Local<v8::Value> args[] = { v8::Integer::New(env->GetIsolate(), 50000 * load_factor)}; @@ -2488,7 +2512,6 @@ TEST(DeoptAtFirstLevelInlinedSource) { iprofiler->DeleteProfile(iprofile); } - // deopt at the second level inlined function TEST(DeoptAtSecondLevelInlinedSource) { if (!CcTest::i_isolate()->use_optimizer() || i::FLAG_always_opt) return; @@ -2623,6 +2646,41 @@ using v8::platform::tracing::TraceObject; namespace { +#ifdef V8_USE_PERFETTO + +class CpuProfilerListener : public platform::tracing::TraceEventListener { + public: + void ProcessPacket(const ::perfetto::protos::TracePacket& packet) { + for (const ::perfetto::protos::ChromeTraceEvent& trace_event : + packet.chrome_events().trace_events()) { + if (trace_event.name() != std::string("Profile") && + trace_event.name() != std::string("ProfileChunk")) + return; + CHECK(!profile_id_ || trace_event.id() == profile_id_); + CHECK_EQ(1, trace_event.args_size()); + CHECK(trace_event.args()[0].has_json_value()); + profile_id_ = trace_event.id(); + result_json_ += result_json_.empty() ? "[" : ",\n"; + result_json_ += trace_event.args()[0].json_value(); + } + } + + const std::string& result_json() { + result_json_ += "]"; + return result_json_; + } + void Reset() { + result_json_.clear(); + profile_id_ = 0; + } + + private: + std::string result_json_; + uint64_t profile_id_ = 0; +}; + +#else + class CpuProfileEventChecker : public v8::platform::tracing::TraceWriter { public: void AppendTraceEvent(TraceObject* trace_event) override { @@ -2651,6 +2709,8 @@ class CpuProfileEventChecker : public v8::platform::tracing::TraceWriter { uint64_t profile_id_ = 0; }; +#endif // !V8_USE_PERFETTO + } // namespace TEST(TracingCpuProfiler) { @@ -2658,17 +2718,20 @@ TEST(TracingCpuProfiler) { v8::Local<v8::Context> env = CcTest::NewContext({PROFILER_EXTENSION_ID}); v8::Context::Scope context_scope(env); - CpuProfileEventChecker* event_checker = new CpuProfileEventChecker(); - TraceBuffer* ring_buffer = - TraceBuffer::CreateTraceBufferRingBuffer(1, event_checker); auto* tracing_controller = static_cast<v8::platform::tracing::TracingController*>( i::V8::GetCurrentPlatform()->GetTracingController()); - tracing_controller->Initialize(ring_buffer); #ifdef V8_USE_PERFETTO std::ostringstream perfetto_output; tracing_controller->InitializeForPerfetto(&perfetto_output); + CpuProfilerListener listener; + tracing_controller->SetTraceEventListenerForTesting(&listener); +#else + CpuProfileEventChecker* event_checker = new CpuProfileEventChecker(); + TraceBuffer* ring_buffer = + TraceBuffer::CreateTraceBufferRingBuffer(1, event_checker); + tracing_controller->Initialize(ring_buffer); #endif bool result = false; @@ -2693,8 +2756,13 @@ TEST(TracingCpuProfiler) { CompileRun(test_code.c_str()); tracing_controller->StopTracing(); +#ifdef V8_USE_PERFETTO + std::string profile_json = listener.result_json(); + listener.Reset(); +#else std::string profile_json = event_checker->result_json(); event_checker->Reset(); +#endif CHECK_LT(0u, profile_json.length()); printf("Profile JSON: %s\n", profile_json.c_str()); @@ -2930,6 +2998,15 @@ TEST(SourcePositionTable) { CHECK_EQ(SourcePosition::kNotInlined, info.GetInliningId(21)); CHECK_EQ(0, info.GetInliningId(100)); + + // Test that subsequent SetPosition calls with the same pc_offset are ignored. + info.SetPosition(25, 4, SourcePosition::kNotInlined); + CHECK_EQ(2, info.GetSourceLineNumber(21)); + CHECK_EQ(3, info.GetSourceLineNumber(100)); + CHECK_EQ(3, info.GetSourceLineNumber(std::numeric_limits<int>::max())); + + CHECK_EQ(SourcePosition::kNotInlined, info.GetInliningId(21)); + CHECK_EQ(0, info.GetInliningId(100)); } TEST(MultipleProfilers) { @@ -3034,8 +3111,8 @@ TEST(MultipleIsolates) { IsolateThread thread1; IsolateThread thread2; - thread1.Start(); - thread2.Start(); + CHECK(thread1.Start()); + CHECK(thread2.Start()); thread1.Join(); thread2.Join(); @@ -3062,12 +3139,13 @@ TEST(FastStopProfiling) { TEST(LowPrecisionSamplingStartStopInternal) { i::Isolate* isolate = CcTest::i_isolate(); CpuProfilesCollection profiles(isolate); - ProfileGenerator generator(&profiles); + ProfilerCodeObserver code_observer(isolate); + ProfileGenerator generator(&profiles, code_observer.code_map()); std::unique_ptr<ProfilerEventsProcessor> processor( - new SamplingEventsProcessor(isolate, &generator, + new SamplingEventsProcessor(isolate, &generator, &code_observer, v8::base::TimeDelta::FromMicroseconds(100), false)); - processor->Start(); + CHECK(processor->Start()); processor->StopSynchronously(); } @@ -3187,11 +3265,15 @@ TEST(ProflilerSubsampling) { i::HandleScope scope(isolate); CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate); - ProfileGenerator* generator = new ProfileGenerator(profiles); - ProfilerEventsProcessor* processor = new SamplingEventsProcessor( - isolate, generator, v8::base::TimeDelta::FromMicroseconds(1), - /* use_precise_sampling */ true); - CpuProfiler profiler(isolate, kDebugNaming, profiles, generator, processor); + ProfilerCodeObserver code_observer(isolate); + ProfileGenerator* generator = + new ProfileGenerator(profiles, code_observer.code_map()); + ProfilerEventsProcessor* processor = + new SamplingEventsProcessor(isolate, generator, &code_observer, + v8::base::TimeDelta::FromMicroseconds(1), + /* use_precise_sampling */ true); + CpuProfiler profiler(isolate, kDebugNaming, kLazyLogging, profiles, generator, + processor); // Create a new CpuProfile that wants samples at 8us. CpuProfile profile(&profiler, "", @@ -3228,11 +3310,15 @@ TEST(DynamicResampling) { i::HandleScope scope(isolate); CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate); - ProfileGenerator* generator = new ProfileGenerator(profiles); - ProfilerEventsProcessor* processor = new SamplingEventsProcessor( - isolate, generator, v8::base::TimeDelta::FromMicroseconds(1), - /* use_precise_sampling */ true); - CpuProfiler profiler(isolate, kDebugNaming, profiles, generator, processor); + ProfilerCodeObserver code_observer(isolate); + ProfileGenerator* generator = + new ProfileGenerator(profiles, code_observer.code_map()); + ProfilerEventsProcessor* processor = + new SamplingEventsProcessor(isolate, generator, &code_observer, + v8::base::TimeDelta::FromMicroseconds(1), + /* use_precise_sampling */ true); + CpuProfiler profiler(isolate, kDebugNaming, kLazyLogging, profiles, generator, + processor); // Set a 1us base sampling rate, dividing all possible intervals. profiler.set_sampling_interval(base::TimeDelta::FromMicroseconds(1)); @@ -3286,11 +3372,15 @@ TEST(DynamicResamplingWithBaseInterval) { i::HandleScope scope(isolate); CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate); - ProfileGenerator* generator = new ProfileGenerator(profiles); - ProfilerEventsProcessor* processor = new SamplingEventsProcessor( - isolate, generator, v8::base::TimeDelta::FromMicroseconds(1), - /* use_precise_sampling */ true); - CpuProfiler profiler(isolate, kDebugNaming, profiles, generator, processor); + ProfilerCodeObserver code_observer(isolate); + ProfileGenerator* generator = + new ProfileGenerator(profiles, code_observer.code_map()); + ProfilerEventsProcessor* processor = + new SamplingEventsProcessor(isolate, generator, &code_observer, + v8::base::TimeDelta::FromMicroseconds(1), + /* use_precise_sampling */ true); + CpuProfiler profiler(isolate, kDebugNaming, kLazyLogging, profiles, generator, + processor); profiler.set_sampling_interval(base::TimeDelta::FromMicroseconds(7)); @@ -3338,6 +3428,184 @@ TEST(DynamicResamplingWithBaseInterval) { profiles->StopProfiling("5us"); } +// Tests that functions compiled after a started profiler is stopped are still +// visible when the profiler is started again. (https://crbug.com/v8/9151) +TEST(Bug9151StaleCodeEntries) { + LocalContext env; + v8::HandleScope scope(env->GetIsolate()); + + v8::Local<v8::FunctionTemplate> func_template = + v8::FunctionTemplate::New(env->GetIsolate(), CallCollectSample); + v8::Local<v8::Function> func = + func_template->GetFunction(env.local()).ToLocalChecked(); + func->SetName(v8_str("CallCollectSample")); + env->Global()->Set(env.local(), v8_str("CallCollectSample"), func).FromJust(); + + v8::CpuProfiler* profiler = + v8::CpuProfiler::New(env->GetIsolate(), kDebugNaming, kEagerLogging); + v8::Local<v8::String> profile_name = v8_str(""); + + // Warm up the profiler to create the initial code map. + profiler->StartProfiling(profile_name); + profiler->StopProfiling(profile_name); + + // Log a function compilation (executed once to force a compilation). + CompileRun(R"( + function start() { + CallCollectSample(); + } + start(); + )"); + + // Restart the profiler, and execute both the JS function and callback. + profiler->StartProfiling(profile_name, true); + CompileRun("start();"); + v8::CpuProfile* profile = profiler->StopProfiling(profile_name); + + auto* root = profile->GetTopDownRoot(); + auto* toplevel = GetChild(env.local(), root, ""); + + auto* start = FindChild(env.local(), toplevel, "start"); + CHECK(start); + + auto* callback = FindChild(env.local(), start, "CallCollectSample"); + CHECK(callback); +} + +// Tests that functions from other contexts aren't recorded when filtering for +// another context. +TEST(ContextIsolation) { + i::FLAG_allow_natives_syntax = true; + LocalContext execution_env; + i::HandleScope scope(CcTest::i_isolate()); + + // Install CollectSample callback for more deterministic sampling. + v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New( + execution_env.local()->GetIsolate(), CallCollectSample); + v8::Local<v8::Function> func = + func_template->GetFunction(execution_env.local()).ToLocalChecked(); + func->SetName(v8_str("CallCollectSample")); + execution_env->Global() + ->Set(execution_env.local(), v8_str("CallCollectSample"), func) + .FromJust(); + + ProfilerHelper helper(execution_env.local()); + CompileRun(R"( + function optimized() { + CallCollectSample(); + } + + function unoptimized() { + CallCollectSample(); + } + + function start() { + // Test optimized functions + %PrepareFunctionForOptimization(optimized); + optimized(); + optimized(); + %OptimizeFunctionOnNextCall(optimized); + optimized(); + + // Test unoptimized functions + %NeverOptimizeFunction(unoptimized); + unoptimized(); + + // Test callback + CallCollectSample(); + } + )"); + v8::Local<v8::Function> function = + GetFunction(execution_env.local(), "start"); + + v8::CpuProfile* same_context_profile = helper.Run( + function, nullptr, 0, 0, 0, v8::CpuProfilingMode::kLeafNodeLineNumbers, + v8::CpuProfilingOptions::kNoSampleLimit, execution_env.local()); + const v8::CpuProfileNode* root = same_context_profile->GetTopDownRoot(); + const v8::CpuProfileNode* start_node = FindChild(root, "start"); + CHECK(start_node); + const v8::CpuProfileNode* optimized_node = FindChild(start_node, "optimized"); + CHECK(optimized_node); + const v8::CpuProfileNode* unoptimized_node = + FindChild(start_node, "unoptimized"); + CHECK(unoptimized_node); + const v8::CpuProfileNode* callback_node = + FindChild(start_node, "CallCollectSample"); + CHECK(callback_node); + + { + LocalContext filter_env; + v8::CpuProfile* diff_context_profile = helper.Run( + function, nullptr, 0, 0, 0, v8::CpuProfilingMode::kLeafNodeLineNumbers, + v8::CpuProfilingOptions::kNoSampleLimit, filter_env.local()); + const v8::CpuProfileNode* diff_root = + diff_context_profile->GetTopDownRoot(); + // Ensure that no children were recorded (including callbacks, builtins). + CHECK(!FindChild(diff_root, "start")); + } +} + +// Tests that when a native context that's being filtered is moved, we continue +// to track its execution. +TEST(ContextFilterMovedNativeContext) { + i::FLAG_allow_natives_syntax = true; + i::FLAG_manual_evacuation_candidates_selection = true; + LocalContext env; + i::HandleScope scope(CcTest::i_isolate()); + + { + // Install CollectSample callback for more deterministic sampling. + v8::Local<v8::FunctionTemplate> sample_func_template = + v8::FunctionTemplate::New(env.local()->GetIsolate(), CallCollectSample); + v8::Local<v8::Function> sample_func = + sample_func_template->GetFunction(env.local()).ToLocalChecked(); + sample_func->SetName(v8_str("CallCollectSample")); + env->Global() + ->Set(env.local(), v8_str("CallCollectSample"), sample_func) + .FromJust(); + + // Install a function that triggers the native context to be moved. + v8::Local<v8::FunctionTemplate> move_func_template = + v8::FunctionTemplate::New( + env.local()->GetIsolate(), + [](const v8::FunctionCallbackInfo<v8::Value>& info) { + i::Isolate* isolate = + reinterpret_cast<i::Isolate*>(info.GetIsolate()); + i::heap::ForceEvacuationCandidate( + i::Page::FromHeapObject(isolate->raw_native_context())); + CcTest::CollectAllGarbage(); + }); + v8::Local<v8::Function> move_func = + move_func_template->GetFunction(env.local()).ToLocalChecked(); + move_func->SetName(v8_str("ForceNativeContextMove")); + env->Global() + ->Set(env.local(), v8_str("ForceNativeContextMove"), move_func) + .FromJust(); + + ProfilerHelper helper(env.local()); + CompileRun(R"( + function start() { + ForceNativeContextMove(); + CallCollectSample(); + } + )"); + v8::Local<v8::Function> function = GetFunction(env.local(), "start"); + + v8::CpuProfile* profile = helper.Run( + function, nullptr, 0, 0, 0, v8::CpuProfilingMode::kLeafNodeLineNumbers, + v8::CpuProfilingOptions::kNoSampleLimit, env.local()); + const v8::CpuProfileNode* root = profile->GetTopDownRoot(); + const v8::CpuProfileNode* start_node = FindChild(root, "start"); + CHECK(start_node); + + // Verify that after moving the native context, CallCollectSample is still + // recorded. + const v8::CpuProfileNode* callback_node = + FindChild(start_node, "CallCollectSample"); + CHECK(callback_node); + } +} + enum class EntryCountMode { kAll, kOnlyInlined }; // Count the number of unique source positions. diff --git a/deps/v8/test/cctest/test-debug-helper.cc b/deps/v8/test/cctest/test-debug-helper.cc new file mode 100644 index 0000000000..67236e5a31 --- /dev/null +++ b/deps/v8/test/cctest/test-debug-helper.cc @@ -0,0 +1,227 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "src/api/api-inl.h" +#include "src/heap/spaces.h" +#include "test/cctest/cctest.h" +#include "tools/debug_helper/debug-helper.h" + +namespace v8 { +namespace internal { + +namespace { + +namespace d = v8::debug_helper; + +uintptr_t memory_fail_start = 0; +uintptr_t memory_fail_end = 0; + +class MemoryFailureRegion { + public: + MemoryFailureRegion(uintptr_t start, uintptr_t end) { + memory_fail_start = start; + memory_fail_end = end; + } + ~MemoryFailureRegion() { + memory_fail_start = 0; + memory_fail_end = 0; + } +}; + +// Implement the memory-reading callback. This one just fetches memory from the +// current process, but a real implementation for a debugging extension would +// fetch memory from the debuggee process or crash dump. +d::MemoryAccessResult ReadMemory(uintptr_t address, uint8_t* destination, + size_t byte_count) { + if (address >= memory_fail_start && address <= memory_fail_end) { + // Simulate failure to read debuggee memory. + return d::MemoryAccessResult::kAddressValidButInaccessible; + } + memcpy(destination, reinterpret_cast<void*>(address), byte_count); + return d::MemoryAccessResult::kOk; +} + +void CheckProp(const d::ObjectProperty& property, const char* expected_type, + const char* expected_name, + d::PropertyKind expected_kind = d::PropertyKind::kSingle, + size_t expected_num_values = 1) { + CHECK_EQ(property.num_values, expected_num_values); + CHECK(property.type == std::string("v8::internal::TaggedValue") || + property.type == std::string(expected_type)); + CHECK(property.decompressed_type == std::string(expected_type)); + CHECK(property.kind == expected_kind); + CHECK(property.name == std::string(expected_name)); +} + +template <typename TValue> +void CheckProp(const d::ObjectProperty& property, const char* expected_type, + const char* expected_name, TValue expected_value) { + CheckProp(property, expected_type, expected_name); + CHECK(*reinterpret_cast<TValue*>(property.address) == expected_value); +} + +} // namespace + +TEST(GetObjectProperties) { + CcTest::InitializeVM(); + v8::Isolate* isolate = CcTest::isolate(); + v8::HandleScope scope(isolate); + LocalContext context; + d::Roots roots{0, 0, 0, 0}; // We don't know the heap roots. + + v8::Local<v8::Value> v = CompileRun("42"); + Handle<Object> o = v8::Utils::OpenHandle(*v); + d::ObjectPropertiesResultPtr props = + d::GetObjectProperties(o->ptr(), &ReadMemory, roots); + CHECK(props->type_check_result == d::TypeCheckResult::kSmi); + CHECK(props->brief == std::string("42 (0x2a)")); + CHECK(props->type == std::string("v8::internal::Smi")); + CHECK_EQ(props->num_properties, 0); + + v = CompileRun("[\"a\", \"bc\"]"); + o = v8::Utils::OpenHandle(*v); + props = d::GetObjectProperties(o->ptr(), &ReadMemory, roots); + CHECK(props->type_check_result == d::TypeCheckResult::kUsedMap); + CHECK(props->type == std::string("v8::internal::JSArray")); + CHECK_EQ(props->num_properties, 4); + CheckProp(*props->properties[0], "v8::internal::Map", "map"); + CheckProp(*props->properties[1], "v8::internal::Object", + "properties_or_hash"); + CheckProp(*props->properties[2], "v8::internal::FixedArrayBase", "elements"); + CheckProp(*props->properties[3], "v8::internal::Object", "length", + static_cast<i::Tagged_t>(IntToSmi(2))); + + // We need to supply a root address for decompression before reading the + // elements from the JSArray. + roots.any_heap_pointer = o->ptr(); + + i::Tagged_t properties_or_hash = + *reinterpret_cast<i::Tagged_t*>(props->properties[1]->address); + i::Tagged_t elements = + *reinterpret_cast<i::Tagged_t*>(props->properties[2]->address); + + // The properties_or_hash_code field should be an empty fixed array. Since + // that is at a known offset, we should be able to detect it even without + // any ability to read memory. + { + MemoryFailureRegion failure(0, UINTPTR_MAX); + props = d::GetObjectProperties(properties_or_hash, &ReadMemory, roots); + CHECK(props->type_check_result == + d::TypeCheckResult::kObjectPointerValidButInaccessible); + CHECK(props->type == std::string("v8::internal::HeapObject")); + CHECK_EQ(props->num_properties, 1); + CheckProp(*props->properties[0], "v8::internal::Map", "map"); + CHECK(std::string(props->brief).substr(0, 21) == + std::string("maybe EmptyFixedArray")); + + // Provide a heap root so the API can be more sure. + roots.read_only_space = + reinterpret_cast<uintptr_t>(reinterpret_cast<i::Isolate*>(isolate) + ->heap() + ->read_only_space() + ->first_page()); + props = d::GetObjectProperties(properties_or_hash, &ReadMemory, roots); + CHECK(props->type_check_result == + d::TypeCheckResult::kObjectPointerValidButInaccessible); + CHECK(props->type == std::string("v8::internal::HeapObject")); + CHECK_EQ(props->num_properties, 1); + CheckProp(*props->properties[0], "v8::internal::Map", "map"); + CHECK(std::string(props->brief).substr(0, 15) == + std::string("EmptyFixedArray")); + } + + props = d::GetObjectProperties(elements, &ReadMemory, roots); + CHECK(props->type_check_result == d::TypeCheckResult::kUsedMap); + CHECK(props->type == std::string("v8::internal::FixedArray")); + CHECK_EQ(props->num_properties, 3); + CheckProp(*props->properties[0], "v8::internal::Map", "map"); + CheckProp(*props->properties[1], "v8::internal::Object", "length", + static_cast<i::Tagged_t>(IntToSmi(2))); + CheckProp(*props->properties[2], "v8::internal::Object", "objects", + d::PropertyKind::kArrayOfKnownSize, 2); + + // Get the second string value from the FixedArray. + i::Tagged_t second_string_address = *reinterpret_cast<i::Tagged_t*>( + props->properties[2]->address + sizeof(i::Tagged_t)); + props = d::GetObjectProperties(second_string_address, &ReadMemory, roots); + CHECK(props->type_check_result == d::TypeCheckResult::kUsedMap); + CHECK(props->type == std::string("v8::internal::SeqOneByteString")); + CHECK_EQ(props->num_properties, 4); + CheckProp(*props->properties[0], "v8::internal::Map", "map"); + CheckProp(*props->properties[1], "uint32_t", "hash_field"); + CheckProp(*props->properties[2], "int32_t", "length", 2); + CheckProp(*props->properties[3], "char", "chars", + d::PropertyKind::kArrayOfKnownSize, 2); + CHECK_EQ( + strncmp("bc", + reinterpret_cast<const char*>(props->properties[3]->address), 2), + 0); + + // Read the second string again, using a type hint instead of the map. All of + // its properties should match what we read last time. + d::ObjectPropertiesResultPtr props2; + { + uintptr_t map_address = + d::GetObjectProperties( + *reinterpret_cast<i::Tagged_t*>(props->properties[0]->address), + &ReadMemory, roots) + ->properties[0] + ->address; + MemoryFailureRegion failure(map_address, map_address + i::Map::kSize); + props2 = d::GetObjectProperties(second_string_address, &ReadMemory, roots, + "v8::internal::String"); + CHECK(props2->type_check_result == d::TypeCheckResult::kUsedTypeHint); + CHECK(props2->type == std::string("v8::internal::String")); + CHECK_EQ(props2->num_properties, 3); + CheckProp(*props2->properties[0], "v8::internal::Map", "map", + *reinterpret_cast<i::Tagged_t*>(props->properties[0]->address)); + CheckProp(*props2->properties[1], "uint32_t", "hash_field", + *reinterpret_cast<int32_t*>(props->properties[1]->address)); + CheckProp(*props2->properties[2], "int32_t", "length", 2); + } + + // Try a weak reference. + props2 = d::GetObjectProperties(second_string_address | kWeakHeapObjectMask, + &ReadMemory, roots); + std::string weak_ref_prefix = "weak ref to "; + CHECK(weak_ref_prefix + props->brief == props2->brief); + CHECK(props2->type_check_result == d::TypeCheckResult::kUsedMap); + CHECK(props2->type == std::string("v8::internal::SeqOneByteString")); + CHECK_EQ(props2->num_properties, 4); + CheckProp(*props2->properties[0], "v8::internal::Map", "map", + *reinterpret_cast<i::Tagged_t*>(props->properties[0]->address)); + CheckProp(*props2->properties[1], "uint32_t", "hash_field", + *reinterpret_cast<i::Tagged_t*>(props->properties[1]->address)); + CheckProp(*props2->properties[2], "int32_t", "length", 2); + + // Build a complicated string (multi-level cons with slices inside) to test + // string printing. + v = CompileRun(R"( + const alphabet = "abcdefghijklmnopqrstuvwxyz"; + alphabet.substr(3,20) + alphabet.toUpperCase().substr(5,15) + "7")"); + o = v8::Utils::OpenHandle(*v); + props = d::GetObjectProperties(o->ptr(), &ReadMemory, roots); + CHECK(std::string(props->brief).substr(0, 38) == + std::string("\"defghijklmnopqrstuvwFGHIJKLMNOPQRST7\"")); + + // Cause a failure when reading the "second" pointer within the top-level + // ConsString. + { + CheckProp(*props->properties[4], "v8::internal::String", "second"); + uintptr_t second_address = props->properties[4]->address; + MemoryFailureRegion failure(second_address, second_address + 4); + props = d::GetObjectProperties(o->ptr(), &ReadMemory, roots); + CHECK(std::string(props->brief).substr(0, 40) == + std::string("\"defghijklmnopqrstuvwFGHIJKLMNOPQRST...\"")); + } + + // Build a very long string. + v = CompileRun("'a'.repeat(1000)"); + o = v8::Utils::OpenHandle(*v); + props = d::GetObjectProperties(o->ptr(), &ReadMemory, roots); + CHECK(std::string(props->brief).substr(79, 7) == std::string("aa...\" ")); +} + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-debug.cc b/deps/v8/test/cctest/test-debug.cc index b3da0329f6..4ad55ef6b5 100644 --- a/deps/v8/test/cctest/test-debug.cc +++ b/deps/v8/test/cctest/test-debug.cc @@ -553,7 +553,7 @@ TEST(BreakPointBuiltin) { builtin = CompileRun("String.prototype.repeat").As<v8::Function>(); // Run with breakpoint. - bp = SetBreakPoint(builtin, 0); + bp = SetBreakPoint(builtin, 0, "this != 1"); ExpectString("'b'.repeat(10)", "bbbbbbbbbb"); CHECK_EQ(1, break_point_hit_count); @@ -754,7 +754,7 @@ TEST(BreakPointConstructorBuiltin) { CHECK_EQ(0, break_point_hit_count); // Run with breakpoint. - bp = SetBreakPoint(builtin, 0); + bp = SetBreakPoint(builtin, 0, "this != 1"); ExpectString("(new Promise(()=>{})).toString()", "[object Promise]"); CHECK_EQ(1, break_point_hit_count); @@ -821,7 +821,7 @@ TEST(BreakPointInlinedBuiltin) { CHECK_EQ(0, break_point_hit_count); // Run with breakpoint. - bp = SetBreakPoint(builtin, 0); + bp = SetBreakPoint(builtin, 0, "this != 1"); CompileRun("Math.sin(0.1);"); CHECK_EQ(1, break_point_hit_count); CompileRun("test(0.2);"); @@ -869,7 +869,7 @@ TEST(BreakPointInlineBoundBuiltin) { CHECK_EQ(0, break_point_hit_count); // Run with breakpoint. - bp = SetBreakPoint(builtin, 0); + bp = SetBreakPoint(builtin, 0, "this != 1"); CompileRun("'a'.repeat(2);"); CHECK_EQ(1, break_point_hit_count); CompileRun("test(7);"); @@ -914,7 +914,7 @@ TEST(BreakPointInlinedConstructorBuiltin) { CHECK_EQ(0, break_point_hit_count); // Run with breakpoint. - bp = SetBreakPoint(builtin, 0); + bp = SetBreakPoint(builtin, 0, "this != 1"); CompileRun("new Promise(()=>{});"); CHECK_EQ(1, break_point_hit_count); CompileRun("test(7);"); @@ -1090,13 +1090,18 @@ TEST(BreakPointApiFunction) { break_point_hit_count = 0; // Run with breakpoint. - bp = SetBreakPoint(function, 0); + bp = SetBreakPoint(function, 0, "this != 1"); ExpectInt32("f()", 2); CHECK_EQ(1, break_point_hit_count); ExpectInt32("f()", 2); CHECK_EQ(2, break_point_hit_count); + // Direct call through API does not trigger breakpoint. + function->Call(env.local(), v8::Undefined(env->GetIsolate()), 0, nullptr) + .ToLocalChecked(); + CHECK_EQ(2, break_point_hit_count); + // Run without breakpoints. ClearBreakPoint(bp); ExpectInt32("f()", 2); @@ -1106,6 +1111,46 @@ TEST(BreakPointApiFunction) { CheckDebuggerUnloaded(); } +TEST(BreakPointApiConstructor) { + LocalContext env; + v8::HandleScope scope(env->GetIsolate()); + + DebugEventCounter delegate; + v8::debug::SetDebugDelegate(env->GetIsolate(), &delegate); + + i::Handle<i::BreakPoint> bp; + + v8::Local<v8::FunctionTemplate> function_template = + v8::FunctionTemplate::New(env->GetIsolate(), NoOpFunctionCallback); + + v8::Local<v8::Function> function = + function_template->GetFunction(env.local()).ToLocalChecked(); + + env->Global()->Set(env.local(), v8_str("f"), function).ToChecked(); + + // === Test simple builtin === + break_point_hit_count = 0; + + // Run with breakpoint. + bp = SetBreakPoint(function, 0, "this != 1"); + CompileRun("new f()"); + CHECK_EQ(1, break_point_hit_count); + CompileRun("new f()"); + CHECK_EQ(2, break_point_hit_count); + + // Direct call through API does not trigger breakpoint. + function->NewInstance(env.local()).ToLocalChecked(); + CHECK_EQ(2, break_point_hit_count); + + // Run without breakpoints. + ClearBreakPoint(bp); + CompileRun("new f()"); + CHECK_EQ(2, break_point_hit_count); + + v8::debug::SetDebugDelegate(env->GetIsolate(), nullptr); + CheckDebuggerUnloaded(); +} + void GetWrapperCallback(const v8::FunctionCallbackInfo<v8::Value>& args) { args.GetReturnValue().Set( args[0] @@ -1145,15 +1190,16 @@ TEST(BreakPointApiGetter) { // Run with breakpoint. bp = SetBreakPoint(function, 0); CompileRun("get_wrapper(o, 'f')"); - CHECK_EQ(1, break_point_hit_count); + CHECK_EQ(0, break_point_hit_count); CompileRun("o.f"); - CHECK_EQ(2, break_point_hit_count); + CHECK_EQ(1, break_point_hit_count); // Run without breakpoints. ClearBreakPoint(bp); CompileRun("get_wrapper(o, 'f', 2)"); - CHECK_EQ(2, break_point_hit_count); + CompileRun("o.f"); + CHECK_EQ(1, break_point_hit_count); v8::debug::SetDebugDelegate(env->GetIsolate(), nullptr); CheckDebuggerUnloaded(); @@ -1202,12 +1248,12 @@ TEST(BreakPointApiSetter) { CHECK_EQ(1, break_point_hit_count); CompileRun("set_wrapper(o, 'f', 2)"); - CHECK_EQ(2, break_point_hit_count); + CHECK_EQ(1, break_point_hit_count); // Run without breakpoints. ClearBreakPoint(bp); CompileRun("o.f = 3"); - CHECK_EQ(2, break_point_hit_count); + CHECK_EQ(1, break_point_hit_count); // === Test API builtin as setter, with condition === break_point_hit_count = 0; @@ -1218,15 +1264,16 @@ TEST(BreakPointApiSetter) { CHECK_EQ(0, break_point_hit_count); CompileRun("set_wrapper(o, 'f', 3)"); - CHECK_EQ(1, break_point_hit_count); + CHECK_EQ(0, break_point_hit_count); CompileRun("o.f = 3"); - CHECK_EQ(2, break_point_hit_count); + CHECK_EQ(1, break_point_hit_count); // Run without breakpoints. ClearBreakPoint(bp); CompileRun("set_wrapper(o, 'f', 2)"); - CHECK_EQ(2, break_point_hit_count); + CompileRun("o.f = 3"); + CHECK_EQ(1, break_point_hit_count); v8::debug::SetDebugDelegate(env->GetIsolate(), nullptr); CheckDebuggerUnloaded(); @@ -3435,6 +3482,35 @@ TEST(SyntaxErrorEventOnSyntaxException) { CHECK_EQ(3, delegate.compile_error_event_count); } +class ExceptionEventCounter : public v8::debug::DebugDelegate { + public: + void ExceptionThrown(v8::Local<v8::Context> paused_context, + v8::Local<v8::Value> exception, + v8::Local<v8::Value> promise, bool is_uncaught, + v8::debug::ExceptionType) override { + exception_event_count++; + } + int exception_event_count = 0; +}; + +TEST(NoBreakOnStackOverflow) { + i::FLAG_stack_size = 100; + LocalContext env; + v8::HandleScope scope(env->GetIsolate()); + + ChangeBreakOnException(true, true); + + ExceptionEventCounter delegate; + v8::debug::SetDebugDelegate(env->GetIsolate(), &delegate); + CHECK_EQ(0, delegate.exception_event_count); + + CompileRun( + "function f() { return f(); }" + "try { f() } catch {}"); + + CHECK_EQ(0, delegate.exception_event_count); +} + // Tests that break event is sent when event listener is reset. TEST(BreakEventWhenEventListenerIsReset) { LocalContext env; @@ -3854,7 +3930,7 @@ TEST(DebugBreakOffThreadTerminate) { DebugBreakTriggerTerminate delegate; v8::debug::SetDebugDelegate(isolate, &delegate); TerminationThread terminator(isolate); - terminator.Start(); + CHECK(terminator.Start()); v8::TryCatch try_catch(env->GetIsolate()); env->GetIsolate()->RequestInterrupt(BreakRightNow, nullptr); CompileRun("while (true);"); @@ -3950,7 +4026,7 @@ class ArchiveRestoreThread : public v8::base::Thread, // on) so that the ThreadManager is forced to archive and restore // the current thread. ArchiveRestoreThread child(isolate_, spawn_count_ - 1); - child.Start(); + CHECK(child.Start()); child.Join(); // The child thread sets itself as the debug delegate, so we need to diff --git a/deps/v8/test/cctest/test-disasm-arm64.cc b/deps/v8/test/cctest/test-disasm-arm64.cc index ed4fe6c6e0..ba4d92d3a2 100644 --- a/deps/v8/test/cctest/test-disasm-arm64.cc +++ b/deps/v8/test/cctest/test-disasm-arm64.cc @@ -854,7 +854,7 @@ TEST_(branch) { COMPARE(br(x0), "br x0"); COMPARE(blr(x1), "blr x1"); COMPARE(ret(x2), "ret x2"); - COMPARE(ret(lr), "ret") + COMPARE(ret(lr), "ret"); CLEANUP(); } @@ -1881,6 +1881,14 @@ TEST_(system_nop) { CLEANUP(); } +TEST(system_pauth) { + SET_UP_ASM(); + + COMPARE(pacia1716(), "pacia1716"); + COMPARE(paciasp(), "paciasp"); + COMPARE(autia1716(), "autia1716"); + COMPARE(autiasp(), "autiasp"); +} TEST_(debug) { InitializeVM(); diff --git a/deps/v8/test/cctest/test-disasm-x64.cc b/deps/v8/test/cctest/test-disasm-x64.cc index ff21e9b265..08793fba4a 100644 --- a/deps/v8/test/cctest/test-disasm-x64.cc +++ b/deps/v8/test/cctest/test-disasm-x64.cc @@ -517,6 +517,8 @@ TEST(DisasmX64) { __ haddps(xmm1, xmm0); __ haddps(xmm1, Operand(rbx, rcx, times_4, 10000)); __ lddqu(xmm1, Operand(rdx, 4)); + __ movddup(xmm1, Operand(rax, 5)); + __ movddup(xmm1, xmm2); } } diff --git a/deps/v8/test/cctest/test-elements-kind.cc b/deps/v8/test/cctest/test-elements-kind.cc index d08f6200ab..2f6ec6c164 100644 --- a/deps/v8/test/cctest/test-elements-kind.cc +++ b/deps/v8/test/cctest/test-elements-kind.cc @@ -63,6 +63,7 @@ bool ElementsKindIsHoleyElementsKindForRead(ElementsKind kind) { case ElementsKind::HOLEY_SMI_ELEMENTS: case ElementsKind::HOLEY_ELEMENTS: case ElementsKind::HOLEY_DOUBLE_ELEMENTS: + case ElementsKind::HOLEY_NONEXTENSIBLE_ELEMENTS: case ElementsKind::HOLEY_SEALED_ELEMENTS: case ElementsKind::HOLEY_FROZEN_ELEMENTS: return true; diff --git a/deps/v8/test/cctest/test-feedback-vector.cc b/deps/v8/test/cctest/test-feedback-vector.cc index 436925146b..91db7e51a5 100644 --- a/deps/v8/test/cctest/test-feedback-vector.cc +++ b/deps/v8/test/cctest/test-feedback-vector.cc @@ -438,9 +438,7 @@ TEST(VectorLoadICStates) { Handle<FeedbackVector>(f->feedback_vector(), isolate); FeedbackSlot slot(0); FeedbackNexus nexus(feedback_vector, slot); - CHECK_EQ(PREMONOMORPHIC, nexus.ic_state()); - CompileRun("f(o)"); CHECK_EQ(MONOMORPHIC, nexus.ic_state()); // Verify that the monomorphic map is the one we expect. v8::MaybeLocal<v8::Value> v8_o = @@ -526,16 +524,13 @@ TEST(VectorLoadICOnSmi) { CompileRun( "var o = { foo: 3 };" "%EnsureFeedbackVectorForFunction(f);" - "function f(a) { return a.foo; } f(o);"); + "function f(a) { return a.foo; } f(34);"); Handle<JSFunction> f = GetFunction("f"); // There should be one IC. Handle<FeedbackVector> feedback_vector = Handle<FeedbackVector>(f->feedback_vector(), isolate); FeedbackSlot slot(0); FeedbackNexus nexus(feedback_vector, slot); - CHECK_EQ(PREMONOMORPHIC, nexus.ic_state()); - - CompileRun("f(34)"); CHECK_EQ(MONOMORPHIC, nexus.ic_state()); // Verify that the monomorphic map is the one we expect. Map number_map = ReadOnlyRoots(heap).heap_number_map(); diff --git a/deps/v8/test/cctest/test-field-type-tracking.cc b/deps/v8/test/cctest/test-field-type-tracking.cc index d23078b68a..512bf2a9c6 100644 --- a/deps/v8/test/cctest/test-field-type-tracking.cc +++ b/deps/v8/test/cctest/test-field-type-tracking.cc @@ -2282,7 +2282,9 @@ TEST(ElementsKindTransitionFromMapOwningDescriptor) { {SEALED, factory->sealed_symbol(), FLAG_enable_sealed_frozen_elements_kind ? HOLEY_SEALED_ELEMENTS : DICTIONARY_ELEMENTS}, - {NONE, factory->nonextensible_symbol(), DICTIONARY_ELEMENTS}}; + {NONE, factory->nonextensible_symbol(), + FLAG_enable_sealed_frozen_elements_kind ? HOLEY_NONEXTENSIBLE_ELEMENTS + : DICTIONARY_ELEMENTS}}; for (size_t i = 0; i < arraysize(configs); i++) { TestGeneralizeFieldWithSpecialTransition( configs[i], @@ -2348,7 +2350,9 @@ TEST(ElementsKindTransitionFromMapNotOwningDescriptor) { {SEALED, factory->sealed_symbol(), FLAG_enable_sealed_frozen_elements_kind ? HOLEY_SEALED_ELEMENTS : DICTIONARY_ELEMENTS}, - {NONE, factory->nonextensible_symbol(), DICTIONARY_ELEMENTS}}; + {NONE, factory->nonextensible_symbol(), + FLAG_enable_sealed_frozen_elements_kind ? HOLEY_NONEXTENSIBLE_ELEMENTS + : DICTIONARY_ELEMENTS}}; for (size_t i = 0; i < arraysize(configs); i++) { TestGeneralizeFieldWithSpecialTransition( configs[i], @@ -2407,7 +2411,6 @@ TEST(PrototypeTransitionFromMapOwningDescriptor) { {PropertyConstness::kMutable, Representation::Tagged(), any_type}, true); } - TEST(PrototypeTransitionFromMapNotOwningDescriptor) { CcTest::InitializeVM(); v8::HandleScope scope(CcTest::isolate()); @@ -2461,7 +2464,6 @@ TEST(PrototypeTransitionFromMapNotOwningDescriptor) { {PropertyConstness::kMutable, Representation::Tagged(), any_type}, true); } - //////////////////////////////////////////////////////////////////////////////// // A set of tests for higher level transitioning mechanics. // @@ -2776,15 +2778,15 @@ TEST(TransitionAccessorConstantToSameAccessorConstant) { // TODO(ishell): add this test once IS_ACCESSOR_FIELD_SUPPORTED is supported. // TEST(TransitionAccessorConstantToAnotherAccessorConstant) -TEST(HoleyMutableHeapNumber) { +TEST(HoleyHeapNumber) { CcTest::InitializeVM(); v8::HandleScope scope(CcTest::isolate()); Isolate* isolate = CcTest::i_isolate(); - auto mhn = isolate->factory()->NewMutableHeapNumberWithHoleNaN(); + auto mhn = isolate->factory()->NewHeapNumberWithHoleNaN(); CHECK_EQ(kHoleNanInt64, mhn->value_as_bits()); - mhn = isolate->factory()->NewMutableHeapNumber(0.0); + mhn = isolate->factory()->NewHeapNumber(0.0); CHECK_EQ(uint64_t{0}, mhn->value_as_bits()); mhn->set_value_as_bits(kHoleNanInt64); @@ -2796,12 +2798,12 @@ TEST(HoleyMutableHeapNumber) { Handle<Object> obj = Object::NewStorageFor(isolate, isolate->factory()->uninitialized_value(), Representation::Double()); - CHECK(obj->IsMutableHeapNumber()); - CHECK_EQ(kHoleNanInt64, MutableHeapNumber::cast(*obj).value_as_bits()); + CHECK(obj->IsHeapNumber()); + CHECK_EQ(kHoleNanInt64, HeapNumber::cast(*obj).value_as_bits()); obj = Object::NewStorageFor(isolate, mhn, Representation::Double()); - CHECK(obj->IsMutableHeapNumber()); - CHECK_EQ(kHoleNanInt64, MutableHeapNumber::cast(*obj).value_as_bits()); + CHECK(obj->IsHeapNumber()); + CHECK_EQ(kHoleNanInt64, HeapNumber::cast(*obj).value_as_bits()); } namespace { diff --git a/deps/v8/test/cctest/test-flags.cc b/deps/v8/test/cctest/test-flags.cc index 93c7048f81..4e5fcffa62 100644 --- a/deps/v8/test/cctest/test-flags.cc +++ b/deps/v8/test/cctest/test-flags.cc @@ -209,5 +209,11 @@ TEST(FlagsJitlessImplications) { } } +TEST(FlagsRegexpInterpretAllImplications) { + if (FLAG_regexp_interpret_all) { + CHECK(!FLAG_regexp_tier_up); + } +} + } // 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 e534670bb6..3aec4ae003 100644 --- a/deps/v8/test/cctest/test-heap-profiler.cc +++ b/deps/v8/test/cctest/test-heap-profiler.cc @@ -46,6 +46,7 @@ #include "src/profiler/heap-snapshot-generator-inl.h" #include "test/cctest/cctest.h" #include "test/cctest/collector.h" +#include "test/cctest/heap/heap-utils.h" using i::AllocationTraceNode; using i::AllocationTraceTree; @@ -1693,6 +1694,154 @@ TEST(HeapSnapshotRetainedObjectInfo) { CHECK_EQ(native_group_ccc, GetChildByName(n_CCC, "ccc-group")); } +namespace { + +class EmbedderGraphBuilderForNativeSnapshotObjectId final { + public: + class RegularNode : public v8::EmbedderGraph::Node { + public: + RegularNode(v8::NativeObject native_object, const char* name, size_t size, + Node* wrapper_node) + : name_(name), + size_(size), + native_object_(native_object), + wrapper_node_(wrapper_node) {} + // v8::EmbedderGraph::Node + const char* Name() override { return name_; } + size_t SizeInBytes() override { return size_; } + Node* WrapperNode() override { return wrapper_node_; } + v8::NativeObject GetNativeObject() override { + return native_object_ ? native_object_ : this; + } + + private: + const char* name_; + size_t size_; + v8::NativeObject native_object_; + Node* wrapper_node_; + }; + + class RootNode : public RegularNode { + public: + explicit RootNode(const char* name) + : RegularNode(nullptr, name, 0, nullptr) {} + // v8::EmbedderGraph::EmbedderNode + bool IsRootNode() override { return true; } + }; + + struct BuildParameter { + v8::Persistent<v8::String>* wrapper; + void* native1; + void* native2; + }; + + static void BuildEmbedderGraph(v8::Isolate* isolate, v8::EmbedderGraph* graph, + void* data) { + BuildParameter* parameter = reinterpret_cast<BuildParameter*>(data); + v8::Local<v8::String> local_str = + v8::Local<v8::String>::New(isolate, *(parameter->wrapper)); + auto* v8_node = graph->V8Node(local_str); + CHECK(!v8_node->IsEmbedderNode()); + auto* root_node = + graph->AddNode(std::unique_ptr<RootNode>(new RootNode("root"))); + auto* non_merged_node = graph->AddNode(std::unique_ptr<RegularNode>( + new RegularNode(parameter->native1, "non-merged", 0, nullptr))); + auto* merged_node = graph->AddNode(std::unique_ptr<RegularNode>( + new RegularNode(parameter->native2, "merged", 0, v8_node))); + graph->AddEdge(root_node, non_merged_node); + graph->AddEdge(root_node, merged_node); + } +}; + +} // namespace + +TEST(NativeSnapshotObjectId) { + LocalContext env; + v8::Isolate* isolate = env->GetIsolate(); + v8::HandleScope scope(isolate); + v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler(); + + v8::Persistent<v8::String> wrapper(isolate, v8_str("wrapper")); + int native1; + int native2; + + EmbedderGraphBuilderForNativeSnapshotObjectId::BuildParameter parameter{ + &wrapper, &native1, &native2}; + heap_profiler->AddBuildEmbedderGraphCallback( + EmbedderGraphBuilderForNativeSnapshotObjectId::BuildEmbedderGraph, + ¶meter); + const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); + CHECK(ValidateSnapshot(snapshot)); + + v8::SnapshotObjectId non_merged_id = heap_profiler->GetObjectId(&native1); + CHECK_NE(v8::HeapProfiler::kUnknownObjectId, non_merged_id); + v8::SnapshotObjectId merged_id = heap_profiler->GetObjectId(&native2); + CHECK_NE(v8::HeapProfiler::kUnknownObjectId, merged_id); + CHECK_NE(non_merged_id, merged_id); + const v8::HeapGraphNode* non_merged_node = + snapshot->GetNodeById(non_merged_id); + CHECK_NOT_NULL(non_merged_node); + const v8::HeapGraphNode* merged_node = snapshot->GetNodeById(merged_id); + CHECK_NOT_NULL(merged_node); + + heap_profiler->ClearObjectIds(); + CHECK_EQ(v8::HeapProfiler::kUnknownObjectId, + heap_profiler->GetObjectId(&native1)); + CHECK_EQ(v8::HeapProfiler::kUnknownObjectId, + heap_profiler->GetObjectId(&native2)); +} + +TEST(NativeSnapshotObjectIdMoving) { + // Required to allow moving specific objects. + i::FLAG_manual_evacuation_candidates_selection = true; + + LocalContext env; + v8::Isolate* isolate = env->GetIsolate(); + v8::HandleScope scope(isolate); + v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler(); + heap_profiler->StartTrackingHeapObjects(true); + + v8::Persistent<v8::String> wrapper(isolate, v8_str("wrapper")); + int native1; + int native2; + + EmbedderGraphBuilderForNativeSnapshotObjectId::BuildParameter parameter{ + &wrapper, &native1, &native2}; + heap_profiler->AddBuildEmbedderGraphCallback( + EmbedderGraphBuilderForNativeSnapshotObjectId::BuildEmbedderGraph, + ¶meter); + const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); + CHECK(ValidateSnapshot(snapshot)); + + v8::SnapshotObjectId non_merged_id = heap_profiler->GetObjectId(&native1); + CHECK_NE(v8::HeapProfiler::kUnknownObjectId, non_merged_id); + v8::SnapshotObjectId merged_id = heap_profiler->GetObjectId(&native2); + CHECK_NE(v8::HeapProfiler::kUnknownObjectId, merged_id); + CHECK_NE(non_merged_id, merged_id); + const v8::HeapGraphNode* non_merged_node = + snapshot->GetNodeById(non_merged_id); + CHECK_NOT_NULL(non_merged_node); + const v8::HeapGraphNode* merged_node = snapshot->GetNodeById(merged_id); + CHECK_NOT_NULL(merged_node); + + { + v8::HandleScope scope(isolate); + auto local = v8::Local<v8::String>::New(isolate, wrapper); + i::Handle<i::String> internal = i::Handle<i::String>::cast( + v8::Utils::OpenHandle(*v8::Local<v8::String>::Cast(local))); + i::heap::ForceEvacuationCandidate(i::Page::FromHeapObject(*internal)); + } + CcTest::CollectAllGarbage(); + + non_merged_id = heap_profiler->GetObjectId(&native1); + CHECK_NE(v8::HeapProfiler::kUnknownObjectId, non_merged_id); + merged_id = heap_profiler->GetObjectId(&native2); + CHECK_NE(v8::HeapProfiler::kUnknownObjectId, merged_id); + CHECK_NE(non_merged_id, merged_id); + + heap_profiler->StopTrackingHeapObjects(); +} + TEST(DeleteAllHeapSnapshots) { LocalContext env; v8::HandleScope scope(env->GetIsolate()); diff --git a/deps/v8/test/cctest/test-inobject-slack-tracking.cc b/deps/v8/test/cctest/test-inobject-slack-tracking.cc index f0df0c6149..6a25536dd5 100644 --- a/deps/v8/test/cctest/test-inobject-slack-tracking.cc +++ b/deps/v8/test/cctest/test-inobject-slack-tracking.cc @@ -84,8 +84,8 @@ static double GetDoubleFieldValue(JSObject obj, FieldIndex field_index) { return obj.RawFastDoublePropertyAt(field_index); } else { Object value = obj.RawFastPropertyAt(field_index); - if (value.IsMutableHeapNumber()) { - return MutableHeapNumber::cast(value).value(); + if (value.IsHeapNumber()) { + return HeapNumber::cast(value).value(); } else { return value.Number(); } diff --git a/deps/v8/test/cctest/test-js-weak-refs.cc b/deps/v8/test/cctest/test-js-weak-refs.cc index 51add24a60..9e44c3ad20 100644 --- a/deps/v8/test/cctest/test-js-weak-refs.cc +++ b/deps/v8/test/cctest/test-js-weak-refs.cc @@ -731,7 +731,7 @@ TEST(TestJSWeakRefKeepDuringJob) { CHECK(!weak_ref->target().IsUndefined(isolate)); // Clears the KeepDuringJob set. - isolate->default_microtask_queue()->RunMicrotasks(isolate); + context->GetIsolate()->ClearKeptObjects(); CcTest::CollectAllGarbage(); CHECK(weak_ref->target().IsUndefined(isolate)); @@ -769,7 +769,7 @@ TEST(TestJSWeakRefKeepDuringJobIncrementalMarking) { CHECK(!weak_ref->target().IsUndefined(isolate)); // Clears the KeepDuringJob set. - isolate->default_microtask_queue()->RunMicrotasks(isolate); + context->GetIsolate()->ClearKeptObjects(); heap::SimulateIncrementalMarking(heap, true); CcTest::CollectAllGarbage(); diff --git a/deps/v8/test/cctest/test-lockers.cc b/deps/v8/test/cctest/test-lockers.cc index 571b0000eb..092c107841 100644 --- a/deps/v8/test/cctest/test-lockers.cc +++ b/deps/v8/test/cctest/test-lockers.cc @@ -82,7 +82,7 @@ void UnlockForDeoptimization(const v8::FunctionCallbackInfo<v8::Value>& args) { isolate->Exit(); v8::Unlocker unlocker(isolate); // Starts the deoptimizing thread. - deoptimizer->Start(); + CHECK(deoptimizer->Start()); // Waits for deoptimization to finish. deoptimizer->Join(); } @@ -107,7 +107,7 @@ void UnlockForDeoptimizationIfReady( isolate->Exit(); v8::Unlocker unlocker(isolate); // Starts the thread that deoptimizes the function. - deoptimizer->Start(); + CHECK(deoptimizer->Start()); // Waits for the deoptimizing thread to finish. deoptimizer->Join(); } @@ -339,7 +339,7 @@ TEST(KangarooIsolates) { CompileRun("function getValue() { return 30; }"); thread1.reset(new KangarooThread(isolate, context)); } - thread1->Start(); + CHECK(thread1->Start()); thread1->Join(); } @@ -364,9 +364,7 @@ class JoinableThread { virtual ~JoinableThread() = default; - void Start() { - thread_.Start(); - } + void Start() { CHECK(thread_.Start()); } void Join() { semaphore_.Wait(); diff --git a/deps/v8/test/cctest/test-log-stack-tracer.cc b/deps/v8/test/cctest/test-log-stack-tracer.cc index 83060f0cac..854a31f66b 100644 --- a/deps/v8/test/cctest/test-log-stack-tracer.cc +++ b/deps/v8/test/cctest/test-log-stack-tracer.cc @@ -37,6 +37,7 @@ #include "src/execution/vm-state-inl.h" #include "src/init/v8.h" #include "src/objects/objects-inl.h" +#include "src/profiler/tick-sample.h" #include "test/cctest/cctest.h" #include "test/cctest/trace-extension.h" diff --git a/deps/v8/test/cctest/test-orderedhashtable.cc b/deps/v8/test/cctest/test-orderedhashtable.cc index 9b1bc651fa..44a845eb74 100644 --- a/deps/v8/test/cctest/test-orderedhashtable.cc +++ b/deps/v8/test/cctest/test-orderedhashtable.cc @@ -509,14 +509,14 @@ TEST(OrderedHashTableInsertion) { Handle<Smi> key1(Smi::FromInt(1), isolate); Handle<Smi> value1(Smi::FromInt(1), isolate); CHECK(!OrderedHashMap::HasKey(isolate, *map, *key1)); - map = OrderedHashMap::Add(isolate, map, key1, value1); + map = OrderedHashMap::Add(isolate, map, key1, value1).ToHandleChecked(); Verify(isolate, map); CHECK_EQ(2, map->NumberOfBuckets()); CHECK_EQ(1, map->NumberOfElements()); CHECK(OrderedHashMap::HasKey(isolate, *map, *key1)); // Add existing key. - map = OrderedHashMap::Add(isolate, map, key1, value1); + map = OrderedHashMap::Add(isolate, map, key1, value1).ToHandleChecked(); Verify(isolate, map); CHECK_EQ(2, map->NumberOfBuckets()); CHECK_EQ(1, map->NumberOfElements()); @@ -525,14 +525,14 @@ TEST(OrderedHashTableInsertion) { Handle<String> key2 = factory->NewStringFromAsciiChecked("foo"); Handle<String> value = factory->NewStringFromAsciiChecked("bar"); CHECK(!OrderedHashMap::HasKey(isolate, *map, *key2)); - map = OrderedHashMap::Add(isolate, map, key2, value); + map = OrderedHashMap::Add(isolate, map, key2, value).ToHandleChecked(); Verify(isolate, map); CHECK_EQ(2, map->NumberOfBuckets()); CHECK_EQ(2, map->NumberOfElements()); CHECK(OrderedHashMap::HasKey(isolate, *map, *key1)); CHECK(OrderedHashMap::HasKey(isolate, *map, *key2)); - map = OrderedHashMap::Add(isolate, map, key2, value); + map = OrderedHashMap::Add(isolate, map, key2, value).ToHandleChecked(); Verify(isolate, map); CHECK_EQ(2, map->NumberOfBuckets()); CHECK_EQ(2, map->NumberOfElements()); @@ -541,7 +541,7 @@ TEST(OrderedHashTableInsertion) { Handle<Symbol> key3 = factory->NewSymbol(); CHECK(!OrderedHashMap::HasKey(isolate, *map, *key3)); - map = OrderedHashMap::Add(isolate, map, key3, value); + map = OrderedHashMap::Add(isolate, map, key3, value).ToHandleChecked(); Verify(isolate, map); CHECK_EQ(2, map->NumberOfBuckets()); CHECK_EQ(3, map->NumberOfElements()); @@ -549,7 +549,7 @@ TEST(OrderedHashTableInsertion) { CHECK(OrderedHashMap::HasKey(isolate, *map, *key2)); CHECK(OrderedHashMap::HasKey(isolate, *map, *key3)); - map = OrderedHashMap::Add(isolate, map, key3, value); + map = OrderedHashMap::Add(isolate, map, key3, value).ToHandleChecked(); Verify(isolate, map); CHECK_EQ(2, map->NumberOfBuckets()); CHECK_EQ(3, map->NumberOfElements()); @@ -559,7 +559,7 @@ TEST(OrderedHashTableInsertion) { Handle<Object> key4 = factory->NewHeapNumber(42.0); CHECK(!OrderedHashMap::HasKey(isolate, *map, *key4)); - map = OrderedHashMap::Add(isolate, map, key4, value); + map = OrderedHashMap::Add(isolate, map, key4, value).ToHandleChecked(); Verify(isolate, map); CHECK_EQ(2, map->NumberOfBuckets()); CHECK_EQ(4, map->NumberOfElements()); @@ -568,7 +568,7 @@ TEST(OrderedHashTableInsertion) { CHECK(OrderedHashMap::HasKey(isolate, *map, *key3)); CHECK(OrderedHashMap::HasKey(isolate, *map, *key4)); - map = OrderedHashMap::Add(isolate, map, key4, value); + map = OrderedHashMap::Add(isolate, map, key4, value).ToHandleChecked(); Verify(isolate, map); CHECK_EQ(2, map->NumberOfBuckets()); CHECK_EQ(4, map->NumberOfElements()); @@ -587,7 +587,7 @@ TEST(OrderedHashMapDuplicateHashCode) { Handle<OrderedHashMap> map = factory->NewOrderedHashMap(); Handle<JSObject> key1 = factory->NewJSObjectWithNullProto(); Handle<JSObject> value = factory->NewJSObjectWithNullProto(); - map = OrderedHashMap::Add(isolate, map, key1, value); + map = OrderedHashMap::Add(isolate, map, key1, value).ToHandleChecked(); Verify(isolate, map); CHECK_EQ(2, map->NumberOfBuckets()); CHECK_EQ(1, map->NumberOfElements()); @@ -596,7 +596,7 @@ TEST(OrderedHashMapDuplicateHashCode) { Handle<JSObject> key2 = factory->NewJSObjectWithNullProto(); CopyHashCode(key1, key2); - map = OrderedHashMap::Add(isolate, map, key2, value); + map = OrderedHashMap::Add(isolate, map, key2, value).ToHandleChecked(); Verify(isolate, map); CHECK_EQ(2, map->NumberOfBuckets()); CHECK_EQ(2, map->NumberOfElements()); @@ -627,7 +627,7 @@ TEST(OrderedHashMapDeletion) { CHECK_EQ(0, map->NumberOfDeletedElements()); CHECK(!OrderedHashMap::HasKey(isolate, *map, *key1)); - map = OrderedHashMap::Add(isolate, map, key1, value1); + map = OrderedHashMap::Add(isolate, map, key1, value1).ToHandleChecked(); Verify(isolate, map); CHECK_EQ(2, map->NumberOfBuckets()); CHECK_EQ(1, map->NumberOfElements()); @@ -642,7 +642,7 @@ TEST(OrderedHashMapDeletion) { CHECK_EQ(1, map->NumberOfDeletedElements()); CHECK(!OrderedHashMap::HasKey(isolate, *map, *key1)); - map = OrderedHashMap::Add(isolate, map, key1, value1); + map = OrderedHashMap::Add(isolate, map, key1, value1).ToHandleChecked(); Verify(isolate, map); CHECK_EQ(2, map->NumberOfBuckets()); CHECK_EQ(1, map->NumberOfElements()); @@ -651,7 +651,7 @@ TEST(OrderedHashMapDeletion) { Handle<String> key2 = factory->NewStringFromAsciiChecked("foo"); CHECK(!OrderedHashMap::HasKey(isolate, *map, *key2)); - map = OrderedHashMap::Add(isolate, map, key2, value); + map = OrderedHashMap::Add(isolate, map, key2, value).ToHandleChecked(); Verify(isolate, map); CHECK_EQ(2, map->NumberOfBuckets()); CHECK_EQ(2, map->NumberOfElements()); @@ -660,7 +660,7 @@ TEST(OrderedHashMapDeletion) { Handle<Symbol> key3 = factory->NewSymbol(); CHECK(!OrderedHashMap::HasKey(isolate, *map, *key3)); - map = OrderedHashMap::Add(isolate, map, key3, value); + map = OrderedHashMap::Add(isolate, map, key3, value).ToHandleChecked(); Verify(isolate, map); CHECK_EQ(2, map->NumberOfBuckets()); CHECK_EQ(3, map->NumberOfElements()); @@ -709,7 +709,7 @@ TEST(OrderedHashMapDeletion) { // Delete non existent key from non empty hash table map = OrderedHashMap::Shrink(isolate, map); - map = OrderedHashMap::Add(isolate, map, key1, value); + map = OrderedHashMap::Add(isolate, map, key1, value).ToHandleChecked(); Verify(isolate, map); CHECK_EQ(2, map->NumberOfBuckets()); CHECK_EQ(1, map->NumberOfElements()); @@ -858,7 +858,7 @@ TEST(OrderedHashMapDuplicateHashCodeDeletion) { Handle<OrderedHashMap> map = factory->NewOrderedHashMap(); Handle<JSObject> key1 = factory->NewJSObjectWithNullProto(); Handle<JSObject> value = factory->NewJSObjectWithNullProto(); - map = OrderedHashMap::Add(isolate, map, key1, value); + map = OrderedHashMap::Add(isolate, map, key1, value).ToHandleChecked(); Verify(isolate, map); CHECK_EQ(2, map->NumberOfBuckets()); CHECK_EQ(1, map->NumberOfElements()); @@ -928,7 +928,7 @@ TEST(OrderedHashSetDeletion) { CHECK_EQ(0, set->NumberOfDeletedElements()); CHECK(!OrderedHashSet::HasKey(isolate, *set, *key1)); - set = OrderedHashSet::Add(isolate, set, key1); + set = OrderedHashSet::Add(isolate, set, key1).ToHandleChecked(); Verify(isolate, set); CHECK_EQ(2, set->NumberOfBuckets()); CHECK_EQ(1, set->NumberOfElements()); @@ -943,7 +943,7 @@ TEST(OrderedHashSetDeletion) { CHECK_EQ(1, set->NumberOfDeletedElements()); CHECK(!OrderedHashSet::HasKey(isolate, *set, *key1)); - set = OrderedHashSet::Add(isolate, set, key1); + set = OrderedHashSet::Add(isolate, set, key1).ToHandleChecked(); Verify(isolate, set); CHECK_EQ(2, set->NumberOfBuckets()); CHECK_EQ(1, set->NumberOfElements()); @@ -952,7 +952,7 @@ TEST(OrderedHashSetDeletion) { Handle<String> key2 = factory->NewStringFromAsciiChecked("foo"); CHECK(!OrderedHashSet::HasKey(isolate, *set, *key2)); - set = OrderedHashSet::Add(isolate, set, key2); + set = OrderedHashSet::Add(isolate, set, key2).ToHandleChecked(); Verify(isolate, set); CHECK_EQ(2, set->NumberOfBuckets()); CHECK_EQ(2, set->NumberOfElements()); @@ -961,7 +961,7 @@ TEST(OrderedHashSetDeletion) { Handle<Symbol> key3 = factory->NewSymbol(); CHECK(!OrderedHashSet::HasKey(isolate, *set, *key3)); - set = OrderedHashSet::Add(isolate, set, key3); + set = OrderedHashSet::Add(isolate, set, key3).ToHandleChecked(); Verify(isolate, set); CHECK_EQ(2, set->NumberOfBuckets()); CHECK_EQ(3, set->NumberOfElements()); @@ -1010,7 +1010,7 @@ TEST(OrderedHashSetDeletion) { // Delete non existent key from non empty hash table set = OrderedHashSet::Shrink(isolate, set); - set = OrderedHashSet::Add(isolate, set, key1); + set = OrderedHashSet::Add(isolate, set, key1).ToHandleChecked(); Verify(isolate, set); CHECK_EQ(2, set->NumberOfBuckets()); CHECK_EQ(1, set->NumberOfElements()); @@ -1156,7 +1156,7 @@ TEST(OrderedHashSetDuplicateHashCodeDeletion) { Handle<OrderedHashSet> set = factory->NewOrderedHashSet(); Handle<JSObject> key1 = factory->NewJSObjectWithNullProto(); - set = OrderedHashSet::Add(isolate, set, key1); + set = OrderedHashSet::Add(isolate, set, key1).ToHandleChecked(); Verify(isolate, set); CHECK_EQ(2, set->NumberOfBuckets()); CHECK_EQ(1, set->NumberOfElements()); @@ -1209,25 +1209,26 @@ TEST(OrderedHashSetHandlerInsertion) { Isolate* isolate = GetIsolateFrom(&context); HandleScope scope(isolate); - Handle<HeapObject> set = OrderedHashSetHandler::Allocate(isolate, 4); + Handle<HeapObject> set = + OrderedHashSetHandler::Allocate(isolate, 4).ToHandleChecked(); Verify(isolate, set); // Add a new key. Handle<Smi> key1(Smi::FromInt(1), isolate); CHECK(!OrderedHashSetHandler::HasKey(isolate, set, key1)); - set = OrderedHashSetHandler::Add(isolate, set, key1); + set = OrderedHashSetHandler::Add(isolate, set, key1).ToHandleChecked(); Verify(isolate, set); CHECK(OrderedHashSetHandler::HasKey(isolate, set, key1)); // Add existing key. - set = OrderedHashSetHandler::Add(isolate, set, key1); + set = OrderedHashSetHandler::Add(isolate, set, key1).ToHandleChecked(); Verify(isolate, set); CHECK(OrderedHashSetHandler::HasKey(isolate, set, key1)); CHECK(SmallOrderedHashSet::Is(set)); for (int i = 0; i < 1024; i++) { Handle<Smi> key_i(Smi::FromInt(i), isolate); - set = OrderedHashSetHandler::Add(isolate, set, key_i); + set = OrderedHashSetHandler::Add(isolate, set, key_i).ToHandleChecked(); Verify(isolate, set); for (int j = 0; j <= i; j++) { Handle<Smi> key_j(Smi::FromInt(j), isolate); @@ -1242,26 +1243,30 @@ TEST(OrderedHashMapHandlerInsertion) { Isolate* isolate = GetIsolateFrom(&context); HandleScope scope(isolate); - Handle<HeapObject> map = OrderedHashMapHandler::Allocate(isolate, 4); + Handle<HeapObject> map = + OrderedHashMapHandler::Allocate(isolate, 4).ToHandleChecked(); Verify(isolate, map); // Add a new key. Handle<Smi> key1(Smi::FromInt(1), isolate); Handle<Smi> value1(Smi::FromInt(1), isolate); CHECK(!OrderedHashMapHandler::HasKey(isolate, map, key1)); - map = OrderedHashMapHandler::Add(isolate, map, key1, value1); + map = + OrderedHashMapHandler::Add(isolate, map, key1, value1).ToHandleChecked(); Verify(isolate, map); CHECK(OrderedHashMapHandler::HasKey(isolate, map, key1)); // Add existing key. - map = OrderedHashMapHandler::Add(isolate, map, key1, value1); + map = + OrderedHashMapHandler::Add(isolate, map, key1, value1).ToHandleChecked(); Verify(isolate, map); CHECK(OrderedHashMapHandler::HasKey(isolate, map, key1)); CHECK(SmallOrderedHashMap::Is(map)); for (int i = 0; i < 1024; i++) { Handle<Smi> key_i(Smi::FromInt(i), isolate); Handle<Smi> value_i(Smi::FromInt(i), isolate); - map = OrderedHashMapHandler::Add(isolate, map, key_i, value_i); + map = OrderedHashMapHandler::Add(isolate, map, key_i, value_i) + .ToHandleChecked(); Verify(isolate, map); for (int j = 0; j <= i; j++) { Handle<Smi> key_j(Smi::FromInt(j), isolate); @@ -1286,7 +1291,8 @@ TEST(OrderedNameDictionaryInsertion) { Handle<String> value = isolate->factory()->InternalizeUtf8String("bar"); CHECK_EQ(OrderedNameDictionary::kNotFound, dict->FindEntry(isolate, *key1)); PropertyDetails details = PropertyDetails::Empty(); - dict = OrderedNameDictionary::Add(isolate, dict, key1, value, details); + dict = OrderedNameDictionary::Add(isolate, dict, key1, value, details) + .ToHandleChecked(); Verify(isolate, dict); CHECK_EQ(2, dict->NumberOfBuckets()); CHECK_EQ(1, dict->NumberOfElements()); @@ -1295,7 +1301,8 @@ TEST(OrderedNameDictionaryInsertion) { Handle<Symbol> key2 = factory->NewSymbol(); CHECK_EQ(OrderedNameDictionary::kNotFound, dict->FindEntry(isolate, *key2)); - dict = OrderedNameDictionary::Add(isolate, dict, key2, value, details); + dict = OrderedNameDictionary::Add(isolate, dict, key2, value, details) + .ToHandleChecked(); Verify(isolate, dict); CHECK_EQ(2, dict->NumberOfBuckets()); CHECK_EQ(2, dict->NumberOfElements()); @@ -1317,7 +1324,8 @@ TEST(OrderedNameDictionaryFindEntry) { Handle<String> key1 = isolate->factory()->InternalizeUtf8String("foo"); Handle<String> value = isolate->factory()->InternalizeUtf8String("bar"); PropertyDetails details = PropertyDetails::Empty(); - dict = OrderedNameDictionary::Add(isolate, dict, key1, value, details); + dict = OrderedNameDictionary::Add(isolate, dict, key1, value, details) + .ToHandleChecked(); Verify(isolate, dict); CHECK_EQ(2, dict->NumberOfBuckets()); CHECK_EQ(1, dict->NumberOfElements()); @@ -1327,7 +1335,8 @@ TEST(OrderedNameDictionaryFindEntry) { CHECK_NE(entry, OrderedNameDictionary::kNotFound); Handle<Symbol> key2 = factory->NewSymbol(); - dict = OrderedNameDictionary::Add(isolate, dict, key2, value, details); + dict = OrderedNameDictionary::Add(isolate, dict, key2, value, details) + .ToHandleChecked(); Verify(isolate, dict); CHECK_EQ(2, dict->NumberOfBuckets()); CHECK_EQ(2, dict->NumberOfElements()); @@ -1356,7 +1365,8 @@ TEST(OrderedNameDictionaryValueAtAndValueAtPut) { Handle<String> value = isolate->factory()->InternalizeUtf8String("bar"); CHECK_EQ(OrderedNameDictionary::kNotFound, dict->FindEntry(isolate, *key1)); PropertyDetails details = PropertyDetails::Empty(); - dict = OrderedNameDictionary::Add(isolate, dict, key1, value, details); + dict = OrderedNameDictionary::Add(isolate, dict, key1, value, details) + .ToHandleChecked(); Verify(isolate, dict); CHECK_EQ(2, dict->NumberOfBuckets()); CHECK_EQ(1, dict->NumberOfElements()); @@ -1376,7 +1386,8 @@ TEST(OrderedNameDictionaryValueAtAndValueAtPut) { Handle<Symbol> key2 = factory->NewSymbol(); CHECK_EQ(OrderedNameDictionary::kNotFound, dict->FindEntry(isolate, *key2)); - dict = OrderedNameDictionary::Add(isolate, dict, key2, value, details); + dict = OrderedNameDictionary::Add(isolate, dict, key2, value, details) + .ToHandleChecked(); Verify(isolate, dict); CHECK_EQ(2, dict->NumberOfBuckets()); CHECK_EQ(2, dict->NumberOfElements()); @@ -1414,7 +1425,8 @@ TEST(OrderedNameDictionaryDetailsAtAndDetailsAtPut) { Handle<String> value = isolate->factory()->InternalizeUtf8String("bar"); CHECK_EQ(OrderedNameDictionary::kNotFound, dict->FindEntry(isolate, *key1)); PropertyDetails details = PropertyDetails::Empty(); - dict = OrderedNameDictionary::Add(isolate, dict, key1, value, details); + dict = OrderedNameDictionary::Add(isolate, dict, key1, value, details) + .ToHandleChecked(); Verify(isolate, dict); CHECK_EQ(2, dict->NumberOfBuckets()); CHECK_EQ(1, dict->NumberOfElements()); @@ -1434,7 +1446,8 @@ TEST(OrderedNameDictionaryDetailsAtAndDetailsAtPut) { Handle<Symbol> key2 = factory->NewSymbol(); CHECK_EQ(OrderedNameDictionary::kNotFound, dict->FindEntry(isolate, *key2)); - dict = OrderedNameDictionary::Add(isolate, dict, key2, value, details); + dict = OrderedNameDictionary::Add(isolate, dict, key2, value, details) + .ToHandleChecked(); Verify(isolate, dict); CHECK_EQ(2, dict->NumberOfBuckets()); CHECK_EQ(2, dict->NumberOfElements()); @@ -1725,7 +1738,8 @@ TEST(OrderedNameDictionarySetAndMigrateHash) { for (int i = 0; i <= 1024; i++) { CHECK_LT(0, snprintf(buf, sizeof(buf), "foo%d", i)); Handle<String> key = isolate->factory()->InternalizeUtf8String(buf); - dict = OrderedNameDictionary::Add(isolate, dict, key, value, details); + dict = OrderedNameDictionary::Add(isolate, dict, key, value, details) + .ToHandleChecked(); Verify(isolate, dict); CHECK_EQ(100, dict->Hash()); } @@ -1736,7 +1750,8 @@ TEST(OrderedNameDictionaryHandlerInsertion) { Isolate* isolate = GetIsolateFrom(&context); HandleScope scope(isolate); - Handle<HeapObject> table = OrderedNameDictionaryHandler::Allocate(isolate, 4); + Handle<HeapObject> table = + OrderedNameDictionaryHandler::Allocate(isolate, 4).ToHandleChecked(); CHECK(table->IsSmallOrderedNameDictionary()); Verify(isolate, table); @@ -1745,8 +1760,8 @@ TEST(OrderedNameDictionaryHandlerInsertion) { Handle<String> key = isolate->factory()->InternalizeUtf8String("foo"); PropertyDetails details = PropertyDetails::Empty(); - table = - OrderedNameDictionaryHandler::Add(isolate, table, key, value, details); + table = OrderedNameDictionaryHandler::Add(isolate, table, key, value, details) + .ToHandleChecked(); DCHECK(key->IsUniqueName()); Verify(isolate, table); CHECK(table->IsSmallOrderedNameDictionary()); @@ -1758,7 +1773,8 @@ TEST(OrderedNameDictionaryHandlerInsertion) { CHECK_LT(0, snprintf(buf, sizeof(buf), "foo%d", i)); key = isolate->factory()->InternalizeUtf8String(buf); table = - OrderedNameDictionaryHandler::Add(isolate, table, key, value, details); + OrderedNameDictionaryHandler::Add(isolate, table, key, value, details) + .ToHandleChecked(); DCHECK(key->IsUniqueName()); Verify(isolate, table); @@ -1798,7 +1814,8 @@ TEST(OrderedNameDictionarySetEntry) { Handle<String> value = factory->InternalizeUtf8String("bar"); CHECK_EQ(OrderedNameDictionary::kNotFound, dict->FindEntry(isolate, *key)); PropertyDetails details = PropertyDetails::Empty(); - dict = OrderedNameDictionary::Add(isolate, dict, key, value, details); + dict = OrderedNameDictionary::Add(isolate, dict, key, value, details) + .ToHandleChecked(); Verify(isolate, dict); CHECK_EQ(2, dict->NumberOfBuckets()); CHECK_EQ(1, dict->NumberOfElements()); @@ -1884,7 +1901,8 @@ TEST(OrderedNameDictionaryDeleteEntry) { Handle<String> value = factory->InternalizeUtf8String("bar"); CHECK_EQ(OrderedNameDictionary::kNotFound, dict->FindEntry(isolate, *key)); PropertyDetails details = PropertyDetails::Empty(); - dict = OrderedNameDictionary::Add(isolate, dict, key, value, details); + dict = OrderedNameDictionary::Add(isolate, dict, key, value, details) + .ToHandleChecked(); Verify(isolate, dict); CHECK_EQ(2, dict->NumberOfBuckets()); CHECK_EQ(1, dict->NumberOfElements()); @@ -1903,7 +1921,8 @@ TEST(OrderedNameDictionaryDeleteEntry) { for (int i = 0; i < 100; i++) { CHECK_LT(0, snprintf(buf, sizeof(buf), "foo%d", i)); key = factory->InternalizeUtf8String(buf); - dict = OrderedNameDictionary::Add(isolate, dict, key, value, details); + dict = OrderedNameDictionary::Add(isolate, dict, key, value, details) + .ToHandleChecked(); DCHECK(key->IsUniqueName()); Verify(isolate, dict); } diff --git a/deps/v8/test/cctest/test-parsing.cc b/deps/v8/test/cctest/test-parsing.cc index ba69b6d2f6..857bd7a454 100644 --- a/deps/v8/test/cctest/test-parsing.cc +++ b/deps/v8/test/cctest/test-parsing.cc @@ -261,6 +261,7 @@ TEST(ArrowOrAssignmentOp) { bool TokenIsBinaryOp(Token::Value token) { switch (token) { case Token::COMMA: + case Token::NULLISH: case Token::OR: case Token::AND: #define T(name, string, precedence) case Token::name: @@ -390,6 +391,7 @@ bool TokenIsPropertyOrCall(Token::Value token) { case Token::TEMPLATE_SPAN: case Token::TEMPLATE_TAIL: case Token::PERIOD: + case Token::QUESTION_PERIOD: case Token::LBRACK: case Token::LPAREN: return true; @@ -1096,7 +1098,7 @@ TEST(ScopeUsesArgumentsSuperThis) { } if (is_sloppy(scope->language_mode())) { CHECK_EQ((source_data[i].expected & EVAL) != 0, - scope->AsDeclarationScope()->calls_sloppy_eval()); + scope->AsDeclarationScope()->sloppy_eval_can_extend_vars()); } } } @@ -1529,7 +1531,8 @@ enum ParserFlag { kAllowHarmonyPrivateMethods, kAllowHarmonyDynamicImport, kAllowHarmonyImportMeta, - kAllowHarmonyNumericSeparator + kAllowHarmonyNullish, + kAllowHarmonyOptionalChaining, }; enum ParserSyncTestResult { @@ -1543,8 +1546,9 @@ void SetGlobalFlags(base::EnumSet<ParserFlag> flags) { i::FLAG_harmony_private_methods = flags.contains(kAllowHarmonyPrivateMethods); i::FLAG_harmony_dynamic_import = flags.contains(kAllowHarmonyDynamicImport); i::FLAG_harmony_import_meta = flags.contains(kAllowHarmonyImportMeta); - i::FLAG_harmony_numeric_separator = - flags.contains(kAllowHarmonyNumericSeparator); + i::FLAG_harmony_optional_chaining = + flags.contains(kAllowHarmonyOptionalChaining); + i::FLAG_harmony_nullish = flags.contains(kAllowHarmonyNullish); } void SetParserFlags(i::PreParser* parser, base::EnumSet<ParserFlag> flags) { @@ -1555,8 +1559,9 @@ void SetParserFlags(i::PreParser* parser, base::EnumSet<ParserFlag> flags) { flags.contains(kAllowHarmonyDynamicImport)); parser->set_allow_harmony_import_meta( flags.contains(kAllowHarmonyImportMeta)); - parser->set_allow_harmony_numeric_separator( - flags.contains(kAllowHarmonyNumericSeparator)); + parser->set_allow_harmony_optional_chaining( + flags.contains(kAllowHarmonyOptionalChaining)); + parser->set_allow_harmony_nullish(flags.contains(kAllowHarmonyNullish)); } void TestParserSyncWithFlags(i::Handle<i::String> source, @@ -1883,6 +1888,18 @@ void RunModuleParserSyncTest( always_false_len, true, test_preparser, ignore_error_msg); } +TEST(NonOctalDecimalIntegerStrictError) { + v8::HandleScope handles(CcTest::isolate()); + v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); + v8::Context::Scope context_scope(context); + + const char* context_data[][2] = {{"\"use strict\";", ""}, {nullptr, nullptr}}; + const char* statement_data[] = {"09", "09.1_2", nullptr}; + + RunParserSyncTest(context_data, statement_data, kError, nullptr, 0, nullptr, + 0, nullptr, 0, false, true); +} + TEST(NumericSeparator) { v8::HandleScope handles(CcTest::isolate()); v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); @@ -1894,11 +1911,7 @@ TEST(NumericSeparator) { "1_0_0_0", "1_0e+1", "1_0e+1_0", "0xF_F_FF", "0o7_7_7", "0b0_1_0_1_0", ".3_2_1", "0.0_2_1", "1_0.0_1", ".0_1_2", nullptr}; - static const ParserFlag flags[] = {kAllowHarmonyNumericSeparator}; - RunParserSyncTest(context_data, statement_data, kSuccess, nullptr, 0, flags, - 1); - - RunParserSyncTest(context_data, statement_data, kError); + RunParserSyncTest(context_data, statement_data, kSuccess); } TEST(NumericSeparatorErrors) { @@ -1914,11 +1927,8 @@ TEST(NumericSeparatorErrors) { "0b1__1", "0_b1", "0_b_1", "0o777_", "0o_777", "0o7__77", "0.0_2_1_", "0.0__21", "0_.01", "0._01", nullptr}; - static const ParserFlag flags[] = {kAllowHarmonyNumericSeparator}; - RunParserSyncTest(context_data, statement_data, kError, nullptr, 0, flags, 1, - nullptr, 0, false, true, true); - - RunParserSyncTest(context_data, statement_data, kError); + RunParserSyncTest(context_data, statement_data, kError, nullptr, 0, nullptr, + 0, nullptr, 0, false, true); } TEST(NumericSeparatorImplicitOctalsErrors) { @@ -1932,11 +1942,32 @@ TEST(NumericSeparatorImplicitOctalsErrors) { "0_7_7_7", "0_777", "07_7_7_", "07__77", "0__777", nullptr}; - static const ParserFlag flags[] = {kAllowHarmonyNumericSeparator}; - RunParserSyncTest(context_data, statement_data, kError, nullptr, 0, flags, 1, - nullptr, 0, false, true, true); + RunParserSyncTest(context_data, statement_data, kError, nullptr, 0, nullptr, + 0, nullptr, 0, false, true); +} - RunParserSyncTest(context_data, statement_data, kError); +TEST(NumericSeparatorNonOctalDecimalInteger) { + v8::HandleScope handles(CcTest::isolate()); + v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); + v8::Context::Scope context_scope(context); + + const char* context_data[][2] = {{"", ""}, {nullptr, nullptr}}; + const char* statement_data[] = {"09.1_2", nullptr}; + + RunParserSyncTest(context_data, statement_data, kSuccess, nullptr, 0, nullptr, + 0, nullptr, 0, false, true); +} + +TEST(NumericSeparatorNonOctalDecimalIntegerErrors) { + v8::HandleScope handles(CcTest::isolate()); + v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); + v8::Context::Scope context_scope(context); + + const char* context_data[][2] = {{"", ""}, {nullptr, nullptr}}; + const char* statement_data[] = {"09_12", nullptr}; + + RunParserSyncTest(context_data, statement_data, kError, nullptr, 0, nullptr, + 0, nullptr, 0, false, true); } TEST(NumericSeparatorUnicodeEscapeSequencesErrors) { @@ -1949,12 +1980,74 @@ TEST(NumericSeparatorUnicodeEscapeSequencesErrors) { // https://github.com/tc39/proposal-numeric-separator/issues/25 const char* statement_data[] = {"\\u{10_FFFF}", nullptr}; - static const ParserFlag flags[] = {kAllowHarmonyNumericSeparator}; - RunParserSyncTest(context_data, statement_data, kError, nullptr, 0, flags, 1); + RunParserSyncTest(context_data, statement_data, kError); +} + +TEST(OptionalChaining) { + v8::HandleScope handles(CcTest::isolate()); + v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); + v8::Context::Scope context_scope(context); + + const char* context_data[][2] = { + {"", ""}, {"'use strict';", ""}, {nullptr, nullptr}}; + const char* statement_data[] = {"a?.b", "a?.['b']", "a?.()", nullptr}; + + static const ParserFlag flags[] = {kAllowHarmonyOptionalChaining}; + RunParserSyncTest(context_data, statement_data, kSuccess, nullptr, 0, flags, + 1, nullptr, 0, false, true, true); + RunParserSyncTest(context_data, statement_data, kError); +} + +TEST(OptionalChainingTaggedError) { + v8::HandleScope handles(CcTest::isolate()); + v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); + v8::Context::Scope context_scope(context); + + const char* context_data[][2] = { + {"", ""}, {"'use strict';", ""}, {nullptr, nullptr}}; + const char* statement_data[] = {"a?.b``", "a?.['b']``", "a?.()``", nullptr}; + static const ParserFlag flags[] = {kAllowHarmonyOptionalChaining}; + RunParserSyncTest(context_data, statement_data, kError, nullptr, 9, flags, 1, + nullptr, 0, false, true, true); RunParserSyncTest(context_data, statement_data, kError); } +TEST(Nullish) { + v8::HandleScope handles(CcTest::isolate()); + v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); + v8::Context::Scope context_scope(context); + + const char* context_data[][2] = { + {"", ""}, {"'use strict';", ""}, {nullptr, nullptr}}; + const char* statement_data[] = {"a ?? b", "a ?? b ?? c", + "a ?? b ? c : d" + "a ?? b ?? c ? d : e", + nullptr}; + + static const ParserFlag flags[] = {kAllowHarmonyNullish}; + RunParserSyncTest(context_data, statement_data, kSuccess, nullptr, 0, flags, + 1, nullptr, 0, false, true, true); + RunParserSyncTest(context_data, statement_data, kError); +} + +TEST(NullishNotContained) { + v8::HandleScope handles(CcTest::isolate()); + v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); + v8::Context::Scope context_scope(context); + + const char* context_data[][2] = { + {"", ""}, {"'use strict';", ""}, {nullptr, nullptr}}; + const char* statement_data[] = {"a || b ?? c", "a ?? b || c", + "a && b ?? c" + "a ?? b && c", + nullptr}; + + static const ParserFlag flags[] = {kAllowHarmonyNullish}; + RunParserSyncTest(context_data, statement_data, kError, nullptr, 0, flags, 1, + nullptr, 0, false, true, true); +} + TEST(ErrorsEvalAndArguments) { // Tests that both preparsing and parsing produce the right kind of errors for // using "eval" and "arguments" as identifiers. Without the strict mode, it's @@ -5542,7 +5635,10 @@ TEST(PrivateMethodsErrors) { "async #['a']() { }", "async *#['a]() { }", - // TODO(joyee): check duplicate accessors + "get #a() {} get #a() {}", + "get #a() {} get #['a']() {}", + "set #a(val) {} set #a(val) {}", + "set #a(val) {} set #['a'](val) {}", "#a\n#", "#a() c", @@ -5561,6 +5657,14 @@ TEST(PrivateMethodsErrors) { "set #constructor(test) {}", "#constructor() {}", "get #constructor() {}", + + "static async *#constructor() {}", + "static *#constructor() {}", + "static async #constructor() {}", + "static set #constructor(test) {}", + "static #constructor() {}", + "static get #constructor() {}", + nullptr }; // clang-format on @@ -5572,8 +5676,60 @@ TEST(PrivateMethodsErrors) { private_methods, arraysize(private_methods)); } +// Test that private members parse in class bodies nested in object literals +TEST(PrivateMembersNestedInObjectLiteralsNoErrors) { + // clang-format off + const char* context_data[][2] = {{"({", "})"}, + {"'use strict'; ({", "});"}, + {nullptr, nullptr}}; + const char* class_body_data[] = { + "a: class { #a = 1 }", + "a: class { #a = () => {} }", + "a: class { #a }", + "a: class { #a() { } }", + "a: class { get #a() { } }", + "a: class { set #a(foo) { } }", + "a: class { *#a() { } }", + "a: class { async #a() { } }", + "a: class { async *#a() { } }", + nullptr + }; + // clang-format on + + static const ParserFlag private_methods[] = {kAllowHarmonyPrivateMethods}; + RunParserSyncTest(context_data, class_body_data, kSuccess, nullptr, 0, + private_methods, arraysize(private_methods)); +} + +// Test that private members parse in class bodies nested in classes +TEST(PrivateMembersInNestedClassNoErrors) { + // clang-format off + const char* context_data[][2] = {{"(class {", "});"}, + {"(class extends Base {", "});"}, + {"class C {", "}"}, + {"class C extends Base {", "}"}, + {nullptr, nullptr}}; + const char* class_body_data[] = { + "a = class { #a = 1 }", + "a = class { #a = () => {} }", + "a = class { #a }", + "a = class { #a() { } }", + "a = class { get #a() { } }", + "a = class { set #a(foo) { } }", + "a = class { *#a() { } }", + "a = class { async #a() { } }", + "a = class { async *#a() { } }", + nullptr + }; + // clang-format on + + static const ParserFlag private_methods[] = {kAllowHarmonyPrivateMethods}; + RunParserSyncTest(context_data, class_body_data, kSuccess, nullptr, 0, + private_methods, arraysize(private_methods)); +} + // Test that private members do not parse outside class bodies -TEST(PrivateMembersInNonClassNoErrors) { +TEST(PrivateMembersInNonClassErrors) { // clang-format off const char* context_data[][2] = {{"", ""}, {"({", "})"}, @@ -5605,6 +5761,122 @@ TEST(PrivateMembersInNonClassNoErrors) { private_methods, arraysize(private_methods)); } +// Test that nested private members parse +TEST(PrivateMembersNestedNoErrors) { + // clang-format off + const char* context_data[][2] = {{"(class { get #a() { ", "} });"}, + { + "(class { set #a(val) {} get #a() { ", + "} });" + }, + {"(class { set #a(val) {", "} });"}, + {"(class { #a() { ", "} });"}, + {nullptr, nullptr}}; + const char* class_body_data[] = { + "class C { #a() {} }", + "class C { get #a() {} }", + "class C { get #a() {} set #a(val) {} }", + "class C { set #a(val) {} }", + nullptr + }; + // clang-format on + + static const ParserFlag private_methods[] = {kAllowHarmonyPrivateMethods}; + RunParserSyncTest(context_data, class_body_data, kSuccess, nullptr, 0, + private_methods, arraysize(private_methods)); +} + +// Test that acessing undeclared private members result in early errors +TEST(PrivateMembersEarlyErrors) { + // clang-format off + const char* context_data[][2] = {{"(class {", "});"}, + {"(class extends Base {", "});"}, + {"class C {", "}"}, + {"class C extends Base {", "}"}, + {nullptr, nullptr}}; + const char* class_body_data[] = { + "set #b(val) { this.#a = val; }", + "get #b() { return this.#a; }", + "foo() { return this.#a; }", + "foo() { this.#a = 1; }", + nullptr + }; + // clang-format on + + RunParserSyncTest(context_data, class_body_data, kError); + + static const ParserFlag private_methods[] = {kAllowHarmonyPrivateMethods}; + RunParserSyncTest(context_data, class_body_data, kError, nullptr, 0, + private_methods, arraysize(private_methods)); +} + +// Test that acessing wrong kind private members do not error early. +// Instead these should be runtime errors. +TEST(PrivateMembersWrongAccessNoEarlyErrors) { + // clang-format off + const char* context_data[][2] = {{"(class {", "});"}, + {"(class extends Base {", "});"}, + {"class C {", "}"}, + {"class C extends Base {", "}"}, + {nullptr, nullptr}}; + const char* class_body_data[] = { + // Private setter only + "set #b(val) {} fn() { return this.#b; }", + "set #b(val) {} fn() { this.#b++; }", + // Nested private setter only + R"(get #b() {} + fn() { + return new class { set #b(val) {} fn() { this.#b++; } }; + })", + R"(get #b() {} + fn() { + return new class { set #b(val) {} fn() { return this.#b; } }; + })", + + // Private getter only + "get #b() { } fn() { this.#b = 1; }", + "get #b() { } fn() { this.#b++; }", + "get #b() { } fn(obj) { ({ y: this.#b } = obj); }", + // Nested private getter only + R"(set #b(val) {} + fn() { + return new class { get #b() {} fn() { this.#b++; } }; + })", + R"(set #b(val) {} + fn() { + return new class { get #b() {} fn() { this.#b = 1; } }; + })", + R"(set #b(val) {} + fn() { + return new class { get #b() {} fn() { ({ y: this.#b } = obj); } }; + })", + + // Writing to private methods + "#b() { } fn() { this.#b = 1; }", + "#b() { } fn() { this.#b++; }", + "#b() {} fn(obj) { ({ y: this.#b } = obj); }", + // Writing to nested private methods + R"(#b() {} + fn() { + return new class { get #b() {} fn() { this.#b++; } }; + })", + R"(#b() {} + fn() { + return new class { get #b() {} fn() { this.#b = 1; } }; + })", + R"(#b() {} + fn() { + return new class { get #b() {} fn() { ({ y: this.#b } = obj); } }; + })", + nullptr + }; + // clang-format on + + static const ParserFlag private_methods[] = {kAllowHarmonyPrivateMethods}; + RunParserSyncTest(context_data, class_body_data, kSuccess, nullptr, 0, + private_methods, arraysize(private_methods)); +} + TEST(PrivateClassFieldsNoErrors) { // clang-format off // Tests proposed class fields syntax. diff --git a/deps/v8/test/cctest/test-pointer-auth-arm64.cc b/deps/v8/test/cctest/test-pointer-auth-arm64.cc new file mode 100644 index 0000000000..11632be808 --- /dev/null +++ b/deps/v8/test/cctest/test-pointer-auth-arm64.cc @@ -0,0 +1,76 @@ +// Copyright 2019 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/codegen/arm64/decoder-arm64-inl.h" +#include "src/execution/arm64/simulator-arm64.h" + +#include "test/cctest/cctest.h" + +namespace v8 { +namespace internal { + +#ifdef USE_SIMULATOR +TEST(compute_pac) { + Decoder<DispatchingDecoderVisitor>* decoder = + new Decoder<DispatchingDecoderVisitor>(); + Simulator simulator(decoder); + + uint64_t data1 = 0xfb623599da6e8127; + uint64_t data2 = 0x27979fadf7d53cb7; + uint64_t context = 0x477d469dec0b8762; + Simulator::PACKey key = {0x84be85ce9804e94b, 0xec2802d4e0a488e9, -1}; + + uint64_t pac1 = simulator.ComputePAC(data1, context, key); + uint64_t pac2 = simulator.ComputePAC(data2, context, key); + + // NOTE: If the PAC implementation is changed, this may fail due to a hash + // collision. + CHECK_NE(pac1, pac2); +} + +TEST(add_and_auth_pac) { + Decoder<DispatchingDecoderVisitor>* decoder = + new Decoder<DispatchingDecoderVisitor>(); + Simulator simulator(decoder); + + uint64_t ptr = 0x0000000012345678; + uint64_t context = 0x477d469dec0b8762; + Simulator::PACKey key_a = {0x84be85ce9804e94b, 0xec2802d4e0a488e9, 0}; + Simulator::PACKey key_b = {0xec1119e288704d13, 0xd7f6b76e1cea585e, 1}; + + uint64_t ptr_a = + simulator.AddPAC(ptr, context, key_a, Simulator::kInstructionPointer); + + // Attempt to authenticate the pointer with PAC using different keys. + uint64_t success = + simulator.AuthPAC(ptr_a, context, key_a, Simulator::kInstructionPointer); + uint64_t fail = + simulator.AuthPAC(ptr_a, context, key_b, Simulator::kInstructionPointer); + + uint64_t pac_mask = + simulator.CalculatePACMask(ptr, Simulator::kInstructionPointer, 0); + + // NOTE: If the PAC implementation is changed, this may fail due to a hash + // collision. + CHECK_NE((ptr_a & pac_mask), 0); + CHECK_EQ(success, ptr); + CHECK_NE(fail, ptr); +} + +TEST(add_and_strip_pac) { + Decoder<DispatchingDecoderVisitor>* decoder = + new Decoder<DispatchingDecoderVisitor>(); + Simulator simulator(decoder); + + uint64_t ptr = 0xff00000012345678; + uint64_t pac_mask = + simulator.CalculatePACMask(ptr, Simulator::kInstructionPointer, 0); + uint64_t ptr_a = ptr | pac_mask; + + CHECK_EQ(simulator.StripPAC(ptr_a, Simulator::kInstructionPointer), ptr); +} +#endif // USE_SIMULATOR + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-poison-disasm-arm.cc b/deps/v8/test/cctest/test-poison-disasm-arm.cc index 37bb4e1b39..3410e5487d 100644 --- a/deps/v8/test/cctest/test-poison-disasm-arm.cc +++ b/deps/v8/test/cctest/test-poison-disasm-arm.cc @@ -71,7 +71,6 @@ TEST(DisasmPoisonPolymorphicLoad) { "let o2 = { y : 1 };" "o2.x = 2;" "%PrepareFunctionForOptimization(poly);" - "poly(o1);" "poly(o2);" "poly(o1);" "poly(o2);" diff --git a/deps/v8/test/cctest/test-poison-disasm-arm64.cc b/deps/v8/test/cctest/test-poison-disasm-arm64.cc index d767fea9fb..a428ce7b89 100644 --- a/deps/v8/test/cctest/test-poison-disasm-arm64.cc +++ b/deps/v8/test/cctest/test-poison-disasm-arm64.cc @@ -84,7 +84,6 @@ TEST(DisasmPoisonPolymorphicLoad) { "let o2 = { y : 1 };" "o2.x = 2;" "%PrepareFunctionForOptimization(poly);" - "poly(o1);" "poly(o2);" "poly(o1);" "poly(o2);" @@ -115,7 +114,7 @@ TEST(DisasmPoisonPolymorphicLoad) { "csel " + kPReg + ", xzr, " + kPReg + ", ne", // update the poison "csdb", // spec. barrier "ldursw x<<BSt:[0-9]+>>, \\[<<Obj>>, #[0-9]+\\]", // load backing store - "tbz w<<BSt>>, #0, #\\+0x8", // branchful decompress + // branchful decompress "add x<<BSt>>, x26, x<<BSt>>", // Add root to ref "and x<<BSt>>, x<<BSt>>, " + kPReg, // apply the poison "ldur w<<Prop:[0-9]+>>, \\[x<<BSt>>, #[0-9]+\\]", // load the property diff --git a/deps/v8/test/cctest/test-profile-generator.cc b/deps/v8/test/cctest/test-profile-generator.cc index 051affc898..ccebabec30 100644 --- a/deps/v8/test/cctest/test-profile-generator.cc +++ b/deps/v8/test/cctest/test-profile-generator.cc @@ -200,7 +200,9 @@ TEST(ProfileTreeAddPathFromEndWithLineNumbers) { ProfileTree tree(CcTest::i_isolate()); ProfileTreeTestHelper helper(&tree); - ProfileStackTrace path = {{&c, 5}, {&b, 3}, {&a, 1}}; + ProfileStackTrace path = {{{&c, 5}, kNullAddress, false}, + {{&b, 3}, kNullAddress, false}, + {{&a, 1}, kNullAddress, false}}; tree.AddPathFromEnd(path, v8::CpuProfileNode::kNoLineNumberInfo, true, v8::CpuProfilingMode::kCallerLineNumbers); @@ -381,7 +383,8 @@ TEST(RecordTickSample) { CpuProfiler profiler(isolate); profiles.set_cpu_profiler(&profiler); profiles.StartProfiling(""); - ProfileGenerator generator(&profiles); + CodeMap code_map; + ProfileGenerator generator(&profiles, &code_map); CodeEntry* entry1 = new CodeEntry(i::Logger::FUNCTION_TAG, "aaa"); CodeEntry* entry2 = new CodeEntry(i::Logger::FUNCTION_TAG, "bbb"); CodeEntry* entry3 = new CodeEntry(i::Logger::FUNCTION_TAG, "ccc"); @@ -449,7 +452,8 @@ TEST(SampleIds) { CpuProfiler profiler(isolate); profiles.set_cpu_profiler(&profiler); profiles.StartProfiling("", {CpuProfilingMode::kLeafNodeLineNumbers}); - ProfileGenerator generator(&profiles); + CodeMap code_map; + ProfileGenerator generator(&profiles, &code_map); CodeEntry* entry1 = new CodeEntry(i::Logger::FUNCTION_TAG, "aaa"); CodeEntry* entry2 = new CodeEntry(i::Logger::FUNCTION_TAG, "bbb"); CodeEntry* entry3 = new CodeEntry(i::Logger::FUNCTION_TAG, "ccc"); @@ -503,7 +507,8 @@ TEST(NoSamples) { CpuProfiler profiler(isolate); profiles.set_cpu_profiler(&profiler); profiles.StartProfiling(""); - ProfileGenerator generator(&profiles); + CodeMap code_map; + ProfileGenerator generator(&profiles, &code_map); CodeEntry* entry1 = new CodeEntry(i::Logger::FUNCTION_TAG, "aaa"); generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200); diff --git a/deps/v8/test/cctest/test-regexp.cc b/deps/v8/test/cctest/test-regexp.cc index 1dad8febda..1374673c61 100644 --- a/deps/v8/test/cctest/test-regexp.cc +++ b/deps/v8/test/cctest/test-regexp.cc @@ -35,6 +35,7 @@ #include "src/codegen/assembler-arch.h" #include "src/codegen/macro-assembler.h" #include "src/init/v8.h" +#include "src/objects/js-regexp-inl.h" #include "src/objects/objects-inl.h" #include "src/regexp/regexp-bytecode-generator.h" #include "src/regexp/regexp-compiler.h" @@ -535,6 +536,7 @@ static RegExpNode* Compile(const char* input, bool multiline, bool unicode, Isolate* isolate = CcTest::i_isolate(); FlatStringReader reader(isolate, CStrVector(input)); RegExpCompileData compile_data; + compile_data.compilation_target = RegExpCompilationTarget::kNative; JSRegExp::Flags flags = JSRegExp::kNone; if (multiline) flags = JSRegExp::kMultiline; if (unicode) flags = JSRegExp::kUnicode; @@ -629,16 +631,35 @@ class ContextInitializer { v8::Local<v8::Context> env_; }; -static ArchRegExpMacroAssembler::Result Execute(Code code, String input, +// Create new JSRegExp object with only necessary fields (for this tests) +// initialized. +static Handle<JSRegExp> CreateJSRegExp(Handle<String> source, Handle<Code> code, + bool is_unicode = false) { + Isolate* isolate = CcTest::i_isolate(); + Factory* factory = isolate->factory(); + Handle<JSFunction> constructor = isolate->regexp_function(); + Handle<JSRegExp> regexp = + Handle<JSRegExp>::cast(factory->NewJSObject(constructor)); + + factory->SetRegExpIrregexpData(regexp, JSRegExp::IRREGEXP, source, + JSRegExp::kNone, 0); + regexp->SetDataAt(is_unicode ? JSRegExp::kIrregexpUC16CodeIndex + : JSRegExp::kIrregexpLatin1CodeIndex, + *code); + + return regexp; +} + +static ArchRegExpMacroAssembler::Result Execute(JSRegExp regexp, String input, int start_offset, Address input_start, Address input_end, int* captures) { return static_cast<NativeRegExpMacroAssembler::Result>( - NativeRegExpMacroAssembler::Execute(code, input, start_offset, - reinterpret_cast<byte*>(input_start), - reinterpret_cast<byte*>(input_end), - captures, 0, CcTest::i_isolate())); + NativeRegExpMacroAssembler::Execute( + input, start_offset, reinterpret_cast<byte*>(input_start), + reinterpret_cast<byte*>(input_end), captures, 0, CcTest::i_isolate(), + regexp)); } TEST(MacroAssemblerNativeSuccess) { @@ -656,19 +677,15 @@ TEST(MacroAssemblerNativeSuccess) { Handle<String> source = factory->NewStringFromStaticChars(""); Handle<Object> code_object = m.GetCode(source); Handle<Code> code = Handle<Code>::cast(code_object); + Handle<JSRegExp> regexp = CreateJSRegExp(source, code); int captures[4] = {42, 37, 87, 117}; Handle<String> input = factory->NewStringFromStaticChars("foofoo"); Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); Address start_adr = seq_input->GetCharsAddress(); - NativeRegExpMacroAssembler::Result result = - Execute(*code, - *input, - 0, - start_adr, - start_adr + seq_input->length(), - captures); + NativeRegExpMacroAssembler::Result result = Execute( + *regexp, *input, 0, start_adr, start_adr + seq_input->length(), captures); CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); CHECK_EQ(-1, captures[0]); @@ -710,19 +727,15 @@ TEST(MacroAssemblerNativeSimple) { Handle<String> source = factory->NewStringFromStaticChars("^foo"); Handle<Object> code_object = m.GetCode(source); Handle<Code> code = Handle<Code>::cast(code_object); + Handle<JSRegExp> regexp = CreateJSRegExp(source, code); int captures[4] = {42, 37, 87, 117}; Handle<String> input = factory->NewStringFromStaticChars("foofoo"); Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); Address start_adr = seq_input->GetCharsAddress(); - NativeRegExpMacroAssembler::Result result = - Execute(*code, - *input, - 0, - start_adr, - start_adr + input->length(), - captures); + NativeRegExpMacroAssembler::Result result = Execute( + *regexp, *input, 0, start_adr, start_adr + input->length(), captures); CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); CHECK_EQ(0, captures[0]); @@ -734,11 +747,7 @@ TEST(MacroAssemblerNativeSimple) { seq_input = Handle<SeqOneByteString>::cast(input); start_adr = seq_input->GetCharsAddress(); - result = Execute(*code, - *input, - 0, - start_adr, - start_adr + input->length(), + result = Execute(*regexp, *input, 0, start_adr, start_adr + input->length(), captures); CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); @@ -777,6 +786,7 @@ TEST(MacroAssemblerNativeSimpleUC16) { Handle<String> source = factory->NewStringFromStaticChars("^foo"); Handle<Object> code_object = m.GetCode(source); Handle<Code> code = Handle<Code>::cast(code_object); + Handle<JSRegExp> regexp = CreateJSRegExp(source, code, true); int captures[4] = {42, 37, 87, 117}; const uc16 input_data[6] = {'f', 'o', 'o', 'f', 'o', @@ -786,13 +796,8 @@ TEST(MacroAssemblerNativeSimpleUC16) { Handle<SeqTwoByteString> seq_input = Handle<SeqTwoByteString>::cast(input); Address start_adr = seq_input->GetCharsAddress(); - NativeRegExpMacroAssembler::Result result = - Execute(*code, - *input, - 0, - start_adr, - start_adr + input->length(), - captures); + NativeRegExpMacroAssembler::Result result = Execute( + *regexp, *input, 0, start_adr, start_adr + input->length(), captures); CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); CHECK_EQ(0, captures[0]); @@ -807,12 +812,8 @@ TEST(MacroAssemblerNativeSimpleUC16) { seq_input = Handle<SeqTwoByteString>::cast(input); start_adr = seq_input->GetCharsAddress(); - result = Execute(*code, - *input, - 0, - start_adr, - start_adr + input->length() * 2, - captures); + result = Execute(*regexp, *input, 0, start_adr, + start_adr + input->length() * 2, captures); CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); } @@ -842,13 +843,14 @@ TEST(MacroAssemblerNativeBacktrack) { Handle<String> source = factory->NewStringFromStaticChars(".........."); Handle<Object> code_object = m.GetCode(source); Handle<Code> code = Handle<Code>::cast(code_object); + Handle<JSRegExp> regexp = CreateJSRegExp(source, code); Handle<String> input = factory->NewStringFromStaticChars("foofoo"); Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); Address start_adr = seq_input->GetCharsAddress(); NativeRegExpMacroAssembler::Result result = Execute( - *code, *input, 0, start_adr, start_adr + input->length(), nullptr); + *regexp, *input, 0, start_adr, start_adr + input->length(), nullptr); CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); } @@ -882,19 +884,15 @@ TEST(MacroAssemblerNativeBackReferenceLATIN1) { Handle<String> source = factory->NewStringFromStaticChars("^(..)..\1"); Handle<Object> code_object = m.GetCode(source); Handle<Code> code = Handle<Code>::cast(code_object); + Handle<JSRegExp> regexp = CreateJSRegExp(source, code); Handle<String> input = factory->NewStringFromStaticChars("fooofo"); Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); Address start_adr = seq_input->GetCharsAddress(); int output[4]; - NativeRegExpMacroAssembler::Result result = - Execute(*code, - *input, - 0, - start_adr, - start_adr + input->length(), - output); + NativeRegExpMacroAssembler::Result result = Execute( + *regexp, *input, 0, start_adr, start_adr + input->length(), output); CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); CHECK_EQ(0, output[0]); @@ -932,6 +930,7 @@ TEST(MacroAssemblerNativeBackReferenceUC16) { Handle<String> source = factory->NewStringFromStaticChars("^(..)..\1"); Handle<Object> code_object = m.GetCode(source); Handle<Code> code = Handle<Code>::cast(code_object); + Handle<JSRegExp> regexp = CreateJSRegExp(source, code, true); const uc16 input_data[6] = {'f', 0x2028, 'o', 'o', 'f', 0x2028}; Handle<String> input = factory->NewStringFromTwoByte( @@ -940,13 +939,8 @@ TEST(MacroAssemblerNativeBackReferenceUC16) { Address start_adr = seq_input->GetCharsAddress(); int output[4]; - NativeRegExpMacroAssembler::Result result = - Execute(*code, - *input, - 0, - start_adr, - start_adr + input->length() * 2, - output); + NativeRegExpMacroAssembler::Result result = Execute( + *regexp, *input, 0, start_adr, start_adr + input->length() * 2, output); CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); CHECK_EQ(0, output[0]); @@ -991,18 +985,19 @@ TEST(MacroAssemblernativeAtStart) { Handle<String> source = factory->NewStringFromStaticChars("(^f|ob)"); Handle<Object> code_object = m.GetCode(source); Handle<Code> code = Handle<Code>::cast(code_object); + Handle<JSRegExp> regexp = CreateJSRegExp(source, code); Handle<String> input = factory->NewStringFromStaticChars("foobar"); Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); Address start_adr = seq_input->GetCharsAddress(); NativeRegExpMacroAssembler::Result result = Execute( - *code, *input, 0, start_adr, start_adr + input->length(), nullptr); + *regexp, *input, 0, start_adr, start_adr + input->length(), nullptr); CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); - result = Execute(*code, *input, 3, start_adr + 3, start_adr + input->length(), - nullptr); + result = Execute(*regexp, *input, 3, start_adr + 3, + start_adr + input->length(), nullptr); CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); } @@ -1044,19 +1039,15 @@ TEST(MacroAssemblerNativeBackRefNoCase) { factory->NewStringFromStaticChars("^(abc)\1\1(?!\1)...(?!\1)"); Handle<Object> code_object = m.GetCode(source); Handle<Code> code = Handle<Code>::cast(code_object); + Handle<JSRegExp> regexp = CreateJSRegExp(source, code); Handle<String> input = factory->NewStringFromStaticChars("aBcAbCABCxYzab"); Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); Address start_adr = seq_input->GetCharsAddress(); int output[4]; - NativeRegExpMacroAssembler::Result result = - Execute(*code, - *input, - 0, - start_adr, - start_adr + input->length(), - output); + NativeRegExpMacroAssembler::Result result = Execute( + *regexp, *input, 0, start_adr, start_adr + input->length(), output); CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); CHECK_EQ(0, output[0]); @@ -1144,6 +1135,7 @@ TEST(MacroAssemblerNativeRegisters) { Handle<String> source = factory->NewStringFromStaticChars("<loop test>"); Handle<Object> code_object = m.GetCode(source); Handle<Code> code = Handle<Code>::cast(code_object); + Handle<JSRegExp> regexp = CreateJSRegExp(source, code); // String long enough for test (content doesn't matter). Handle<String> input = factory->NewStringFromStaticChars("foofoofoofoofoo"); @@ -1151,13 +1143,8 @@ TEST(MacroAssemblerNativeRegisters) { Address start_adr = seq_input->GetCharsAddress(); int output[6]; - NativeRegExpMacroAssembler::Result result = - Execute(*code, - *input, - 0, - start_adr, - start_adr + input->length(), - output); + NativeRegExpMacroAssembler::Result result = Execute( + *regexp, *input, 0, start_adr, start_adr + input->length(), output); CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); CHECK_EQ(0, output[0]); @@ -1188,6 +1175,7 @@ TEST(MacroAssemblerStackOverflow) { factory->NewStringFromStaticChars("<stack overflow test>"); Handle<Object> code_object = m.GetCode(source); Handle<Code> code = Handle<Code>::cast(code_object); + Handle<JSRegExp> regexp = CreateJSRegExp(source, code); // String long enough for test (content doesn't matter). Handle<String> input = factory->NewStringFromStaticChars("dummy"); @@ -1195,7 +1183,7 @@ TEST(MacroAssemblerStackOverflow) { Address start_adr = seq_input->GetCharsAddress(); NativeRegExpMacroAssembler::Result result = Execute( - *code, *input, 0, start_adr, start_adr + input->length(), nullptr); + *regexp, *input, 0, start_adr, start_adr + input->length(), nullptr); CHECK_EQ(NativeRegExpMacroAssembler::EXCEPTION, result); CHECK(isolate->has_pending_exception()); @@ -1230,6 +1218,7 @@ TEST(MacroAssemblerNativeLotsOfRegisters) { factory->NewStringFromStaticChars("<huge register space test>"); Handle<Object> code_object = m.GetCode(source); Handle<Code> code = Handle<Code>::cast(code_object); + Handle<JSRegExp> regexp = CreateJSRegExp(source, code); // String long enough for test (content doesn't matter). Handle<String> input = factory->NewStringFromStaticChars("sample text"); @@ -1237,13 +1226,8 @@ TEST(MacroAssemblerNativeLotsOfRegisters) { Address start_adr = seq_input->GetCharsAddress(); int captures[2]; - NativeRegExpMacroAssembler::Result result = - Execute(*code, - *input, - 0, - start_adr, - start_adr + input->length(), - captures); + NativeRegExpMacroAssembler::Result result = Execute( + *regexp, *input, 0, start_adr, start_adr + input->length(), captures); CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); CHECK_EQ(0, captures[0]); @@ -1298,7 +1282,9 @@ TEST(MacroAssembler) { Handle<String> f1_16 = factory->NewStringFromTwoByte( Vector<const uc16>(str1, 6)).ToHandleChecked(); - CHECK(IrregexpInterpreter::Match(isolate, array, f1_16, captures, 0)); + CHECK(IrregexpInterpreter::MatchInternal(isolate, *array, *f1_16, captures, 5, + 0, + RegExp::CallOrigin::kFromRuntime)); CHECK_EQ(0, captures[0]); CHECK_EQ(3, captures[1]); CHECK_EQ(1, captures[2]); @@ -1309,7 +1295,9 @@ TEST(MacroAssembler) { Handle<String> f2_16 = factory->NewStringFromTwoByte( Vector<const uc16>(str2, 6)).ToHandleChecked(); - CHECK(!IrregexpInterpreter::Match(isolate, array, f2_16, captures, 0)); + CHECK(!IrregexpInterpreter::MatchInternal(isolate, *array, *f2_16, captures, + 5, 0, + RegExp::CallOrigin::kFromRuntime)); CHECK_EQ(42, captures[0]); } @@ -1692,8 +1680,7 @@ void MockUseCounterCallback(v8::Isolate* isolate, } } - -// Test that ES2015 RegExp compatibility fixes are in place, that they +// Test that ES2015+ RegExp compatibility fixes are in place, that they // are not overly broad, and the appropriate UseCounters are incremented TEST(UseCountRegExp) { v8::Isolate* isolate = CcTest::isolate(); @@ -1715,7 +1702,7 @@ TEST(UseCountRegExp) { CHECK_EQ(0, use_counts[v8::Isolate::kRegExpPrototypeToString]); CHECK(resultReSticky->IsFalse()); - // When the getter is caleld on another object, throw an exception + // When the getter is called on another object, throw an exception // and don't increment the UseCounter v8::Local<v8::Value> resultStickyError = CompileRun( "var exception;" @@ -1757,6 +1744,19 @@ TEST(UseCountRegExp) { CHECK_EQ(2, use_counts[v8::Isolate::kRegExpPrototypeStickyGetter]); CHECK_EQ(1, use_counts[v8::Isolate::kRegExpPrototypeToString]); CHECK(resultToStringError->IsObject()); + + // Increment a UseCounter when .matchAll() is used with a non-global + // regular expression. + CHECK_EQ(0, use_counts[v8::Isolate::kRegExpMatchAllWithNonGlobalRegExp]); + v8::Local<v8::Value> resultReMatchAllNonGlobal = + CompileRun("'a'.matchAll(/./)"); + CHECK_EQ(1, use_counts[v8::Isolate::kRegExpMatchAllWithNonGlobalRegExp]); + CHECK(resultReMatchAllNonGlobal->IsObject()); + // Don't increment the counter for global regular expressions. + v8::Local<v8::Value> resultReMatchAllGlobal = + CompileRun("'a'.matchAll(/./g)"); + CHECK_EQ(1, use_counts[v8::Isolate::kRegExpMatchAllWithNonGlobalRegExp]); + CHECK(resultReMatchAllGlobal->IsObject()); } class UncachedExternalString diff --git a/deps/v8/test/cctest/test-serialize.cc b/deps/v8/test/cctest/test-serialize.cc index 1ed1547b34..407437c4b1 100644 --- a/deps/v8/test/cctest/test-serialize.cc +++ b/deps/v8/test/cctest/test-serialize.cc @@ -1516,6 +1516,50 @@ static Handle<SharedFunctionInfo> CompileScriptAndProduceCache( return sfi; } +TEST(CodeSerializerWithProfiler) { + FLAG_enable_lazy_source_positions = true; + FLAG_stress_lazy_source_positions = false; + + LocalContext context; + Isolate* isolate = CcTest::i_isolate(); + isolate->compilation_cache()->Disable(); // Disable same-isolate code cache. + + v8::HandleScope scope(CcTest::isolate()); + + const char* source = "1 + 1"; + + Handle<String> orig_source = isolate->factory() + ->NewStringFromUtf8(CStrVector(source)) + .ToHandleChecked(); + Handle<String> copy_source = isolate->factory() + ->NewStringFromUtf8(CStrVector(source)) + .ToHandleChecked(); + CHECK(!orig_source.is_identical_to(copy_source)); + CHECK(orig_source->Equals(*copy_source)); + + ScriptData* cache = nullptr; + + Handle<SharedFunctionInfo> orig = CompileScriptAndProduceCache( + isolate, orig_source, Handle<String>(), &cache, + v8::ScriptCompiler::kNoCompileOptions); + + CHECK(!orig->GetBytecodeArray().HasSourcePositionTable()); + + isolate->set_is_profiling(true); + + // This does not assert that no compilation can happen as source position + // collection could trigger it. + Handle<SharedFunctionInfo> copy = + CompileScript(isolate, copy_source, Handle<String>(), cache, + v8::ScriptCompiler::kConsumeCodeCache); + + // Since the profiler is now enabled, source positions should be collected + // after deserialization. + CHECK(copy->GetBytecodeArray().HasSourcePositionTable()); + + delete cache; +} + void TestCodeSerializerOnePlusOneImpl(bool verify_builtins_count = true) { LocalContext context; Isolate* isolate = CcTest::i_isolate(); @@ -3565,6 +3609,7 @@ UNINITIALIZED_TEST(SnapshotCreatorIncludeGlobalProxy) { base::make_unique<v8::Extension>("new extension", "function i() { return 24; }" "function j() { return 25; }" + "let a = 26;" "try {" " if (o.p == 7) o.p++;" "} catch {}"); @@ -3582,6 +3627,7 @@ UNINITIALIZED_TEST(SnapshotCreatorIncludeGlobalProxy) { ExpectInt32("i()", 24); ExpectInt32("j()", 25); ExpectInt32("o.p", 8); + ExpectInt32("a", 26); v8::TryCatch try_catch(isolate); CHECK(CompileRun("x").IsEmpty()); CHECK(try_catch.HasCaught()); diff --git a/deps/v8/test/cctest/test-stack-unwinding-x64.cc b/deps/v8/test/cctest/test-stack-unwinding-win64.cc index 583e14111a..84f1318a29 100644 --- a/deps/v8/test/cctest/test-stack-unwinding-x64.cc +++ b/deps/v8/test/cctest/test-stack-unwinding-win64.cc @@ -6,9 +6,15 @@ #include "src/init/v8.h" #include "test/cctest/cctest.h" -class UnwindingWinX64Callbacks { +#if defined(V8_OS_WIN_X64) +#define CONTEXT_PC(context) (context.Rip) +#elif defined(V8_OS_WIN_ARM64) +#define CONTEXT_PC(context) (context.Pc) +#endif + +class UnwindingWin64Callbacks { public: - UnwindingWinX64Callbacks() = default; + UnwindingWin64Callbacks() = default; static void Getter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info) { @@ -31,25 +37,26 @@ class UnwindingWinX64Callbacks { int iframe = 0; while (++iframe < max_frames) { uint64_t image_base; - PRUNTIME_FUNCTION function_entry = - ::RtlLookupFunctionEntry(context_record.Rip, &image_base, nullptr); + PRUNTIME_FUNCTION function_entry = ::RtlLookupFunctionEntry( + CONTEXT_PC(context_record), &image_base, nullptr); if (!function_entry) break; void* handler_data; uint64_t establisher_frame; - ::RtlVirtualUnwind(UNW_FLAG_NHANDLER, image_base, context_record.Rip, - function_entry, &context_record, &handler_data, - &establisher_frame, NULL); + ::RtlVirtualUnwind(UNW_FLAG_NHANDLER, image_base, + CONTEXT_PC(context_record), function_entry, + &context_record, &handler_data, &establisher_frame, + NULL); } return iframe; } }; -// Verifies that stack unwinding data has been correctly registered on Win/x64. -UNINITIALIZED_TEST(StackUnwindingWinX64) { +// Verifies that stack unwinding data has been correctly registered on Win64. +UNINITIALIZED_TEST(StackUnwindingWin64) { #ifdef V8_WIN64_UNWINDING_INFO - static const char* unwinding_win_x64_test_source = + static const char* unwinding_win64_test_source = "function start(count) {\n" " for (var i = 0; i < count; i++) {\n" " var o = instance.foo;\n" @@ -79,18 +86,18 @@ UNINITIALIZED_TEST(StackUnwindingWinX64) { v8::Local<v8::ObjectTemplate> instance_template = func_template->InstanceTemplate(); - UnwindingWinX64Callbacks accessors; + UnwindingWin64Callbacks accessors; v8::Local<v8::External> data = v8::External::New(isolate, &accessors); instance_template->SetAccessor(v8_str("foo"), - &UnwindingWinX64Callbacks::Getter, - &UnwindingWinX64Callbacks::Setter, data); + &UnwindingWin64Callbacks::Getter, + &UnwindingWin64Callbacks::Setter, data); v8::Local<v8::Function> func = func_template->GetFunction(env.local()).ToLocalChecked(); v8::Local<v8::Object> instance = func->NewInstance(env.local()).ToLocalChecked(); env->Global()->Set(env.local(), v8_str("instance"), instance).FromJust(); - CompileRun(unwinding_win_x64_test_source); + CompileRun(unwinding_win64_test_source); v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( env->Global()->Get(env.local(), v8_str("start")).ToLocalChecked()); @@ -106,3 +113,5 @@ UNINITIALIZED_TEST(StackUnwindingWinX64) { #endif // V8_WIN64_UNWINDING_INFO } + +#undef CONTEXT_PC diff --git a/deps/v8/test/cctest/test-sync-primitives-arm.cc b/deps/v8/test/cctest/test-sync-primitives-arm.cc index 84dc0575cf..6afa9e5192 100644 --- a/deps/v8/test/cctest/test-sync-primitives-arm.cc +++ b/deps/v8/test/cctest/test-sync-primitives-arm.cc @@ -352,7 +352,7 @@ TEST(simulator_invalidate_exclusive_access_threaded) { TestData test_data(1); MemoryAccessThread thread; - thread.Start(); + CHECK(thread.Start()); MemoryAccess ldrex_w(Kind::LoadExcl, Size::Word, offsetof(TestData, w)); MemoryAccess strex_w(Kind::StoreExcl, Size::Word, offsetof(TestData, w), 7); diff --git a/deps/v8/test/cctest/test-sync-primitives-arm64.cc b/deps/v8/test/cctest/test-sync-primitives-arm64.cc index 38adf8486a..f5f19f0687 100644 --- a/deps/v8/test/cctest/test-sync-primitives-arm64.cc +++ b/deps/v8/test/cctest/test-sync-primitives-arm64.cc @@ -359,7 +359,7 @@ TEST(simulator_invalidate_exclusive_access_threaded) { TestData test_data(1); MemoryAccessThread thread; - thread.Start(); + CHECK(thread.Start()); MemoryAccess ldaxr_w(Kind::LoadExcl, Size::Word, offsetof(TestData, w)); MemoryAccess stlxr_w(Kind::StoreExcl, Size::Word, offsetof(TestData, w), 7); diff --git a/deps/v8/test/cctest/test-thread-termination.cc b/deps/v8/test/cctest/test-thread-termination.cc index ca9ac5efaa..db9b5c928a 100644 --- a/deps/v8/test/cctest/test-thread-termination.cc +++ b/deps/v8/test/cctest/test-thread-termination.cc @@ -179,7 +179,7 @@ class TerminatorThread : public v8::base::Thread { void TestTerminatingSlowOperation(const char* source) { semaphore = new v8::base::Semaphore(0); TerminatorThread thread(CcTest::i_isolate()); - thread.Start(); + CHECK(thread.Start()); v8::HandleScope scope(CcTest::isolate()); v8::Local<v8::ObjectTemplate> global = @@ -474,7 +474,7 @@ void MicrotaskLoopForever(const v8::FunctionCallbackInfo<v8::Value>& info) { TEST(TerminateFromOtherThreadWhileMicrotaskRunning) { semaphore = new v8::base::Semaphore(0); TerminatorThread thread(CcTest::i_isolate()); - thread.Start(); + CHECK(thread.Start()); v8::Isolate* isolate = CcTest::isolate(); isolate->SetMicrotasksPolicy(v8::MicrotasksPolicy::kExplicit); @@ -878,7 +878,7 @@ TEST(TerminateRegExp) { CHECK(!isolate->IsExecutionTerminating()); CHECK(!CompileRun("var re = /(x+)+y$/; re.test('x');").IsEmpty()); TerminatorSleeperThread terminator(isolate, 100); - terminator.Start(); + CHECK(terminator.Start()); CHECK(CompileRun("re.test('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); fail();") .IsEmpty()); CHECK(try_catch.HasCaught()); diff --git a/deps/v8/test/cctest/test-threads.cc b/deps/v8/test/cctest/test-threads.cc index be76f5e93f..2062724043 100644 --- a/deps/v8/test/cctest/test-threads.cc +++ b/deps/v8/test/cctest/test-threads.cc @@ -54,7 +54,7 @@ class ThreadIdValidationThread : public base::Thread { } refs_[thread_no_].store(thread_id, std::memory_order_relaxed); if (thread_to_start_ != nullptr) { - thread_to_start_->Start(); + CHECK(thread_to_start_->Start()); } semaphore_->Signal(); } @@ -77,7 +77,7 @@ TEST(ThreadIdValidation) { threads[i] = base::make_unique<ThreadIdValidationThread>(prev, refs, i, &semaphore); } - threads[0]->Start(); + CHECK(threads[0]->Start()); for (int i = 0; i < kNThreads; i++) { semaphore.Wait(); } diff --git a/deps/v8/test/cctest/test-unboxed-doubles.cc b/deps/v8/test/cctest/test-unboxed-doubles.cc index 78ec000d65..9cfc40d37d 100644 --- a/deps/v8/test/cctest/test-unboxed-doubles.cc +++ b/deps/v8/test/cctest/test-unboxed-doubles.cc @@ -73,8 +73,8 @@ static double GetDoubleFieldValue(JSObject obj, FieldIndex field_index) { return obj.RawFastDoublePropertyAt(field_index); } else { Object value = obj.RawFastPropertyAt(field_index); - CHECK(value.IsMutableHeapNumber()); - return MutableHeapNumber::cast(value).value(); + CHECK(value.IsHeapNumber()); + return HeapNumber::cast(value).value(); } } @@ -1120,7 +1120,7 @@ TEST(DoScavenge) { double boom_value = bit_cast<double>(fake_object); FieldIndex field_index = FieldIndex::ForDescriptor(obj->map(), 0); - auto boom_number = factory->NewMutableHeapNumber(boom_value); + auto boom_number = factory->NewHeapNumber(boom_value); obj->FastPropertyAtPut(field_index, *boom_number); // Now |obj| moves to old gen and it has a double field that looks like diff --git a/deps/v8/test/cctest/torque/test-torque.cc b/deps/v8/test/cctest/torque/test-torque.cc index 8b67233963..184a867946 100644 --- a/deps/v8/test/cctest/torque/test-torque.cc +++ b/deps/v8/test/cctest/torque/test-torque.cc @@ -114,7 +114,7 @@ TEST(TestBuiltinSpecialization) { CodeAssemblerTester asm_tester(isolate, 0); TestTorqueAssembler m(asm_tester.state()); { - Node* temp = m.SmiConstant(0); + TNode<Object> temp = m.SmiConstant(0); m.TestBuiltinSpecialization(m.UncheckedCast<Context>(temp)); m.Return(m.UndefinedConstant()); } @@ -171,7 +171,7 @@ TEST(TestFunctionPointerToGeneric) { CodeAssemblerTester asm_tester(isolate, 0); TestTorqueAssembler m(asm_tester.state()); { - Node* temp = m.SmiConstant(0); + TNode<Object> temp = m.SmiConstant(0); m.TestFunctionPointerToGeneric(m.UncheckedCast<Context>(temp)); m.Return(m.UndefinedConstant()); } @@ -184,8 +184,8 @@ TEST(TestUnsafeCast) { CodeAssemblerTester asm_tester(isolate, 0); TestTorqueAssembler m(asm_tester.state()); { - Node* temp = m.SmiConstant(0); - Node* n = m.SmiConstant(10); + TNode<Object> temp = m.SmiConstant(0); + TNode<Smi> n = m.SmiConstant(10); m.Return(m.TestUnsafeCast(m.UncheckedCast<Context>(temp), m.UncheckedCast<Number>(n))); } @@ -328,7 +328,7 @@ TEST(TestCatch1) { TNode<Smi> result = m.TestCatch1(m.UncheckedCast<Context>(m.HeapConstant(context))); USE(result); - CSA_ASSERT(&m, m.WordEqual(result, m.SmiConstant(1))); + CSA_ASSERT(&m, m.TaggedEqual(result, m.SmiConstant(1))); m.Return(m.UndefinedConstant()); } FunctionTester ft(asm_tester.GenerateCode(), 0); @@ -347,7 +347,7 @@ TEST(TestCatch2) { TNode<Smi> result = m.TestCatch2(m.UncheckedCast<Context>(m.HeapConstant(context))); USE(result); - CSA_ASSERT(&m, m.WordEqual(result, m.SmiConstant(2))); + CSA_ASSERT(&m, m.TaggedEqual(result, m.SmiConstant(2))); m.Return(m.UndefinedConstant()); } FunctionTester ft(asm_tester.GenerateCode(), 0); @@ -366,7 +366,7 @@ TEST(TestCatch3) { TNode<Smi> result = m.TestCatch3(m.UncheckedCast<Context>(m.HeapConstant(context))); USE(result); - CSA_ASSERT(&m, m.WordEqual(result, m.SmiConstant(2))); + CSA_ASSERT(&m, m.TaggedEqual(result, m.SmiConstant(2))); m.Return(m.UndefinedConstant()); } FunctionTester ft(asm_tester.GenerateCode(), 0); @@ -484,6 +484,36 @@ TEST(TestReferences) { ft.Call(); } +TEST(TestSlices) { + CcTest::InitializeVM(); + Isolate* isolate(CcTest::i_isolate()); + i::HandleScope scope(isolate); + CodeAssemblerTester asm_tester(isolate); + TestTorqueAssembler m(asm_tester.state()); + { + m.TestSlices(); + m.Return(m.UndefinedConstant()); + } + FunctionTester ft(asm_tester.GenerateCode(), 0); + ft.Call(); +} + +TEST(TestSliceEnumeration) { + CcTest::InitializeVM(); + Isolate* isolate(CcTest::i_isolate()); + i::HandleScope scope(isolate); + Handle<Context> context = + Utils::OpenHandle(*v8::Isolate::GetCurrent()->GetCurrentContext()); + CodeAssemblerTester asm_tester(isolate); + TestTorqueAssembler m(asm_tester.state()); + { + m.TestSliceEnumeration(m.UncheckedCast<Context>(m.HeapConstant(context))); + m.Return(m.UndefinedConstant()); + } + FunctionTester ft(asm_tester.GenerateCode(), 0); + ft.Call(); +} + TEST(TestStaticAssert) { CcTest::InitializeVM(); Isolate* isolate(CcTest::i_isolate()); @@ -580,11 +610,28 @@ TEST(TestGenericStruct2) { i::HandleScope scope(isolate); CodeAssemblerTester asm_tester(isolate); TestTorqueAssembler m(asm_tester.state()); - { m.Return(m.TestGenericStruct2().fst); } + { m.Return(m.TestGenericStruct2().snd.fst); } FunctionTester ft(asm_tester.GenerateCode(), 0); ft.Call(); } +TEST(TestBranchOnBoolOptimization) { + CcTest::InitializeVM(); + Isolate* isolate(CcTest::i_isolate()); + i::HandleScope scope(isolate); + Handle<Context> context = + Utils::OpenHandle(*v8::Isolate::GetCurrent()->GetCurrentContext()); + CodeAssemblerTester asm_tester(isolate, 1); + TestTorqueAssembler m(asm_tester.state()); + { + m.TestBranchOnBoolOptimization( + m.UncheckedCast<Context>(m.HeapConstant(context)), + m.UncheckedCast<Smi>(m.Parameter(0))); + m.Return(m.UndefinedConstant()); + } + asm_tester.GenerateCode(); +} + } // namespace compiler } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/trace-extension.cc b/deps/v8/test/cctest/trace-extension.cc index 08cc024c90..df24e83f39 100644 --- a/deps/v8/test/cctest/trace-extension.cc +++ b/deps/v8/test/cctest/trace-extension.cc @@ -30,6 +30,7 @@ #include "include/v8-profiler.h" #include "src/execution/vm-state-inl.h" #include "src/objects/smi.h" +#include "src/profiler/tick-sample.h" #include "test/cctest/cctest.h" namespace v8 { @@ -89,21 +90,20 @@ Address TraceExtension::GetFP(const v8::FunctionCallbackInfo<v8::Value>& args) { return fp; } -static struct { v8::TickSample* sample; } trace_env = {nullptr}; +static struct { TickSample* sample; } trace_env = {nullptr}; -void TraceExtension::InitTraceEnv(v8::TickSample* sample) { +void TraceExtension::InitTraceEnv(TickSample* sample) { trace_env.sample = sample; } - void TraceExtension::DoTrace(Address fp) { RegisterState regs; regs.fp = reinterpret_cast<void*>(fp); // sp is only used to define stack high bound regs.sp = reinterpret_cast<void*>( reinterpret_cast<Address>(trace_env.sample) - 10240); - trace_env.sample->Init(CcTest::isolate(), regs, - v8::TickSample::kSkipCEntryFrame, true); + trace_env.sample->Init(CcTest::i_isolate(), regs, + TickSample::kSkipCEntryFrame, true); } diff --git a/deps/v8/test/cctest/trace-extension.h b/deps/v8/test/cctest/trace-extension.h index fe62c006b7..78927f0fb6 100644 --- a/deps/v8/test/cctest/trace-extension.h +++ b/deps/v8/test/cctest/trace-extension.h @@ -32,9 +32,10 @@ #include "src/common/globals.h" namespace v8 { -struct TickSample; namespace internal { +struct TickSample; + class TraceExtension : public v8::Extension { public: TraceExtension() : v8::Extension("v8/trace", kSource) { } @@ -45,7 +46,7 @@ class TraceExtension : public v8::Extension { static void JSEntrySP(const v8::FunctionCallbackInfo<v8::Value>& args); static void JSEntrySPLevel2(const v8::FunctionCallbackInfo<v8::Value>& args); static Address GetJsEntrySp(); - static void InitTraceEnv(v8::TickSample* sample); + static void InitTraceEnv(TickSample* sample); static void DoTrace(Address fp); private: static Address GetFP(const v8::FunctionCallbackInfo<v8::Value>& args); diff --git a/deps/v8/test/cctest/wasm/test-jump-table-assembler.cc b/deps/v8/test/cctest/wasm/test-jump-table-assembler.cc index dc02cfd14a..556d74daef 100644 --- a/deps/v8/test/cctest/wasm/test-jump-table-assembler.cc +++ b/deps/v8/test/cctest/wasm/test-jump-table-assembler.cc @@ -32,16 +32,18 @@ constexpr int kJumpTableSlotCount = 128; constexpr uint32_t kJumpTableSize = JumpTableAssembler::SizeForNumberOfSlots(kJumpTableSlotCount); +constexpr size_t kThunkBufferSize = AssemblerBase::kMinimalBufferSize; + #if V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_X64 constexpr uint32_t kAvailableBufferSlots = - (kMaxWasmCodeMemory - kJumpTableSize) / AssemblerBase::kMinimalBufferSize; + (kMaxWasmCodeMemory - kJumpTableSize) / kThunkBufferSize; constexpr uint32_t kBufferSlotStartOffset = - RoundUp<AssemblerBase::kMinimalBufferSize>(kJumpTableSize); + RoundUp<kThunkBufferSize>(kJumpTableSize); #else constexpr uint32_t kAvailableBufferSlots = 0; #endif -Address GenerateJumpTableThunk( +Address AllocateJumpTableThunk( Address jump_target, byte* thunk_slot_buffer, std::bitset<kAvailableBufferSlots>* used_slots, std::vector<std::unique_ptr<TestingAssemblerBuffer>>* thunk_buffers) { @@ -62,20 +64,22 @@ Address GenerateJumpTableThunk( buffer_index = rng->NextInt(kAvailableBufferSlots); } while (used_slots->test(buffer_index)); used_slots->set(buffer_index); - byte* buffer = - thunk_slot_buffer + buffer_index * AssemblerBase::kMinimalBufferSize; + return reinterpret_cast<Address>(thunk_slot_buffer + + buffer_index * kThunkBufferSize); #else USE(thunk_slot_buffer); USE(used_slots); - thunk_buffers->emplace_back(AllocateAssemblerBuffer( - AssemblerBase::kMinimalBufferSize, GetRandomMmapAddr())); - byte* buffer = thunk_buffers->back()->start(); + thunk_buffers->emplace_back( + AllocateAssemblerBuffer(kThunkBufferSize, GetRandomMmapAddr())); + return reinterpret_cast<Address>(thunk_buffers->back()->start()); #endif +} - MacroAssembler masm( - nullptr, AssemblerOptions{}, CodeObjectRequired::kNo, - ExternalAssemblerBuffer(buffer, AssemblerBase::kMinimalBufferSize)); +void CompileJumpTableThunk(Address thunk, Address jump_target) { + MacroAssembler masm(nullptr, AssemblerOptions{}, CodeObjectRequired::kNo, + ExternalAssemblerBuffer(reinterpret_cast<void*>(thunk), + kThunkBufferSize)); Label exit; Register scratch = kReturnRegister0; @@ -132,9 +136,9 @@ Address GenerateJumpTableThunk( __ bind(&exit); __ Ret(); - CodeDesc desc; - masm.GetCode(nullptr, &desc); - return reinterpret_cast<Address>(buffer); + FlushInstructionCache(thunk, kThunkBufferSize); + CHECK(SetPermissions(GetPlatformPageAllocator(), thunk, kThunkBufferSize, + v8::PageAllocator::kReadExecute)); } class JumpTableRunner : public v8::base::Thread { @@ -159,29 +163,38 @@ class JumpTableRunner : public v8::base::Thread { class JumpTablePatcher : public v8::base::Thread { public: JumpTablePatcher(Address slot_start, uint32_t slot_index, Address thunk1, - Address thunk2) + Address thunk2, base::Mutex* jump_table_mutex) : Thread(Options("JumpTablePatcher")), slot_start_(slot_start), slot_index_(slot_index), - thunks_{thunk1, thunk2} {} + thunks_{thunk1, thunk2}, + jump_table_mutex_(jump_table_mutex) {} void Run() override { - TRACE("Patcher is starting ...\n"); + TRACE("Patcher %p is starting ...\n", this); + Address slot_address = + slot_start_ + JumpTableAssembler::JumpSlotIndexToOffset(slot_index_); + // First, emit code to the two thunks. + for (Address thunk : thunks_) { + CompileJumpTableThunk(thunk, slot_address); + } + // Then, repeatedly patch the jump table to jump to one of the two thunks. constexpr int kNumberOfPatchIterations = 64; for (int i = 0; i < kNumberOfPatchIterations; ++i) { - TRACE(" patch slot " V8PRIxPTR_FMT " to thunk #%d\n", - slot_start_ + JumpTableAssembler::SlotIndexToOffset(slot_index_), - i % 2); + TRACE(" patcher %p patch slot " V8PRIxPTR_FMT " to thunk #%d\n", this, + slot_address, i % 2); + base::MutexGuard jump_table_guard(jump_table_mutex_); JumpTableAssembler::PatchJumpTableSlot( slot_start_, slot_index_, thunks_[i % 2], WasmCode::kFlushICache); } - TRACE("Patcher is stopping ...\n"); + TRACE("Patcher %p is stopping ...\n", this); } private: Address slot_start_; uint32_t slot_index_; Address thunks_[2]; + base::Mutex* jump_table_mutex_; }; } // namespace @@ -198,9 +211,10 @@ class JumpTablePatcher : public v8::base::Thread { // one of the runners is currently executing the jump-table slot. TEST(JumpTablePatchingStress) { constexpr int kNumberOfRunnerThreads = 5; + constexpr int kNumberOfPatcherThreads = 3; #if V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_X64 - // We need the branches (from GenerateJumpTableThunk) to be within near-call + // We need the branches (from CompileJumpTableThunk) to be within near-call // range of the jump table slots. The address hint to AllocateAssemblerBuffer // is not reliable enough to guarantee that we can always achieve this with // separate allocations, so for Arm64 we generate all code in a single @@ -226,29 +240,42 @@ TEST(JumpTablePatchingStress) { TRACE("Hammering on jump table slot #%d ...\n", slot); uint32_t slot_offset = JumpTableAssembler::JumpSlotIndexToOffset(slot); std::vector<std::unique_ptr<TestingAssemblerBuffer>> thunk_buffers; - Address thunk1 = - GenerateJumpTableThunk(slot_start + slot_offset, thunk_slot_buffer, - &used_thunk_slots, &thunk_buffers); - Address thunk2 = - GenerateJumpTableThunk(slot_start + slot_offset, thunk_slot_buffer, - &used_thunk_slots, &thunk_buffers); - TRACE(" generated thunk1: " V8PRIxPTR_FMT "\n", thunk1); - TRACE(" generated thunk2: " V8PRIxPTR_FMT "\n", thunk2); - JumpTableAssembler::PatchJumpTableSlot(slot_start, slot, thunk1, - WasmCode::kFlushICache); + // Patch the jump table slot to jump to itself. This will later be patched + // by the patchers. + JumpTableAssembler::PatchJumpTableSlot( + slot_start, slot, slot_start + slot_offset, WasmCode::kFlushICache); + // For each patcher, generate two thunks where this patcher can emit code + // which finally jumps back to {slot} in the jump table. + std::vector<Address> patcher_thunks; + for (int i = 0; i < 2 * kNumberOfPatcherThreads; ++i) { + Address thunk = + AllocateJumpTableThunk(slot_start + slot_offset, thunk_slot_buffer, + &used_thunk_slots, &thunk_buffers); + ZapCode(thunk, kThunkBufferSize); + patcher_thunks.push_back(thunk); + TRACE(" generated jump thunk: " V8PRIxPTR_FMT "\n", + patcher_thunks.back()); + } - for (auto& buf : thunk_buffers) buf->MakeExecutable(); - // Start multiple runner threads and a patcher thread that hammer on the - // same jump-table slot concurrently. + // Start multiple runner threads that execute the jump table slot + // concurrently. std::list<JumpTableRunner> runners; for (int runner = 0; runner < kNumberOfRunnerThreads; ++runner) { runners.emplace_back(slot_start + slot_offset, runner); } - JumpTablePatcher patcher(slot_start, slot, thunk1, thunk2); + // Start multiple patcher thread that concurrently generate code and insert + // jumps to that into the jump table slot. + std::list<JumpTablePatcher> patchers; + // Only one patcher should modify the jump table at a time. + base::Mutex jump_table_mutex; + for (int i = 0; i < kNumberOfPatcherThreads; ++i) { + patchers.emplace_back(slot_start, slot, patcher_thunks[2 * i], + patcher_thunks[2 * i + 1], &jump_table_mutex); + } global_stop_bit = 0; // Signal runners to keep going. - for (auto& runner : runners) runner.Start(); - patcher.Start(); - patcher.Join(); + for (auto& runner : runners) CHECK(runner.Start()); + for (auto& patcher : patchers) CHECK(patcher.Start()); + for (auto& patcher : patchers) patcher.Join(); global_stop_bit = -1; // Signal runners to stop. for (auto& runner : runners) runner.Join(); } 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 c8dd901161..3f96f8720f 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-64.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-64.cc @@ -618,7 +618,9 @@ WASM_EXEC_TEST(F32UConvertI64) { {0x8000008000000000, 0x5F000000}, {0x8000008000000001, 0x5F000001}, {0x8000000000000400, 0x5F000000}, - {0x8000000000000401, 0x5F000000}}; + {0x8000000000000401, 0x5F000000}, + {0x20000020000001, 0x5a000001}, + {0xFFFFFe8000000001, 0x5f7FFFFF}}; WasmRunner<float, uint64_t> r(execution_tier); BUILD(r, WASM_F32_UCONVERT_I64(WASM_GET_LOCAL(0))); for (size_t i = 0; i < arraysize(values); i++) { 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 60cda4adde..354ff436c0 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-atomics.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-atomics.cc @@ -317,6 +317,54 @@ WASM_EXEC_TEST(AtomicFence) { CHECK_EQ(0, r.Call()); } +WASM_EXEC_TEST(AtomicStoreNoConsideredEffectful) { + EXPERIMENTAL_FLAG_SCOPE(threads); + FLAG_wasm_trap_handler = false; // To use {Load} instead of {ProtectedLoad}. + WasmRunner<uint32_t> r(execution_tier); + r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t)); + r.builder().SetHasSharedMemory(); + BUILD(r, WASM_LOAD_MEM(MachineType::Int64(), WASM_ZERO), + WASM_ATOMICS_STORE_OP(kExprI32AtomicStore, WASM_ZERO, WASM_I32V_1(20), + MachineRepresentation::kWord32), + kExprI64Eqz); + CHECK_EQ(1, r.Call()); +} + +void RunNoEffectTest(ExecutionTier execution_tier, WasmOpcode wasm_op) { + EXPERIMENTAL_FLAG_SCOPE(threads); + FLAG_wasm_trap_handler = false; // To use {Load} instead of {ProtectedLoad}. + WasmRunner<uint32_t> r(execution_tier); + r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t)); + r.builder().SetHasSharedMemory(); + BUILD(r, WASM_LOAD_MEM(MachineType::Int64(), WASM_ZERO), + WASM_ATOMICS_BINOP(wasm_op, WASM_ZERO, WASM_I32V_1(20), + MachineRepresentation::kWord32), + WASM_DROP, kExprI64Eqz); + CHECK_EQ(1, r.Call()); +} + +WASM_EXEC_TEST(AtomicAddNoConsideredEffectful) { + RunNoEffectTest(execution_tier, kExprI32AtomicAdd); +} + +WASM_EXEC_TEST(AtomicExchangeNoConsideredEffectful) { + RunNoEffectTest(execution_tier, kExprI32AtomicExchange); +} + +WASM_EXEC_TEST(AtomicCompareExchangeNoConsideredEffectful) { + EXPERIMENTAL_FLAG_SCOPE(threads); + FLAG_wasm_trap_handler = false; // To use {Load} instead of {ProtectedLoad}. + WasmRunner<uint32_t> r(execution_tier); + r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t)); + r.builder().SetHasSharedMemory(); + BUILD(r, WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO), + WASM_ATOMICS_TERNARY_OP(kExprI32AtomicCompareExchange, WASM_ZERO, + WASM_ZERO, WASM_I32V_1(30), + MachineRepresentation::kWord32), + WASM_DROP, kExprI32Eqz); + CHECK_EQ(1, r.Call()); +} + } // namespace test_run_wasm_atomics } // namespace wasm } // namespace internal diff --git a/deps/v8/test/cctest/wasm/test-run-wasm-atomics64.cc b/deps/v8/test/cctest/wasm/test-run-wasm-atomics64.cc index 2d5d6a945c..748adc4a67 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-atomics64.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-atomics64.cc @@ -646,6 +646,54 @@ WASM_EXEC_TEST(I64AtomicCompareExchange32UFail) { CHECK_EQ(initial, r.builder().ReadMemory(&memory[0])); } +WASM_EXEC_TEST(AtomicStoreNoConsideredEffectful) { + EXPERIMENTAL_FLAG_SCOPE(threads); + FLAG_wasm_trap_handler = false; // To use {Load} instead of {ProtectedLoad}. + WasmRunner<uint32_t> r(execution_tier); + r.builder().AddMemoryElems<int64_t>(kWasmPageSize / sizeof(int64_t)); + r.builder().SetHasSharedMemory(); + BUILD(r, WASM_LOAD_MEM(MachineType::Int64(), WASM_ZERO), + WASM_ATOMICS_STORE_OP(kExprI64AtomicStore, WASM_ZERO, WASM_I64V(20), + MachineRepresentation::kWord64), + kExprI64Eqz); + CHECK_EQ(1, r.Call()); +} + +void RunNoEffectTest(ExecutionTier execution_tier, WasmOpcode wasm_op) { + EXPERIMENTAL_FLAG_SCOPE(threads); + FLAG_wasm_trap_handler = false; // To use {Load} instead of {ProtectedLoad}. + WasmRunner<uint32_t> r(execution_tier); + r.builder().AddMemoryElems<int64_t>(kWasmPageSize / sizeof(int64_t)); + r.builder().SetHasSharedMemory(); + BUILD(r, WASM_LOAD_MEM(MachineType::Int64(), WASM_ZERO), + WASM_ATOMICS_BINOP(wasm_op, WASM_ZERO, WASM_I64V(20), + MachineRepresentation::kWord64), + WASM_DROP, kExprI64Eqz); + CHECK_EQ(1, r.Call()); +} + +WASM_EXEC_TEST(AtomicAddNoConsideredEffectful) { + RunNoEffectTest(execution_tier, kExprI64AtomicAdd); +} + +WASM_EXEC_TEST(AtomicExchangeNoConsideredEffectful) { + RunNoEffectTest(execution_tier, kExprI64AtomicExchange); +} + +WASM_EXEC_TEST(AtomicCompareExchangeNoConsideredEffectful) { + EXPERIMENTAL_FLAG_SCOPE(threads); + FLAG_wasm_trap_handler = false; // To use {Load} instead of {ProtectedLoad}. + WasmRunner<uint32_t> r(execution_tier); + r.builder().AddMemoryElems<uint64_t>(kWasmPageSize / sizeof(uint64_t)); + r.builder().SetHasSharedMemory(); + BUILD(r, WASM_LOAD_MEM(MachineType::Int64(), WASM_ZERO), + WASM_ATOMICS_TERNARY_OP(kExprI64AtomicCompareExchange, WASM_ZERO, + WASM_I64V(0), WASM_I64V(30), + MachineRepresentation::kWord64), + WASM_DROP, kExprI64Eqz); + CHECK_EQ(1, r.Call()); +} + } // namespace test_run_wasm_atomics_64 } // namespace wasm } // namespace internal 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 526c5846a2..51d97650d4 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-module.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-module.cc @@ -583,7 +583,7 @@ TEST(TestInterruptLoop) { int32_t* memory_array = reinterpret_cast<int32_t*>(memory->backing_store()); InterruptThread thread(isolate, memory_array); - thread.Start(); + CHECK(thread.Start()); testing::RunWasmModuleForTesting(isolate, instance, 0, nullptr); Address address = reinterpret_cast<Address>( &memory_array[InterruptThread::interrupt_location_]); @@ -910,6 +910,8 @@ TEST(EmptyMemoryEmptyDataSegment) { TEST(MemoryWithOOBEmptyDataSegment) { { + FlagScope<bool> no_bulk_memory( + &v8::internal::FLAG_experimental_wasm_bulk_memory, false); Isolate* isolate = CcTest::InitIsolateOnce(); HandleScope scope(isolate); testing::SetupIsolateForWasmModule(isolate); 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 b1d95a12bb..b48321df40 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-simd.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-simd.cc @@ -20,6 +20,7 @@ namespace test_run_wasm_simd { namespace { using DoubleUnOp = double (*)(double); +using DoubleBinOp = double (*)(double, double); using DoubleCompareOp = int64_t (*)(double, double); using FloatUnOp = float (*)(float); using FloatBinOp = float (*)(float, float); @@ -85,6 +86,13 @@ T Mul(T a, T b) { return a * b; } +template <typename T, typename = typename std::enable_if< + std::is_floating_point<T>::value>::type> +T Div(T a, T b) { + // Workaround C++ undefined behavior when b is 0. + return base::Divide(a, b); +} + template <typename T> T Minimum(T a, T b) { return a <= b ? a : b; @@ -271,7 +279,7 @@ T Sqrt(T a) { return std::sqrt(a); } -#if V8_TARGET_ARCH_X64 +#if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64 // only used for F64x2 tests below int64_t Equal(double a, double b) { return a == b ? -1 : 0; } @@ -284,7 +292,7 @@ int64_t GreaterEqual(double a, double b) { return a >= b ? -1 : 0; } int64_t Less(double a, double b) { return a < b ? -1 : 0; } int64_t LessEqual(double a, double b) { return a <= b ? -1 : 0; } -#endif // V8_TARGET_ARCH_X64 +#endif // V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64 } // namespace @@ -299,7 +307,7 @@ int64_t LessEqual(double a, double b) { return a <= b ? -1 : 0; } #define WASM_SIMD_SPLAT(Type, ...) __VA_ARGS__, WASM_SIMD_OP(kExpr##Type##Splat) #define WASM_SIMD_UNOP(op, x) x, WASM_SIMD_OP(op) #define WASM_SIMD_BINOP(op, x, y) x, y, WASM_SIMD_OP(op) -#define WASM_SIMD_SHIFT_OP(op, shift, x) x, WASM_SIMD_OP(op), TO_BYTE(shift) +#define WASM_SIMD_SHIFT_OP(op, x, y) x, y, WASM_SIMD_OP(op) #define WASM_SIMD_CONCAT_OP(op, bytes, x, y) \ x, y, WASM_SIMD_OP(op), TO_BYTE(bytes) #define WASM_SIMD_SELECT(format, x, y, z) x, y, z, WASM_SIMD_OP(kExprS128Select) @@ -652,12 +660,13 @@ WASM_SIMD_TEST(F32x4Sub) { WASM_SIMD_TEST(F32x4Mul) { RunF32x4BinOpTest(execution_tier, lower_simd, kExprF32x4Mul, Mul); } -// v8:8425 tracks this test being enabled in the interpreter. -WASM_SIMD_COMPILED_TEST(F32x4Min) { +WASM_SIMD_TEST(F32x4Div) { + RunF32x4BinOpTest(execution_tier, lower_simd, kExprF32x4Div, Div); +} +WASM_SIMD_TEST(F32x4Min) { RunF32x4BinOpTest(execution_tier, lower_simd, kExprF32x4Min, JSMin); } -// v8:8425 tracks this test being enabled in the interpreter. -WASM_SIMD_COMPILED_TEST(F32x4Max) { +WASM_SIMD_TEST(F32x4Max) { RunF32x4BinOpTest(execution_tier, lower_simd, kExprF32x4Max, JSMax); } @@ -715,7 +724,201 @@ WASM_SIMD_TEST(F32x4Le) { RunF32x4CompareOpTest(execution_tier, lower_simd, kExprF32x4Le, LessEqual); } -#if V8_TARGET_ARCH_X64 +#if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64 +WASM_SIMD_TEST_NO_LOWERING(I64x2Splat) { + WasmRunner<int32_t, int64_t> r(execution_tier, lower_simd); + // Set up a global to hold output vector. + int64_t* g = r.builder().AddGlobal<int64_t>(kWasmS128); + byte param1 = 0; + BUILD(r, WASM_SET_GLOBAL(0, WASM_SIMD_I64x2_SPLAT(WASM_GET_LOCAL(param1))), + WASM_ONE); + + FOR_INT64_INPUTS(x) { + r.Call(x); + int64_t expected = x; + for (int i = 0; i < 2; i++) { + int64_t actual = ReadLittleEndianValue<int64_t>(&g[i]); + CHECK_EQ(actual, expected); + } + } +} + +WASM_SIMD_TEST_NO_LOWERING(I64x2ExtractLane) { + WasmRunner<int64_t> r(execution_tier, lower_simd); + r.AllocateLocal(kWasmI64); + r.AllocateLocal(kWasmS128); + BUILD( + r, + WASM_SET_LOCAL(0, WASM_SIMD_I64x2_EXTRACT_LANE( + 0, WASM_SIMD_I64x2_SPLAT(WASM_I64V(0xFFFFFFFFFF)))), + WASM_SET_LOCAL(1, WASM_SIMD_I64x2_SPLAT(WASM_GET_LOCAL(0))), + WASM_SIMD_I64x2_EXTRACT_LANE(1, WASM_GET_LOCAL(1))); + CHECK_EQ(0xFFFFFFFFFF, r.Call()); +} + +WASM_SIMD_TEST_NO_LOWERING(I64x2ReplaceLane) { + WasmRunner<int32_t> r(execution_tier, lower_simd); + // Set up a global to hold input/output vector. + int64_t* g = r.builder().AddGlobal<int64_t>(kWasmS128); + // Build function to replace each lane with its index. + byte temp1 = r.AllocateLocal(kWasmS128); + BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_I64x2_SPLAT(WASM_I64V(-1))), + WASM_SET_LOCAL(temp1, WASM_SIMD_I64x2_REPLACE_LANE( + 0, WASM_GET_LOCAL(temp1), WASM_I64V(0))), + WASM_SET_GLOBAL(0, WASM_SIMD_I64x2_REPLACE_LANE( + 1, WASM_GET_LOCAL(temp1), WASM_I64V(1))), + WASM_ONE); + + r.Call(); + for (int64_t i = 0; i < 2; i++) { + CHECK_EQ(i, ReadLittleEndianValue<int64_t>(&g[i])); + } +} + +void RunI64x2UnOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, + WasmOpcode opcode, Int64UnOp expected_op) { + WasmRunner<int32_t, int64_t> r(execution_tier, lower_simd); + // Global to hold output. + int64_t* g = r.builder().AddGlobal<int64_t>(kWasmS128); + // Build fn to splat test value, perform unop, and write the result. + byte value = 0; + byte temp1 = r.AllocateLocal(kWasmS128); + BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_I64x2_SPLAT(WASM_GET_LOCAL(value))), + WASM_SET_GLOBAL(0, WASM_SIMD_UNOP(opcode, WASM_GET_LOCAL(temp1))), + WASM_ONE); + + FOR_INT64_INPUTS(x) { + r.Call(x); + int64_t expected = expected_op(x); + for (int i = 0; i < 2; i++) { + CHECK_EQ(expected, ReadLittleEndianValue<int64_t>(&g[i])); + } + } +} + +WASM_SIMD_TEST_NO_LOWERING(I64x2Neg) { + RunI64x2UnOpTest(execution_tier, lower_simd, kExprI64x2Neg, + base::NegateWithWraparound); +} + +void RunI64x2ShiftOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, + WasmOpcode opcode, Int64ShiftOp expected_op) { + for (int shift = 1; shift < 64; shift++) { + WasmRunner<int32_t, int64_t> r(execution_tier, lower_simd); + int64_t* g = r.builder().AddGlobal<int64_t>(kWasmS128); + byte value = 0; + byte shift_index = r.AllocateLocal(kWasmI32); + byte simd1 = r.AllocateLocal(kWasmS128); + BUILD(r, + WASM_SET_LOCAL(simd1, WASM_SIMD_I64x2_SPLAT(WASM_GET_LOCAL(value))), + WASM_SET_LOCAL(shift_index, WASM_I32V(shift)), + WASM_SET_GLOBAL(0, WASM_SIMD_SHIFT_OP(opcode, WASM_GET_LOCAL(simd1), + WASM_GET_LOCAL(shift_index))), + WASM_ONE); + + FOR_INT64_INPUTS(x) { + r.Call(x); + int64_t expected = expected_op(x, shift); + for (int i = 0; i < 2; i++) { + CHECK_EQ(expected, ReadLittleEndianValue<int64_t>(&g[i])); + } + } + } +} + +WASM_SIMD_TEST_NO_LOWERING(I64x2Shl) { + RunI64x2ShiftOpTest(execution_tier, lower_simd, kExprI64x2Shl, + LogicalShiftLeft); +} + +WASM_SIMD_TEST_NO_LOWERING(I64x2ShrS) { + RunI64x2ShiftOpTest(execution_tier, lower_simd, kExprI64x2ShrS, + ArithmeticShiftRight); +} + +WASM_SIMD_TEST_NO_LOWERING(I64x2ShrU) { + RunI64x2ShiftOpTest(execution_tier, lower_simd, kExprI64x2ShrU, + LogicalShiftRight); +} + +void RunI64x2BinOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, + WasmOpcode opcode, Int64BinOp expected_op) { + WasmRunner<int32_t, int64_t, int64_t> r(execution_tier, lower_simd); + // Global to hold output. + int64_t* g = r.builder().AddGlobal<int64_t>(kWasmS128); + // Build fn to splat test values, perform binop, and write the result. + byte value1 = 0, value2 = 1; + byte temp1 = r.AllocateLocal(kWasmS128); + byte temp2 = r.AllocateLocal(kWasmS128); + BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_I64x2_SPLAT(WASM_GET_LOCAL(value1))), + WASM_SET_LOCAL(temp2, WASM_SIMD_I64x2_SPLAT(WASM_GET_LOCAL(value2))), + WASM_SET_GLOBAL(0, WASM_SIMD_BINOP(opcode, WASM_GET_LOCAL(temp1), + WASM_GET_LOCAL(temp2))), + WASM_ONE); + + FOR_INT64_INPUTS(x) { + FOR_INT64_INPUTS(y) { + r.Call(x, y); + int64_t expected = expected_op(x, y); + for (int i = 0; i < 2; i++) { + CHECK_EQ(expected, ReadLittleEndianValue<int64_t>(&g[i])); + } + } + } +} + +WASM_SIMD_TEST_NO_LOWERING(I64x2Add) { + RunI64x2BinOpTest(execution_tier, lower_simd, kExprI64x2Add, + base::AddWithWraparound); +} + +WASM_SIMD_TEST_NO_LOWERING(I64x2Sub) { + RunI64x2BinOpTest(execution_tier, lower_simd, kExprI64x2Sub, + base::SubWithWraparound); +} + +WASM_SIMD_TEST_NO_LOWERING(I64x2Eq) { + RunI64x2BinOpTest(execution_tier, lower_simd, kExprI64x2Eq, Equal); +} + +WASM_SIMD_TEST_NO_LOWERING(I64x2Ne) { + RunI64x2BinOpTest(execution_tier, lower_simd, kExprI64x2Ne, NotEqual); +} + +WASM_SIMD_TEST_NO_LOWERING(I64x2LtS) { + RunI64x2BinOpTest(execution_tier, lower_simd, kExprI64x2LtS, Less); +} + +WASM_SIMD_TEST_NO_LOWERING(I64x2LeS) { + RunI64x2BinOpTest(execution_tier, lower_simd, kExprI64x2LeS, LessEqual); +} + +WASM_SIMD_TEST_NO_LOWERING(I64x2GtS) { + RunI64x2BinOpTest(execution_tier, lower_simd, kExprI64x2GtS, Greater); +} + +WASM_SIMD_TEST_NO_LOWERING(I64x2GeS) { + RunI64x2BinOpTest(execution_tier, lower_simd, kExprI64x2GeS, GreaterEqual); +} + +WASM_SIMD_TEST_NO_LOWERING(I64x2LtU) { + RunI64x2BinOpTest(execution_tier, lower_simd, kExprI64x2LtU, UnsignedLess); +} + +WASM_SIMD_TEST_NO_LOWERING(I64x2LeU) { + RunI64x2BinOpTest(execution_tier, lower_simd, kExprI64x2LeU, + UnsignedLessEqual); +} + +WASM_SIMD_TEST_NO_LOWERING(I64x2GtU) { + RunI64x2BinOpTest(execution_tier, lower_simd, kExprI64x2GtU, UnsignedGreater); +} + +WASM_SIMD_TEST_NO_LOWERING(I64x2GeU) { + RunI64x2BinOpTest(execution_tier, lower_simd, kExprI64x2GeU, + UnsignedGreaterEqual); +} + WASM_SIMD_TEST_NO_LOWERING(F64x2Splat) { WasmRunner<int32_t, double> r(execution_tier, lower_simd); // Set up a global to hold output vector. @@ -770,6 +973,16 @@ WASM_SIMD_TEST_NO_LOWERING(F64x2ExtractLane) { } } +WASM_SIMD_TEST_NO_LOWERING(I64x2ExtractWithF64x2) { + WasmRunner<int64_t> r(execution_tier, lower_simd); + BUILD(r, WASM_IF_ELSE_L( + WASM_I64_EQ(WASM_SIMD_I64x2_EXTRACT_LANE( + 0, WASM_SIMD_F64x2_SPLAT(WASM_F64(1e15))), + WASM_I64_REINTERPRET_F64(WASM_F64(1e15))), + WASM_I64V(1), WASM_I64V(0))); + CHECK_EQ(1, r.Call()); +} + WASM_SIMD_TEST_NO_LOWERING(F64x2ReplaceLane) { WasmRunner<int32_t> r(execution_tier, lower_simd); // Set up a global to hold input/output vector. @@ -789,58 +1002,12 @@ WASM_SIMD_TEST_NO_LOWERING(F64x2ReplaceLane) { } } -void RunF64x2CompareOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, - WasmOpcode opcode, DoubleCompareOp expected_op) { - WasmRunner<int32_t, double, double> r(execution_tier, lower_simd); - // Set up global to hold mask output. - int64_t* g = r.builder().AddGlobal<int64_t>(kWasmS128); - // Build fn to splat test values, perform compare op, and write the result. - byte value1 = 0, value2 = 1; - byte temp1 = r.AllocateLocal(kWasmS128); - byte temp2 = r.AllocateLocal(kWasmS128); - BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_F64x2_SPLAT(WASM_GET_LOCAL(value1))), - WASM_SET_LOCAL(temp2, WASM_SIMD_F64x2_SPLAT(WASM_GET_LOCAL(value2))), - WASM_SET_GLOBAL(0, WASM_SIMD_BINOP(opcode, WASM_GET_LOCAL(temp1), - WASM_GET_LOCAL(temp2))), - WASM_ONE); - - FOR_FLOAT64_INPUTS(x) { - if (!PlatformCanRepresent(x)) continue; - FOR_FLOAT64_INPUTS(y) { - if (!PlatformCanRepresent(y)) continue; - double diff = x - y; // Model comparison as subtraction. - if (!PlatformCanRepresent(diff)) continue; - r.Call(x, y); - int64_t expected = expected_op(x, y); - for (int i = 0; i < 2; i++) { - CHECK_EQ(expected, ReadLittleEndianValue<int64_t>(&g[i])); - } - } - } -} - -WASM_SIMD_TEST_NO_LOWERING(F64x2Eq) { - RunF64x2CompareOpTest(execution_tier, lower_simd, kExprF64x2Eq, Equal); -} - -WASM_SIMD_TEST_NO_LOWERING(F64x2Ne) { - RunF64x2CompareOpTest(execution_tier, lower_simd, kExprF64x2Ne, NotEqual); -} - -WASM_SIMD_TEST_NO_LOWERING(F64x2Gt) { - RunF64x2CompareOpTest(execution_tier, lower_simd, kExprF64x2Gt, Greater); -} - -WASM_SIMD_TEST_NO_LOWERING(F64x2Ge) { - RunF64x2CompareOpTest(execution_tier, lower_simd, kExprF64x2Ge, GreaterEqual); -} - -WASM_SIMD_TEST_NO_LOWERING(F64x2Lt) { - RunF64x2CompareOpTest(execution_tier, lower_simd, kExprF64x2Lt, Less); -} - -WASM_SIMD_TEST_NO_LOWERING(F64x2Le) { - RunF64x2CompareOpTest(execution_tier, lower_simd, kExprF64x2Le, LessEqual); +bool IsExtreme(double x) { + double abs_x = std::fabs(x); + const double kSmallFloatThreshold = 1.0e-298; + const double kLargeFloatThreshold = 1.0e298; + return abs_x != 0.0f && // 0 or -0 are fine. + (abs_x < kSmallFloatThreshold || abs_x > kLargeFloatThreshold); } bool IsSameNan(double expected, double actual) { @@ -855,7 +1022,7 @@ bool IsSameNan(double expected, double actual) { bool IsCanonical(double actual) { uint64_t actual_bits = bit_cast<uint64_t>(actual); // Canonical NaN has quiet bit and no payload. - return (actual_bits & 0xFF80000000000000) == actual_bits; + return (actual_bits & 0xFFF8000000000000) == actual_bits; } void CheckDoubleResult(double x, double y, double expected, double actual, @@ -948,7 +1115,6 @@ void RunF64x2UnOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, } } } -#undef FOR_FLOAT64_NAN_INPUTS WASM_SIMD_TEST_NO_LOWERING(F64x2Abs) { RunF64x2UnOpTest(execution_tier, lower_simd, kExprF64x2Abs, std::abs); @@ -958,96 +1124,90 @@ WASM_SIMD_TEST_NO_LOWERING(F64x2Neg) { RunF64x2UnOpTest(execution_tier, lower_simd, kExprF64x2Neg, Negate); } -WASM_SIMD_TEST_NO_LOWERING(I64x2Splat) { - WasmRunner<int32_t, int64_t> r(execution_tier, lower_simd); - // Set up a global to hold output vector. - int64_t* g = r.builder().AddGlobal<int64_t>(kWasmS128); - byte param1 = 0; - BUILD(r, WASM_SET_GLOBAL(0, WASM_SIMD_I64x2_SPLAT(WASM_GET_LOCAL(param1))), +void RunF64x2BinOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, + WasmOpcode opcode, DoubleBinOp expected_op) { + WasmRunner<int32_t, double, double> r(execution_tier, lower_simd); + // Global to hold output. + double* g = r.builder().AddGlobal<double>(kWasmS128); + // Build fn to splat test value, perform binop, and write the result. + byte value1 = 0, value2 = 1; + byte temp1 = r.AllocateLocal(kWasmS128); + byte temp2 = r.AllocateLocal(kWasmS128); + BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_F64x2_SPLAT(WASM_GET_LOCAL(value1))), + WASM_SET_LOCAL(temp2, WASM_SIMD_F64x2_SPLAT(WASM_GET_LOCAL(value2))), + WASM_SET_GLOBAL(0, WASM_SIMD_BINOP(opcode, WASM_GET_LOCAL(temp1), + WASM_GET_LOCAL(temp2))), WASM_ONE); - FOR_INT64_INPUTS(x) { - r.Call(x); - int64_t expected = x; - for (int i = 0; i < 2; i++) { - int64_t actual = ReadLittleEndianValue<int64_t>(&g[i]); - CHECK_EQ(actual, expected); + FOR_FLOAT64_INPUTS(x) { + if (!PlatformCanRepresent(x)) continue; + FOR_FLOAT64_INPUTS(y) { + if (!PlatformCanRepresent(x)) continue; + double expected = expected_op(x, y); + if (!PlatformCanRepresent(expected)) continue; + r.Call(x, y); + for (int i = 0; i < 2; i++) { + double actual = ReadLittleEndianValue<double>(&g[i]); + CheckDoubleResult(x, y, expected, actual, true /* exact */); + } } } -} -WASM_SIMD_TEST_NO_LOWERING(I64x2ExtractWithF64x2) { - WasmRunner<int64_t> r(execution_tier, lower_simd); - BUILD(r, WASM_IF_ELSE_L( - WASM_I64_EQ(WASM_SIMD_I64x2_EXTRACT_LANE( - 0, WASM_SIMD_F64x2_SPLAT(WASM_F64(1e15))), - WASM_I64_REINTERPRET_F64(WASM_F64(1e15))), - WASM_I64V(1), WASM_I64V(0))); - CHECK_EQ(1, r.Call()); + FOR_FLOAT64_NAN_INPUTS(i) { + double x = bit_cast<double>(double_nan_test_array[i]); + if (!PlatformCanRepresent(x)) continue; + FOR_FLOAT64_NAN_INPUTS(j) { + double y = bit_cast<double>(double_nan_test_array[j]); + double expected = expected_op(x, y); + if (!PlatformCanRepresent(expected)) continue; + r.Call(x, y); + for (int i = 0; i < 2; i++) { + double actual = ReadLittleEndianValue<double>(&g[i]); + CheckDoubleResult(x, y, expected, actual, true /* exact */); + } + } + } } -WASM_SIMD_TEST_NO_LOWERING(I64x2ReplaceLane) { - WasmRunner<int32_t> r(execution_tier, lower_simd); - // Set up a global to hold input/output vector. - int64_t* g = r.builder().AddGlobal<int64_t>(kWasmS128); - // Build function to replace each lane with its index. - byte temp1 = r.AllocateLocal(kWasmS128); - BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_I64x2_SPLAT(WASM_I64V(-1))), - WASM_SET_LOCAL(temp1, WASM_SIMD_I64x2_REPLACE_LANE( - 0, WASM_GET_LOCAL(temp1), WASM_I64V(0))), - WASM_SET_GLOBAL(0, WASM_SIMD_I64x2_REPLACE_LANE( - 1, WASM_GET_LOCAL(temp1), WASM_I64V(1))), - WASM_ONE); +#undef FOR_FLOAT64_NAN_INPUTS - r.Call(); - for (int64_t i = 0; i < 2; i++) { - CHECK_EQ(i, ReadLittleEndianValue<int64_t>(&g[i])); - } +WASM_SIMD_TEST_NO_LOWERING(F64x2Add) { + RunF64x2BinOpTest(execution_tier, lower_simd, kExprF64x2Add, Add); } -void RunI64x2UnOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, - WasmOpcode opcode, Int64UnOp expected_op) { - WasmRunner<int32_t, int64_t> r(execution_tier, lower_simd); - // Global to hold output. - int64_t* g = r.builder().AddGlobal<int64_t>(kWasmS128); - // Build fn to splat test value, perform unop, and write the result. - byte value = 0; - byte temp1 = r.AllocateLocal(kWasmS128); - BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_I64x2_SPLAT(WASM_GET_LOCAL(value))), - WASM_SET_GLOBAL(0, WASM_SIMD_UNOP(opcode, WASM_GET_LOCAL(temp1))), - WASM_ONE); +WASM_SIMD_TEST_NO_LOWERING(F64x2Sub) { + RunF64x2BinOpTest(execution_tier, lower_simd, kExprF64x2Sub, Sub); +} - FOR_INT64_INPUTS(x) { - r.Call(x); - int64_t expected = expected_op(x); - for (int i = 0; i < 2; i++) { - CHECK_EQ(expected, ReadLittleEndianValue<int64_t>(&g[i])); - } - } +WASM_SIMD_TEST_NO_LOWERING(F64x2Mul) { + RunF64x2BinOpTest(execution_tier, lower_simd, kExprF64x2Mul, Mul); } -WASM_SIMD_TEST_NO_LOWERING(I64x2Neg) { - RunI64x2UnOpTest(execution_tier, lower_simd, kExprI64x2Neg, - base::NegateWithWraparound); +WASM_SIMD_TEST_NO_LOWERING(F64x2Div) { + RunF64x2BinOpTest(execution_tier, lower_simd, kExprF64x2Div, Div); } -void RunI64x2BinOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, - WasmOpcode opcode, Int64BinOp expected_op) { - WasmRunner<int32_t, int64_t, int64_t> r(execution_tier, lower_simd); - // Global to hold output. +void RunF64x2CompareOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, + WasmOpcode opcode, DoubleCompareOp expected_op) { + WasmRunner<int32_t, double, double> r(execution_tier, lower_simd); + // Set up global to hold mask output. int64_t* g = r.builder().AddGlobal<int64_t>(kWasmS128); - // Build fn to splat test values, perform binop, and write the result. + // Build fn to splat test values, perform compare op, and write the result. byte value1 = 0, value2 = 1; byte temp1 = r.AllocateLocal(kWasmS128); byte temp2 = r.AllocateLocal(kWasmS128); - BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_I64x2_SPLAT(WASM_GET_LOCAL(value1))), - WASM_SET_LOCAL(temp2, WASM_SIMD_I64x2_SPLAT(WASM_GET_LOCAL(value2))), + BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_F64x2_SPLAT(WASM_GET_LOCAL(value1))), + WASM_SET_LOCAL(temp2, WASM_SIMD_F64x2_SPLAT(WASM_GET_LOCAL(value2))), WASM_SET_GLOBAL(0, WASM_SIMD_BINOP(opcode, WASM_GET_LOCAL(temp1), WASM_GET_LOCAL(temp2))), WASM_ONE); - FOR_INT64_INPUTS(x) { - FOR_INT64_INPUTS(y) { + FOR_FLOAT64_INPUTS(x) { + if (!PlatformCanRepresent(x)) continue; + FOR_FLOAT64_INPUTS(y) { + if (!PlatformCanRepresent(y)) continue; + double diff = x - y; // Model comparison as subtraction. + if (!PlatformCanRepresent(diff)) continue; r.Call(x, y); int64_t expected = expected_op(x, y); for (int i = 0; i < 2; i++) { @@ -1057,101 +1217,63 @@ void RunI64x2BinOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, } } -WASM_SIMD_TEST_NO_LOWERING(I64x2Add) { - RunI64x2BinOpTest(execution_tier, lower_simd, kExprI64x2Add, - base::AddWithWraparound); -} - -WASM_SIMD_TEST_NO_LOWERING(I64x2Sub) { - RunI64x2BinOpTest(execution_tier, lower_simd, kExprI64x2Sub, - base::SubWithWraparound); -} - -WASM_SIMD_TEST_NO_LOWERING(I64x2Mul) { - RunI64x2BinOpTest(execution_tier, lower_simd, kExprI64x2Mul, - base::MulWithWraparound); -} - -WASM_SIMD_TEST_NO_LOWERING(I64x2Eq) { - RunI64x2BinOpTest(execution_tier, lower_simd, kExprI64x2Eq, Equal); -} - -WASM_SIMD_TEST_NO_LOWERING(I64x2Ne) { - RunI64x2BinOpTest(execution_tier, lower_simd, kExprI64x2Ne, NotEqual); +WASM_SIMD_TEST_NO_LOWERING(F64x2Eq) { + RunF64x2CompareOpTest(execution_tier, lower_simd, kExprF64x2Eq, Equal); } -WASM_SIMD_TEST_NO_LOWERING(I64x2LtS) { - RunI64x2BinOpTest(execution_tier, lower_simd, kExprI64x2LtS, Less); +WASM_SIMD_TEST_NO_LOWERING(F64x2Ne) { + RunF64x2CompareOpTest(execution_tier, lower_simd, kExprF64x2Ne, NotEqual); } -WASM_SIMD_TEST_NO_LOWERING(I64x2LeS) { - RunI64x2BinOpTest(execution_tier, lower_simd, kExprI64x2LeS, LessEqual); +WASM_SIMD_TEST_NO_LOWERING(F64x2Gt) { + RunF64x2CompareOpTest(execution_tier, lower_simd, kExprF64x2Gt, Greater); } -WASM_SIMD_TEST_NO_LOWERING(I64x2GtS) { - RunI64x2BinOpTest(execution_tier, lower_simd, kExprI64x2GtS, Greater); +WASM_SIMD_TEST_NO_LOWERING(F64x2Ge) { + RunF64x2CompareOpTest(execution_tier, lower_simd, kExprF64x2Ge, GreaterEqual); } -WASM_SIMD_TEST_NO_LOWERING(I64x2GeS) { - RunI64x2BinOpTest(execution_tier, lower_simd, kExprI64x2GeS, GreaterEqual); +WASM_SIMD_TEST_NO_LOWERING(F64x2Lt) { + RunF64x2CompareOpTest(execution_tier, lower_simd, kExprF64x2Lt, Less); } -WASM_SIMD_TEST_NO_LOWERING(I64x2LtU) { - RunI64x2BinOpTest(execution_tier, lower_simd, kExprI64x2LtU, UnsignedLess); +WASM_SIMD_TEST_NO_LOWERING(F64x2Le) { + RunF64x2CompareOpTest(execution_tier, lower_simd, kExprF64x2Le, LessEqual); } -WASM_SIMD_TEST_NO_LOWERING(I64x2LeU) { - RunI64x2BinOpTest(execution_tier, lower_simd, kExprI64x2LeU, - UnsignedLessEqual); +WASM_SIMD_TEST_NO_LOWERING(F64x2Min) { + RunF64x2BinOpTest(execution_tier, lower_simd, kExprF64x2Min, JSMin); } -WASM_SIMD_TEST_NO_LOWERING(I64x2GtU) { - RunI64x2BinOpTest(execution_tier, lower_simd, kExprI64x2GtU, UnsignedGreater); +WASM_SIMD_TEST_NO_LOWERING(F64x2Max) { + RunF64x2BinOpTest(execution_tier, lower_simd, kExprF64x2Max, JSMax); } -WASM_SIMD_TEST_NO_LOWERING(I64x2GeU) { - RunI64x2BinOpTest(execution_tier, lower_simd, kExprI64x2GeU, - UnsignedGreaterEqual); +#if V8_TARGET_ARCH_X64 +WASM_SIMD_TEST_NO_LOWERING(I64x2Mul) { + RunI64x2BinOpTest(execution_tier, lower_simd, kExprI64x2Mul, + base::MulWithWraparound); } -void RunI64x2ShiftOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, - WasmOpcode opcode, Int64ShiftOp expected_op) { - for (int shift = 1; shift < 64; shift++) { - WasmRunner<int32_t, int64_t> r(execution_tier, lower_simd); - int64_t* g = r.builder().AddGlobal<int64_t>(kWasmS128); - byte value = 0; - byte simd1 = r.AllocateLocal(kWasmS128); - BUILD(r, - WASM_SET_LOCAL(simd1, WASM_SIMD_I64x2_SPLAT(WASM_GET_LOCAL(value))), - WASM_SET_GLOBAL( - 0, WASM_SIMD_SHIFT_OP(opcode, shift, WASM_GET_LOCAL(simd1))), - WASM_ONE); - - FOR_INT64_INPUTS(x) { - r.Call(x); - int64_t expected = expected_op(x, shift); - for (int i = 0; i < 2; i++) { - CHECK_EQ(expected, ReadLittleEndianValue<int64_t>(&g[i])); - } - } - } +WASM_SIMD_TEST_NO_LOWERING(I64x2MinS) { + RunI64x2BinOpTest(execution_tier, lower_simd, kExprI64x2MinS, Minimum); } -WASM_SIMD_TEST_NO_LOWERING(I64x2Shl) { - RunI64x2ShiftOpTest(execution_tier, lower_simd, kExprI64x2Shl, - LogicalShiftLeft); +WASM_SIMD_TEST_NO_LOWERING(I64x2MaxS) { + RunI64x2BinOpTest(execution_tier, lower_simd, kExprI64x2MaxS, Maximum); } -WASM_SIMD_TEST_NO_LOWERING(I64x2ShrS) { - RunI64x2ShiftOpTest(execution_tier, lower_simd, kExprI64x2ShrS, - ArithmeticShiftRight); +WASM_SIMD_TEST_NO_LOWERING(I64x2MinU) { + RunI64x2BinOpTest(execution_tier, lower_simd, kExprI64x2MinU, + UnsignedMinimum); } -WASM_SIMD_TEST_NO_LOWERING(I64x2ShrU) { - RunI64x2ShiftOpTest(execution_tier, lower_simd, kExprI64x2ShrU, - LogicalShiftRight); +WASM_SIMD_TEST_NO_LOWERING(I64x2MaxU) { + RunI64x2BinOpTest(execution_tier, lower_simd, kExprI64x2MaxU, + UnsignedMaximum); } #endif // V8_TARGET_ARCH_X64 +#endif // V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64 WASM_SIMD_TEST(I32x4Splat) { WasmRunner<int32_t, int32_t> r(execution_tier, lower_simd); @@ -1534,16 +1656,17 @@ void RunI32x4ShiftOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, WasmRunner<int32_t, int32_t> r(execution_tier, lower_simd); int32_t* g = r.builder().AddGlobal<int32_t>(kWasmS128); byte value = 0; + byte shift_index = r.AllocateLocal(kWasmI32); byte simd1 = r.AllocateLocal(kWasmS128); - BUILD(r, + BUILD(r, WASM_SET_LOCAL(shift_index, WASM_I32V(shift)), WASM_SET_LOCAL(simd1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(value))), - WASM_SET_GLOBAL( - 0, WASM_SIMD_SHIFT_OP(opcode, shift, WASM_GET_LOCAL(simd1))), + WASM_SET_GLOBAL(0, WASM_SIMD_SHIFT_OP(opcode, WASM_GET_LOCAL(simd1), + WASM_GET_LOCAL(shift_index))), WASM_ONE); FOR_INT32_INPUTS(x) { r.Call(x); - float expected = expected_op(x, shift); + int32_t expected = expected_op(x, shift); for (int i = 0; i < 4; i++) { CHECK_EQ(expected, ReadLittleEndianValue<int32_t>(&g[i])); } @@ -1551,17 +1674,17 @@ void RunI32x4ShiftOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, } } -WASM_SIMD_TEST(I32x4Shl) { +WASM_SIMD_TEST_NO_LOWERING(I32x4Shl) { RunI32x4ShiftOpTest(execution_tier, lower_simd, kExprI32x4Shl, LogicalShiftLeft); } -WASM_SIMD_TEST(I32x4ShrS) { +WASM_SIMD_TEST_NO_LOWERING(I32x4ShrS) { RunI32x4ShiftOpTest(execution_tier, lower_simd, kExprI32x4ShrS, ArithmeticShiftRight); } -WASM_SIMD_TEST(I32x4ShrU) { +WASM_SIMD_TEST_NO_LOWERING(I32x4ShrU) { RunI32x4ShiftOpTest(execution_tier, lower_simd, kExprI32x4ShrU, LogicalShiftRight); } @@ -1784,10 +1907,12 @@ void RunI16x8ShiftOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, int16_t* g = r.builder().AddGlobal<int16_t>(kWasmS128); byte value = 0; byte simd1 = r.AllocateLocal(kWasmS128); + byte shift_index = r.AllocateLocal(kWasmI32); BUILD(r, WASM_SET_LOCAL(simd1, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(value))), - WASM_SET_GLOBAL( - 0, WASM_SIMD_SHIFT_OP(opcode, shift, WASM_GET_LOCAL(simd1))), + WASM_SET_LOCAL(shift_index, WASM_I32V(shift)), + WASM_SET_GLOBAL(0, WASM_SIMD_SHIFT_OP(opcode, WASM_GET_LOCAL(simd1), + WASM_GET_LOCAL(shift_index))), WASM_ONE); FOR_INT16_INPUTS(x) { @@ -1800,17 +1925,17 @@ void RunI16x8ShiftOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, } } -WASM_SIMD_TEST(I16x8Shl) { +WASM_SIMD_TEST_NO_LOWERING(I16x8Shl) { RunI16x8ShiftOpTest(execution_tier, lower_simd, kExprI16x8Shl, LogicalShiftLeft); } -WASM_SIMD_TEST(I16x8ShrS) { +WASM_SIMD_TEST_NO_LOWERING(I16x8ShrS) { RunI16x8ShiftOpTest(execution_tier, lower_simd, kExprI16x8ShrS, ArithmeticShiftRight); } -WASM_SIMD_TEST(I16x8ShrU) { +WASM_SIMD_TEST_NO_LOWERING(I16x8ShrU) { RunI16x8ShiftOpTest(execution_tier, lower_simd, kExprI16x8ShrU, LogicalShiftRight); } @@ -1998,15 +2123,17 @@ void RunI8x16ShiftOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, int8_t* g = r.builder().AddGlobal<int8_t>(kWasmS128); byte value = 0; byte simd1 = r.AllocateLocal(kWasmS128); + byte shift_index = r.AllocateLocal(kWasmI32); BUILD(r, WASM_SET_LOCAL(simd1, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(value))), - WASM_SET_GLOBAL( - 0, WASM_SIMD_SHIFT_OP(opcode, shift, WASM_GET_LOCAL(simd1))), + WASM_SET_LOCAL(shift_index, WASM_I32V(shift)), + WASM_SET_GLOBAL(0, WASM_SIMD_SHIFT_OP(opcode, WASM_GET_LOCAL(simd1), + WASM_GET_LOCAL(shift_index))), WASM_ONE); FOR_INT8_INPUTS(x) { r.Call(x); - float expected = expected_op(x, shift); + int8_t expected = expected_op(x, shift); for (int i = 0; i < 16; i++) { CHECK_EQ(expected, ReadLittleEndianValue<int8_t>(&g[i])); } @@ -2014,17 +2141,17 @@ void RunI8x16ShiftOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, } } -WASM_SIMD_TEST(I8x16Shl) { +WASM_SIMD_TEST_NO_LOWERING(I8x16Shl) { RunI8x16ShiftOpTest(execution_tier, lower_simd, kExprI8x16Shl, LogicalShiftLeft); } -WASM_SIMD_TEST(I8x16ShrS) { +WASM_SIMD_TEST_NO_LOWERING(I8x16ShrS) { RunI8x16ShiftOpTest(execution_tier, lower_simd, kExprI8x16ShrS, ArithmeticShiftRight); } -WASM_SIMD_TEST(I8x16ShrU) { +WASM_SIMD_TEST_NO_LOWERING(I8x16ShrU) { RunI8x16ShiftOpTest(execution_tier, lower_simd, kExprI8x16ShrU, LogicalShiftRight); } @@ -2432,13 +2559,14 @@ WASM_SIMD_COMPILED_TEST(S8x16MultiShuffleFuzz) { // 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) \ +#define WASM_SIMD_BOOL_REDUCTION_TEST(format, lanes, int_type) \ WASM_SIMD_TEST(ReductionTest##lanes) { \ WasmRunner<int32_t> r(execution_tier, lower_simd); \ + if (lanes == 2 && lower_simd == kLowerSimd) return; \ byte zero = r.AllocateLocal(kWasmS128); \ byte one_one = r.AllocateLocal(kWasmS128); \ byte reduced = r.AllocateLocal(kWasmI32); \ - BUILD(r, WASM_SET_LOCAL(zero, WASM_SIMD_I##format##_SPLAT(WASM_ZERO)), \ + BUILD(r, WASM_SET_LOCAL(zero, WASM_SIMD_I##format##_SPLAT(int_type(0))), \ WASM_SET_LOCAL( \ reduced, WASM_SIMD_UNOP(kExprS1x##lanes##AnyTrue, \ WASM_SIMD_BINOP(kExprI##format##Eq, \ @@ -2469,7 +2597,7 @@ WASM_SIMD_COMPILED_TEST(S8x16MultiShuffleFuzz) { WASM_RETURN1(WASM_ZERO)), \ WASM_SET_LOCAL(one_one, \ WASM_SIMD_I##format##_REPLACE_LANE( \ - lanes - 1, WASM_GET_LOCAL(zero), WASM_ONE)), \ + lanes - 1, WASM_GET_LOCAL(zero), int_type(1))), \ WASM_SET_LOCAL( \ reduced, WASM_SIMD_UNOP(kExprS1x##lanes##AnyTrue, \ WASM_SIMD_BINOP(kExprI##format##Eq, \ @@ -2502,9 +2630,12 @@ WASM_SIMD_COMPILED_TEST(S8x16MultiShuffleFuzz) { CHECK_EQ(1, r.Call()); \ } -WASM_SIMD_BOOL_REDUCTION_TEST(32x4, 4) -WASM_SIMD_BOOL_REDUCTION_TEST(16x8, 8) -WASM_SIMD_BOOL_REDUCTION_TEST(8x16, 16) +#if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64 +WASM_SIMD_BOOL_REDUCTION_TEST(64x2, 2, WASM_I64V) +#endif // V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64 +WASM_SIMD_BOOL_REDUCTION_TEST(32x4, 4, WASM_I32V) +WASM_SIMD_BOOL_REDUCTION_TEST(16x8, 8, WASM_I32V) +WASM_SIMD_BOOL_REDUCTION_TEST(8x16, 16, WASM_I32V) WASM_SIMD_TEST(SimdI32x4ExtractWithF32x4) { WasmRunner<int32_t> r(execution_tier, lower_simd); @@ -2758,7 +2889,7 @@ WASM_SIMD_TEST(SimdF32x4SetGlobal) { CHECK_EQ(GetScalar(global, 3), 65.0f); } -WASM_SIMD_COMPILED_TEST(SimdLoadStoreLoad) { +WASM_SIMD_TEST(SimdLoadStoreLoad) { WasmRunner<int32_t> r(execution_tier, lower_simd); int32_t* memory = r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t)); @@ -2776,11 +2907,10 @@ WASM_SIMD_COMPILED_TEST(SimdLoadStoreLoad) { #if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_ARM64 || \ V8_TARGET_ARCH_ARM -// V8:8665 - Tracking bug to enable reduction tests in the interpreter, -// and for SIMD lowering. #define WASM_SIMD_ANYTRUE_TEST(format, lanes, max, param_type) \ - WASM_SIMD_TEST_NO_LOWERING(S##format##AnyTrue) { \ + WASM_SIMD_TEST(S##format##AnyTrue) { \ WasmRunner<int32_t, param_type> r(execution_tier, lower_simd); \ + if (lanes == 2 && lower_simd == kLowerSimd) return; \ byte simd = r.AllocateLocal(kWasmS128); \ BUILD( \ r, \ @@ -2790,16 +2920,17 @@ WASM_SIMD_COMPILED_TEST(SimdLoadStoreLoad) { DCHECK_EQ(1, r.Call(5)); \ DCHECK_EQ(0, r.Call(0)); \ } -#if V8_TARGET_ARCH_X64 +#if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64 WASM_SIMD_ANYTRUE_TEST(64x2, 2, 0xffffffffffffffff, int64_t) -#endif // V8_TARGET_ARCH_X64 +#endif // V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64 WASM_SIMD_ANYTRUE_TEST(32x4, 4, 0xffffffff, int32_t) WASM_SIMD_ANYTRUE_TEST(16x8, 8, 0xffff, int32_t) WASM_SIMD_ANYTRUE_TEST(8x16, 16, 0xff, int32_t) #define WASM_SIMD_ALLTRUE_TEST(format, lanes, max, param_type) \ - WASM_SIMD_TEST_NO_LOWERING(S##format##AllTrue) { \ + WASM_SIMD_TEST(S##format##AllTrue) { \ WasmRunner<int32_t, param_type> r(execution_tier, lower_simd); \ + if (lanes == 2 && lower_simd == kLowerSimd) return; \ byte simd = r.AllocateLocal(kWasmS128); \ BUILD( \ r, \ @@ -2809,9 +2940,9 @@ WASM_SIMD_ANYTRUE_TEST(8x16, 16, 0xff, int32_t) DCHECK_EQ(1, r.Call(0x1)); \ DCHECK_EQ(0, r.Call(0)); \ } -#if V8_TARGET_ARCH_X64 +#if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64 WASM_SIMD_ALLTRUE_TEST(64x2, 2, 0xffffffffffffffff, int64_t) -#endif // V8_TARGET_ARCH_X64 +#endif // V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64 WASM_SIMD_ALLTRUE_TEST(32x4, 4, 0xffffffff, int32_t) WASM_SIMD_ALLTRUE_TEST(16x8, 8, 0xffff, int32_t) WASM_SIMD_ALLTRUE_TEST(8x16, 16, 0xff, int32_t) diff --git a/deps/v8/test/cctest/wasm/test-streaming-compilation.cc b/deps/v8/test/cctest/wasm/test-streaming-compilation.cc index 93ae92d697..795fa30e72 100644 --- a/deps/v8/test/cctest/wasm/test-streaming-compilation.cc +++ b/deps/v8/test/cctest/wasm/test-streaming-compilation.cc @@ -267,7 +267,7 @@ size_t GetFunctionOffset(i::Isolate* isolate, const uint8_t* buffer, kAllWasmFeatures, buffer, buffer + size, false, ModuleOrigin::kWasmOrigin, isolate->counters(), isolate->wasm_engine()->allocator()); CHECK(result.ok()); - const WasmFunction* func = &result.value()->functions[1]; + const WasmFunction* func = &result.value()->functions[index]; return func->code.offset(); } diff --git a/deps/v8/test/cctest/wasm/test-wasm-shared-engine.cc b/deps/v8/test/cctest/wasm/test-wasm-shared-engine.cc index 855e44aba2..b5bacf57d4 100644 --- a/deps/v8/test/cctest/wasm/test-wasm-shared-engine.cc +++ b/deps/v8/test/cctest/wasm/test-wasm-shared-engine.cc @@ -273,8 +273,8 @@ TEST(SharedEngineRunThreadedBuildingSync) { Handle<WasmInstanceObject> instance = isolate.CompileAndInstantiate(buffer); CHECK_EQ(42, isolate.Run(instance)); }); - thread1.Start(); - thread2.Start(); + CHECK(thread1.Start()); + CHECK(thread2.Start()); thread1.Join(); thread2.Join(); } @@ -295,8 +295,8 @@ TEST(SharedEngineRunThreadedBuildingAsync) { CompileAndInstantiateAsync(isolate, buffer); CHECK_EQ(42, isolate.Run(instance)); }); - thread1.Start(); - thread2.Start(); + CHECK(thread1.Start()); + CHECK(thread2.Start()); thread1.Join(); thread2.Join(); } @@ -321,8 +321,8 @@ TEST(SharedEngineRunThreadedExecution) { Handle<WasmInstanceObject> instance = isolate.ImportInstance(module); CHECK_EQ(23, isolate.Run(instance)); }); - thread1.Start(); - thread2.Start(); + CHECK(thread1.Start()); + CHECK(thread2.Start()); thread1.Join(); thread2.Join(); } @@ -358,7 +358,7 @@ TEST(SharedEngineRunThreadedTierUp) { &module->module()->functions[0], ExecutionTier::kTurbofan); CHECK_EQ(23, isolate.Run(instance)); }); - for (auto& thread : threads) thread.Start(); + for (auto& thread : threads) CHECK(thread.Start()); for (auto& thread : threads) thread.Join(); } diff --git a/deps/v8/test/cctest/wasm/wasm-run-utils.cc b/deps/v8/test/cctest/wasm/wasm-run-utils.cc index 6a17b81c56..528d71f53c 100644 --- a/deps/v8/test/cctest/wasm/wasm-run-utils.cc +++ b/deps/v8/test/cctest/wasm/wasm-run-utils.cc @@ -47,8 +47,8 @@ TestingModuleBuilder::TestingModuleBuilder( if (maybe_import) { // Manually compile an import wrapper and insert it into the instance. CodeSpaceMemoryModificationScope modification_scope(isolate_->heap()); - auto resolved = compiler::ResolveWasmImportCall(maybe_import->js_function, - maybe_import->sig, false); + auto resolved = compiler::ResolveWasmImportCall( + maybe_import->js_function, maybe_import->sig, enabled_features_); compiler::WasmImportCallKind kind = resolved.first; Handle<JSReceiver> callable = resolved.second; WasmImportWrapperCache::ModificationScope cache_scope( @@ -159,7 +159,7 @@ void TestingModuleBuilder::FreezeSignatureMapAndInitializeWrapperCache() { Handle<JSFunction> TestingModuleBuilder::WrapCode(uint32_t index) { FreezeSignatureMapAndInitializeWrapperCache(); SetExecutable(); - return WasmInstanceObject::GetOrCreateWasmExportedFunction( + return WasmInstanceObject::GetOrCreateWasmExternalFunction( isolate_, instance_object(), index); } @@ -324,9 +324,14 @@ Handle<WasmInstanceObject> TestingModuleBuilder::InitInstanceObject() { Handle<Script> script = isolate_->factory()->NewScript(isolate_->factory()->empty_string()); script->set_type(Script::TYPE_WASM); + + auto native_module = isolate_->wasm_engine()->NewNativeModule( + isolate_, enabled_features_, test_module_); + native_module->SetWireBytes(OwnedVector<const uint8_t>()); + native_module->SetRuntimeStubs(isolate_); + Handle<WasmModuleObject> module_object = - WasmModuleObject::New(isolate_, enabled_features_, test_module_, {}, - script, Handle<ByteArray>::null()); + WasmModuleObject::New(isolate_, std::move(native_module), script); // 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. @@ -360,7 +365,7 @@ void TestBuildingGraphWithBuilder(compiler::WasmGraphBuilder* builder, FATAL("Verification failed; pc = +%x, msg = %s", result.error().offset(), result.error().message().c_str()); } - builder->LowerInt64(); + builder->LowerInt64(compiler::WasmGraphBuilder::kCalledFromWasm); if (!CpuFeatures::SupportsWasmSimd128()) { builder->SimdScalarLoweringForTesting(); } @@ -453,8 +458,8 @@ Handle<Code> WasmFunctionWrapper::GetWrapperCode() { if (!code_.ToHandle(&code)) { Isolate* isolate = CcTest::InitIsolateOnce(); - auto call_descriptor = - compiler::Linkage::GetSimplifiedCDescriptor(zone(), signature_, true); + auto call_descriptor = compiler::Linkage::GetSimplifiedCDescriptor( + zone(), signature_, CallDescriptor::kInitializeRootRegister); if (kSystemPointerSize == 4) { size_t num_params = signature_->parameter_count(); |