diff options
Diffstat (limited to 'deps/v8/test/cctest')
124 files changed, 4191 insertions, 2915 deletions
diff --git a/deps/v8/test/cctest/BUILD.gn b/deps/v8/test/cctest/BUILD.gn index c4aa51b818..df37a3d4c5 100644 --- a/deps/v8/test/cctest/BUILD.gn +++ b/deps/v8/test/cctest/BUILD.gn @@ -214,6 +214,7 @@ v8_source_set("cctest_sources") { "test-roots.cc", "test-sampler-api.cc", "test-serialize.cc", + "test-smi-lexicographic-compare.cc", "test-strings.cc", "test-strtod.cc", "test-symbols.cc", @@ -237,6 +238,7 @@ v8_source_set("cctest_sources") { "trace-extension.cc", "trace-extension.h", "types-fuzz.h", + "unicode-helpers.cc", "unicode-helpers.h", "wasm/test-c-wasm-entry.cc", "wasm/test-jump-table-assembler.cc", @@ -285,6 +287,7 @@ v8_source_set("cctest_sources") { "test-code-stubs.h", "test-disasm-arm.cc", "test-macro-assembler-arm.cc", + "test-poison-disasm-arm.cc", "test-sync-primitives-arm.cc", ] } else if (v8_current_cpu == "arm64") { diff --git a/deps/v8/test/cctest/cctest.cc b/deps/v8/test/cctest/cctest.cc index 0919f39efe..1b1eeb5d41 100644 --- a/deps/v8/test/cctest/cctest.cc +++ b/deps/v8/test/cctest/cctest.cc @@ -123,16 +123,21 @@ void CcTest::CollectGarbage(i::AllocationSpace space) { heap()->CollectGarbage(space, i::GarbageCollectionReason::kTesting); } -void CcTest::CollectAllGarbage() { - CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask); +void CcTest::CollectAllGarbage(i::Isolate* isolate) { + i::Isolate* iso = isolate ? isolate : i_isolate(); + iso->heap()->CollectAllGarbage(i::Heap::kNoGCFlags, + i::GarbageCollectionReason::kTesting); } -void CcTest::CollectAllGarbage(int flags) { - heap()->CollectAllGarbage(flags, i::GarbageCollectionReason::kTesting); +void CcTest::CollectAllAvailableGarbage(i::Isolate* isolate) { + i::Isolate* iso = isolate ? isolate : i_isolate(); + iso->heap()->CollectAllAvailableGarbage(i::GarbageCollectionReason::kTesting); } -void CcTest::CollectAllAvailableGarbage() { - heap()->CollectAllAvailableGarbage(i::GarbageCollectionReason::kTesting); +void CcTest::PreciseCollectAllGarbage(i::Isolate* isolate) { + i::Isolate* iso = isolate ? isolate : i_isolate(); + iso->heap()->PreciseCollectAllGarbage(i::Heap::kNoGCFlags, + i::GarbageCollectionReason::kTesting); } v8::base::RandomNumberGenerator* CcTest::random_number_generator() { @@ -210,12 +215,12 @@ InitializedHandleScope::InitializedHandleScope() initialized_handle_scope_impl_( new InitializedHandleScopeImpl(main_isolate_)) {} -InitializedHandleScope::~InitializedHandleScope() {} +InitializedHandleScope::~InitializedHandleScope() = default; HandleAndZoneScope::HandleAndZoneScope() : main_zone_(new i::Zone(&allocator_, ZONE_NAME)) {} -HandleAndZoneScope::~HandleAndZoneScope() {} +HandleAndZoneScope::~HandleAndZoneScope() = default; static void PrintTestList(CcTest* current) { if (current == nullptr) return; diff --git a/deps/v8/test/cctest/cctest.h b/deps/v8/test/cctest/cctest.h index 383771710a..9d4af5af3f 100644 --- a/deps/v8/test/cctest/cctest.h +++ b/deps/v8/test/cctest/cctest.h @@ -37,6 +37,7 @@ #include "src/heap/factory.h" #include "src/isolate.h" #include "src/objects.h" +#include "src/register-configuration.h" #include "src/utils.h" #include "src/v8.h" #include "src/zone/accounting-allocator.h" @@ -50,6 +51,13 @@ class RandomNumberGenerator; namespace internal { +#if defined(V8_TARGET_ARCH_IA32) && defined(V8_EMBEDDED_BUILTINS) +// TODO(v8:6666): Fold into Default config once root is fully supported. +const auto GetRegConfig = RegisterConfiguration::PreserveRootIA32; +#else +const auto GetRegConfig = RegisterConfiguration::Default; +#endif + class HandleScope; class Zone; @@ -131,9 +139,9 @@ class CcTest { static i::Heap* heap(); static void CollectGarbage(i::AllocationSpace space); - static void CollectAllGarbage(); - static void CollectAllGarbage(int flags); - static void CollectAllAvailableGarbage(); + static void CollectAllGarbage(i::Isolate* isolate = nullptr); + static void CollectAllAvailableGarbage(i::Isolate* isolate = nullptr); + static void PreciseCollectAllGarbage(i::Isolate* isolate = nullptr); static v8::base::RandomNumberGenerator* random_number_generator(); @@ -193,7 +201,7 @@ class ApiTestFuzzer: public v8::base::Thread { void CallTest(); // The ApiTestFuzzer is also a Thread, so it has a Run method. - virtual void Run(); + void Run() override; enum PartOfTest { FIRST_PART, @@ -220,7 +228,7 @@ class ApiTestFuzzer: public v8::base::Thread { test_number_(num), gate_(0), active_(true) {} - ~ApiTestFuzzer() {} + ~ApiTestFuzzer() override = default; static bool fuzzing_; static int tests_being_run_; @@ -275,14 +283,15 @@ class RegisterThreadedTest { // A LocalContext holds a reference to a v8::Context. class LocalContext { public: - LocalContext(v8::Isolate* isolate, v8::ExtensionConfiguration* extensions = 0, + LocalContext(v8::Isolate* isolate, + v8::ExtensionConfiguration* extensions = nullptr, v8::Local<v8::ObjectTemplate> global_template = v8::Local<v8::ObjectTemplate>(), v8::Local<v8::Value> global_object = v8::Local<v8::Value>()) { Initialize(isolate, extensions, global_template, global_object); } - LocalContext(v8::ExtensionConfiguration* extensions = 0, + LocalContext(v8::ExtensionConfiguration* extensions = nullptr, v8::Local<v8::ObjectTemplate> global_template = v8::Local<v8::ObjectTemplate>(), v8::Local<v8::Value> global_object = v8::Local<v8::Value>()) { @@ -506,9 +515,7 @@ static inline void ExpectInt32(const char* code, int expected) { static inline void ExpectBoolean(const char* code, bool expected) { v8::Local<v8::Value> result = CompileRun(code); CHECK(result->IsBoolean()); - CHECK_EQ(expected, - result->BooleanValue(v8::Isolate::GetCurrent()->GetCurrentContext()) - .FromJust()); + CHECK_EQ(expected, result->BooleanValue(v8::Isolate::GetCurrent())); } @@ -597,11 +604,11 @@ class StaticOneByteResource : public v8::String::ExternalOneByteStringResource { public: explicit StaticOneByteResource(const char* data) : data_(data) {} - ~StaticOneByteResource() {} + ~StaticOneByteResource() override = default; - const char* data() const { return data_; } + const char* data() const override { return data_; } - size_t length() const { return strlen(data_); } + size_t length() const override { return strlen(data_); } private: const char* data_; @@ -677,13 +684,14 @@ class TestPlatform : public v8::Platform { } void CallOnForegroundThread(v8::Isolate* isolate, v8::Task* task) override { - old_platform_->CallOnForegroundThread(isolate, task); + // This is a deprecated function and should not be called anymore. + UNREACHABLE(); } void CallDelayedOnForegroundThread(v8::Isolate* isolate, v8::Task* task, double delay_in_seconds) override { - old_platform_->CallDelayedOnForegroundThread(isolate, task, - delay_in_seconds); + // This is a deprecated function and should not be called anymore. + UNREACHABLE(); } double MonotonicallyIncreasingTime() override { @@ -696,7 +704,8 @@ class TestPlatform : public v8::Platform { void CallIdleOnForegroundThread(v8::Isolate* isolate, v8::IdleTask* task) override { - old_platform_->CallIdleOnForegroundThread(isolate, task); + // This is a deprecated function and should not be called anymore. + UNREACHABLE(); } bool IdleTasksEnabled(v8::Isolate* isolate) override { @@ -709,7 +718,7 @@ class TestPlatform : public v8::Platform { protected: TestPlatform() : old_platform_(i::V8::GetCurrentPlatform()) {} - ~TestPlatform() { i::V8::SetPlatformForTesting(old_platform_); } + ~TestPlatform() override { i::V8::SetPlatformForTesting(old_platform_); } v8::Platform* old_platform() const { return old_platform_; } diff --git a/deps/v8/test/cctest/cctest.status b/deps/v8/test/cctest/cctest.status index c59c443b06..feaf2eb327 100644 --- a/deps/v8/test/cctest/cctest.status +++ b/deps/v8/test/cctest/cctest.status @@ -93,6 +93,9 @@ 'test-cpu-profiler/TracingCpuProfiler': [SKIP], 'test-sampler/LibSamplerCollectSample': [SKIP], + # BUG(v8:8209). Flaky + 'test-cpu-profiler/Issue1398': [SKIP], + # BUG(7702). Flaky data race and other test failures. 'test-cpu-profiler/MultipleProfilers': [SKIP], @@ -154,7 +157,7 @@ 'test-mark-compact/Promotion': [PASS, FAIL], # BUG(v8:3434). - ' test-api/LoadICFastApi_DirectCall_GCMoveStubWithProfiler': [SKIP], + 'test-api/LoadICFastApi_DirectCall_GCMoveStubWithProfiler': [SKIP], }], # 'arch == arm64' ['arch == arm64 and simulator_run', { @@ -256,6 +259,9 @@ # BUG(5920): Flaky crash. 'test-serialize/PartialSerializerContext': [PASS, ['arch == x64 and mode == debug', SKIP]], + + # BUG(v8:8220). Flaky + 'test-log/LogAll': [SKIP], }], # 'system == windows' ############################################################################## @@ -285,10 +291,13 @@ 'test-serialize/StartupSerializerTwice': [SKIP], 'test-serialize/StartupSerializerOnceRunScript': [SKIP], 'test-serialize/StartupSerializerTwiceRunScript': [SKIP], +}], # 'arch == arm' +############################################################################## +['arch == arm and not simulator_run', { # crbug.com/v8/7605 - 'test-heap/OutOfMemorySmallObjects': [PASS, ['not simulator_run', SKIP]], -}], # 'arch == arm' + 'test-heap/OutOfMemorySmallObjects': [SKIP], +}], # 'arch == arm and not simulator_run' ############################################################################## ['arch == mipsel or arch == mips', { @@ -314,12 +323,10 @@ }], # 'arch == mips' ############################################################################## -['arch == mips or arch == mips64', { - # TODO(mips-team): Implement LiftOff on big-endian - 'test-run-wasm/RunWasmLiftoff*': [SKIP], - 'test-run-wasm-64/RunWasmLiftoff*': [SKIP], -}], # 'arch == mips or arch == mips64' - +['arch == mips64', { + # TODO(mips-team): Currently fails on mips64 board. + 'test-run-wasm/RunWasmLiftoff_I32Binop*': [SKIP], +}], # 'arch == mips64' ############################################################################## ['arch == mips64el or arch == mips64', { # BUG(v8:3154). @@ -345,11 +352,10 @@ }], # '(arch == mipsel or arch == mips64el or arch == mips or arch == mips64) and not simd_mips' ############################################################################## -['arch == mipsel or arch == mips64el or arch == mips or arch == mips64 or arch == ppc or arch == ppc64 or arch == s390 or arch == s390x', { +['arch == mipsel or arch == mips64el or arch == mips or arch == mips64', { # TODO(mips-team): Implement I64Atomic operations on MIPS - # TODO(ppc-team, s390-team): Implement I64Atomic operations on PPC/s390 'test-run-wasm-atomics64/*': [SKIP], -}], # 'arch == mipsel or arch == mips64el or arch == mips or arch == mips64 or arch == ppc or arch == ppc64 or arch == s390 or arch == s390x' +}], # 'arch == mipsel or arch == mips64el or arch == mips or arch == mips64' ############################################################################## ['mips_arch_variant == r6', { @@ -372,6 +378,12 @@ }], # 'arch == android_arm or arch == android_ia32' ############################################################################## +['system == android', { + # Uses too much memory. + 'test-api/NewStringRangeError': [SKIP], +}], # 'system == android' + +############################################################################## ['system == aix and arch == ppc64', { # BUG 2857 diff --git a/deps/v8/test/cctest/compiler/call-tester.h b/deps/v8/test/cctest/compiler/call-tester.h index 8a0ea70a2a..4bf06a9ba3 100644 --- a/deps/v8/test/cctest/compiler/call-tester.h +++ b/deps/v8/test/cctest/compiler/call-tester.h @@ -21,7 +21,7 @@ class CallHelper { : csig_(csig), isolate_(isolate) { USE(isolate_); } - virtual ~CallHelper() {} + virtual ~CallHelper() = default; template <typename... Params> R Call(Params... args) { @@ -46,7 +46,7 @@ class CodeRunner : public CallHelper<T> { public: CodeRunner(Isolate* isolate, Handle<Code> code, MachineSignature* csig) : CallHelper<T>(isolate, csig), code_(code) {} - virtual ~CodeRunner() {} + ~CodeRunner() override = default; Address Generate() override { return code_->entry(); } diff --git a/deps/v8/test/cctest/compiler/codegen-tester.h b/deps/v8/test/cctest/compiler/codegen-tester.h index c58eb3b485..f9fbd4af3a 100644 --- a/deps/v8/test/cctest/compiler/codegen-tester.h +++ b/deps/v8/test/cctest/compiler/codegen-tester.h @@ -39,7 +39,25 @@ class RawMachineAssemblerTester : public HandleAndZoneScope, InstructionSelector::SupportedMachineOperatorFlags(), InstructionSelector::AlignmentRequirements()) {} - virtual ~RawMachineAssemblerTester() {} + template <typename... ParamMachTypes> + RawMachineAssemblerTester(Code::Kind kind, ParamMachTypes... p) + : HandleAndZoneScope(), + CallHelper<ReturnType>( + main_isolate(), + CSignature::New(main_zone(), MachineTypeForC<ReturnType>(), p...)), + RawMachineAssembler( + main_isolate(), new (main_zone()) Graph(main_zone()), + Linkage::GetSimplifiedCDescriptor( + main_zone(), + CSignature::New(main_zone(), MachineTypeForC<ReturnType>(), + p...), + true), + MachineType::PointerRepresentation(), + InstructionSelector::SupportedMachineOperatorFlags(), + InstructionSelector::AlignmentRequirements()), + kind_(kind) {} + + ~RawMachineAssemblerTester() override = default; void CheckNumber(double expected, Object* number) { CHECK(this->isolate()->factory()->NewNumber(expected)->SameValue(number)); @@ -59,13 +77,12 @@ class RawMachineAssemblerTester : public HandleAndZoneScope, } protected: - virtual Address Generate() { + Address Generate() override { if (code_.is_null()) { Schedule* schedule = this->Export(); auto call_descriptor = this->call_descriptor(); Graph* graph = this->graph(); - OptimizedCompilationInfo info(ArrayVector("testing"), main_zone(), - Code::STUB); + OptimizedCompilationInfo info(ArrayVector("testing"), main_zone(), kind_); code_ = Pipeline::GenerateCodeForTesting( &info, main_isolate(), call_descriptor, graph, AssemblerOptions::Default(main_isolate()), schedule); @@ -74,6 +91,7 @@ class RawMachineAssemblerTester : public HandleAndZoneScope, } private: + Code::Kind kind_ = Code::Kind::STUB; MaybeHandle<Code> code_; }; @@ -395,7 +413,7 @@ class BinopGen { public: virtual void gen(RawMachineAssemblerTester<int32_t>* m, Node* a, Node* b) = 0; virtual T expected(T a, T b) = 0; - virtual ~BinopGen() {} + virtual ~BinopGen() = default; }; // A helper class to generate various combination of input shape combinations diff --git a/deps/v8/test/cctest/compiler/graph-builder-tester.h b/deps/v8/test/cctest/compiler/graph-builder-tester.h index c16feae340..e0045979d4 100644 --- a/deps/v8/test/cctest/compiler/graph-builder-tester.h +++ b/deps/v8/test/cctest/compiler/graph-builder-tester.h @@ -62,7 +62,7 @@ class GraphBuilderTester : public HandleAndZoneScope, Begin(static_cast<int>(parameter_count())); InitParameters(); } - virtual ~GraphBuilderTester() {} + ~GraphBuilderTester() override = default; void GenerateCode() { Generate(); } Node* Parameter(size_t index) { diff --git a/deps/v8/test/cctest/compiler/test-branch-combine.cc b/deps/v8/test/cctest/compiler/test-branch-combine.cc index ab17ff0992..090a0f23cd 100644 --- a/deps/v8/test/cctest/compiler/test-branch-combine.cc +++ b/deps/v8/test/cctest/compiler/test-branch-combine.cc @@ -309,12 +309,12 @@ class CmpMaterializeBoolGen : public BinopGen<int32_t> { CmpMaterializeBoolGen(IrOpcode::Value opcode, bool i) : w(opcode), invert(i) {} - virtual void gen(RawMachineAssemblerTester<int32_t>* m, Node* a, Node* b) { + void gen(RawMachineAssemblerTester<int32_t>* m, Node* a, Node* b) override { Node* cond = w.MakeNode(m, a, b); if (invert) cond = m->Word32Equal(cond, m->Int32Constant(0)); m->Return(cond); } - virtual int32_t expected(int32_t a, int32_t b) { + int32_t expected(int32_t a, int32_t b) override { if (invert) return !w.Int32Compare(a, b) ? 1 : 0; return w.Int32Compare(a, b) ? 1 : 0; } @@ -333,7 +333,7 @@ class CmpBranchGen : public BinopGen<int32_t> { CmpBranchGen(IrOpcode::Value opcode, bool i, bool t, int32_t eq, int32_t ne) : w(opcode), invert(i), true_first(t), eq_constant(eq), ne_constant(ne) {} - virtual void gen(RawMachineAssemblerTester<int32_t>* m, Node* a, Node* b) { + void gen(RawMachineAssemblerTester<int32_t>* m, Node* a, Node* b) override { RawMachineLabel blocka, blockb; Node* cond = w.MakeNode(m, a, b); if (invert) cond = m->Word32Equal(cond, m->Int32Constant(0)); @@ -350,7 +350,7 @@ class CmpBranchGen : public BinopGen<int32_t> { m->Return(m->Int32Constant(eq_constant)); } } - virtual int32_t expected(int32_t a, int32_t b) { + int32_t expected(int32_t a, int32_t b) override { if (invert) return !w.Int32Compare(a, b) ? eq_constant : ne_constant; return w.Int32Compare(a, b) ? eq_constant : ne_constant; } diff --git a/deps/v8/test/cctest/compiler/test-code-assembler.cc b/deps/v8/test/cctest/compiler/test-code-assembler.cc index 91065cd546..a2243e6edd 100644 --- a/deps/v8/test/cctest/compiler/test-code-assembler.cc +++ b/deps/v8/test/cctest/compiler/test-code-assembler.cc @@ -30,7 +30,7 @@ Node* SmiTag(CodeAssembler& m, Node* value) { } Node* UndefinedConstant(CodeAssembler& m) { - return m.LoadRoot(Heap::kUndefinedValueRootIndex); + return m.LoadRoot(RootIndex::kUndefinedValue); } Node* SmiFromInt32(CodeAssembler& m, Node* value) { diff --git a/deps/v8/test/cctest/compiler/test-code-generator.cc b/deps/v8/test/cctest/compiler/test-code-generator.cc index a3b80bc887..8bf29dca69 100644 --- a/deps/v8/test/cctest/compiler/test-code-generator.cc +++ b/deps/v8/test/cctest/compiler/test-code-generator.cc @@ -50,7 +50,7 @@ Handle<Code> BuildTeardownFunction(Isolate* isolate, // arguments: // ~~~ // FixedArray setup(CodeObject* test, FixedArray state_in) { -// FixedArray state_out = AllocateFixedArray(state_in.length()); +// FixedArray state_out = AllocateZeroedFixedArray(state_in.length()); // // `test` will tail-call to its first parameter which will be `teardown`. // return test(teardown, state_out, state_in[0], state_in[1], // state_in[2], ...); @@ -83,8 +83,8 @@ Handle<Code> BuildSetupFunction(Isolate* isolate, // First allocate the FixedArray which will hold the final results. Here we // should take care of all allocations, meaning we allocate HeapNumbers and // FixedArrays representing Simd128 values. - TNode<FixedArray> state_out = __ Cast(__ AllocateFixedArray( - PACKED_ELEMENTS, __ IntPtrConstant(parameters.size()))); + TNode<FixedArray> state_out = + __ AllocateZeroedFixedArray(__ IntPtrConstant(parameters.size())); for (int i = 0; i < static_cast<int>(parameters.size()); i++) { switch (parameters[i].representation()) { case MachineRepresentation::kTagged: @@ -94,8 +94,8 @@ Handle<Code> BuildSetupFunction(Isolate* isolate, __ StoreFixedArrayElement(state_out, i, __ AllocateHeapNumber()); break; case MachineRepresentation::kSimd128: { - TNode<FixedArray> vector = __ Cast( - __ AllocateFixedArray(PACKED_SMI_ELEMENTS, __ IntPtrConstant(4))); + TNode<FixedArray> vector = + __ AllocateZeroedFixedArray(__ IntPtrConstant(4)); for (int lane = 0; lane < 4; lane++) { __ StoreFixedArrayElement(vector, lane, __ SmiConstant(0)); } @@ -361,7 +361,11 @@ class TestEnvironment : public HandleAndZoneScope { public: // These constants may be tuned to experiment with different environments. +#if defined(V8_TARGET_ARCH_IA32) && defined(V8_EMBEDDED_BUILTINS) + static constexpr int kGeneralRegisterCount = 3; +#else static constexpr int kGeneralRegisterCount = 4; +#endif static constexpr int kDoubleRegisterCount = 6; static constexpr int kTaggedSlotCount = 64; @@ -431,13 +435,10 @@ class TestEnvironment : public HandleAndZoneScope { // kReturnRegister0 as the first parameter, and the call will need a // register to hold the CodeObject address. So the maximum number of // registers left to test with is the number of available registers minus 2. - DCHECK_LE( - kGeneralRegisterCount, - RegisterConfiguration::Default()->num_allocatable_general_registers() - - 2); + DCHECK_LE(kGeneralRegisterCount, + GetRegConfig()->num_allocatable_general_registers() - 2); - int32_t general_mask = - RegisterConfiguration::Default()->allocatable_general_codes_mask(); + int32_t general_mask = GetRegConfig()->allocatable_general_codes_mask(); // kReturnRegister0 is used to hold the "teardown" code object, do not // generate moves using it. std::unique_ptr<const RegisterConfiguration> registers( @@ -639,18 +640,21 @@ class TestEnvironment : public HandleAndZoneScope { case MachineRepresentation::kTagged: state->set(i, Smi::FromInt(rng_->NextInt(Smi::kMaxValue))); break; - case MachineRepresentation::kFloat32: + case MachineRepresentation::kFloat32: { // HeapNumbers are Float64 values. However, we will convert it to a // Float32 and back inside `setup` and `teardown`. Make sure the value // we pick fits in a Float32. - state->set( - i, *main_isolate()->factory()->NewHeapNumber( - static_cast<double>(DoubleToFloat32(rng_->NextDouble())))); + Handle<HeapNumber> num = main_isolate()->factory()->NewHeapNumber( + static_cast<double>(DoubleToFloat32(rng_->NextDouble()))); + state->set(i, *num); break; - case MachineRepresentation::kFloat64: - state->set( - i, *main_isolate()->factory()->NewHeapNumber(rng_->NextDouble())); + } + case MachineRepresentation::kFloat64: { + Handle<HeapNumber> num = + main_isolate()->factory()->NewHeapNumber(rng_->NextDouble()); + state->set(i, *num); break; + } case MachineRepresentation::kSimd128: { Handle<FixedArray> vector = main_isolate()->factory()->NewFixedArray(4); @@ -968,7 +972,7 @@ class CodeGeneratorTester { linkage_(environment->test_descriptor()), frame_(environment->test_descriptor()->CalculateFixedFrameSize()) { // Pick half of the stack parameters at random and move them into spill - // slots, seperated by `extra_stack_space` bytes. + // slots, separated by `extra_stack_space` bytes. // When testing a move with stack slots using CheckAssembleMove or // CheckAssembleSwap, we'll transparently make use of local spill slots // instead of stack parameters for those that were picked. This allows us to @@ -1285,7 +1289,7 @@ TEST(FuzzAssembleMoveAndSwap) { } TEST(AssembleTailCallGap) { - const RegisterConfiguration* conf = RegisterConfiguration::Default(); + const RegisterConfiguration* conf = GetRegConfig(); TestEnvironment env; // This test assumes at least 4 registers are allocatable. diff --git a/deps/v8/test/cctest/compiler/test-js-typed-lowering.cc b/deps/v8/test/cctest/compiler/test-js-typed-lowering.cc index eec562cf36..559ed1088c 100644 --- a/deps/v8/test/cctest/compiler/test-js-typed-lowering.cc +++ b/deps/v8/test/cctest/compiler/test-js-typed-lowering.cc @@ -32,7 +32,7 @@ class JSTypedLoweringTester : public HandleAndZoneScope { simplified(main_zone()), common(main_zone()), graph(main_zone()), - typer(main_isolate(), &js_heap_broker, Typer::kNoFlags, &graph), + typer(&js_heap_broker, Typer::kNoFlags, &graph), context_node(nullptr) { graph.SetStart(graph.NewNode(common.Start(num_parameters))); graph.SetEnd(graph.NewNode(common.End(1), graph.start())); diff --git a/deps/v8/test/cctest/compiler/test-multiple-return.cc b/deps/v8/test/cctest/compiler/test-multiple-return.cc index b591d193e7..dccdbd9b92 100644 --- a/deps/v8/test/cctest/compiler/test-multiple-return.cc +++ b/deps/v8/test/cctest/compiler/test-multiple-return.cc @@ -190,11 +190,10 @@ void TestReturnMultipleValues(MachineType type) { std::unique_ptr<wasm::NativeModule> module = AllocateNativeModule( handles.main_isolate(), code->raw_instruction_size()); - byte* code_start = module->AddCodeCopy(code, wasm::WasmCode::kFunction, 0) - ->instructions() - .start(); + byte* code_start = + module->AddCodeForTesting(code)->instructions().start(); - RawMachineAssemblerTester<int32_t> mt; + RawMachineAssemblerTester<int32_t> mt(Code::Kind::JS_TO_WASM_FUNCTION); const int input_count = 2 + param_count; Node* call_inputs[2 + kMaxParamCount]; call_inputs[0] = mt.PointerConstant(code_start); @@ -280,9 +279,7 @@ void ReturnLastValue(MachineType type) { std::unique_ptr<wasm::NativeModule> module = AllocateNativeModule( handles.main_isolate(), code->raw_instruction_size()); - byte* code_start = module->AddCodeCopy(code, wasm::WasmCode::kFunction, 0) - ->instructions() - .start(); + byte* code_start = module->AddCodeForTesting(code)->instructions().start(); // Generate caller. int expect = return_count - 1; @@ -343,9 +340,7 @@ void ReturnSumOfReturns(MachineType type) { std::unique_ptr<wasm::NativeModule> module = AllocateNativeModule( handles.main_isolate(), code->raw_instruction_size()); - byte* code_start = module->AddCodeCopy(code, wasm::WasmCode::kFunction, 0) - ->instructions() - .start(); + byte* code_start = module->AddCodeForTesting(code)->instructions().start(); // Generate caller. RawMachineAssemblerTester<int32_t> mt; diff --git a/deps/v8/test/cctest/compiler/test-representation-change.cc b/deps/v8/test/cctest/compiler/test-representation-change.cc index 894338b3e2..c334ecb383 100644 --- a/deps/v8/test/cctest/compiler/test-representation-change.cc +++ b/deps/v8/test/cctest/compiler/test-representation-change.cc @@ -6,6 +6,7 @@ #include "src/compiler/node-matchers.h" #include "src/compiler/representation-change.h" +#include "src/compiler/type-cache.h" #include "src/objects-inl.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/codegen-tester.h" @@ -46,6 +47,12 @@ class RepresentationChangerTester : public HandleAndZoneScope, CHECK_EQ(expected, m.Value()); } + void CheckInt64Constant(Node* n, int64_t expected) { + Int64Matcher m(n); + CHECK(m.HasValue()); + CHECK_EQ(expected, m.Value()); + } + void CheckUint32Constant(Node* n, uint32_t expected) { Uint32Matcher m(n); CHECK(m.HasValue()); @@ -267,6 +274,18 @@ TEST(ToUint32_constant) { } } +TEST(ToInt64_constant) { + RepresentationChangerTester r; + FOR_INT32_INPUTS(i) { + Node* n = r.jsgraph()->Constant(*i); + Node* use = r.Return(n); + Node* c = r.changer()->GetRepresentationFor( + n, MachineRepresentation::kTagged, TypeCache::Get().kSafeInteger, use, + UseInfo(MachineRepresentation::kWord64, Truncation::None())); + r.CheckInt64Constant(c, *i); + } +} + static void CheckChange(IrOpcode::Value expected, MachineRepresentation from, Type from_type, UseInfo use_info) { RepresentationChangerTester r; @@ -291,7 +310,7 @@ static void CheckChange(IrOpcode::Value expected, MachineRepresentation from, static void CheckChange(IrOpcode::Value expected, MachineRepresentation from, Type from_type, MachineRepresentation to) { - CheckChange(expected, from, from_type, UseInfo(to, Truncation::None())); + CheckChange(expected, from, from_type, UseInfo(to, Truncation::Any())); } static void CheckTwoChanges(IrOpcode::Value expected2, @@ -328,6 +347,132 @@ static void CheckChange(IrOpcode::Value expected, MachineRepresentation from, CHECK_EQ(n, c->InputAt(0)); } +TEST(Word64) { + CheckChange(IrOpcode::kChangeInt32ToInt64, MachineRepresentation::kWord8, + TypeCache::Get().kInt8, MachineRepresentation::kWord64); + CheckChange(IrOpcode::kChangeUint32ToUint64, MachineRepresentation::kWord8, + TypeCache::Get().kUint8, MachineRepresentation::kWord64); + CheckChange(IrOpcode::kChangeInt32ToInt64, MachineRepresentation::kWord16, + TypeCache::Get().kInt16, MachineRepresentation::kWord64); + CheckChange(IrOpcode::kChangeUint32ToUint64, MachineRepresentation::kWord16, + TypeCache::Get().kUint16, MachineRepresentation::kWord64); + CheckChange(IrOpcode::kChangeInt32ToInt64, MachineRepresentation::kWord32, + Type::Signed32(), MachineRepresentation::kWord64); + CheckChange(IrOpcode::kChangeUint32ToUint64, MachineRepresentation::kWord32, + Type::Unsigned32(), MachineRepresentation::kWord64); + + CheckChange(IrOpcode::kTruncateInt64ToInt32, MachineRepresentation::kWord64, + Type::Signed32(), MachineRepresentation::kWord32); + CheckChange(IrOpcode::kTruncateInt64ToInt32, MachineRepresentation::kWord64, + Type::Unsigned32(), MachineRepresentation::kWord32); + CheckChange(IrOpcode::kTruncateInt64ToInt32, MachineRepresentation::kWord64, + TypeCache::Get().kSafeInteger, MachineRepresentation::kWord32, + UseInfo::TruncatingWord32()); + CheckChange( + IrOpcode::kCheckedInt64ToInt32, MachineRepresentation::kWord64, + TypeCache::Get().kSafeInteger, MachineRepresentation::kWord32, + UseInfo::CheckedSigned32AsWord32(kIdentifyZeros, VectorSlotPair())); + CheckChange( + IrOpcode::kCheckedUint64ToInt32, MachineRepresentation::kWord64, + TypeCache::Get().kPositiveSafeInteger, MachineRepresentation::kWord32, + UseInfo::CheckedSigned32AsWord32(kIdentifyZeros, VectorSlotPair())); + + CheckChange(IrOpcode::kChangeFloat64ToInt64, MachineRepresentation::kFloat64, + Type::Signed32(), MachineRepresentation::kWord64); + CheckChange(IrOpcode::kChangeFloat64ToInt64, MachineRepresentation::kFloat64, + Type::Unsigned32(), MachineRepresentation::kWord64); + CheckChange(IrOpcode::kChangeFloat64ToInt64, MachineRepresentation::kFloat64, + TypeCache::Get().kSafeInteger, MachineRepresentation::kWord64); + CheckChange(IrOpcode::kChangeFloat64ToInt64, MachineRepresentation::kFloat64, + TypeCache::Get().kInt64, MachineRepresentation::kWord64); + CheckChange(IrOpcode::kChangeFloat64ToUint64, MachineRepresentation::kFloat64, + TypeCache::Get().kUint64, MachineRepresentation::kWord64); + + CheckChange(IrOpcode::kChangeInt64ToFloat64, MachineRepresentation::kWord64, + Type::Signed32(), MachineRepresentation::kFloat64); + CheckChange(IrOpcode::kChangeInt64ToFloat64, MachineRepresentation::kWord64, + Type::Unsigned32(), MachineRepresentation::kFloat64); + CheckChange(IrOpcode::kChangeInt64ToFloat64, MachineRepresentation::kWord64, + TypeCache::Get().kSafeInteger, MachineRepresentation::kFloat64); + + CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64, + IrOpcode::kChangeFloat64ToInt64, + MachineRepresentation::kFloat32, Type::Signed32(), + MachineRepresentation::kWord64); + CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64, + IrOpcode::kChangeFloat64ToInt64, + MachineRepresentation::kFloat32, Type::Unsigned32(), + MachineRepresentation::kWord64); + CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64, + IrOpcode::kChangeFloat64ToInt64, + MachineRepresentation::kFloat32, TypeCache::Get().kInt64, + MachineRepresentation::kWord64); + CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64, + IrOpcode::kChangeFloat64ToUint64, + MachineRepresentation::kFloat32, TypeCache::Get().kUint64, + MachineRepresentation::kWord64); + + CheckTwoChanges(IrOpcode::kChangeInt64ToFloat64, + IrOpcode::kTruncateFloat64ToFloat32, + MachineRepresentation::kWord64, Type::Signed32(), + MachineRepresentation::kFloat32); + + CheckChange(IrOpcode::kChangeTaggedToInt64, MachineRepresentation::kTagged, + Type::Signed32(), MachineRepresentation::kWord64); + CheckChange(IrOpcode::kChangeTaggedToInt64, MachineRepresentation::kTagged, + Type::Unsigned32(), MachineRepresentation::kWord64); + CheckChange(IrOpcode::kChangeTaggedToInt64, MachineRepresentation::kTagged, + TypeCache::Get().kSafeInteger, MachineRepresentation::kWord64); + CheckChange(IrOpcode::kChangeTaggedToInt64, MachineRepresentation::kTagged, + TypeCache::Get().kInt64, MachineRepresentation::kWord64); + CheckChange(IrOpcode::kChangeTaggedSignedToInt64, + MachineRepresentation::kTaggedSigned, Type::SignedSmall(), + MachineRepresentation::kWord64); + + CheckTwoChanges(IrOpcode::kTruncateInt64ToInt32, + IrOpcode::kChangeInt31ToTaggedSigned, + MachineRepresentation::kWord64, Type::Signed31(), + MachineRepresentation::kTagged); + CheckTwoChanges(IrOpcode::kTruncateInt64ToInt32, + IrOpcode::kChangeInt32ToTagged, + MachineRepresentation::kWord64, Type::Signed32(), + MachineRepresentation::kTagged); + CheckTwoChanges(IrOpcode::kTruncateInt64ToInt32, + IrOpcode::kChangeUint32ToTagged, + MachineRepresentation::kWord64, Type::Unsigned32(), + MachineRepresentation::kTagged); + CheckChange(IrOpcode::kChangeInt64ToTagged, MachineRepresentation::kWord64, + TypeCache::Get().kSafeInteger, MachineRepresentation::kTagged); + CheckChange(IrOpcode::kChangeUint64ToTagged, MachineRepresentation::kWord64, + TypeCache::Get().kPositiveSafeInteger, + MachineRepresentation::kTagged); + + CheckTwoChanges(IrOpcode::kTruncateInt64ToInt32, + IrOpcode::kChangeInt31ToTaggedSigned, + MachineRepresentation::kWord64, Type::Signed31(), + MachineRepresentation::kTaggedSigned); + if (SmiValuesAre32Bits()) { + CheckTwoChanges(IrOpcode::kTruncateInt64ToInt32, + IrOpcode::kChangeInt32ToTagged, + MachineRepresentation::kWord64, Type::Signed32(), + MachineRepresentation::kTaggedSigned); + } + CheckChange(IrOpcode::kCheckedInt64ToTaggedSigned, + MachineRepresentation::kWord64, TypeCache::Get().kSafeInteger, + MachineRepresentation::kTaggedSigned, + UseInfo::CheckedSignedSmallAsTaggedSigned(VectorSlotPair())); + CheckChange(IrOpcode::kCheckedUint64ToTaggedSigned, + MachineRepresentation::kWord64, + TypeCache::Get().kPositiveSafeInteger, + MachineRepresentation::kTaggedSigned, + UseInfo::CheckedSignedSmallAsTaggedSigned(VectorSlotPair())); + + CheckTwoChanges(IrOpcode::kChangeInt64ToFloat64, + IrOpcode::kChangeFloat64ToTaggedPointer, + MachineRepresentation::kWord64, TypeCache::Get().kSafeInteger, + MachineRepresentation::kTaggedPointer); +} + TEST(SingleChanges) { CheckChange(IrOpcode::kChangeTaggedToBit, MachineRepresentation::kTagged, Type::Boolean(), MachineRepresentation::kBit); @@ -371,6 +516,10 @@ TEST(SingleChanges) { // Int32,Uint32 <-> Float64 are actually machine conversions. CheckChange(IrOpcode::kChangeInt32ToFloat64, MachineRepresentation::kWord32, Type::Signed32(), MachineRepresentation::kFloat64); + CheckChange(IrOpcode::kChangeInt32ToFloat64, MachineRepresentation::kWord32, + Type::Signed32OrMinusZero(), MachineRepresentation::kFloat64, + UseInfo(MachineRepresentation::kFloat64, + Truncation::Any(kIdentifyZeros))); CheckChange(IrOpcode::kChangeUint32ToFloat64, MachineRepresentation::kWord32, Type::Unsigned32(), MachineRepresentation::kFloat64); CheckChange(IrOpcode::kChangeFloat64ToInt32, MachineRepresentation::kFloat64, @@ -425,7 +574,8 @@ TEST(SignednessInWord32) { Type::Signed32(), MachineRepresentation::kWord32); CheckChange(IrOpcode::kTruncateFloat64ToWord32, MachineRepresentation::kFloat64, Type::Number(), - MachineRepresentation::kWord32); + MachineRepresentation::kWord32, + UseInfo(MachineRepresentation::kWord32, Truncation::Word32())); CheckChange(IrOpcode::kCheckedTruncateTaggedToWord32, MachineRepresentation::kTagged, Type::NonInternal(), MachineRepresentation::kWord32, @@ -523,16 +673,10 @@ TEST(TypeErrors) { MachineRepresentation::kWord64); r.CheckTypeError(MachineRepresentation::kTagged, Type::Boolean(), MachineRepresentation::kWord64); - - // Word64 / Word32 shouldn't be implicitly converted. r.CheckTypeError(MachineRepresentation::kWord64, Type::Internal(), MachineRepresentation::kWord32); r.CheckTypeError(MachineRepresentation::kWord32, Type::Number(), MachineRepresentation::kWord64); - r.CheckTypeError(MachineRepresentation::kWord32, Type::Signed32(), - MachineRepresentation::kWord64); - r.CheckTypeError(MachineRepresentation::kWord32, Type::Unsigned32(), - MachineRepresentation::kWord64); } } // namespace compiler diff --git a/deps/v8/test/cctest/compiler/test-run-bytecode-graph-builder.cc b/deps/v8/test/cctest/compiler/test-run-bytecode-graph-builder.cc index c62ed69105..681669f334 100644 --- a/deps/v8/test/cctest/compiler/test-run-bytecode-graph-builder.cc +++ b/deps/v8/test/cctest/compiler/test-run-bytecode-graph-builder.cc @@ -60,7 +60,7 @@ class BytecodeGraphCallable { public: BytecodeGraphCallable(Isolate* isolate, Handle<JSFunction> function) : isolate_(isolate), function_(function) {} - virtual ~BytecodeGraphCallable() {} + virtual ~BytecodeGraphCallable() = default; MaybeHandle<Object> operator()(A... args) { return CallFunction(isolate_, function_, args...); @@ -79,7 +79,7 @@ class BytecodeGraphTester { i::FLAG_always_opt = false; i::FLAG_allow_natives_syntax = true; } - virtual ~BytecodeGraphTester() {} + virtual ~BytecodeGraphTester() = default; template <class... A> BytecodeGraphCallable<A...> GetCallable( diff --git a/deps/v8/test/cctest/compiler/test-run-intrinsics.cc b/deps/v8/test/cctest/compiler/test-run-intrinsics.cc index efae91343f..82c4c447f2 100644 --- a/deps/v8/test/cctest/compiler/test-run-intrinsics.cc +++ b/deps/v8/test/cctest/compiler/test-run-intrinsics.cc @@ -20,21 +20,6 @@ TEST(Call) { T.CheckCall(T.Val("6x"), T.NewObject("({d:'x'})"), T.NewObject("f")); } - -TEST(ClassOf) { - FunctionTester T("(function(a) { return %_ClassOf(a); })", flags); - - T.CheckCall(T.Val("Function"), T.NewObject("(function() {})")); - T.CheckCall(T.Val("Array"), T.NewObject("([1])")); - T.CheckCall(T.Val("Object"), T.NewObject("({})")); - T.CheckCall(T.Val("RegExp"), T.NewObject("(/x/)")); - T.CheckCall(T.null(), T.undefined()); - T.CheckCall(T.null(), T.null()); - T.CheckCall(T.null(), T.Val("x")); - T.CheckCall(T.null(), T.Val(1)); -} - - TEST(IsArray) { FunctionTester T("(function(a) { return %_IsArray(a); })", flags); @@ -50,36 +35,6 @@ TEST(IsArray) { } -TEST(IsDate) { - FunctionTester T("(function(a) { return %_IsDate(a); })", flags); - - T.CheckTrue(T.NewObject("new Date()")); - T.CheckFalse(T.NewObject("(function() {})")); - T.CheckFalse(T.NewObject("([1])")); - T.CheckFalse(T.NewObject("({})")); - T.CheckFalse(T.NewObject("(/x/)")); - T.CheckFalse(T.undefined()); - T.CheckFalse(T.null()); - T.CheckFalse(T.Val("x")); - T.CheckFalse(T.Val(1)); -} - - -TEST(IsFunction) { - FunctionTester T("(function(a) { return %_IsFunction(a); })", flags); - - T.CheckFalse(T.NewObject("new Date()")); - T.CheckTrue(T.NewObject("(function() {})")); - T.CheckFalse(T.NewObject("([1])")); - T.CheckFalse(T.NewObject("({})")); - T.CheckFalse(T.NewObject("(/x/)")); - T.CheckFalse(T.undefined()); - T.CheckFalse(T.null()); - T.CheckFalse(T.Val("x")); - T.CheckFalse(T.Val(1)); -} - - TEST(IsSmi) { FunctionTester T("(function(a) { return %_IsSmi(a); })", flags); @@ -96,15 +51,6 @@ TEST(IsSmi) { T.CheckFalse(T.Val(-2.3)); } - -TEST(StringAdd) { - FunctionTester T("(function(a,b) { return %_StringAdd(a,b); })", flags); - - T.CheckCall(T.Val("aaabbb"), T.Val("aaa"), T.Val("bbb")); - T.CheckCall(T.Val("aaa"), T.Val("aaa"), T.Val("")); - T.CheckCall(T.Val("bbb"), T.Val(""), T.Val("bbb")); -} - } // namespace compiler } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-run-machops.cc b/deps/v8/test/cctest/compiler/test-run-machops.cc index 71adbc738d..419d1b0699 100644 --- a/deps/v8/test/cctest/compiler/test-run-machops.cc +++ b/deps/v8/test/cctest/compiler/test-run-machops.cc @@ -4174,7 +4174,6 @@ TEST(RunChangeFloat64ToInt32_B) { } } - TEST(RunChangeFloat64ToUint32) { BufferedRawMachineAssemblerTester<uint32_t> m(MachineType::Float64()); m.Return(m.ChangeFloat64ToUint32(m.Parameter(0))); @@ -6340,6 +6339,29 @@ TEST(RunCallCFunction9) { #if V8_TARGET_ARCH_64_BIT // TODO(titzer): run int64 tests on all platforms when supported. +TEST(RunChangeFloat64ToInt64) { + BufferedRawMachineAssemblerTester<int64_t> m(MachineType::Float64()); + m.Return(m.ChangeFloat64ToInt64(m.Parameter(0))); + + FOR_INT64_INPUTS(i) { + double input = static_cast<double>(*i); + if (static_cast<int64_t>(input) == *i) { + CHECK_EQ(static_cast<int64_t>(input), m.Call(input)); + } + } +} + +TEST(RunChangeInt64ToFloat64) { + BufferedRawMachineAssemblerTester<double> m(MachineType::Int64()); + m.Return(m.ChangeInt64ToFloat64(m.Parameter(0))); + FOR_INT64_INPUTS(i) { + double output = static_cast<double>(*i); + if (static_cast<int64_t>(output) == *i) { + CHECK_EQ(output, m.Call(*i)); + } + } +} + TEST(RunBitcastInt64ToFloat64) { int64_t input = 1; Float64 output; 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 b23bd500c6..2ddaa1bc07 100644 --- a/deps/v8/test/cctest/compiler/test-run-native-calls.cc +++ b/deps/v8/test/cctest/compiler/test-run-native-calls.cc @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <vector> + #include "src/assembler.h" #include "src/codegen.h" #include "src/compiler/linkage.h" @@ -9,6 +11,7 @@ #include "src/machine-type.h" #include "src/objects-inl.h" #include "src/register-configuration.h" +#include "src/wasm/wasm-linkage.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/codegen-tester.h" @@ -20,8 +23,6 @@ namespace internal { namespace compiler { namespace test_run_native_calls { -const auto GetRegConfig = RegisterConfiguration::Default; - namespace { typedef float float32; typedef double float64; @@ -84,21 +85,12 @@ class RegisterPairs : public Pairs { GetRegConfig()->allocatable_general_codes()) {} }; - -// Pairs of double registers. +// Pairs of float registers. class Float32RegisterPairs : public Pairs { public: Float32RegisterPairs() - : Pairs( - 100, -#if V8_TARGET_ARCH_ARM - // TODO(bbudge) Modify wasm linkage to allow use of all float regs. - GetRegConfig()->num_allocatable_double_registers() / 2 - 2, -#else - GetRegConfig()->num_allocatable_double_registers(), -#endif - GetRegConfig()->allocatable_double_codes()) { - } + : Pairs(100, GetRegConfig()->num_allocatable_float_registers(), + GetRegConfig()->allocatable_float_codes()) {} }; @@ -112,48 +104,39 @@ class Float64RegisterPairs : public Pairs { // Helper for allocating either an GP or FP reg, or the next stack slot. -struct Allocator { - Allocator(int* gp, int gpc, int* fp, int fpc) - : gp_count(gpc), - gp_offset(0), - gp_regs(gp), - fp_count(fpc), - fp_offset(0), - fp_regs(fp), - stack_offset(0) {} - - int gp_count; - int gp_offset; - int* gp_regs; - - int fp_count; - int fp_offset; - int* fp_regs; - - int stack_offset; +class Allocator { + public: + Allocator(int* gp, int gpc, int* fp, int fpc) : stack_offset_(0) { + for (int i = 0; i < gpc; ++i) { + gp_.push_back(Register::from_code(gp[i])); + } + for (int i = 0; i < fpc; ++i) { + fp_.push_back(DoubleRegister::from_code(fp[i])); + } + Reset(); + } + + int stack_offset() const { return stack_offset_; } LinkageLocation Next(MachineType type) { if (IsFloatingPoint(type.representation())) { // Allocate a floating point register/stack location. - if (fp_offset < fp_count) { - int code = fp_regs[fp_offset++]; -#if V8_TARGET_ARCH_ARM - // TODO(bbudge) Modify wasm linkage to allow use of all float regs. - if (type.representation() == MachineRepresentation::kFloat32) code *= 2; -#endif + if (reg_allocator_->CanAllocateFP(type.representation())) { + int code = reg_allocator_->NextFpReg(type.representation()); return LinkageLocation::ForRegister(code, type); } else { - int offset = -1 - stack_offset; - stack_offset += StackWords(type); + int offset = -1 - stack_offset_; + stack_offset_ += StackWords(type); return LinkageLocation::ForCallerFrameSlot(offset, type); } } else { // Allocate a general purpose register/stack location. - if (gp_offset < gp_count) { - return LinkageLocation::ForRegister(gp_regs[gp_offset++], type); + if (reg_allocator_->CanAllocateGP()) { + int code = reg_allocator_->NextGpReg(); + return LinkageLocation::ForRegister(code, type); } else { - int offset = -1 - stack_offset; - stack_offset += StackWords(type); + int offset = -1 - stack_offset_; + stack_offset_ += StackWords(type); return LinkageLocation::ForCallerFrameSlot(offset, type); } } @@ -163,10 +146,17 @@ struct Allocator { return size <= kPointerSize ? 1 : size / kPointerSize; } void Reset() { - fp_offset = 0; - gp_offset = 0; - stack_offset = 0; + stack_offset_ = 0; + reg_allocator_.reset( + new wasm::LinkageAllocator(gp_.data(), static_cast<int>(gp_.size()), + fp_.data(), static_cast<int>(fp_.size()))); } + + private: + std::vector<Register> gp_; + std::vector<DoubleRegister> fp_; + std::unique_ptr<wasm::LinkageAllocator> reg_allocator_; + int stack_offset_; }; @@ -197,7 +187,7 @@ class RegisterConfig { MachineType target_type = MachineType::AnyTagged(); LinkageLocation target_loc = LinkageLocation::ForAnyRegister(); - int stack_param_count = params.stack_offset; + int stack_param_count = params.stack_offset(); return new (zone) CallDescriptor( // -- CallDescriptor::kCallCodeObject, // kind target_type, // target MachineType @@ -868,7 +858,7 @@ TEST(Float32Select_registers) { return; } - int rarray[] = {GetRegConfig()->GetAllocatableDoubleCode(0)}; + int rarray[] = {GetRegConfig()->GetAllocatableFloatCode(0)}; ArgsBuffer<float32>::Sig sig(2); Float32RegisterPairs pairs; @@ -912,7 +902,7 @@ TEST(Float64Select_registers) { TEST(Float32Select_stack_params_return_reg) { - int rarray[] = {GetRegConfig()->GetAllocatableDoubleCode(0)}; + int rarray[] = {GetRegConfig()->GetAllocatableFloatCode(0)}; Allocator params(nullptr, 0, nullptr, 0); Allocator rets(nullptr, 0, rarray, 1); RegisterConfig config(params, rets); diff --git a/deps/v8/test/cctest/compiler/value-helper.h b/deps/v8/test/cctest/compiler/value-helper.h index e66c1ff454..8e652ec3b5 100644 --- a/deps/v8/test/cctest/compiler/value-helper.h +++ b/deps/v8/test/cctest/compiler/value-helper.h @@ -345,29 +345,37 @@ template <typename type> struct FloatCompareWrapper { type value; explicit FloatCompareWrapper(type x) : value(x) {} - bool operator==(type other) const { + bool operator==(FloatCompareWrapper<type> const& other) const { return std::isnan(value) - ? std::isnan(other) - : value == other && std::signbit(value) == std::signbit(other); + ? std::isnan(other.value) + : value == other.value && + std::signbit(value) == std::signbit(other.value); } }; template <typename type> std::ostream& operator<<(std::ostream& out, FloatCompareWrapper<type> wrapper) { - return out << wrapper.value; + uint8_t bytes[sizeof(type)]; + memcpy(bytes, &wrapper.value, sizeof(type)); + out << wrapper.value << " (0x"; + const char* kHexDigits = "0123456789ABCDEF"; + for (unsigned i = 0; i < sizeof(type); ++i) { + out << kHexDigits[bytes[i] >> 4] << kHexDigits[bytes[i] & 15]; + } + return out << ")"; } #define CHECK_FLOAT_EQ(lhs, rhs) \ do { \ using FloatWrapper = ::v8::internal::compiler::FloatCompareWrapper<float>; \ - CHECK_EQ(FloatWrapper(lhs), rhs); \ + CHECK_EQ(FloatWrapper(lhs), FloatWrapper(rhs)); \ } while (false) #define CHECK_DOUBLE_EQ(lhs, rhs) \ do { \ using DoubleWrapper = \ ::v8::internal::compiler::FloatCompareWrapper<double>; \ - CHECK_EQ(DoubleWrapper(lhs), rhs); \ + CHECK_EQ(DoubleWrapper(lhs), DoubleWrapper(rhs)); \ } while (false) } // namespace compiler diff --git a/deps/v8/test/cctest/heap/heap-utils.cc b/deps/v8/test/cctest/heap/heap-utils.cc index 5beed7f4cb..8f70847c9a 100644 --- a/deps/v8/test/cctest/heap/heap-utils.cc +++ b/deps/v8/test/cctest/heap/heap-utils.cc @@ -9,16 +9,15 @@ #include "src/heap/incremental-marking.h" #include "src/heap/mark-compact.h" #include "src/isolate.h" +#include "test/cctest/cctest.h" namespace v8 { namespace internal { namespace heap { void SealCurrentObjects(Heap* heap) { - heap->CollectAllGarbage(Heap::kFinalizeIncrementalMarkingMask, - GarbageCollectionReason::kTesting); - heap->CollectAllGarbage(Heap::kFinalizeIncrementalMarkingMask, - GarbageCollectionReason::kTesting); + CcTest::CollectAllGarbage(); + CcTest::CollectAllGarbage(); heap->mark_compact_collector()->EnsureSweepingCompleted(); heap->old_space()->FreeLinearAllocationArea(); for (Page* page : *heap->old_space()) { diff --git a/deps/v8/test/cctest/heap/test-alloc.cc b/deps/v8/test/cctest/heap/test-alloc.cc index 5a19f806bc..a669233b3a 100644 --- a/deps/v8/test/cctest/heap/test-alloc.cc +++ b/deps/v8/test/cctest/heap/test-alloc.cc @@ -168,84 +168,10 @@ TEST(StressJS) { .ToLocalChecked() ->Run(env) .ToLocalChecked(); - CHECK_EQ(true, result->BooleanValue(env).FromJust()); + CHECK_EQ(true, result->BooleanValue(CcTest::isolate())); env->Exit(); } - -// CodeRange test. -// Tests memory management in a CodeRange by allocating and freeing blocks, -// using a pseudorandom generator to choose block sizes geometrically -// distributed between 2 * Page::kPageSize and 2^5 + 1 * Page::kPageSize. -// Ensure that the freed chunks are collected and reused by allocating (in -// total) more than the size of the CodeRange. - -// This pseudorandom generator does not need to be particularly good. -// Use the lower half of the V8::Random() generator. -unsigned int Pseudorandom() { - static uint32_t lo = 2345; - lo = 18273 * (lo & 0xFFFF) + (lo >> 16); // Provably not 0. - return lo & 0xFFFF; -} - -namespace { - -// Plain old data class. Represents a block of allocated memory. -class Block { - public: - Block(Address base_arg, int size_arg) - : base(base_arg), size(size_arg) {} - - Address base; - int size; -}; - -} // namespace - -TEST(CodeRange) { - const size_t code_range_size = 32*MB; - CcTest::InitializeVM(); - CodeRange code_range(reinterpret_cast<Isolate*>(CcTest::isolate()), - code_range_size); - size_t current_allocated = 0; - size_t total_allocated = 0; - std::vector<Block> blocks; - blocks.reserve(1000); - - while (total_allocated < 5 * code_range_size) { - if (current_allocated < code_range_size / 10) { - // Allocate a block. - // Geometrically distributed sizes, greater than - // kMaxRegularHeapObjectSize (which is greater than code page area). - // TODO(gc): instead of using 3 use some contant based on code_range_size - // kMaxRegularHeapObjectSize. - size_t requested = (kMaxRegularHeapObjectSize << (Pseudorandom() % 3)) + - Pseudorandom() % 5000 + 1; - requested = RoundUp(requested, MemoryAllocator::GetCommitPageSize()); - size_t allocated = 0; - - // The request size has to be at least 2 code guard pages larger than the - // actual commit size. - Address base = code_range.AllocateRawMemory( - requested, requested - (2 * MemoryAllocator::CodePageGuardSize()), - &allocated); - CHECK_NE(base, kNullAddress); - blocks.emplace_back(base, static_cast<int>(allocated)); - current_allocated += static_cast<int>(allocated); - total_allocated += static_cast<int>(allocated); - } else { - // Free a block. - size_t index = Pseudorandom() % blocks.size(); - code_range.FreeRawMemory(blocks[index].base, blocks[index].size); - current_allocated -= blocks[index].size; - if (index < blocks.size() - 1) { - blocks[index] = blocks.back(); - } - blocks.pop_back(); - } - } -} - } // namespace heap } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/heap/test-array-buffer-tracker.cc b/deps/v8/test/cctest/heap/test-array-buffer-tracker.cc index cb35a73126..272c8831fd 100644 --- a/deps/v8/test/cctest/heap/test-array-buffer-tracker.cc +++ b/deps/v8/test/cctest/heap/test-array-buffer-tracker.cc @@ -323,10 +323,8 @@ UNINITIALIZED_TEST(ArrayBuffer_SemiSpaceCopyMultipleTasks) { Heap* heap = i_isolate->heap(); // Ensure heap is in a clean state. - heap->CollectAllGarbage(Heap::kFinalizeIncrementalMarkingMask, - GarbageCollectionReason::kTesting); - heap->CollectAllGarbage(Heap::kFinalizeIncrementalMarkingMask, - GarbageCollectionReason::kTesting); + CcTest::CollectAllGarbage(i_isolate); + CcTest::CollectAllGarbage(i_isolate); Local<v8::ArrayBuffer> ab1 = v8::ArrayBuffer::New(isolate, 100); Handle<JSArrayBuffer> buf1 = v8::Utils::OpenHandle(*ab1); diff --git a/deps/v8/test/cctest/heap/test-concurrent-marking.cc b/deps/v8/test/cctest/heap/test-concurrent-marking.cc index 0f10b1b9bd..d49ccf6213 100644 --- a/deps/v8/test/cctest/heap/test-concurrent-marking.cc +++ b/deps/v8/test/cctest/heap/test-concurrent-marking.cc @@ -39,9 +39,10 @@ TEST(ConcurrentMarking) { } ConcurrentMarking::MarkingWorklist shared, bailout, on_hold; + ConcurrentMarking::EmbedderTracingWorklist embedder_objects; WeakObjects weak_objects; - ConcurrentMarking* concurrent_marking = - new ConcurrentMarking(heap, &shared, &bailout, &on_hold, &weak_objects); + ConcurrentMarking* concurrent_marking = new ConcurrentMarking( + heap, &shared, &bailout, &on_hold, &weak_objects, &embedder_objects); PublishSegment(&shared, ReadOnlyRoots(heap).undefined_value()); concurrent_marking->ScheduleTasks(); concurrent_marking->Stop( @@ -61,9 +62,10 @@ TEST(ConcurrentMarkingReschedule) { } ConcurrentMarking::MarkingWorklist shared, bailout, on_hold; + ConcurrentMarking::EmbedderTracingWorklist embedder_objects; WeakObjects weak_objects; - ConcurrentMarking* concurrent_marking = - new ConcurrentMarking(heap, &shared, &bailout, &on_hold, &weak_objects); + ConcurrentMarking* concurrent_marking = new ConcurrentMarking( + heap, &shared, &bailout, &on_hold, &weak_objects, &embedder_objects); PublishSegment(&shared, ReadOnlyRoots(heap).undefined_value()); concurrent_marking->ScheduleTasks(); concurrent_marking->Stop( @@ -87,9 +89,10 @@ TEST(ConcurrentMarkingPreemptAndReschedule) { } ConcurrentMarking::MarkingWorklist shared, bailout, on_hold; + ConcurrentMarking::EmbedderTracingWorklist embedder_objects; WeakObjects weak_objects; - ConcurrentMarking* concurrent_marking = - new ConcurrentMarking(heap, &shared, &bailout, &on_hold, &weak_objects); + ConcurrentMarking* concurrent_marking = new ConcurrentMarking( + heap, &shared, &bailout, &on_hold, &weak_objects, &embedder_objects); for (int i = 0; i < 5000; i++) PublishSegment(&shared, ReadOnlyRoots(heap).undefined_value()); concurrent_marking->ScheduleTasks(); diff --git a/deps/v8/test/cctest/heap/test-external-string-tracker.cc b/deps/v8/test/cctest/heap/test-external-string-tracker.cc index 501825a296..cfade38da7 100644 --- a/deps/v8/test/cctest/heap/test-external-string-tracker.cc +++ b/deps/v8/test/cctest/heap/test-external-string-tracker.cc @@ -27,14 +27,14 @@ class TestOneByteResource : public v8::String::ExternalOneByteStringResource { length_(strlen(data) - offset), counter_(counter) {} - ~TestOneByteResource() { + ~TestOneByteResource() override { i::DeleteArray(orig_data_); if (counter_ != nullptr) ++*counter_; } - const char* data() const { return data_; } + const char* data() const override { return data_; } - size_t length() const { return length_; } + size_t length() const override { return length_; } private: const char* orig_data_; diff --git a/deps/v8/test/cctest/heap/test-heap.cc b/deps/v8/test/cctest/heap/test-heap.cc index f73f6f0195..8c6a3c446c 100644 --- a/deps/v8/test/cctest/heap/test-heap.cc +++ b/deps/v8/test/cctest/heap/test-heap.cc @@ -898,14 +898,14 @@ static const char* not_so_random_string_table[] = { "volatile", "while", "with", - 0 + nullptr }; - static void CheckInternalizedStrings(const char** strings) { Isolate* isolate = CcTest::i_isolate(); Factory* factory = isolate->factory(); - for (const char* string = *strings; *strings != 0; string = *strings++) { + for (const char* string = *strings; *strings != nullptr; + string = *strings++) { HandleScope scope(isolate); Handle<String> a = isolate->factory()->InternalizeUtf8String(CStrVector(string)); @@ -2192,9 +2192,9 @@ HEAP_TEST(GCFlags) { heap->set_current_gc_flags(Heap::kNoGCFlags); CHECK_EQ(Heap::kNoGCFlags, heap->current_gc_flags_); - // Set the flags to check whether we appropriately resets them after the GC. - heap->set_current_gc_flags(Heap::kAbortIncrementalMarkingMask); - CcTest::CollectAllGarbage(Heap::kReduceMemoryFootprintMask); + // Check whether we appropriately reset flags after GC. + CcTest::heap()->CollectAllGarbage(Heap::kReduceMemoryFootprintMask, + GarbageCollectionReason::kTesting); CHECK_EQ(Heap::kNoGCFlags, heap->current_gc_flags_); MarkCompactCollector* collector = heap->mark_compact_collector(); @@ -2212,7 +2212,7 @@ HEAP_TEST(GCFlags) { // NewSpace scavenges should not overwrite the flags. CHECK_NE(0, heap->current_gc_flags_ & Heap::kReduceMemoryFootprintMask); - CcTest::CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); + CcTest::CollectAllGarbage(); CHECK_EQ(Heap::kNoGCFlags, heap->current_gc_flags_); } @@ -3097,14 +3097,14 @@ TEST(IncrementalMarkingPreservesMonomorphicCallIC) { CHECK_EQ(expected_slots, feedback_helper.slot_count()); int slot1 = 0; int slot2 = 1; - CHECK(feedback_vector->Get(feedback_helper.slot(slot1))->IsWeakHeapObject()); - CHECK(feedback_vector->Get(feedback_helper.slot(slot2))->IsWeakHeapObject()); + CHECK(feedback_vector->Get(feedback_helper.slot(slot1))->IsWeak()); + CHECK(feedback_vector->Get(feedback_helper.slot(slot2))->IsWeak()); heap::SimulateIncrementalMarking(CcTest::heap()); CcTest::CollectAllGarbage(); - feedback_vector->Get(feedback_helper.slot(slot1))->IsWeakHeapObject(); - feedback_vector->Get(feedback_helper.slot(slot2))->IsWeakHeapObject(); + CHECK(feedback_vector->Get(feedback_helper.slot(slot1))->IsWeak()); + CHECK(feedback_vector->Get(feedback_helper.slot(slot2))->IsWeak()); } @@ -3134,12 +3134,12 @@ TEST(IncrementalMarkingPreservesMonomorphicConstructor) { CcTest::global()->Get(ctx, v8_str("f")).ToLocalChecked()))); Handle<FeedbackVector> vector(f->feedback_vector(), f->GetIsolate()); - CHECK(vector->Get(FeedbackSlot(0))->IsWeakOrClearedHeapObject()); + CHECK(vector->Get(FeedbackSlot(0))->IsWeakOrCleared()); heap::SimulateIncrementalMarking(CcTest::heap()); CcTest::CollectAllGarbage(); - CHECK(vector->Get(FeedbackSlot(0))->IsWeakOrClearedHeapObject()); + CHECK(vector->Get(FeedbackSlot(0))->IsWeakOrCleared()); } TEST(IncrementalMarkingPreservesMonomorphicIC) { @@ -3247,14 +3247,14 @@ class SourceResource : public v8::String::ExternalOneByteStringResource { explicit SourceResource(const char* data) : data_(data), length_(strlen(data)) { } - virtual void Dispose() { + void Dispose() override { i::DeleteArray(data_); data_ = nullptr; } - const char* data() const { return data_; } + const char* data() const override { return data_; } - size_t length() const { return length_; } + size_t length() const override { return length_; } bool IsDisposed() { return data_ == nullptr; } @@ -3636,9 +3636,9 @@ TEST(EnsureAllocationSiteDependentCodesProcessed) { dependency->group() == DependentCode::kAllocationSiteTenuringChangedGroup); CHECK_EQ(1, dependency->count()); - CHECK(dependency->object_at(0)->IsWeakHeapObject()); + CHECK(dependency->object_at(0)->IsWeak()); Code* function_bar = - Code::cast(dependency->object_at(0)->ToWeakHeapObject()); + Code::cast(dependency->object_at(0)->GetHeapObjectAssumeWeak()); CHECK_EQ(bar_handle->code(), function_bar); dependency = dependency->next_link(); dependency_group_count++; @@ -3655,7 +3655,7 @@ TEST(EnsureAllocationSiteDependentCodesProcessed) { // The site still exists because of our global handle, but the code is no // longer referred to by dependent_code(). - CHECK(site->dependent_code()->object_at(0)->IsClearedWeakHeapObject()); + CHECK(site->dependent_code()->object_at(0)->IsCleared()); } void CheckNumberOfAllocations(Heap* heap, const char* source, @@ -4133,18 +4133,18 @@ TEST(WeakFunctionInConstructor) { Handle<FeedbackVector>(createObj->feedback_vector(), CcTest::i_isolate()); for (int i = 0; i < 20; i++) { MaybeObject* slot_value = feedback_vector->Get(FeedbackSlot(0)); - CHECK(slot_value->IsWeakOrClearedHeapObject()); - if (slot_value->IsClearedWeakHeapObject()) break; + CHECK(slot_value->IsWeakOrCleared()); + if (slot_value->IsCleared()) break; CcTest::CollectAllGarbage(); } MaybeObject* slot_value = feedback_vector->Get(FeedbackSlot(0)); - CHECK(slot_value->IsClearedWeakHeapObject()); + CHECK(slot_value->IsCleared()); CompileRun( "function coat() { this.x = 6; }" "createObj(coat);"); slot_value = feedback_vector->Get(FeedbackSlot(0)); - CHECK(slot_value->IsWeakHeapObject()); + CHECK(slot_value->IsWeak()); } @@ -4511,8 +4511,7 @@ HEAP_TEST(Regress538257) { heap::ForceEvacuationCandidate(Page::FromAddress(objects[i]->address())); } heap::SimulateFullSpace(old_space); - heap->CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask, - i::GarbageCollectionReason::kTesting); + CcTest::CollectAllGarbage(); // If we get this far, we've successfully aborted compaction. Any further // allocations might trigger OOM. } @@ -4704,7 +4703,7 @@ TEST(Regress3877) { v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(result)); weak_prototype_holder->Set(0, HeapObjectReference::Weak(*proto)); } - CHECK(!weak_prototype_holder->Get(0)->IsClearedWeakHeapObject()); + CHECK(!weak_prototype_holder->Get(0)->IsCleared()); CompileRun( "var a = { };" "a.x = new cls();" @@ -4713,13 +4712,13 @@ TEST(Regress3877) { CcTest::CollectAllGarbage(); } // The map of a.x keeps prototype alive - CHECK(!weak_prototype_holder->Get(0)->IsClearedWeakHeapObject()); + CHECK(!weak_prototype_holder->Get(0)->IsCleared()); // Change the map of a.x and make the previous map garbage collectable. CompileRun("a.x.__proto__ = {};"); for (int i = 0; i < 4; i++) { CcTest::CollectAllGarbage(); } - CHECK(weak_prototype_holder->Get(0)->IsClearedWeakHeapObject()); + CHECK(weak_prototype_holder->Get(0)->IsCleared()); } Handle<WeakFixedArray> AddRetainedMap(Isolate* isolate, Heap* heap) { @@ -4742,15 +4741,15 @@ void CheckMapRetainingFor(int n) { Isolate* isolate = CcTest::i_isolate(); Heap* heap = isolate->heap(); Handle<WeakFixedArray> array_with_map = AddRetainedMap(isolate, heap); - CHECK(array_with_map->Get(0)->IsWeakHeapObject()); + CHECK(array_with_map->Get(0)->IsWeak()); for (int i = 0; i < n; i++) { heap::SimulateIncrementalMarking(heap); CcTest::CollectGarbage(OLD_SPACE); } - CHECK(array_with_map->Get(0)->IsWeakHeapObject()); + CHECK(array_with_map->Get(0)->IsWeak()); heap::SimulateIncrementalMarking(heap); CcTest::CollectGarbage(OLD_SPACE); - CHECK(array_with_map->Get(0)->IsClearedWeakHeapObject()); + CHECK(array_with_map->Get(0)->IsCleared()); } @@ -4766,8 +4765,8 @@ TEST(MapRetaining) { } TEST(WritableVsImmortalRoots) { - for (int i = 0; i < Heap::kStrongRootListLength; ++i) { - Heap::RootListIndex root_index = static_cast<Heap::RootListIndex>(i); + for (RootIndex root_index = RootIndex::kFirstRoot; + root_index <= RootIndex::kLastRoot; ++root_index) { bool writable = Heap::RootCanBeWrittenAfterInitialization(root_index); bool immortal = Heap::RootIsImmortalImmovable(root_index); // A root value can be writable, immortal, or neither, but not both. @@ -5427,11 +5426,11 @@ class StaticOneByteResource : public v8::String::ExternalOneByteStringResource { public: explicit StaticOneByteResource(const char* data) : data_(data) {} - ~StaticOneByteResource() {} + ~StaticOneByteResource() override = default; - const char* data() const { return data_; } + const char* data() const override { return data_; } - size_t length() const { return strlen(data_); } + size_t length() const override { return strlen(data_); } private: const char* data_; @@ -5676,6 +5675,7 @@ TEST(Regress618958) { } TEST(YoungGenerationLargeObjectAllocation) { + if (FLAG_minor_mc) return; FLAG_young_generation_large_objects = true; CcTest::InitializeVM(); v8::HandleScope scope(CcTest::isolate()); @@ -5684,13 +5684,26 @@ TEST(YoungGenerationLargeObjectAllocation) { Handle<FixedArray> array = isolate->factory()->NewFixedArray(200000); MemoryChunk* chunk = MemoryChunk::FromAddress(array->address()); - CHECK(chunk->owner()->identity() == LO_SPACE); + CHECK_EQ(LO_SPACE, chunk->owner()->identity()); CHECK(!chunk->IsFlagSet(MemoryChunk::IN_TO_SPACE)); Handle<FixedArray> array_small = isolate->factory()->NewFixedArray(20000); chunk = MemoryChunk::FromAddress(array_small->address()); - CHECK(chunk->owner()->identity() == NEW_LO_SPACE); + CHECK_EQ(NEW_LO_SPACE, chunk->owner()->identity()); CHECK(chunk->IsFlagSet(MemoryChunk::IN_TO_SPACE)); + + Handle<Object> number = isolate->factory()->NewHeapNumber(123.456); + array_small->set(0, *number); + + CcTest::CollectGarbage(NEW_SPACE); + + // After the first young generation GC array_small will be in the old + // generation large object space. + chunk = MemoryChunk::FromAddress(array_small->address()); + CHECK_EQ(LO_SPACE, chunk->owner()->identity()); + CHECK(!chunk->IsFlagSet(MemoryChunk::IN_TO_SPACE)); + + CcTest::CollectAllAvailableGarbage(); } TEST(UncommitUnusedLargeObjectMemory) { diff --git a/deps/v8/test/cctest/heap/test-incremental-marking.cc b/deps/v8/test/cctest/heap/test-incremental-marking.cc index bbf630f0ba..8213ea6080 100644 --- a/deps/v8/test/cctest/heap/test-incremental-marking.cc +++ b/deps/v8/test/cctest/heap/test-incremental-marking.cc @@ -33,12 +33,13 @@ namespace heap { class MockPlatform : public TestPlatform { public: - MockPlatform() : task_(nullptr), old_platform_(i::V8::GetCurrentPlatform()) { + MockPlatform() + : taskrunner_(new MockTaskRunner()), + old_platform_(i::V8::GetCurrentPlatform()) { // Now that it's completely constructed, make this the current platform. i::V8::SetPlatformForTesting(this); } - virtual ~MockPlatform() { - delete task_; + ~MockPlatform() override { i::V8::SetPlatformForTesting(old_platform_); for (auto& task : worker_tasks_) { old_platform_->CallOnWorkerThread(std::move(task)); @@ -46,8 +47,9 @@ class MockPlatform : public TestPlatform { worker_tasks_.clear(); } - void CallOnForegroundThread(v8::Isolate* isolate, Task* task) override { - task_ = task; + std::shared_ptr<v8::TaskRunner> GetForegroundTaskRunner( + v8::Isolate* isolate) override { + return taskrunner_; } void CallOnWorkerThread(std::unique_ptr<Task> task) override { @@ -56,17 +58,40 @@ class MockPlatform : public TestPlatform { bool IdleTasksEnabled(v8::Isolate* isolate) override { return false; } - bool PendingTask() { return task_ != nullptr; } + bool PendingTask() { return taskrunner_->PendingTask(); } - void PerformTask() { - Task* task = task_; - task_ = nullptr; - task->Run(); - delete task; - } + void PerformTask() { taskrunner_->PerformTask(); } private: - Task* task_; + class MockTaskRunner : public v8::TaskRunner { + public: + void PostTask(std::unique_ptr<v8::Task> task) override { + task_ = std::move(task); + } + + void PostDelayedTask(std::unique_ptr<Task> task, + double delay_in_seconds) override { + UNREACHABLE(); + }; + + void PostIdleTask(std::unique_ptr<IdleTask> task) override { + UNREACHABLE(); + } + + bool IdleTasksEnabled() override { return false; }; + + bool PendingTask() { return task_ != nullptr; } + + void PerformTask() { + std::unique_ptr<Task> task = std::move(task_); + task->Run(); + } + + private: + std::unique_ptr<Task> task_; + }; + + std::shared_ptr<MockTaskRunner> taskrunner_; std::vector<std::unique_ptr<Task>> worker_tasks_; v8::Platform* old_platform_; }; diff --git a/deps/v8/test/cctest/heap/test-lab.cc b/deps/v8/test/cctest/heap/test-lab.cc index 42a3eec04c..ae0bfd969a 100644 --- a/deps/v8/test/cctest/heap/test-lab.cc +++ b/deps/v8/test/cctest/heap/test-lab.cc @@ -63,7 +63,7 @@ TEST(InvalidLab) { TEST(UnusedLabImplicitClose) { CcTest::InitializeVM(); Heap* heap = CcTest::heap(); - heap->root(Heap::kOnePointerFillerMapRootIndex); + heap->root(RootIndex::kOnePointerFillerMap); const int kLabSize = 4 * KB; Address base = AllocateLabBackingStore(heap, kLabSize); Address limit = base + kLabSize; diff --git a/deps/v8/test/cctest/heap/test-spaces.cc b/deps/v8/test/cctest/heap/test-spaces.cc index b930361eb9..e03d8229b3 100644 --- a/deps/v8/test/cctest/heap/test-spaces.cc +++ b/deps/v8/test/cctest/heap/test-spaces.cc @@ -27,6 +27,7 @@ #include <stdlib.h> +#include "src/base/bounded-page-allocator.h" #include "src/base/platform/platform.h" #include "src/heap/factory.h" #include "src/heap/spaces-inl.h" @@ -59,36 +60,43 @@ class TestMemoryAllocatorScope { DISALLOW_COPY_AND_ASSIGN(TestMemoryAllocatorScope); }; - -// Temporarily sets a given code range in an isolate. -class TestCodeRangeScope { +// Temporarily sets a given code page allocator in an isolate. +class TestCodePageAllocatorScope { public: - TestCodeRangeScope(Isolate* isolate, CodeRange* code_range) + TestCodePageAllocatorScope(Isolate* isolate, + v8::PageAllocator* code_page_allocator) : isolate_(isolate), - old_code_range_(isolate->heap()->memory_allocator()->code_range()) { - isolate->heap()->memory_allocator()->code_range_ = code_range; + old_code_page_allocator_( + isolate->heap()->memory_allocator()->code_page_allocator()) { + isolate->heap()->memory_allocator()->code_page_allocator_ = + code_page_allocator; } - ~TestCodeRangeScope() { - isolate_->heap()->memory_allocator()->code_range_ = old_code_range_; + ~TestCodePageAllocatorScope() { + isolate_->heap()->memory_allocator()->code_page_allocator_ = + old_code_page_allocator_; } private: Isolate* isolate_; - CodeRange* old_code_range_; + v8::PageAllocator* old_code_page_allocator_; - DISALLOW_COPY_AND_ASSIGN(TestCodeRangeScope); + DISALLOW_COPY_AND_ASSIGN(TestCodePageAllocatorScope); }; static void VerifyMemoryChunk(Isolate* isolate, Heap* heap, - CodeRange* code_range, size_t reserve_area_size, - size_t commit_area_size, Executability executable, - Space* space) { + v8::PageAllocator* code_page_allocator, + size_t reserve_area_size, size_t commit_area_size, + Executability executable, Space* space) { MemoryAllocator* memory_allocator = new MemoryAllocator(isolate, heap->MaxReserved(), 0); { TestMemoryAllocatorScope test_allocator_scope(isolate, memory_allocator); - TestCodeRangeScope test_code_range_scope(isolate, code_range); + TestCodePageAllocatorScope test_code_page_allocator_scope( + isolate, code_page_allocator); + + v8::PageAllocator* page_allocator = + memory_allocator->page_allocator(executable); size_t header_size = (executable == EXECUTABLE) ? MemoryAllocator::CodePageGuardStartOffset() @@ -98,14 +106,12 @@ static void VerifyMemoryChunk(Isolate* isolate, Heap* heap, MemoryChunk* memory_chunk = memory_allocator->AllocateChunk( reserve_area_size, commit_area_size, executable, space); - size_t alignment = code_range != nullptr && code_range->valid() - ? MemoryChunk::kAlignment - : CommitPageSize(); size_t reserved_size = ((executable == EXECUTABLE)) ? RoundUp(header_size + guard_size + reserve_area_size + guard_size, - alignment) - : RoundUp(header_size + reserve_area_size, CommitPageSize()); + page_allocator->CommitPageSize()) + : RoundUp(header_size + reserve_area_size, + page_allocator->CommitPageSize()); CHECK(memory_chunk->size() == reserved_size); CHECK(memory_chunk->area_start() < memory_chunk->address() + memory_chunk->size()); @@ -119,38 +125,6 @@ static void VerifyMemoryChunk(Isolate* isolate, Heap* heap, delete memory_allocator; } -TEST(Regress3540) { - Isolate* isolate = CcTest::i_isolate(); - Heap* heap = isolate->heap(); - MemoryAllocator* memory_allocator = - new MemoryAllocator(isolate, heap->MaxReserved(), 0); - TestMemoryAllocatorScope test_allocator_scope(isolate, memory_allocator); - size_t code_range_size = - kMinimumCodeRangeSize > 0 ? kMinimumCodeRangeSize : 3 * Page::kPageSize; - CodeRange* code_range = new CodeRange(isolate, code_range_size); - - Address address; - size_t size; - size_t request_size = code_range_size - Page::kPageSize; - address = code_range->AllocateRawMemory( - request_size, request_size - (2 * MemoryAllocator::CodePageGuardSize()), - &size); - CHECK_NE(address, kNullAddress); - - Address null_address; - size_t null_size; - request_size = code_range_size - Page::kPageSize; - null_address = code_range->AllocateRawMemory( - request_size, request_size - (2 * MemoryAllocator::CodePageGuardSize()), - &null_size); - CHECK_EQ(null_address, kNullAddress); - - code_range->FreeRawMemory(address, size); - delete code_range; - memory_allocator->TearDown(); - delete memory_allocator; -} - static unsigned int PseudorandomAreaSize() { static uint32_t lo = 2345; lo = 18273 * (lo & 0xFFFFF) + (lo >> 16); @@ -162,24 +136,31 @@ TEST(MemoryChunk) { Isolate* isolate = CcTest::i_isolate(); Heap* heap = isolate->heap(); + v8::PageAllocator* page_allocator = GetPlatformPageAllocator(); + size_t reserve_area_size = 1 * MB; size_t initial_commit_area_size; for (int i = 0; i < 100; i++) { initial_commit_area_size = - RoundUp(PseudorandomAreaSize(), CommitPageSize()); + RoundUp(PseudorandomAreaSize(), page_allocator->CommitPageSize()); // With CodeRange. const size_t code_range_size = 32 * MB; - CodeRange* code_range = new CodeRange(isolate, code_range_size); + VirtualMemory code_range_reservation(page_allocator, code_range_size, + nullptr, MemoryChunk::kAlignment); + CHECK(code_range_reservation.IsReserved()); + + base::BoundedPageAllocator code_page_allocator( + page_allocator, code_range_reservation.address(), + code_range_reservation.size(), MemoryChunk::kAlignment); - VerifyMemoryChunk(isolate, heap, code_range, reserve_area_size, + VerifyMemoryChunk(isolate, heap, &code_page_allocator, reserve_area_size, initial_commit_area_size, EXECUTABLE, heap->code_space()); - VerifyMemoryChunk(isolate, heap, code_range, reserve_area_size, + VerifyMemoryChunk(isolate, heap, &code_page_allocator, reserve_area_size, initial_commit_area_size, NOT_EXECUTABLE, heap->old_space()); - delete code_range; } } @@ -240,7 +221,8 @@ TEST(NewSpace) { new MemoryAllocator(isolate, heap->MaxReserved(), 0); TestMemoryAllocatorScope test_scope(isolate, memory_allocator); - NewSpace new_space(heap, CcTest::heap()->InitialSemiSpaceSize(), + NewSpace new_space(heap, memory_allocator->data_page_allocator(), + CcTest::heap()->InitialSemiSpaceSize(), CcTest::heap()->InitialSemiSpaceSize()); CHECK(new_space.MaximumCapacity()); @@ -522,9 +504,7 @@ UNINITIALIZED_TEST(InlineAllocationObserverCadence) { // Clear out any pre-existing garbage to make the test consistent // across snapshot/no-snapshot builds. - i_isolate->heap()->CollectAllGarbage( - i::Heap::kFinalizeIncrementalMarkingMask, - i::GarbageCollectionReason::kTesting); + CcTest::CollectAllGarbage(i_isolate); NewSpace* new_space = i_isolate->heap()->new_space(); diff --git a/deps/v8/test/cctest/heap/test-unmapper.cc b/deps/v8/test/cctest/heap/test-unmapper.cc index 880c54457c..1fbe5c1f5c 100644 --- a/deps/v8/test/cctest/heap/test-unmapper.cc +++ b/deps/v8/test/cctest/heap/test-unmapper.cc @@ -23,7 +23,7 @@ class MockPlatformForUnmapper : public TestPlatform { // Now that it's completely constructed, make this the current platform. i::V8::SetPlatformForTesting(this); } - virtual ~MockPlatformForUnmapper() { + ~MockPlatformForUnmapper() override { delete task_; i::V8::SetPlatformForTesting(old_platform_); for (auto& task : worker_tasks_) { diff --git a/deps/v8/test/cctest/heap/test-weak-references.cc b/deps/v8/test/cctest/heap/test-weak-references.cc index a54b13afd2..bbe4776b93 100644 --- a/deps/v8/test/cctest/heap/test-weak-references.cc +++ b/deps/v8/test/cctest/heap/test-weak-references.cc @@ -62,19 +62,19 @@ TEST(WeakReferencesBasic) { fv->set_optimized_code_weak_or_smi(HeapObjectReference::Weak(*code)); HeapObject* code_heap_object; - CHECK( - fv->optimized_code_weak_or_smi()->ToWeakHeapObject(&code_heap_object)); + CHECK(fv->optimized_code_weak_or_smi()->GetHeapObjectIfWeak( + &code_heap_object)); CHECK_EQ(*code, code_heap_object); CcTest::CollectAllGarbage(); - CHECK( - fv->optimized_code_weak_or_smi()->ToWeakHeapObject(&code_heap_object)); + CHECK(fv->optimized_code_weak_or_smi()->GetHeapObjectIfWeak( + &code_heap_object)); CHECK_EQ(*code, code_heap_object); } // code will go out of scope. CcTest::CollectAllGarbage(); - CHECK(fv->optimized_code_weak_or_smi()->IsClearedWeakHeapObject()); + CHECK(fv->optimized_code_weak_or_smi()->IsCleared()); } TEST(WeakReferencesOldToOld) { @@ -103,7 +103,7 @@ TEST(WeakReferencesOldToOld) { CHECK(heap->InOldSpace(*fixed_array)); HeapObject* heap_object; - CHECK(fv->optimized_code_weak_or_smi()->ToWeakHeapObject(&heap_object)); + CHECK(fv->optimized_code_weak_or_smi()->GetHeapObjectIfWeak(&heap_object)); CHECK_EQ(heap_object, *fixed_array); } @@ -128,7 +128,7 @@ TEST(WeakReferencesOldToNew) { CcTest::CollectAllGarbage(); HeapObject* heap_object; - CHECK(fv->optimized_code_weak_or_smi()->ToWeakHeapObject(&heap_object)); + CHECK(fv->optimized_code_weak_or_smi()->GetHeapObjectIfWeak(&heap_object)); CHECK_EQ(heap_object, *fixed_array); } @@ -153,7 +153,7 @@ TEST(WeakReferencesOldToNewScavenged) { CcTest::CollectGarbage(NEW_SPACE); HeapObject* heap_object; - CHECK(fv->optimized_code_weak_or_smi()->ToWeakHeapObject(&heap_object)); + CHECK(fv->optimized_code_weak_or_smi()->GetHeapObjectIfWeak(&heap_object)); CHECK_EQ(heap_object, *fixed_array); } @@ -174,7 +174,7 @@ TEST(WeakReferencesOldToCleared) { fv->set_optimized_code_weak_or_smi(HeapObjectReference::ClearedValue()); CcTest::CollectAllGarbage(); - CHECK(fv->optimized_code_weak_or_smi()->IsClearedWeakHeapObject()); + CHECK(fv->optimized_code_weak_or_smi()->IsCleared()); } TEST(ObjectMovesBeforeClearingWeakField) { @@ -210,11 +210,11 @@ TEST(ObjectMovesBeforeClearingWeakField) { CcTest::CollectGarbage(NEW_SPACE); FeedbackVector* new_fv_location = *fv; CHECK_NE(fv_location, new_fv_location); - CHECK(fv->optimized_code_weak_or_smi()->IsWeakHeapObject()); + CHECK(fv->optimized_code_weak_or_smi()->IsWeak()); // Now we try to clear *fv. CcTest::CollectAllGarbage(); - CHECK(fv->optimized_code_weak_or_smi()->IsClearedWeakHeapObject()); + CHECK(fv->optimized_code_weak_or_smi()->IsCleared()); } TEST(ObjectWithWeakFieldDies) { @@ -277,7 +277,7 @@ TEST(ObjectWithWeakReferencePromoted) { CHECK(heap->InOldSpace(*fixed_array)); HeapObject* heap_object; - CHECK(fv->optimized_code_weak_or_smi()->ToWeakHeapObject(&heap_object)); + CHECK(fv->optimized_code_weak_or_smi()->GetHeapObjectIfWeak(&heap_object)); CHECK_EQ(heap_object, *fixed_array); } @@ -296,14 +296,14 @@ TEST(ObjectWithClearedWeakReferencePromoted) { CcTest::CollectGarbage(NEW_SPACE); CHECK(Heap::InNewSpace(*fv)); - CHECK(fv->optimized_code_weak_or_smi()->IsClearedWeakHeapObject()); + CHECK(fv->optimized_code_weak_or_smi()->IsCleared()); CcTest::CollectGarbage(NEW_SPACE); CHECK(heap->InOldSpace(*fv)); - CHECK(fv->optimized_code_weak_or_smi()->IsClearedWeakHeapObject()); + CHECK(fv->optimized_code_weak_or_smi()->IsCleared()); CcTest::CollectAllGarbage(); - CHECK(fv->optimized_code_weak_or_smi()->IsClearedWeakHeapObject()); + CHECK(fv->optimized_code_weak_or_smi()->IsCleared()); } TEST(WeakReferenceWriteBarrier) { @@ -343,7 +343,7 @@ TEST(WeakReferenceWriteBarrier) { CcTest::CollectAllGarbage(); // Check that the write barrier treated the weak reference as strong. - CHECK(fv->optimized_code_weak_or_smi()->IsWeakHeapObject()); + CHECK(fv->optimized_code_weak_or_smi()->IsWeak()); } TEST(EmptyWeakArray) { @@ -375,7 +375,7 @@ TEST(WeakArraysBasic) { for (int i = 0; i < length; ++i) { HeapObject* heap_object; - CHECK(array->Get(i)->ToStrongHeapObject(&heap_object)); + CHECK(array->Get(i)->GetHeapObjectIfStrong(&heap_object)); CHECK_EQ(heap_object, ReadOnlyRoots(heap).undefined_value()); } @@ -407,23 +407,23 @@ TEST(WeakArraysBasic) { // space. CcTest::CollectGarbage(NEW_SPACE); HeapObject* heap_object; - CHECK(array->Get(0)->ToWeakHeapObject(&heap_object)); + CHECK(array->Get(0)->GetHeapObjectIfWeak(&heap_object)); CHECK_EQ(Smi::cast(FixedArray::cast(heap_object)->get(0))->value(), 2016); - CHECK(array->Get(1)->ToWeakHeapObject(&heap_object)); + CHECK(array->Get(1)->GetHeapObjectIfWeak(&heap_object)); CHECK_EQ(Smi::cast(FixedArray::cast(heap_object)->get(0))->value(), 2017); - CHECK(array->Get(2)->ToStrongHeapObject(&heap_object)); + CHECK(array->Get(2)->GetHeapObjectIfStrong(&heap_object)); CHECK_EQ(Smi::cast(FixedArray::cast(heap_object)->get(0))->value(), 2018); - CHECK(array->Get(3)->ToWeakHeapObject(&heap_object)); + CHECK(array->Get(3)->GetHeapObjectIfWeak(&heap_object)); CHECK_EQ(Smi::cast(FixedArray::cast(heap_object)->get(0))->value(), 2019); CcTest::CollectAllGarbage(); CHECK(heap->InOldSpace(*array)); - CHECK(array->Get(0)->IsClearedWeakHeapObject()); - CHECK(array->Get(1)->ToWeakHeapObject(&heap_object)); + CHECK(array->Get(0)->IsCleared()); + CHECK(array->Get(1)->GetHeapObjectIfWeak(&heap_object)); CHECK_EQ(Smi::cast(FixedArray::cast(heap_object)->get(0))->value(), 2017); - CHECK(array->Get(2)->ToStrongHeapObject(&heap_object)); + CHECK(array->Get(2)->GetHeapObjectIfStrong(&heap_object)); CHECK_EQ(Smi::cast(FixedArray::cast(heap_object)->get(0))->value(), 2018); - CHECK(array->Get(3)->IsClearedWeakHeapObject()); + CHECK(array->Get(3)->IsCleared()); } TEST(WeakArrayListBasic) { @@ -481,13 +481,13 @@ TEST(WeakArrayListBasic) { CHECK(Heap::InNewSpace(*array)); CHECK_EQ(array->Get(0), HeapObjectReference::Weak(*index0)); - CHECK_EQ(Smi::ToInt(array->Get(1)->ToSmi()), 1); + CHECK_EQ(Smi::ToInt(array->Get(1)->cast<Smi>()), 1); CHECK_EQ(array->Get(2), HeapObjectReference::Weak(*index2)); - CHECK_EQ(Smi::ToInt(array->Get(3)->ToSmi()), 3); + CHECK_EQ(Smi::ToInt(array->Get(3)->cast<Smi>()), 3); CHECK_EQ(array->Get(4), HeapObjectReference::Weak(*index4)); - CHECK_EQ(Smi::ToInt(array->Get(5)->ToSmi()), 5); + CHECK_EQ(Smi::ToInt(array->Get(5)->cast<Smi>()), 5); CHECK_EQ(array->Get(6), HeapObjectReference::Weak(*index6)); array = inner_scope.CloseAndEscape(array); @@ -502,37 +502,37 @@ TEST(WeakArrayListBasic) { CcTest::CollectGarbage(NEW_SPACE); HeapObject* heap_object; CHECK_EQ(array->length(), 8); - CHECK(array->Get(0)->ToWeakHeapObject(&heap_object)); + CHECK(array->Get(0)->GetHeapObjectIfWeak(&heap_object)); CHECK_EQ(Smi::cast(FixedArray::cast(heap_object)->get(0))->value(), 2016); - CHECK_EQ(Smi::ToInt(array->Get(1)->ToSmi()), 1); + CHECK_EQ(Smi::ToInt(array->Get(1)->cast<Smi>()), 1); - CHECK(array->Get(2)->ToWeakHeapObject(&heap_object)); + CHECK(array->Get(2)->GetHeapObjectIfWeak(&heap_object)); CHECK_EQ(Smi::cast(FixedArray::cast(heap_object)->get(0))->value(), 2017); - CHECK_EQ(Smi::ToInt(array->Get(3)->ToSmi()), 3); + CHECK_EQ(Smi::ToInt(array->Get(3)->cast<Smi>()), 3); - CHECK(array->Get(4)->ToWeakHeapObject(&heap_object)); + CHECK(array->Get(4)->GetHeapObjectIfWeak(&heap_object)); CHECK_EQ(Smi::cast(FixedArray::cast(heap_object)->get(0))->value(), 2018); - CHECK_EQ(Smi::ToInt(array->Get(5)->ToSmi()), 5); + CHECK_EQ(Smi::ToInt(array->Get(5)->cast<Smi>()), 5); - CHECK(array->Get(6)->ToWeakHeapObject(&heap_object)); + CHECK(array->Get(6)->GetHeapObjectIfWeak(&heap_object)); CHECK_EQ(Smi::cast(FixedArray::cast(heap_object)->get(0))->value(), 2019); - CHECK_EQ(Smi::ToInt(array->Get(7)->ToSmi()), 7); + CHECK_EQ(Smi::ToInt(array->Get(7)->cast<Smi>()), 7); CcTest::CollectAllGarbage(); CHECK(heap->InOldSpace(*array)); CHECK_EQ(array->length(), 8); - CHECK(array->Get(0)->IsClearedWeakHeapObject()); - CHECK_EQ(Smi::ToInt(array->Get(1)->ToSmi()), 1); + CHECK(array->Get(0)->IsCleared()); + CHECK_EQ(Smi::ToInt(array->Get(1)->cast<Smi>()), 1); - CHECK(array->Get(2)->ToWeakHeapObject(&heap_object)); + CHECK(array->Get(2)->GetHeapObjectIfWeak(&heap_object)); CHECK_EQ(Smi::cast(FixedArray::cast(heap_object)->get(0))->value(), 2017); - CHECK_EQ(Smi::ToInt(array->Get(3)->ToSmi()), 3); + CHECK_EQ(Smi::ToInt(array->Get(3)->cast<Smi>()), 3); - CHECK(array->Get(4)->IsClearedWeakHeapObject()); - CHECK_EQ(Smi::ToInt(array->Get(5)->ToSmi()), 5); + CHECK(array->Get(4)->IsCleared()); + CHECK_EQ(Smi::ToInt(array->Get(5)->cast<Smi>()), 5); - CHECK(array->Get(6)->IsClearedWeakHeapObject()); - CHECK_EQ(Smi::ToInt(array->Get(7)->ToSmi()), 7); + CHECK(array->Get(6)->IsCleared()); + CHECK_EQ(Smi::ToInt(array->Get(7)->cast<Smi>()), 7); } TEST(WeakArrayListRemove) { @@ -753,7 +753,7 @@ TEST(PrototypeUsersCompacted) { PrototypeUsers::MarkSlotEmpty(*array, 1); CcTest::CollectAllGarbage(); - CHECK(array->Get(3)->IsClearedWeakHeapObject()); + CHECK(array->Get(3)->IsCleared()); CHECK_EQ(array->length(), 3 + PrototypeUsers::kFirstIndex); WeakArrayList* new_array = diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/ArrayLiterals.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/ArrayLiterals.golden index ae8d050914..31272f1c29 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/ArrayLiterals.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/ArrayLiterals.golden @@ -35,17 +35,17 @@ bytecodes: [ /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), /* 45 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(37), - B(Star), R(1), - B(LdaZero), B(Star), R(2), + B(LdaZero), + B(Star), R(1), B(Ldar), R(0), - /* 54 E> */ B(StaKeyedProperty), R(1), R(2), U8(1), + /* 54 E> */ B(StaInArrayLiteral), R(2), R(1), U8(1), B(LdaSmi), I8(1), - B(Star), R(2), + B(Star), R(1), B(Ldar), R(0), /* 59 E> */ B(AddSmi), I8(1), U8(3), - B(StaKeyedProperty), R(1), R(2), U8(1), - B(Ldar), R(1), + B(StaInArrayLiteral), R(2), R(1), U8(1), + B(Ldar), R(2), /* 65 S> */ B(Return), ] constant pool: [ @@ -84,29 +84,29 @@ bytecodes: [ /* 42 S> */ B(LdaSmi), I8(1), B(Star), R(0), /* 45 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(4), - B(Star), R(1), - B(LdaZero), B(Star), R(2), - B(CreateArrayLiteral), U8(1), U8(3), U8(37), - B(Star), R(3), B(LdaZero), + B(Star), R(1), + B(CreateArrayLiteral), U8(1), U8(1), U8(37), B(Star), R(4), + B(LdaZero), + B(Star), R(3), B(Ldar), R(0), - /* 56 E> */ B(StaKeyedProperty), R(3), R(4), U8(4), - B(Ldar), R(3), - B(StaKeyedProperty), R(1), R(2), U8(1), + /* 56 E> */ B(StaInArrayLiteral), R(4), R(3), U8(2), + B(Ldar), R(4), + B(StaInArrayLiteral), R(2), R(1), U8(4), B(LdaSmi), I8(1), - B(Star), R(2), + B(Star), R(1), B(CreateArrayLiteral), U8(2), U8(6), U8(37), - B(Star), R(3), - B(LdaZero), B(Star), R(4), + B(LdaZero), + B(Star), R(3), B(Ldar), R(0), - /* 68 E> */ B(AddSmi), I8(2), U8(9), - B(StaKeyedProperty), R(3), R(4), U8(7), - B(Ldar), R(3), - B(StaKeyedProperty), R(1), R(2), U8(1), - B(Ldar), R(1), + /* 68 E> */ B(AddSmi), I8(2), U8(7), + B(StaInArrayLiteral), R(4), R(3), U8(8), + B(Ldar), R(4), + B(StaInArrayLiteral), R(2), R(1), U8(4), + B(Ldar), R(2), /* 76 S> */ B(Return), ] constant pool: [ @@ -121,50 +121,18 @@ handlers: [ snippet: " var a = [ 1, 2 ]; return [ ...a ]; " -frame size: 8 +frame size: 1 parameter count: 1 -bytecode array length: 86 +bytecode array length: 9 bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(37), B(Star), R(0), - /* 52 S> */ B(CreateArrayLiteral), U8(1), U8(1), U8(37), - B(Star), R(1), - B(LdaConstant), U8(2), - /* 64 S> */ B(Star), R(2), - B(LdaNamedProperty), R(0), U8(3), U8(7), - B(Star), R(7), - B(CallProperty0), R(7), R(0), U8(9), - B(Mov), R(0), R(6), - B(JumpIfJSReceiver), U8(7), - B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), - B(Star), R(5), - B(LdaNamedProperty), R(5), U8(4), U8(11), - B(Star), R(4), - B(CallProperty0), R(4), R(5), U8(13), - B(Star), R(3), - B(JumpIfJSReceiver), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(3), U8(1), - B(LdaNamedProperty), R(3), U8(5), U8(15), - B(JumpIfToBooleanTrue), U8(21), - B(LdaNamedProperty), R(3), U8(6), U8(17), - B(Star), R(3), - B(StaInArrayLiteral), R(1), R(2), U8(2), - B(Ldar), R(2), - B(Inc), U8(4), - B(Star), R(2), - B(JumpLoop), U8(35), I8(0), - B(Ldar), R(1), + /* 52 S> */ B(CreateArrayFromIterable), /* 68 S> */ B(Return), ] constant pool: [ ARRAY_BOILERPLATE_DESCRIPTION_TYPE, - ARRAY_BOILERPLATE_DESCRIPTION_TYPE, - Smi [0], - SYMBOL_TYPE, - ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], - ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], - ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], ] handlers: [ ] @@ -181,32 +149,32 @@ bytecodes: [ /* 42 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(37), B(Star), R(0), /* 52 S> */ B(CreateArrayLiteral), U8(1), U8(1), U8(37), - B(Star), R(1), + B(Star), R(2), B(LdaConstant), U8(2), - /* 67 S> */ B(Star), R(2), - B(LdaNamedProperty), R(0), U8(3), U8(7), + /* 67 S> */ B(Star), R(1), + B(LdaNamedProperty), R(0), U8(3), U8(5), B(Star), R(7), - B(CallProperty0), R(7), R(0), U8(9), + B(CallProperty0), R(7), R(0), U8(7), B(Mov), R(0), R(6), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), B(Star), R(5), - B(LdaNamedProperty), R(5), U8(4), U8(11), + B(LdaNamedProperty), R(5), U8(4), U8(9), B(Star), R(4), - B(CallProperty0), R(4), R(5), U8(13), + B(CallProperty0), R(4), R(5), U8(11), B(Star), R(3), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(3), U8(1), - B(LdaNamedProperty), R(3), U8(5), U8(15), + B(LdaNamedProperty), R(3), U8(5), U8(13), B(JumpIfToBooleanTrue), U8(21), - B(LdaNamedProperty), R(3), U8(6), U8(17), + B(LdaNamedProperty), R(3), U8(6), U8(15), B(Star), R(3), - B(StaInArrayLiteral), R(1), R(2), U8(2), - B(Ldar), R(2), - B(Inc), U8(4), - B(Star), R(2), - B(JumpLoop), U8(35), I8(0), + B(StaInArrayLiteral), R(2), R(1), U8(3), B(Ldar), R(1), + B(Inc), U8(2), + B(Star), R(1), + B(JumpLoop), U8(35), I8(0), + B(Ldar), R(2), /* 71 S> */ B(Return), ] constant pool: [ @@ -225,55 +193,25 @@ handlers: [ snippet: " var a = [ 1, 2 ]; return [ ...a, 3 ]; " -frame size: 8 +frame size: 3 parameter count: 1 -bytecode array length: 98 +bytecode array length: 25 bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(37), B(Star), R(0), - /* 52 S> */ B(CreateArrayLiteral), U8(1), U8(1), U8(37), - B(Star), R(1), - B(LdaConstant), U8(2), - /* 64 S> */ B(Star), R(2), - B(LdaNamedProperty), R(0), U8(3), U8(7), - B(Star), R(7), - B(CallProperty0), R(7), R(0), U8(9), - B(Mov), R(0), R(6), - B(JumpIfJSReceiver), U8(7), - B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), - B(Star), R(5), - B(LdaNamedProperty), R(5), U8(4), U8(11), - B(Star), R(4), - B(CallProperty0), R(4), R(5), U8(13), - B(Star), R(3), - B(JumpIfJSReceiver), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(3), U8(1), - B(LdaNamedProperty), R(3), U8(5), U8(15), - B(JumpIfToBooleanTrue), U8(21), - B(LdaNamedProperty), R(3), U8(6), U8(17), - B(Star), R(3), - B(StaInArrayLiteral), R(1), R(2), U8(2), - B(Ldar), R(2), - B(Inc), U8(4), + /* 52 S> */ B(CreateArrayFromIterable), B(Star), R(2), - B(JumpLoop), U8(35), I8(0), + B(LdaNamedProperty), R(2), U8(1), U8(1), + B(Star), R(1), B(LdaSmi), I8(3), - B(StaInArrayLiteral), R(1), R(2), U8(2), + B(StaInArrayLiteral), R(2), R(1), U8(3), B(Ldar), R(2), - B(Inc), U8(4), - B(Star), R(2), - B(Ldar), R(1), /* 71 S> */ B(Return), ] constant pool: [ ARRAY_BOILERPLATE_DESCRIPTION_TYPE, - ARRAY_BOILERPLATE_DESCRIPTION_TYPE, - Smi [0], - SYMBOL_TYPE, - ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], - ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], - ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["length"], ] handlers: [ ] diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/AsyncGenerators.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/AsyncGenerators.golden index f5cbed6a7a..f3ddec23a0 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/AsyncGenerators.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/AsyncGenerators.golden @@ -252,19 +252,19 @@ frame size: 22 parameter count: 1 bytecode array length: 490 bytecodes: [ - B(SwitchOnGeneratorState), R(2), U8(0), U8(3), + B(SwitchOnGeneratorState), R(0), U8(0), U8(3), B(Mov), R(closure), R(11), B(Mov), R(this), R(12), B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(11), U8(2), - B(Star), R(2), + B(Star), R(0), /* 17 E> */ B(StackCheck), B(Mov), R(context), R(13), B(Mov), R(context), R(14), - B(Ldar), R(2), - /* 17 E> */ B(SuspendGenerator), R(2), R(0), U8(15), U8(0), - B(ResumeGenerator), R(2), R(0), U8(15), + B(Ldar), R(0), + /* 17 E> */ B(SuspendGenerator), R(0), R(0), U8(15), U8(0), + B(ResumeGenerator), R(0), R(0), U8(15), B(Star), R(15), - B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(2), U8(1), + B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1), B(SwitchOnSmiNoFeedback), U8(3), U8(2), I8(0), B(Ldar), R(15), /* 17 E> */ B(Throw), @@ -300,16 +300,16 @@ bytecodes: [ B(Star), R(7), B(Mov), R(8), R(3), /* 22 E> */ B(StackCheck), - B(Mov), R(3), R(0), + B(Mov), R(3), R(1), /* 42 S> */ B(LdaFalse), B(Star), R(21), - B(Mov), R(2), R(19), - B(Mov), R(0), R(20), + B(Mov), R(0), R(19), + B(Mov), R(1), R(20), B(InvokeIntrinsic), U8(Runtime::k_AsyncGeneratorYield), R(19), U8(3), - /* 42 E> */ B(SuspendGenerator), R(2), R(0), U8(19), U8(1), - B(ResumeGenerator), R(2), R(0), U8(19), + /* 42 E> */ B(SuspendGenerator), R(0), R(0), U8(19), U8(1), + B(ResumeGenerator), R(0), R(0), U8(19), B(Star), R(19), - B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(2), U8(1), + B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1), B(SwitchOnSmiNoFeedback), U8(10), U8(2), I8(0), B(Ldar), R(19), /* 42 E> */ B(Throw), @@ -362,7 +362,7 @@ bytecodes: [ B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(153), + B(Wide), B(LdaSmi), I16(154), B(Star), R(18), B(LdaConstant), U8(14), B(Star), R(19), @@ -398,12 +398,12 @@ bytecodes: [ B(ReThrow), B(LdaUndefined), B(Star), R(16), - B(Mov), R(2), R(15), + B(Mov), R(0), R(15), B(CallJSRuntime), U8(%async_generator_await_uncaught), R(15), U8(2), - B(SuspendGenerator), R(2), R(0), U8(15), U8(2), - B(ResumeGenerator), R(2), R(0), U8(15), + B(SuspendGenerator), R(0), R(0), U8(15), U8(2), + B(ResumeGenerator), R(0), R(0), U8(15), B(Star), R(15), - B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(2), U8(1), + B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1), B(Star), R(16), B(LdaZero), B(TestReferenceEqual), R(16), @@ -424,7 +424,7 @@ bytecodes: [ B(PushContext), R(15), B(LdaImmutableCurrentContextSlot), U8(4), B(Star), R(17), - B(Mov), R(2), R(16), + B(Mov), R(0), R(16), B(InvokeIntrinsic), U8(Runtime::k_AsyncGeneratorReject), R(16), U8(2), B(PopContext), R(15), B(Star), R(12), @@ -441,7 +441,7 @@ bytecodes: [ B(LdaTheHole), B(SetPendingMessage), B(Star), R(13), - B(InvokeIntrinsic), U8(Runtime::k_GeneratorClose), R(2), U8(1), + B(InvokeIntrinsic), U8(Runtime::k_GeneratorClose), R(0), U8(1), B(Ldar), R(13), B(SetPendingMessage), B(Ldar), R(11), @@ -449,7 +449,7 @@ bytecodes: [ B(Jump), U8(22), B(LdaTrue), B(Star), R(16), - B(Mov), R(2), R(14), + B(Mov), R(0), R(14), B(Mov), R(12), R(15), B(InvokeIntrinsic), U8(Runtime::k_AsyncGeneratorResolve), R(14), U8(3), /* 50 S> */ B(Return), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/CallAndSpread.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/CallAndSpread.golden index 779e12c4ec..4c27e3a8d4 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/CallAndSpread.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/CallAndSpread.golden @@ -67,7 +67,7 @@ snippet: " " frame size: 10 parameter count: 1 -bytecode array length: 112 +bytecode array length: 109 bytecodes: [ /* 30 E> */ B(StackCheck), /* 34 S> */ B(LdaGlobal), U8(0), U8(0), @@ -75,38 +75,36 @@ bytecodes: [ B(LdaNamedProperty), R(0), U8(1), U8(2), B(Star), R(1), B(CreateArrayLiteral), U8(2), U8(4), U8(37), - B(Star), R(3), - B(LdaConstant), U8(3), B(Star), R(4), - /* 49 S> */ B(CreateArrayLiteral), U8(4), U8(10), U8(37), + B(LdaConstant), U8(3), + B(Star), R(3), + /* 49 S> */ B(CreateArrayLiteral), U8(4), U8(8), U8(37), B(Star), R(8), - B(LdaNamedProperty), R(8), U8(5), U8(11), + B(LdaNamedProperty), R(8), U8(5), U8(9), B(Star), R(9), - B(CallProperty0), R(9), R(8), U8(13), + B(CallProperty0), R(9), R(8), U8(11), B(Mov), R(0), R(2), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), B(Star), R(7), - B(LdaNamedProperty), R(7), U8(6), U8(15), + B(LdaNamedProperty), R(7), U8(6), U8(13), B(Star), R(6), - B(CallProperty0), R(6), R(7), U8(17), + B(CallProperty0), R(6), R(7), U8(15), B(Star), R(5), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(5), U8(1), - B(LdaNamedProperty), R(5), U8(7), U8(19), + B(LdaNamedProperty), R(5), U8(7), U8(17), B(JumpIfToBooleanTrue), U8(21), - B(LdaNamedProperty), R(5), U8(8), U8(21), + B(LdaNamedProperty), R(5), U8(8), U8(19), B(Star), R(5), - B(StaInArrayLiteral), R(3), R(4), U8(5), - B(Ldar), R(4), - B(Inc), U8(7), - B(Star), R(4), + B(StaInArrayLiteral), R(4), R(3), U8(6), + B(Ldar), R(3), + B(Inc), U8(5), + B(Star), R(3), B(JumpLoop), U8(35), I8(0), B(LdaSmi), I8(4), - B(StaInArrayLiteral), R(3), R(4), U8(5), - B(Ldar), R(4), - B(Inc), U8(7), - B(Star), R(4), + B(StaInArrayLiteral), R(4), R(3), U8(6), + B(Mov), R(4), R(3), B(CallJSRuntime), U8(%reflect_apply), R(1), U8(3), B(LdaUndefined), /* 64 S> */ B(Return), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/ClassDeclarations.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/ClassDeclarations.golden index 737d423fcb..c56e29436e 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/ClassDeclarations.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/ClassDeclarations.golden @@ -103,12 +103,12 @@ bytecodes: [ B(Star), R(3), B(LdaConstant), U8(3), B(Star), R(4), - B(LdaImmutableCurrentContextSlot), U8(4), - /* 75 E> */ B(ToName), R(7), + /* 75 S> */ B(LdaImmutableCurrentContextSlot), U8(4), + B(ToName), R(7), B(CreateClosure), U8(5), U8(1), U8(2), B(Star), R(8), - B(LdaImmutableCurrentContextSlot), U8(5), - /* 106 E> */ B(ToName), R(9), + /* 106 S> */ B(LdaImmutableCurrentContextSlot), U8(5), + B(ToName), R(9), B(LdaConstant), U8(6), B(TestEqualStrict), R(9), U8(2), B(Mov), R(3), R(5), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/ForAwaitOf.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/ForAwaitOf.golden index c5fae1f4f6..098130c480 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/ForAwaitOf.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/ForAwaitOf.golden @@ -16,20 +16,20 @@ snippet: " " frame size: 23 parameter count: 1 -bytecode array length: 514 +bytecode array length: 518 bytecodes: [ - B(SwitchOnGeneratorState), R(2), U8(0), U8(3), + B(SwitchOnGeneratorState), R(3), U8(0), U8(3), B(Mov), R(closure), R(12), B(Mov), R(this), R(13), B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(12), U8(2), - B(Star), R(2), + B(Star), R(3), /* 16 E> */ B(StackCheck), B(CallJSRuntime), U8(%async_function_promise_create), R(0), U8(0), - B(Star), R(11), + B(Star), R(0), B(Mov), R(context), R(14), B(Mov), R(context), R(15), B(LdaZero), - B(Star), R(7), + B(Star), R(8), B(Mov), R(context), R(18), B(Mov), R(context), R(19), /* 43 S> */ B(CreateArrayLiteral), U8(3), U8(0), U8(37), @@ -46,40 +46,40 @@ bytecodes: [ B(CallProperty0), R(21), R(20), U8(7), B(Star), R(21), B(InvokeIntrinsic), U8(Runtime::k_CreateAsyncFromSyncIterator), R(21), U8(1), - B(Star), R(4), - /* 43 E> */ B(LdaNamedProperty), R(4), U8(6), U8(9), B(Star), R(5), - /* 40 S> */ B(CallProperty0), R(5), R(4), U8(11), + /* 43 E> */ B(LdaNamedProperty), R(5), U8(6), U8(9), + B(Star), R(6), + /* 40 S> */ B(CallProperty0), R(6), R(5), U8(11), B(Star), R(21), - B(Mov), R(2), R(20), - B(Mov), R(11), R(22), + B(Mov), R(3), R(20), + B(Mov), R(0), R(22), B(CallJSRuntime), U8(%async_function_await_uncaught), R(20), U8(3), - /* 40 E> */ B(SuspendGenerator), R(2), R(0), U8(20), U8(0), - B(ResumeGenerator), R(2), R(0), U8(20), + /* 40 E> */ B(SuspendGenerator), R(3), R(0), U8(20), U8(0), + B(ResumeGenerator), R(3), R(0), U8(20), B(Star), R(20), - B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(2), U8(1), + B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(3), U8(1), B(Star), R(21), B(LdaZero), B(TestReferenceEqual), R(21), B(JumpIfTrue), U8(5), B(Ldar), R(20), B(ReThrow), - B(Mov), R(20), R(6), + B(Mov), R(20), R(7), /* 40 E> */ B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(20), U8(1), B(ToBooleanLogicalNot), B(JumpIfFalse), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(6), U8(1), - B(LdaNamedProperty), R(6), U8(7), U8(13), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(7), U8(1), + B(LdaNamedProperty), R(7), U8(7), U8(13), B(JumpIfToBooleanTrue), U8(25), - B(LdaNamedProperty), R(6), U8(8), U8(15), - B(Star), R(8), + B(LdaNamedProperty), R(7), U8(8), U8(15), + B(Star), R(9), B(LdaSmi), I8(2), - B(Star), R(7), - B(Mov), R(8), R(3), + B(Star), R(8), + B(Mov), R(9), R(4), /* 23 E> */ B(StackCheck), - B(Mov), R(3), R(0), + B(Mov), R(4), R(1), B(LdaZero), - B(Star), R(7), + B(Star), R(8), B(JumpLoop), U8(82), I8(0), B(Jump), U8(37), B(Star), R(20), @@ -90,10 +90,10 @@ bytecodes: [ B(Ldar), R(19), B(PushContext), R(20), B(LdaSmi), I8(2), - B(TestEqualStrict), R(7), U8(17), + B(TestEqualStrict), R(8), U8(17), B(JumpIfFalse), U8(6), B(LdaSmi), I8(1), - B(Star), R(7), + B(Star), R(8), B(LdaImmutableCurrentContextSlot), U8(4), B(Star), R(21), B(CallRuntime), U16(Runtime::kReThrow), R(21), U8(1), @@ -109,38 +109,38 @@ bytecodes: [ B(SetPendingMessage), B(Star), R(18), B(LdaZero), - B(TestEqualStrict), R(7), U8(18), + B(TestEqualStrict), R(8), U8(18), B(JumpIfTrue), U8(167), - B(LdaNamedProperty), R(4), U8(10), U8(19), - B(Star), R(9), + B(LdaNamedProperty), R(5), U8(10), U8(19), + B(Star), R(10), B(TestUndetectable), B(JumpIfFalse), U8(4), B(Jump), U8(156), B(LdaSmi), I8(1), - B(TestEqualStrict), R(7), U8(21), + B(TestEqualStrict), R(8), U8(21), B(JumpIfFalse), U8(86), - B(Ldar), R(9), + B(Ldar), R(10), B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(153), + B(Wide), B(LdaSmi), I16(154), B(Star), R(19), B(LdaConstant), U8(11), B(Star), R(20), B(CallRuntime), U16(Runtime::kNewTypeError), R(19), U8(2), B(Throw), B(Mov), R(context), R(19), - B(Mov), R(9), R(20), - B(Mov), R(4), R(21), + B(Mov), R(10), R(20), + B(Mov), R(5), R(21), B(InvokeIntrinsic), U8(Runtime::k_Call), R(20), U8(2), B(Star), R(21), - B(Mov), R(2), R(20), - B(Mov), R(11), R(22), + B(Mov), R(3), R(20), + B(Mov), R(0), R(22), B(CallJSRuntime), U8(%async_function_await_caught), R(20), U8(3), - B(SuspendGenerator), R(2), R(0), U8(20), U8(1), - B(ResumeGenerator), R(2), R(0), U8(20), + B(SuspendGenerator), R(3), R(0), U8(20), U8(1), + B(ResumeGenerator), R(3), R(0), U8(20), B(Star), R(20), - B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(2), U8(1), + B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(3), U8(1), B(Star), R(21), B(LdaZero), B(TestReferenceEqual), R(21), @@ -153,28 +153,28 @@ bytecodes: [ B(SetPendingMessage), B(Ldar), R(19), B(Jump), U8(65), - B(Mov), R(9), R(19), - B(Mov), R(4), R(20), + B(Mov), R(10), R(19), + B(Mov), R(5), R(20), B(InvokeIntrinsic), U8(Runtime::k_Call), R(19), U8(2), B(Star), R(20), - B(Mov), R(2), R(19), - B(Mov), R(11), R(21), + B(Mov), R(3), R(19), + B(Mov), R(0), R(21), B(CallJSRuntime), U8(%async_function_await_uncaught), R(19), U8(3), - B(SuspendGenerator), R(2), R(0), U8(19), U8(2), - B(ResumeGenerator), R(2), R(0), U8(19), + B(SuspendGenerator), R(3), R(0), U8(19), U8(2), + B(ResumeGenerator), R(3), R(0), U8(19), B(Star), R(19), - B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(2), U8(1), + B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(3), U8(1), B(Star), R(20), B(LdaZero), B(TestReferenceEqual), R(20), B(JumpIfTrue), U8(5), B(Ldar), R(19), B(ReThrow), - B(Mov), R(19), R(10), + B(Mov), R(19), R(11), B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(19), U8(1), B(JumpIfToBooleanFalse), U8(4), B(Jump), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(10), U8(1), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(11), U8(1), B(Ldar), R(18), B(SetPendingMessage), B(LdaZero), @@ -183,14 +183,11 @@ bytecodes: [ B(Ldar), R(17), B(ReThrow), B(LdaUndefined), - B(Star), R(17), - B(Mov), R(11), R(16), - B(InvokeIntrinsic), U8(Runtime::k_ResolvePromise), R(16), U8(2), + B(Star), R(13), B(LdaZero), B(Star), R(12), - B(Mov), R(11), R(13), - B(Jump), U8(55), - B(Jump), U8(39), + B(Jump), U8(56), + B(Jump), U8(40), B(Star), R(16), B(CreateCatchContext), R(16), U8(12), B(Star), R(15), @@ -202,32 +199,37 @@ bytecodes: [ B(Star), R(18), B(LdaFalse), B(Star), R(19), - B(Mov), R(11), R(17), + B(Mov), R(0), R(17), B(InvokeIntrinsic), U8(Runtime::k_RejectPromise), R(17), U8(3), B(PopContext), R(16), - B(LdaZero), + B(LdaSmi), I8(1), B(Star), R(12), - B(Mov), R(11), R(13), + B(Mov), R(0), R(13), B(Jump), U8(16), B(LdaSmi), I8(-1), B(Star), R(13), B(Star), R(12), B(Jump), U8(8), B(Star), R(13), - B(LdaSmi), I8(1), + B(LdaSmi), I8(2), B(Star), R(12), B(LdaTheHole), B(SetPendingMessage), B(Star), R(14), B(LdaTrue), B(Star), R(16), - B(Mov), R(11), R(15), + B(Mov), R(0), R(15), B(CallJSRuntime), U8(%async_function_promise_release), R(15), U8(2), B(Ldar), R(14), B(SetPendingMessage), B(Ldar), R(12), - B(SwitchOnSmiNoFeedback), U8(13), U8(2), I8(0), - B(Jump), U8(8), + B(SwitchOnSmiNoFeedback), U8(13), U8(3), I8(0), + B(Jump), U8(21), + B(Mov), R(0), R(15), + B(Mov), R(13), R(16), + B(InvokeIntrinsic), U8(Runtime::k_ResolvePromise), R(15), U8(2), + B(Ldar), R(0), + /* 57 S> */ B(Return), B(Ldar), R(13), /* 57 S> */ B(Return), B(Ldar), R(13), @@ -250,11 +252,12 @@ constant pool: [ ONE_BYTE_INTERNALIZED_STRING_TYPE [""], SCOPE_INFO_TYPE, Smi [6], - Smi [9], + Smi [19], + Smi [22], ] handlers: [ - [26, 467, 475], - [29, 428, 430], + [26, 458, 466], + [29, 418, 420], [35, 211, 219], [38, 174, 176], [279, 328, 330], @@ -269,20 +272,20 @@ snippet: " " frame size: 23 parameter count: 1 -bytecode array length: 543 +bytecode array length: 532 bytecodes: [ - B(SwitchOnGeneratorState), R(2), U8(0), U8(3), + B(SwitchOnGeneratorState), R(3), U8(0), U8(3), B(Mov), R(closure), R(12), B(Mov), R(this), R(13), B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(12), U8(2), - B(Star), R(2), + B(Star), R(3), /* 16 E> */ B(StackCheck), B(CallJSRuntime), U8(%async_function_promise_create), R(0), U8(0), - B(Star), R(11), + B(Star), R(0), B(Mov), R(context), R(14), B(Mov), R(context), R(15), B(LdaZero), - B(Star), R(7), + B(Star), R(8), B(Mov), R(context), R(18), B(Mov), R(context), R(19), /* 43 S> */ B(CreateArrayLiteral), U8(3), U8(0), U8(37), @@ -299,41 +302,41 @@ bytecodes: [ B(CallProperty0), R(21), R(20), U8(7), B(Star), R(21), B(InvokeIntrinsic), U8(Runtime::k_CreateAsyncFromSyncIterator), R(21), U8(1), - B(Star), R(4), - /* 43 E> */ B(LdaNamedProperty), R(4), U8(6), U8(9), B(Star), R(5), - /* 40 S> */ B(CallProperty0), R(5), R(4), U8(11), + /* 43 E> */ B(LdaNamedProperty), R(5), U8(6), U8(9), + B(Star), R(6), + /* 40 S> */ B(CallProperty0), R(6), R(5), U8(11), B(Star), R(21), - B(Mov), R(2), R(20), - B(Mov), R(11), R(22), + B(Mov), R(3), R(20), + B(Mov), R(0), R(22), B(CallJSRuntime), U8(%async_function_await_uncaught), R(20), U8(3), - /* 40 E> */ B(SuspendGenerator), R(2), R(0), U8(20), U8(0), - B(ResumeGenerator), R(2), R(0), U8(20), + /* 40 E> */ B(SuspendGenerator), R(3), R(0), U8(20), U8(0), + B(ResumeGenerator), R(3), R(0), U8(20), B(Star), R(20), - B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(2), U8(1), + B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(3), U8(1), B(Star), R(21), B(LdaZero), B(TestReferenceEqual), R(21), B(JumpIfTrue), U8(5), B(Ldar), R(20), B(ReThrow), - B(Mov), R(20), R(6), + B(Mov), R(20), R(7), /* 40 E> */ B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(20), U8(1), B(ToBooleanLogicalNot), B(JumpIfFalse), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(6), U8(1), - B(LdaNamedProperty), R(6), U8(7), U8(13), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(7), U8(1), + B(LdaNamedProperty), R(7), U8(7), U8(13), B(JumpIfToBooleanTrue), U8(27), - B(LdaNamedProperty), R(6), U8(8), U8(15), - B(Star), R(8), + B(LdaNamedProperty), R(7), U8(8), U8(15), + B(Star), R(9), B(LdaSmi), I8(2), - B(Star), R(7), - B(Mov), R(8), R(3), + B(Star), R(8), + B(Mov), R(9), R(4), /* 23 E> */ B(StackCheck), - B(Mov), R(3), R(0), + B(Mov), R(4), R(1), /* 56 S> */ B(LdaZero), B(Star), R(16), - B(Mov), R(8), R(17), + B(Mov), R(9), R(17), B(Jump), U8(53), B(Jump), U8(37), B(Star), R(20), @@ -344,10 +347,10 @@ bytecodes: [ B(Ldar), R(19), B(PushContext), R(20), B(LdaSmi), I8(2), - B(TestEqualStrict), R(7), U8(17), + B(TestEqualStrict), R(8), U8(17), B(JumpIfFalse), U8(6), B(LdaSmi), I8(1), - B(Star), R(7), + B(Star), R(8), B(LdaImmutableCurrentContextSlot), U8(4), B(Star), R(21), B(CallRuntime), U16(Runtime::kReThrow), R(21), U8(1), @@ -363,38 +366,38 @@ bytecodes: [ B(SetPendingMessage), B(Star), R(18), B(LdaZero), - B(TestEqualStrict), R(7), U8(18), + B(TestEqualStrict), R(8), U8(18), B(JumpIfTrue), U8(167), - B(LdaNamedProperty), R(4), U8(10), U8(19), - B(Star), R(9), + B(LdaNamedProperty), R(5), U8(10), U8(19), + B(Star), R(10), B(TestUndetectable), B(JumpIfFalse), U8(4), B(Jump), U8(156), B(LdaSmi), I8(1), - B(TestEqualStrict), R(7), U8(21), + B(TestEqualStrict), R(8), U8(21), B(JumpIfFalse), U8(86), - B(Ldar), R(9), + B(Ldar), R(10), B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(153), + B(Wide), B(LdaSmi), I16(154), B(Star), R(19), B(LdaConstant), U8(11), B(Star), R(20), B(CallRuntime), U16(Runtime::kNewTypeError), R(19), U8(2), B(Throw), B(Mov), R(context), R(19), - B(Mov), R(9), R(20), - B(Mov), R(4), R(21), + B(Mov), R(10), R(20), + B(Mov), R(5), R(21), B(InvokeIntrinsic), U8(Runtime::k_Call), R(20), U8(2), B(Star), R(21), - B(Mov), R(2), R(20), - B(Mov), R(11), R(22), + B(Mov), R(3), R(20), + B(Mov), R(0), R(22), B(CallJSRuntime), U8(%async_function_await_caught), R(20), U8(3), - B(SuspendGenerator), R(2), R(0), U8(20), U8(1), - B(ResumeGenerator), R(2), R(0), U8(20), + B(SuspendGenerator), R(3), R(0), U8(20), U8(1), + B(ResumeGenerator), R(3), R(0), U8(20), B(Star), R(20), - B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(2), U8(1), + B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(3), U8(1), B(Star), R(21), B(LdaZero), B(TestReferenceEqual), R(21), @@ -407,28 +410,28 @@ bytecodes: [ B(SetPendingMessage), B(Ldar), R(19), B(Jump), U8(65), - B(Mov), R(9), R(19), - B(Mov), R(4), R(20), + B(Mov), R(10), R(19), + B(Mov), R(5), R(20), B(InvokeIntrinsic), U8(Runtime::k_Call), R(19), U8(2), B(Star), R(20), - B(Mov), R(2), R(19), - B(Mov), R(11), R(21), + B(Mov), R(3), R(19), + B(Mov), R(0), R(21), B(CallJSRuntime), U8(%async_function_await_uncaught), R(19), U8(3), - B(SuspendGenerator), R(2), R(0), U8(19), U8(2), - B(ResumeGenerator), R(2), R(0), U8(19), + B(SuspendGenerator), R(3), R(0), U8(19), U8(2), + B(ResumeGenerator), R(3), R(0), U8(19), B(Star), R(19), - B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(2), U8(1), + B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(3), U8(1), B(Star), R(20), B(LdaZero), B(TestReferenceEqual), R(20), B(JumpIfTrue), U8(5), B(Ldar), R(19), B(ReThrow), - B(Mov), R(19), R(10), + B(Mov), R(19), R(11), B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(19), U8(1), B(JumpIfToBooleanFalse), U8(4), B(Jump), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(10), U8(1), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(11), U8(1), B(Ldar), R(18), B(SetPendingMessage), B(Ldar), R(16), @@ -437,16 +440,13 @@ bytecodes: [ B(LdaZero), B(Star), R(12), B(Mov), R(17), R(13), - B(Jump), U8(78), + B(Jump), U8(67), B(Ldar), R(17), B(ReThrow), B(LdaUndefined), - B(Star), R(17), - B(Mov), R(11), R(16), - B(InvokeIntrinsic), U8(Runtime::k_ResolvePromise), R(16), U8(2), - B(LdaSmi), I8(1), + B(Star), R(13), + B(LdaZero), B(Star), R(12), - B(Mov), R(11), R(13), B(Jump), U8(56), B(Jump), U8(40), B(Star), R(16), @@ -460,12 +460,12 @@ bytecodes: [ B(Star), R(18), B(LdaFalse), B(Star), R(19), - B(Mov), R(11), R(17), + B(Mov), R(0), R(17), B(InvokeIntrinsic), U8(Runtime::k_RejectPromise), R(17), U8(3), B(PopContext), R(16), B(LdaSmi), I8(1), B(Star), R(12), - B(Mov), R(11), R(13), + B(Mov), R(0), R(13), B(Jump), U8(16), B(LdaSmi), I8(-1), B(Star), R(13), @@ -479,17 +479,17 @@ bytecodes: [ B(Star), R(14), B(LdaTrue), B(Star), R(16), - B(Mov), R(11), R(15), + B(Mov), R(0), R(15), B(CallJSRuntime), U8(%async_function_promise_release), R(15), U8(2), B(Ldar), R(14), B(SetPendingMessage), B(Ldar), R(12), B(SwitchOnSmiNoFeedback), U8(15), U8(3), I8(0), B(Jump), U8(21), - B(Mov), R(11), R(15), + B(Mov), R(0), R(15), B(Mov), R(13), R(16), B(InvokeIntrinsic), U8(Runtime::k_ResolvePromise), R(15), U8(2), - B(Ldar), R(11), + B(Ldar), R(0), /* 68 S> */ B(Return), B(Ldar), R(13), /* 68 S> */ B(Return), @@ -519,8 +519,8 @@ constant pool: [ Smi [22], ] handlers: [ - [26, 483, 491], - [29, 443, 445], + [26, 472, 480], + [29, 432, 434], [35, 213, 221], [38, 176, 178], [282, 331, 333], @@ -538,20 +538,20 @@ snippet: " " frame size: 23 parameter count: 1 -bytecode array length: 532 +bytecode array length: 536 bytecodes: [ - B(SwitchOnGeneratorState), R(2), U8(0), U8(3), + B(SwitchOnGeneratorState), R(3), U8(0), U8(3), B(Mov), R(closure), R(12), B(Mov), R(this), R(13), B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(12), U8(2), - B(Star), R(2), + B(Star), R(3), /* 16 E> */ B(StackCheck), B(CallJSRuntime), U8(%async_function_promise_create), R(0), U8(0), - B(Star), R(11), + B(Star), R(0), B(Mov), R(context), R(14), B(Mov), R(context), R(15), B(LdaZero), - B(Star), R(7), + B(Star), R(8), B(Mov), R(context), R(18), B(Mov), R(context), R(19), /* 43 S> */ B(CreateArrayLiteral), U8(3), U8(0), U8(37), @@ -568,48 +568,48 @@ bytecodes: [ B(CallProperty0), R(21), R(20), U8(7), B(Star), R(21), B(InvokeIntrinsic), U8(Runtime::k_CreateAsyncFromSyncIterator), R(21), U8(1), - B(Star), R(4), - /* 43 E> */ B(LdaNamedProperty), R(4), U8(6), U8(9), B(Star), R(5), - /* 40 S> */ B(CallProperty0), R(5), R(4), U8(11), + /* 43 E> */ B(LdaNamedProperty), R(5), U8(6), U8(9), + B(Star), R(6), + /* 40 S> */ B(CallProperty0), R(6), R(5), U8(11), B(Star), R(21), - B(Mov), R(2), R(20), - B(Mov), R(11), R(22), + B(Mov), R(3), R(20), + B(Mov), R(0), R(22), B(CallJSRuntime), U8(%async_function_await_uncaught), R(20), U8(3), - /* 40 E> */ B(SuspendGenerator), R(2), R(0), U8(20), U8(0), - B(ResumeGenerator), R(2), R(0), U8(20), + /* 40 E> */ B(SuspendGenerator), R(3), R(0), U8(20), U8(0), + B(ResumeGenerator), R(3), R(0), U8(20), B(Star), R(20), - B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(2), U8(1), + B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(3), U8(1), B(Star), R(21), B(LdaZero), B(TestReferenceEqual), R(21), B(JumpIfTrue), U8(5), B(Ldar), R(20), B(ReThrow), - B(Mov), R(20), R(6), + B(Mov), R(20), R(7), /* 40 E> */ B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(20), U8(1), B(ToBooleanLogicalNot), B(JumpIfFalse), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(6), U8(1), - B(LdaNamedProperty), R(6), U8(7), U8(13), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(7), U8(1), + B(LdaNamedProperty), R(7), U8(7), U8(13), B(JumpIfToBooleanTrue), U8(43), - B(LdaNamedProperty), R(6), U8(8), U8(15), - B(Star), R(8), + B(LdaNamedProperty), R(7), U8(8), U8(15), + B(Star), R(9), B(LdaSmi), I8(2), - B(Star), R(7), - B(Mov), R(8), R(3), + B(Star), R(8), + B(Mov), R(9), R(4), /* 23 E> */ B(StackCheck), - B(Mov), R(3), R(0), + B(Mov), R(4), R(1), /* 63 S> */ B(LdaSmi), I8(10), - /* 69 E> */ B(TestEqual), R(0), U8(17), + /* 69 E> */ B(TestEqual), R(1), U8(17), B(JumpIfFalse), U8(4), /* 76 S> */ B(Jump), U8(14), /* 90 S> */ B(LdaSmi), I8(20), - /* 96 E> */ B(TestEqual), R(0), U8(18), + /* 96 E> */ B(TestEqual), R(1), U8(18), B(JumpIfFalse), U8(4), /* 103 S> */ B(Jump), U8(8), B(LdaZero), - B(Star), R(7), + B(Star), R(8), B(JumpLoop), U8(100), I8(0), B(Jump), U8(37), B(Star), R(20), @@ -620,10 +620,10 @@ bytecodes: [ B(Ldar), R(19), B(PushContext), R(20), B(LdaSmi), I8(2), - B(TestEqualStrict), R(7), U8(19), + B(TestEqualStrict), R(8), U8(19), B(JumpIfFalse), U8(6), B(LdaSmi), I8(1), - B(Star), R(7), + B(Star), R(8), B(LdaImmutableCurrentContextSlot), U8(4), B(Star), R(21), B(CallRuntime), U16(Runtime::kReThrow), R(21), U8(1), @@ -639,38 +639,38 @@ bytecodes: [ B(SetPendingMessage), B(Star), R(18), B(LdaZero), - B(TestEqualStrict), R(7), U8(20), + B(TestEqualStrict), R(8), U8(20), B(JumpIfTrue), U8(167), - B(LdaNamedProperty), R(4), U8(10), U8(21), - B(Star), R(9), + B(LdaNamedProperty), R(5), U8(10), U8(21), + B(Star), R(10), B(TestUndetectable), B(JumpIfFalse), U8(4), B(Jump), U8(156), B(LdaSmi), I8(1), - B(TestEqualStrict), R(7), U8(23), + B(TestEqualStrict), R(8), U8(23), B(JumpIfFalse), U8(86), - B(Ldar), R(9), + B(Ldar), R(10), B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(153), + B(Wide), B(LdaSmi), I16(154), B(Star), R(19), B(LdaConstant), U8(11), B(Star), R(20), B(CallRuntime), U16(Runtime::kNewTypeError), R(19), U8(2), B(Throw), B(Mov), R(context), R(19), - B(Mov), R(9), R(20), - B(Mov), R(4), R(21), + B(Mov), R(10), R(20), + B(Mov), R(5), R(21), B(InvokeIntrinsic), U8(Runtime::k_Call), R(20), U8(2), B(Star), R(21), - B(Mov), R(2), R(20), - B(Mov), R(11), R(22), + B(Mov), R(3), R(20), + B(Mov), R(0), R(22), B(CallJSRuntime), U8(%async_function_await_caught), R(20), U8(3), - B(SuspendGenerator), R(2), R(0), U8(20), U8(1), - B(ResumeGenerator), R(2), R(0), U8(20), + B(SuspendGenerator), R(3), R(0), U8(20), U8(1), + B(ResumeGenerator), R(3), R(0), U8(20), B(Star), R(20), - B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(2), U8(1), + B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(3), U8(1), B(Star), R(21), B(LdaZero), B(TestReferenceEqual), R(21), @@ -683,28 +683,28 @@ bytecodes: [ B(SetPendingMessage), B(Ldar), R(19), B(Jump), U8(65), - B(Mov), R(9), R(19), - B(Mov), R(4), R(20), + B(Mov), R(10), R(19), + B(Mov), R(5), R(20), B(InvokeIntrinsic), U8(Runtime::k_Call), R(19), U8(2), B(Star), R(20), - B(Mov), R(2), R(19), - B(Mov), R(11), R(21), + B(Mov), R(3), R(19), + B(Mov), R(0), R(21), B(CallJSRuntime), U8(%async_function_await_uncaught), R(19), U8(3), - B(SuspendGenerator), R(2), R(0), U8(19), U8(2), - B(ResumeGenerator), R(2), R(0), U8(19), + B(SuspendGenerator), R(3), R(0), U8(19), U8(2), + B(ResumeGenerator), R(3), R(0), U8(19), B(Star), R(19), - B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(2), U8(1), + B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(3), U8(1), B(Star), R(20), B(LdaZero), B(TestReferenceEqual), R(20), B(JumpIfTrue), U8(5), B(Ldar), R(19), B(ReThrow), - B(Mov), R(19), R(10), + B(Mov), R(19), R(11), B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(19), U8(1), B(JumpIfToBooleanFalse), U8(4), B(Jump), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(10), U8(1), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(11), U8(1), B(Ldar), R(18), B(SetPendingMessage), B(LdaZero), @@ -713,14 +713,11 @@ bytecodes: [ B(Ldar), R(17), B(ReThrow), B(LdaUndefined), - B(Star), R(17), - B(Mov), R(11), R(16), - B(InvokeIntrinsic), U8(Runtime::k_ResolvePromise), R(16), U8(2), + B(Star), R(13), B(LdaZero), B(Star), R(12), - B(Mov), R(11), R(13), - B(Jump), U8(55), - B(Jump), U8(39), + B(Jump), U8(56), + B(Jump), U8(40), B(Star), R(16), B(CreateCatchContext), R(16), U8(12), B(Star), R(15), @@ -732,32 +729,37 @@ bytecodes: [ B(Star), R(18), B(LdaFalse), B(Star), R(19), - B(Mov), R(11), R(17), + B(Mov), R(0), R(17), B(InvokeIntrinsic), U8(Runtime::k_RejectPromise), R(17), U8(3), B(PopContext), R(16), - B(LdaZero), + B(LdaSmi), I8(1), B(Star), R(12), - B(Mov), R(11), R(13), + B(Mov), R(0), R(13), B(Jump), U8(16), B(LdaSmi), I8(-1), B(Star), R(13), B(Star), R(12), B(Jump), U8(8), B(Star), R(13), - B(LdaSmi), I8(1), + B(LdaSmi), I8(2), B(Star), R(12), B(LdaTheHole), B(SetPendingMessage), B(Star), R(14), B(LdaTrue), B(Star), R(16), - B(Mov), R(11), R(15), + B(Mov), R(0), R(15), B(CallJSRuntime), U8(%async_function_promise_release), R(15), U8(2), B(Ldar), R(14), B(SetPendingMessage), B(Ldar), R(12), - B(SwitchOnSmiNoFeedback), U8(13), U8(2), I8(0), - B(Jump), U8(8), + B(SwitchOnSmiNoFeedback), U8(13), U8(3), I8(0), + B(Jump), U8(21), + B(Mov), R(0), R(15), + B(Mov), R(13), R(16), + B(InvokeIntrinsic), U8(Runtime::k_ResolvePromise), R(15), U8(2), + B(Ldar), R(0), + /* 114 S> */ B(Return), B(Ldar), R(13), /* 114 S> */ B(Return), B(Ldar), R(13), @@ -780,11 +782,12 @@ constant pool: [ ONE_BYTE_INTERNALIZED_STRING_TYPE [""], SCOPE_INFO_TYPE, Smi [6], - Smi [9], + Smi [19], + Smi [22], ] handlers: [ - [26, 485, 493], - [29, 446, 448], + [26, 476, 484], + [29, 436, 438], [35, 229, 237], [38, 192, 194], [297, 346, 348], @@ -800,17 +803,17 @@ snippet: " " frame size: 20 parameter count: 1 -bytecode array length: 403 +bytecode array length: 392 bytecodes: [ /* 16 E> */ B(StackCheck), B(CallJSRuntime), U8(%async_function_promise_create), R(0), U8(0), - B(Star), R(9), + B(Star), R(0), B(Mov), R(context), R(12), B(Mov), R(context), R(13), /* 31 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(41), R(14), - B(Mov), R(14), R(1), + B(Mov), R(14), R(2), B(LdaZero), - B(Star), R(5), + B(Star), R(6), B(Mov), R(context), R(16), B(Mov), R(context), R(17), /* 68 S> */ B(CreateArrayLiteral), U8(1), U8(1), U8(37), @@ -820,25 +823,25 @@ bytecodes: [ B(CallProperty0), R(19), R(18), U8(4), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), - B(Star), R(2), - /* 68 E> */ B(LdaNamedProperty), R(2), U8(3), U8(6), B(Star), R(3), - /* 59 S> */ B(CallProperty0), R(3), R(2), U8(8), + /* 68 E> */ B(LdaNamedProperty), R(3), U8(3), U8(6), B(Star), R(4), - /* 59 E> */ B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(4), U8(1), + /* 59 S> */ B(CallProperty0), R(4), R(3), U8(8), + B(Star), R(5), + /* 59 E> */ B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(5), U8(1), B(ToBooleanLogicalNot), B(JumpIfFalse), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(4), U8(1), - B(LdaNamedProperty), R(4), U8(4), U8(10), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(5), U8(1), + B(LdaNamedProperty), R(5), U8(4), U8(10), B(JumpIfToBooleanTrue), U8(30), - /* 58 E> */ B(LdaNamedProperty), R(4), U8(5), U8(12), - B(Star), R(6), + /* 58 E> */ B(LdaNamedProperty), R(5), U8(5), U8(12), + B(Star), R(7), B(LdaSmi), I8(2), - B(Star), R(5), - B(Ldar), R(6), - B(StaNamedProperty), R(1), U8(6), U8(14), + B(Star), R(6), + B(Ldar), R(7), + B(StaNamedProperty), R(2), U8(6), U8(14), /* 53 E> */ B(StackCheck), - /* 87 S> */ B(LdaNamedProperty), R(1), U8(6), U8(16), + /* 87 S> */ B(LdaNamedProperty), R(2), U8(6), U8(16), B(Star), R(15), B(LdaZero), B(Star), R(14), @@ -852,10 +855,10 @@ bytecodes: [ B(Ldar), R(17), B(PushContext), R(18), B(LdaSmi), I8(2), - B(TestEqualStrict), R(5), U8(18), + B(TestEqualStrict), R(6), U8(18), B(JumpIfFalse), U8(6), B(LdaSmi), I8(1), - B(Star), R(5), + B(Star), R(6), B(LdaImmutableCurrentContextSlot), U8(4), B(Star), R(19), B(CallRuntime), U16(Runtime::kReThrow), R(19), U8(1), @@ -871,43 +874,43 @@ bytecodes: [ B(SetPendingMessage), B(Star), R(16), B(LdaZero), - B(TestEqualStrict), R(5), U8(19), + B(TestEqualStrict), R(6), U8(19), B(JumpIfTrue), U8(90), - B(LdaNamedProperty), R(2), U8(8), U8(20), - B(Star), R(7), + B(LdaNamedProperty), R(3), U8(8), U8(20), + B(Star), R(8), B(TestUndetectable), B(JumpIfFalse), U8(4), B(Jump), U8(79), B(LdaSmi), I8(1), - B(TestEqualStrict), R(5), U8(22), + B(TestEqualStrict), R(6), U8(22), B(JumpIfFalse), U8(47), - B(Ldar), R(7), + B(Ldar), R(8), B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(153), + B(Wide), B(LdaSmi), I16(154), B(Star), R(17), B(LdaConstant), U8(9), B(Star), R(18), B(CallRuntime), U16(Runtime::kNewTypeError), R(17), U8(2), B(Throw), B(Mov), R(context), R(17), - B(Mov), R(7), R(18), - B(Mov), R(2), R(19), + B(Mov), R(8), R(18), + B(Mov), R(3), R(19), B(InvokeIntrinsic), U8(Runtime::k_Call), R(18), U8(2), B(Jump), U8(6), B(LdaTheHole), B(SetPendingMessage), B(Ldar), R(17), B(Jump), U8(27), - B(Mov), R(7), R(17), - B(Mov), R(2), R(18), + B(Mov), R(8), R(17), + B(Mov), R(3), R(18), B(InvokeIntrinsic), U8(Runtime::k_Call), R(17), U8(2), - B(Star), R(8), - B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(8), U8(1), + B(Star), R(9), + B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(9), U8(1), B(JumpIfToBooleanFalse), U8(4), B(Jump), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(8), U8(1), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(9), U8(1), B(Ldar), R(16), B(SetPendingMessage), B(Ldar), R(14), @@ -916,16 +919,13 @@ bytecodes: [ B(LdaZero), B(Star), R(10), B(Mov), R(15), R(11), - B(Jump), U8(78), + B(Jump), U8(67), B(Ldar), R(15), B(ReThrow), B(LdaUndefined), - B(Star), R(15), - B(Mov), R(9), R(14), - B(InvokeIntrinsic), U8(Runtime::k_ResolvePromise), R(14), U8(2), - B(LdaSmi), I8(1), + B(Star), R(11), + B(LdaZero), B(Star), R(10), - B(Mov), R(9), R(11), B(Jump), U8(56), B(Jump), U8(40), B(Star), R(14), @@ -939,12 +939,12 @@ bytecodes: [ B(Star), R(16), B(LdaFalse), B(Star), R(17), - B(Mov), R(9), R(15), + B(Mov), R(0), R(15), B(InvokeIntrinsic), U8(Runtime::k_RejectPromise), R(15), U8(3), B(PopContext), R(14), B(LdaSmi), I8(1), B(Star), R(10), - B(Mov), R(9), R(11), + B(Mov), R(0), R(11), B(Jump), U8(16), B(LdaSmi), I8(-1), B(Star), R(11), @@ -958,17 +958,17 @@ bytecodes: [ B(Star), R(12), B(LdaFalse), B(Star), R(14), - B(Mov), R(9), R(13), + B(Mov), R(0), R(13), B(CallJSRuntime), U8(%async_function_promise_release), R(13), U8(2), B(Ldar), R(12), B(SetPendingMessage), B(Ldar), R(10), B(SwitchOnSmiNoFeedback), U8(13), U8(3), I8(0), B(Jump), U8(21), - B(Mov), R(9), R(13), + B(Mov), R(0), R(13), B(Mov), R(11), R(14), B(InvokeIntrinsic), U8(Runtime::k_ResolvePromise), R(13), U8(2), - B(Ldar), R(9), + B(Ldar), R(0), /* 96 S> */ B(Return), B(Ldar), R(11), /* 96 S> */ B(Return), @@ -996,8 +996,8 @@ constant pool: [ Smi [22], ] handlers: [ - [10, 343, 351], - [13, 303, 305], + [10, 332, 340], + [13, 292, 294], [27, 150, 158], [30, 113, 115], [219, 229, 231], diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOf.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOf.golden index bcb462bc75..b43429e008 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOf.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOf.golden @@ -85,7 +85,7 @@ bytecodes: [ B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(153), + B(Wide), B(LdaSmi), I16(154), B(Star), R(12), B(LdaConstant), U8(7), B(Star), R(13), @@ -217,7 +217,7 @@ bytecodes: [ B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(153), + B(Wide), B(LdaSmi), I16(154), B(Star), R(13), B(LdaConstant), U8(7), B(Star), R(14), @@ -361,7 +361,7 @@ bytecodes: [ B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(153), + B(Wide), B(LdaSmi), I16(154), B(Star), R(12), B(LdaConstant), U8(7), B(Star), R(13), @@ -495,7 +495,7 @@ bytecodes: [ B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(153), + B(Wide), B(LdaSmi), I16(154), B(Star), R(11), B(LdaConstant), U8(9), B(Star), R(12), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOfLoop.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOfLoop.golden index d4fe1a091c..9755e0af17 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOfLoop.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOfLoop.golden @@ -89,7 +89,7 @@ bytecodes: [ B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(153), + B(Wide), B(LdaSmi), I16(154), B(Star), R(14), B(LdaConstant), U8(6), B(Star), R(15), @@ -256,7 +256,7 @@ bytecodes: [ B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(153), + B(Wide), B(LdaSmi), I16(154), B(Star), R(14), B(LdaConstant), U8(11), B(Star), R(15), @@ -401,7 +401,7 @@ bytecodes: [ B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(153), + B(Wide), B(LdaSmi), I16(154), B(Star), R(12), B(LdaConstant), U8(8), B(Star), R(13), @@ -550,7 +550,7 @@ bytecodes: [ B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(153), + B(Wide), B(LdaSmi), I16(154), B(Star), R(17), B(LdaConstant), U8(8), B(Star), R(18), @@ -697,7 +697,7 @@ bytecodes: [ B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(153), + B(Wide), B(LdaSmi), I16(154), B(Star), R(15), B(LdaConstant), U8(9), B(Star), R(16), @@ -859,7 +859,7 @@ bytecodes: [ B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(153), + B(Wide), B(LdaSmi), I16(154), B(Star), R(14), B(LdaConstant), U8(12), B(Star), R(15), @@ -926,15 +926,15 @@ snippet: " " frame size: 23 parameter count: 2 -bytecode array length: 363 +bytecode array length: 367 bytecodes: [ /* 16 E> */ B(StackCheck), B(CallJSRuntime), U8(%async_function_promise_create), R(0), U8(0), - B(Star), R(12), + B(Star), R(0), B(Mov), R(context), R(15), B(Mov), R(context), R(16), B(LdaZero), - B(Star), R(8), + B(Star), R(9), B(Mov), R(context), R(19), B(Mov), R(context), R(20), /* 40 S> */ B(LdaNamedProperty), R(arg0), U8(0), U8(0), @@ -943,27 +943,27 @@ bytecodes: [ B(Mov), R(arg0), R(21), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), - B(Star), R(5), - /* 40 E> */ B(LdaNamedProperty), R(5), U8(1), U8(4), B(Star), R(6), - /* 35 S> */ B(CallProperty0), R(6), R(5), U8(6), + /* 40 E> */ B(LdaNamedProperty), R(6), U8(1), U8(4), B(Star), R(7), - /* 35 E> */ B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(7), U8(1), + /* 35 S> */ B(CallProperty0), R(7), R(6), U8(6), + B(Star), R(8), + /* 35 E> */ B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(8), U8(1), B(ToBooleanLogicalNot), B(JumpIfFalse), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(7), U8(1), - B(LdaNamedProperty), R(7), U8(2), U8(8), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(8), U8(1), + B(LdaNamedProperty), R(8), U8(2), U8(8), B(JumpIfToBooleanTrue), U8(28), - B(LdaNamedProperty), R(7), U8(3), U8(10), - B(Star), R(9), + B(LdaNamedProperty), R(8), U8(3), U8(10), + B(Star), R(10), B(LdaSmi), I8(2), - B(Star), R(8), - B(Mov), R(9), R(4), + B(Star), R(9), + B(Mov), R(10), R(5), /* 26 E> */ B(StackCheck), - B(Mov), R(4), R(1), - /* 55 S> */ B(Mov), R(1), R(0), + B(Mov), R(5), R(2), + /* 55 S> */ B(Mov), R(2), R(1), B(LdaZero), - B(Star), R(8), + B(Star), R(9), B(JumpLoop), U8(47), I8(0), B(Jump), U8(37), B(Star), R(21), @@ -974,10 +974,10 @@ bytecodes: [ B(Ldar), R(20), B(PushContext), R(21), B(LdaSmi), I8(2), - B(TestEqualStrict), R(8), U8(12), + B(TestEqualStrict), R(9), U8(12), B(JumpIfFalse), U8(6), B(LdaSmi), I8(1), - B(Star), R(8), + B(Star), R(9), B(LdaImmutableCurrentContextSlot), U8(4), B(Star), R(22), B(CallRuntime), U16(Runtime::kReThrow), R(22), U8(1), @@ -993,43 +993,43 @@ bytecodes: [ B(SetPendingMessage), B(Star), R(19), B(LdaZero), - B(TestEqualStrict), R(8), U8(13), + B(TestEqualStrict), R(9), U8(13), B(JumpIfTrue), U8(90), - B(LdaNamedProperty), R(5), U8(5), U8(14), - B(Star), R(10), + B(LdaNamedProperty), R(6), U8(5), U8(14), + B(Star), R(11), B(TestUndetectable), B(JumpIfFalse), U8(4), B(Jump), U8(79), B(LdaSmi), I8(1), - B(TestEqualStrict), R(8), U8(16), + B(TestEqualStrict), R(9), U8(16), B(JumpIfFalse), U8(47), - B(Ldar), R(10), + B(Ldar), R(11), B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(153), + B(Wide), B(LdaSmi), I16(154), B(Star), R(20), B(LdaConstant), U8(6), B(Star), R(21), B(CallRuntime), U16(Runtime::kNewTypeError), R(20), U8(2), B(Throw), B(Mov), R(context), R(20), - B(Mov), R(10), R(21), - B(Mov), R(5), R(22), + B(Mov), R(11), R(21), + B(Mov), R(6), R(22), B(InvokeIntrinsic), U8(Runtime::k_Call), R(21), U8(2), B(Jump), U8(6), B(LdaTheHole), B(SetPendingMessage), B(Ldar), R(20), B(Jump), U8(27), - B(Mov), R(10), R(20), - B(Mov), R(5), R(21), + B(Mov), R(11), R(20), + B(Mov), R(6), R(21), B(InvokeIntrinsic), U8(Runtime::k_Call), R(20), U8(2), - B(Star), R(11), - B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(11), U8(1), + B(Star), R(12), + B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(12), U8(1), B(JumpIfToBooleanFalse), U8(4), B(Jump), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(11), U8(1), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(12), U8(1), B(Ldar), R(19), B(SetPendingMessage), B(LdaZero), @@ -1038,14 +1038,11 @@ bytecodes: [ B(Ldar), R(18), B(ReThrow), B(LdaUndefined), - B(Star), R(18), - B(Mov), R(12), R(17), - B(InvokeIntrinsic), U8(Runtime::k_ResolvePromise), R(17), U8(2), + B(Star), R(14), B(LdaZero), B(Star), R(13), - B(Mov), R(12), R(14), - B(Jump), U8(55), - B(Jump), U8(39), + B(Jump), U8(56), + B(Jump), U8(40), B(Star), R(17), B(CreateCatchContext), R(17), U8(7), B(Star), R(16), @@ -1057,32 +1054,37 @@ bytecodes: [ B(Star), R(19), B(LdaFalse), B(Star), R(20), - B(Mov), R(12), R(18), + B(Mov), R(0), R(18), B(InvokeIntrinsic), U8(Runtime::k_RejectPromise), R(18), U8(3), B(PopContext), R(17), - B(LdaZero), + B(LdaSmi), I8(1), B(Star), R(13), - B(Mov), R(12), R(14), + B(Mov), R(0), R(14), B(Jump), U8(16), B(LdaSmi), I8(-1), B(Star), R(14), B(Star), R(13), B(Jump), U8(8), B(Star), R(14), - B(LdaSmi), I8(1), + B(LdaSmi), I8(2), B(Star), R(13), B(LdaTheHole), B(SetPendingMessage), B(Star), R(15), B(LdaFalse), B(Star), R(17), - B(Mov), R(12), R(16), + B(Mov), R(0), R(16), B(CallJSRuntime), U8(%async_function_promise_release), R(16), U8(2), B(Ldar), R(15), B(SetPendingMessage), B(Ldar), R(13), - B(SwitchOnSmiNoFeedback), U8(8), U8(2), I8(0), - B(Jump), U8(8), + B(SwitchOnSmiNoFeedback), U8(8), U8(3), I8(0), + B(Jump), U8(21), + B(Mov), R(0), R(16), + B(Mov), R(14), R(17), + B(InvokeIntrinsic), U8(Runtime::k_ResolvePromise), R(16), U8(2), + B(Ldar), R(0), + /* 60 S> */ B(Return), B(Ldar), R(14), /* 60 S> */ B(Return), B(Ldar), R(14), @@ -1100,11 +1102,12 @@ constant pool: [ ONE_BYTE_INTERNALIZED_STRING_TYPE [""], SCOPE_INFO_TYPE, Smi [6], - Smi [9], + Smi [19], + Smi [22], ] handlers: [ - [10, 316, 324], - [13, 277, 279], + [10, 307, 315], + [13, 267, 269], [19, 137, 145], [22, 100, 102], [205, 215, 217], @@ -1119,20 +1122,20 @@ snippet: " " frame size: 23 parameter count: 2 -bytecode array length: 414 +bytecode array length: 418 bytecodes: [ - B(SwitchOnGeneratorState), R(2), U8(0), U8(1), + B(SwitchOnGeneratorState), R(3), U8(0), U8(1), B(Mov), R(closure), R(12), B(Mov), R(this), R(13), B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(12), U8(2), - B(Star), R(2), + B(Star), R(3), /* 16 E> */ B(StackCheck), B(CallJSRuntime), U8(%async_function_promise_create), R(0), U8(0), - B(Star), R(11), + B(Star), R(0), B(Mov), R(context), R(14), B(Mov), R(context), R(15), B(LdaZero), - B(Star), R(7), + B(Star), R(8), B(Mov), R(context), R(18), B(Mov), R(context), R(19), /* 40 S> */ B(LdaNamedProperty), R(arg0), U8(1), U8(0), @@ -1141,32 +1144,32 @@ bytecodes: [ B(Mov), R(arg0), R(20), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), - B(Star), R(4), - /* 40 E> */ B(LdaNamedProperty), R(4), U8(2), U8(4), B(Star), R(5), - /* 35 S> */ B(CallProperty0), R(5), R(4), U8(6), + /* 40 E> */ B(LdaNamedProperty), R(5), U8(2), U8(4), B(Star), R(6), - /* 35 E> */ B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(6), U8(1), + /* 35 S> */ B(CallProperty0), R(6), R(5), U8(6), + B(Star), R(7), + /* 35 E> */ B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(7), U8(1), B(ToBooleanLogicalNot), B(JumpIfFalse), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(6), U8(1), - B(LdaNamedProperty), R(6), U8(3), U8(8), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(7), U8(1), + B(LdaNamedProperty), R(7), U8(3), U8(8), B(JumpIfToBooleanTrue), U8(63), - B(LdaNamedProperty), R(6), U8(4), U8(10), - B(Star), R(8), + B(LdaNamedProperty), R(7), U8(4), U8(10), + B(Star), R(9), B(LdaSmi), I8(2), - B(Star), R(7), - B(Mov), R(8), R(3), + B(Star), R(8), + B(Mov), R(9), R(4), /* 26 E> */ B(StackCheck), - B(Mov), R(3), R(0), - /* 45 S> */ B(Mov), R(2), R(20), - B(Mov), R(0), R(21), - B(Mov), R(11), R(22), + B(Mov), R(4), R(1), + /* 45 S> */ B(Mov), R(3), R(20), + B(Mov), R(1), R(21), + B(Mov), R(0), R(22), B(CallJSRuntime), U8(%async_function_await_uncaught), R(20), U8(3), - /* 45 E> */ B(SuspendGenerator), R(2), R(0), U8(20), U8(0), - B(ResumeGenerator), R(2), R(0), U8(20), + /* 45 E> */ B(SuspendGenerator), R(3), R(0), U8(20), U8(0), + B(ResumeGenerator), R(3), R(0), U8(20), B(Star), R(20), - B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(2), U8(1), + B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(3), U8(1), B(Star), R(21), B(LdaZero), B(TestReferenceEqual), R(21), @@ -1174,7 +1177,7 @@ bytecodes: [ B(Ldar), R(20), B(ReThrow), B(LdaZero), - B(Star), R(7), + B(Star), R(8), B(JumpLoop), U8(82), I8(0), B(Jump), U8(37), B(Star), R(20), @@ -1185,10 +1188,10 @@ bytecodes: [ B(Ldar), R(19), B(PushContext), R(20), B(LdaSmi), I8(2), - B(TestEqualStrict), R(7), U8(12), + B(TestEqualStrict), R(8), U8(12), B(JumpIfFalse), U8(6), B(LdaSmi), I8(1), - B(Star), R(7), + B(Star), R(8), B(LdaImmutableCurrentContextSlot), U8(4), B(Star), R(21), B(CallRuntime), U16(Runtime::kReThrow), R(21), U8(1), @@ -1204,43 +1207,43 @@ bytecodes: [ B(SetPendingMessage), B(Star), R(18), B(LdaZero), - B(TestEqualStrict), R(7), U8(13), + B(TestEqualStrict), R(8), U8(13), B(JumpIfTrue), U8(90), - B(LdaNamedProperty), R(4), U8(6), U8(14), - B(Star), R(9), + B(LdaNamedProperty), R(5), U8(6), U8(14), + B(Star), R(10), B(TestUndetectable), B(JumpIfFalse), U8(4), B(Jump), U8(79), B(LdaSmi), I8(1), - B(TestEqualStrict), R(7), U8(16), + B(TestEqualStrict), R(8), U8(16), B(JumpIfFalse), U8(47), - B(Ldar), R(9), + B(Ldar), R(10), B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(153), + B(Wide), B(LdaSmi), I16(154), B(Star), R(19), B(LdaConstant), U8(7), B(Star), R(20), B(CallRuntime), U16(Runtime::kNewTypeError), R(19), U8(2), B(Throw), B(Mov), R(context), R(19), - B(Mov), R(9), R(20), - B(Mov), R(4), R(21), + B(Mov), R(10), R(20), + B(Mov), R(5), R(21), B(InvokeIntrinsic), U8(Runtime::k_Call), R(20), U8(2), B(Jump), U8(6), B(LdaTheHole), B(SetPendingMessage), B(Ldar), R(19), B(Jump), U8(27), - B(Mov), R(9), R(19), - B(Mov), R(4), R(20), + B(Mov), R(10), R(19), + B(Mov), R(5), R(20), B(InvokeIntrinsic), U8(Runtime::k_Call), R(19), U8(2), - B(Star), R(10), - B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(10), U8(1), + B(Star), R(11), + B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(11), U8(1), B(JumpIfToBooleanFalse), U8(4), B(Jump), U8(7), - B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(10), U8(1), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(11), U8(1), B(Ldar), R(18), B(SetPendingMessage), B(LdaZero), @@ -1249,14 +1252,11 @@ bytecodes: [ B(Ldar), R(17), B(ReThrow), B(LdaUndefined), - B(Star), R(17), - B(Mov), R(11), R(16), - B(InvokeIntrinsic), U8(Runtime::k_ResolvePromise), R(16), U8(2), + B(Star), R(13), B(LdaZero), B(Star), R(12), - B(Mov), R(11), R(13), - B(Jump), U8(55), - B(Jump), U8(39), + B(Jump), U8(56), + B(Jump), U8(40), B(Star), R(16), B(CreateCatchContext), R(16), U8(8), B(Star), R(15), @@ -1268,32 +1268,37 @@ bytecodes: [ B(Star), R(18), B(LdaFalse), B(Star), R(19), - B(Mov), R(11), R(17), + B(Mov), R(0), R(17), B(InvokeIntrinsic), U8(Runtime::k_RejectPromise), R(17), U8(3), B(PopContext), R(16), - B(LdaZero), + B(LdaSmi), I8(1), B(Star), R(12), - B(Mov), R(11), R(13), + B(Mov), R(0), R(13), B(Jump), U8(16), B(LdaSmi), I8(-1), B(Star), R(13), B(Star), R(12), B(Jump), U8(8), B(Star), R(13), - B(LdaSmi), I8(1), + B(LdaSmi), I8(2), B(Star), R(12), B(LdaTheHole), B(SetPendingMessage), B(Star), R(14), B(LdaTrue), B(Star), R(16), - B(Mov), R(11), R(15), + B(Mov), R(0), R(15), B(CallJSRuntime), U8(%async_function_promise_release), R(15), U8(2), B(Ldar), R(14), B(SetPendingMessage), B(Ldar), R(12), - B(SwitchOnSmiNoFeedback), U8(9), U8(2), I8(0), - B(Jump), U8(8), + B(SwitchOnSmiNoFeedback), U8(9), U8(3), I8(0), + B(Jump), U8(21), + B(Mov), R(0), R(15), + B(Mov), R(13), R(16), + B(InvokeIntrinsic), U8(Runtime::k_ResolvePromise), R(15), U8(2), + B(Ldar), R(0), + /* 54 S> */ B(Return), B(Ldar), R(13), /* 54 S> */ B(Return), B(Ldar), R(13), @@ -1312,11 +1317,12 @@ constant pool: [ ONE_BYTE_INTERNALIZED_STRING_TYPE [""], SCOPE_INFO_TYPE, Smi [6], - Smi [9], + Smi [19], + Smi [22], ] handlers: [ - [26, 367, 375], - [29, 328, 330], + [26, 358, 366], + [29, 318, 320], [35, 188, 196], [38, 151, 153], [256, 266, 268], diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/Generators.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/Generators.golden index 641a2b2eb0..df054bd5b2 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/Generators.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/Generators.golden @@ -203,7 +203,7 @@ bytecodes: [ B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(153), + B(Wide), B(LdaSmi), I16(154), B(Star), R(14), B(LdaConstant), U8(13), B(Star), R(15), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/IIFEWithOneshotOpt.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/IIFEWithOneshotOpt.golden index f2653a6ed1..a9f03b2c28 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/IIFEWithOneshotOpt.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/IIFEWithOneshotOpt.golden @@ -19,9 +19,9 @@ snippet: " })(); " -frame size: 6 +frame size: 3 parameter count: 1 -bytecode array length: 82 +bytecode array length: 40 bytecodes: [ B(CreateMappedArguments), B(Star), R(0), @@ -31,32 +31,14 @@ bytecodes: [ /* 45 S> */ B(LdaGlobal), U8(0), U8(2), B(Star), R(1), B(LdaSmi), I8(2), - B(Star), R(4), - B(LdaConstant), U8(1), - B(Star), R(3), - B(LdaZero), - B(Star), R(5), - B(Mov), R(1), R(2), - /* 50 E> */ B(CallRuntime), U16(Runtime::kSetProperty), R(2), U8(4), + /* 50 E> */ B(StaNamedPropertyNoFeedback), R(1), U8(1), U8(0), /* 63 S> */ B(LdaGlobal), U8(0), U8(2), B(Star), R(1), /* 70 E> */ B(LdaGlobal), U8(0), U8(2), B(Star), R(2), - B(LdaConstant), U8(1), - B(Star), R(4), - B(Mov), R(2), R(3), - /* 72 E> */ B(InvokeIntrinsic), U8(Runtime::k_GetProperty), R(3), U8(2), - B(Star), R(4), - B(LdaConstant), U8(2), - B(Star), R(3), - B(LdaZero), - B(Star), R(5), - B(Mov), R(1), R(2), - /* 68 E> */ B(CallRuntime), U16(Runtime::kSetProperty), R(2), U8(4), - /* 84 S> */ B(LdaConstant), U8(3), - B(Star), R(3), - B(Mov), R(0), R(2), - /* 101 E> */ B(InvokeIntrinsic), U8(Runtime::k_GetProperty), R(2), U8(2), + /* 72 E> */ B(LdaNamedPropertyNoFeedback), R(2), U8(1), + /* 68 E> */ B(StaNamedPropertyNoFeedback), R(1), U8(2), U8(0), + /* 101 S> */ B(LdaNamedPropertyNoFeedback), R(0), U8(3), /* 108 S> */ B(Return), ] constant pool: [ @@ -81,9 +63,9 @@ snippet: " })(); " -frame size: 4 +frame size: 3 parameter count: 1 -bytecode array length: 77 +bytecode array length: 69 bytecodes: [ B(CreateMappedArguments), B(Star), R(0), @@ -112,10 +94,7 @@ bytecodes: [ B(Inc), U8(15), /* 66 E> */ B(StaGlobal), U8(1), U8(2), B(JumpLoop), U8(50), I8(0), - /* 132 S> */ B(LdaConstant), U8(4), - B(Star), R(3), - B(Mov), R(0), R(2), - /* 149 E> */ B(InvokeIntrinsic), U8(Runtime::k_GetProperty), R(2), U8(2), + /* 149 S> */ B(LdaNamedPropertyNoFeedback), R(0), U8(4), /* 156 S> */ B(Return), ] constant pool: [ @@ -143,9 +122,9 @@ snippet: " })(); " -frame size: 4 +frame size: 3 parameter count: 1 -bytecode array length: 78 +bytecode array length: 70 bytecodes: [ B(CreateMappedArguments), B(Star), R(0), @@ -174,10 +153,7 @@ bytecodes: [ B(Dec), U8(15), /* 129 E> */ B(StaGlobal), U8(1), U8(2), B(JumpLoop), U8(50), I8(0), - /* 151 S> */ B(LdaConstant), U8(4), - B(Star), R(3), - B(Mov), R(0), R(2), - /* 168 E> */ B(InvokeIntrinsic), U8(Runtime::k_GetProperty), R(2), U8(2), + /* 168 S> */ B(LdaNamedPropertyNoFeedback), R(0), U8(4), /* 175 S> */ B(Return), ] constant pool: [ @@ -205,9 +181,9 @@ snippet: " })(); " -frame size: 4 +frame size: 3 parameter count: 1 -bytecode array length: 78 +bytecode array length: 70 bytecodes: [ B(CreateMappedArguments), B(Star), R(0), @@ -236,10 +212,7 @@ bytecodes: [ /* 141 E> */ B(TestGreaterThan), R(1), U8(15), B(JumpIfFalse), U8(5), B(JumpLoop), U8(50), I8(0), - /* 154 S> */ B(LdaConstant), U8(4), - B(Star), R(3), - B(Mov), R(0), R(2), - /* 171 E> */ B(InvokeIntrinsic), U8(Runtime::k_GetProperty), R(2), U8(2), + /* 171 S> */ B(LdaNamedPropertyNoFeedback), R(0), U8(4), /* 178 S> */ B(Return), ] constant pool: [ @@ -269,9 +242,9 @@ snippet: " })(); " -frame size: 6 +frame size: 4 parameter count: 1 -bytecode array length: 121 +bytecode array length: 71 bytecodes: [ B(CreateMappedArguments), B(Star), R(0), @@ -284,44 +257,23 @@ bytecodes: [ /* 31 E> */ B(StaGlobal), U8(1), U8(0), /* 95 S> */ B(LdaGlobal), U8(1), U8(2), B(Star), R(1), - B(LdaConstant), U8(2), - B(Star), R(3), - B(Mov), R(1), R(2), - /* 101 E> */ B(InvokeIntrinsic), U8(Runtime::k_GetProperty), R(2), U8(2), + /* 101 E> */ B(LdaNamedPropertyNoFeedback), R(1), U8(2), B(Star), R(1), B(LdaSmi), I8(3), /* 104 E> */ B(TestLessThan), R(1), U8(4), - B(JumpIfFalse), U8(28), + B(JumpIfFalse), U8(15), /* 121 S> */ B(LdaGlobal), U8(1), U8(2), B(Star), R(1), B(LdaSmi), I8(3), - B(Star), R(4), - B(LdaConstant), U8(2), - B(Star), R(3), - B(LdaZero), - B(Star), R(5), - B(Mov), R(1), R(2), - /* 126 E> */ B(CallRuntime), U16(Runtime::kSetProperty), R(2), U8(4), - B(Jump), U8(40), + /* 126 E> */ B(StaNamedPropertyNoFeedback), R(1), U8(2), U8(0), + B(Jump), U8(19), /* 158 S> */ B(LdaGlobal), U8(1), U8(2), B(Star), R(1), /* 165 E> */ B(LdaGlobal), U8(1), U8(2), B(Star), R(2), - B(LdaConstant), U8(3), - B(Star), R(4), - B(Mov), R(2), R(3), - /* 167 E> */ B(InvokeIntrinsic), U8(Runtime::k_GetProperty), R(3), U8(2), - B(Star), R(4), - B(LdaConstant), U8(2), - B(Star), R(3), - B(LdaZero), - B(Star), R(5), - B(Mov), R(1), R(2), - /* 163 E> */ B(CallRuntime), U16(Runtime::kSetProperty), R(2), U8(4), - /* 189 S> */ B(LdaConstant), U8(4), - B(Star), R(3), - B(Mov), R(0), R(2), - /* 206 E> */ B(InvokeIntrinsic), U8(Runtime::k_GetProperty), R(2), U8(2), + /* 167 E> */ B(LdaNamedPropertyNoFeedback), R(2), U8(3), + /* 163 E> */ B(StaNamedPropertyNoFeedback), R(1), U8(2), U8(0), + /* 206 S> */ B(LdaNamedPropertyNoFeedback), R(0), U8(4), /* 213 S> */ B(Return), ] constant pool: [ @@ -343,23 +295,20 @@ snippet: " })(); " -frame size: 4 +frame size: 5 parameter count: 1 -bytecode array length: 32 +bytecode array length: 24 bytecodes: [ B(CreateMappedArguments), B(Star), R(0), /* 16 E> */ B(StackCheck), /* 29 S> */ B(LdaConstant), U8(0), - B(Star), R(1), + B(Star), R(3), B(LdaSmi), I8(4), - B(Star), R(2), - B(CallRuntime), U16(Runtime::kCreateArrayLiteralWithoutAllocationSite), R(1), U8(2), + B(Star), R(4), + B(CallRuntime), U16(Runtime::kCreateArrayLiteralWithoutAllocationSite), R(3), U8(2), /* 31 E> */ B(StaGlobal), U8(1), U8(0), - /* 60 S> */ B(LdaConstant), U8(2), - B(Star), R(3), - B(Mov), R(0), R(2), - /* 77 E> */ B(InvokeIntrinsic), U8(Runtime::k_GetProperty), R(2), U8(2), + /* 77 S> */ B(LdaNamedPropertyNoFeedback), R(0), U8(2), /* 84 S> */ B(Return), ] constant pool: [ @@ -379,23 +328,20 @@ snippet: " })(); " -frame size: 4 +frame size: 5 parameter count: 1 -bytecode array length: 32 +bytecode array length: 24 bytecodes: [ B(CreateMappedArguments), B(Star), R(0), /* 16 E> */ B(StackCheck), /* 29 S> */ B(LdaConstant), U8(0), - B(Star), R(1), + B(Star), R(3), B(LdaSmi), I8(37), - B(Star), R(2), - B(CallRuntime), U16(Runtime::kCreateArrayLiteralWithoutAllocationSite), R(1), U8(2), + B(Star), R(4), + B(CallRuntime), U16(Runtime::kCreateArrayLiteralWithoutAllocationSite), R(3), U8(2), /* 31 E> */ B(StaGlobal), U8(1), U8(0), - /* 45 S> */ B(LdaConstant), U8(2), - B(Star), R(3), - B(Mov), R(0), R(2), - /* 62 E> */ B(InvokeIntrinsic), U8(Runtime::k_GetProperty), R(2), U8(2), + /* 62 S> */ B(LdaNamedPropertyNoFeedback), R(0), U8(2), /* 69 S> */ B(Return), ] constant pool: [ @@ -406,3 +352,300 @@ constant pool: [ handlers: [ ] +--- +snippet: " + + this.f0 = function() {}; + this.f1 = function(a) {}; + this.f2 = function(a, b) {}; + this.f3 = function(a, b, c) {}; + this.f4 = function(a, b, c, d) {}; + this.f5 = function(a, b, c, d, e) {}; + (function() { + this.f0(); + this.f1(1); + this.f2(1, 2); + this.f3(1, 2, 3); + this.f4(1, 2, 3, 4); + this.f5(1, 2, 3, 4, 5); + return arguments.callee; + })(); + +" +frame size: 8 +parameter count: 1 +bytecode array length: 137 +bytecodes: [ + B(CreateMappedArguments), + B(Star), R(0), + /* 237 E> */ B(StackCheck), + /* 255 S> */ B(LdaNamedPropertyNoFeedback), R(this), U8(0), + B(Star), R(1), + /* 255 E> */ B(CallNoFeedback), R(1), R(this), U8(1), + /* 274 S> */ B(LdaNamedPropertyNoFeedback), R(this), U8(1), + B(Star), R(1), + B(LdaSmi), I8(1), + B(Star), R(3), + B(Mov), R(this), R(2), + /* 274 E> */ B(CallNoFeedback), R(1), R(2), U8(2), + /* 294 S> */ B(LdaNamedPropertyNoFeedback), R(this), U8(2), + B(Star), R(1), + B(LdaSmi), I8(1), + B(Star), R(3), + B(LdaSmi), I8(2), + B(Star), R(4), + B(Mov), R(this), R(2), + /* 294 E> */ B(CallNoFeedback), R(1), R(2), U8(3), + /* 317 S> */ B(LdaNamedPropertyNoFeedback), R(this), U8(3), + B(Star), R(1), + B(LdaSmi), I8(1), + B(Star), R(3), + B(LdaSmi), I8(2), + B(Star), R(4), + B(LdaSmi), I8(3), + B(Star), R(5), + B(Mov), R(this), R(2), + /* 317 E> */ B(CallNoFeedback), R(1), R(2), U8(4), + /* 343 S> */ B(LdaNamedPropertyNoFeedback), R(this), U8(4), + B(Star), R(1), + B(LdaSmi), I8(1), + B(Star), R(3), + B(LdaSmi), I8(2), + B(Star), R(4), + B(LdaSmi), I8(3), + B(Star), R(5), + B(LdaSmi), I8(4), + B(Star), R(6), + B(Mov), R(this), R(2), + /* 343 E> */ B(CallNoFeedback), R(1), R(2), U8(5), + /* 372 S> */ B(LdaNamedPropertyNoFeedback), R(this), U8(5), + B(Star), R(1), + B(LdaSmi), I8(1), + B(Star), R(3), + B(LdaSmi), I8(2), + B(Star), R(4), + B(LdaSmi), I8(3), + B(Star), R(5), + B(LdaSmi), I8(4), + B(Star), R(6), + B(LdaSmi), I8(5), + B(Star), R(7), + B(Mov), R(this), R(2), + /* 372 E> */ B(CallNoFeedback), R(1), R(2), U8(6), + /* 416 S> */ B(LdaNamedPropertyNoFeedback), R(0), U8(6), + /* 423 S> */ B(Return), +] +constant pool: [ + ONE_BYTE_INTERNALIZED_STRING_TYPE ["f0"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["f1"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["f2"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["f3"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["f4"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["f5"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["callee"], +] +handlers: [ +] + +--- +snippet: " + + function f0() {} + function f1(a) {} + function f2(a, b) {} + function f3(a, b, c) {} + function f4(a, b, c, d) {} + function f5(a, b, c, d, e) {} + (function() { + f0(); + f1(1); + f2(1, 2); + f3(1, 2, 3); + f4(1, 2, 3, 4); + f5(1, 2, 3, 4, 5); + return arguments.callee; + })(); + +" +frame size: 8 +parameter count: 1 +bytecode array length: 140 +bytecodes: [ + B(CreateMappedArguments), + B(Star), R(0), + /* 189 E> */ B(StackCheck), + /* 202 S> */ B(LdaUndefined), + B(Star), R(2), + B(LdaGlobal), U8(0), U8(0), + B(Star), R(1), + /* 202 E> */ B(CallNoFeedback), R(1), R(2), U8(1), + /* 216 S> */ B(LdaUndefined), + B(Star), R(2), + B(LdaGlobal), U8(1), U8(2), + B(Star), R(1), + B(LdaSmi), I8(1), + B(Star), R(3), + /* 216 E> */ B(CallNoFeedback), R(1), R(2), U8(2), + /* 231 S> */ B(LdaUndefined), + B(Star), R(2), + B(LdaGlobal), U8(2), U8(4), + B(Star), R(1), + B(LdaSmi), I8(1), + B(Star), R(3), + B(LdaSmi), I8(2), + B(Star), R(4), + /* 231 E> */ B(CallNoFeedback), R(1), R(2), U8(3), + /* 249 S> */ B(LdaUndefined), + B(Star), R(2), + B(LdaGlobal), U8(3), U8(6), + B(Star), R(1), + B(LdaSmi), I8(1), + B(Star), R(3), + B(LdaSmi), I8(2), + B(Star), R(4), + B(LdaSmi), I8(3), + B(Star), R(5), + /* 249 E> */ B(CallNoFeedback), R(1), R(2), U8(4), + /* 270 S> */ B(LdaUndefined), + B(Star), R(2), + B(LdaGlobal), U8(4), U8(8), + B(Star), R(1), + B(LdaSmi), I8(1), + B(Star), R(3), + B(LdaSmi), I8(2), + B(Star), R(4), + B(LdaSmi), I8(3), + B(Star), R(5), + B(LdaSmi), I8(4), + B(Star), R(6), + /* 270 E> */ B(CallNoFeedback), R(1), R(2), U8(5), + /* 294 S> */ B(LdaUndefined), + B(Star), R(2), + B(LdaGlobal), U8(5), U8(10), + B(Star), R(1), + B(LdaSmi), I8(1), + B(Star), R(3), + B(LdaSmi), I8(2), + B(Star), R(4), + B(LdaSmi), I8(3), + B(Star), R(5), + B(LdaSmi), I8(4), + B(Star), R(6), + B(LdaSmi), I8(5), + B(Star), R(7), + /* 294 E> */ B(CallNoFeedback), R(1), R(2), U8(6), + /* 338 S> */ B(LdaNamedPropertyNoFeedback), R(0), U8(6), + /* 345 S> */ B(Return), +] +constant pool: [ + ONE_BYTE_INTERNALIZED_STRING_TYPE ["f0"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["f1"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["f2"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["f3"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["f4"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["f5"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["callee"], +] +handlers: [ +] + +--- +snippet: " + + var t = 0; + function f2() {}; + if (t == 0) { + (function(){ + l = {}; + l.a = 3; + l.b = 4; + f2(); + return arguments.callee; + })(); + } + +" +frame size: 3 +parameter count: 1 +bytecode array length: 46 +bytecodes: [ + B(CreateMappedArguments), + B(Star), R(0), + /* 79 E> */ B(StackCheck), + /* 93 S> */ B(CreateEmptyObjectLiteral), + /* 95 E> */ B(StaGlobal), U8(0), U8(0), + /* 111 S> */ B(LdaGlobal), U8(0), U8(2), + B(Star), R(1), + B(LdaSmi), I8(3), + /* 115 E> */ B(StaNamedPropertyNoFeedback), R(1), U8(1), U8(0), + /* 130 S> */ B(LdaGlobal), U8(0), U8(2), + B(Star), R(1), + B(LdaSmi), I8(4), + /* 134 E> */ B(StaNamedPropertyNoFeedback), R(1), U8(2), U8(0), + /* 149 S> */ B(LdaUndefined), + B(Star), R(2), + B(LdaGlobal), U8(3), U8(4), + B(Star), R(1), + /* 149 E> */ B(CallNoFeedback), R(1), R(2), U8(1), + /* 182 S> */ B(LdaNamedPropertyNoFeedback), R(0), U8(4), + /* 189 S> */ B(Return), +] +constant pool: [ + ONE_BYTE_INTERNALIZED_STRING_TYPE ["l"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["a"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["b"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["f2"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["callee"], +] +handlers: [ +] + +--- +snippet: " + + function f2() {}; + function f() { + return (function(){ + l = {}; + l.a = 3; + l.b = 4; + f2(); + return arguments.callee; + })(); + } + f(); + +" +frame size: 2 +parameter count: 1 +bytecode array length: 43 +bytecodes: [ + B(CreateMappedArguments), + B(Star), R(0), + /* 76 E> */ B(StackCheck), + /* 92 S> */ B(CreateEmptyObjectLiteral), + /* 94 E> */ B(StaGlobal), U8(0), U8(0), + /* 112 S> */ B(LdaGlobal), U8(0), U8(2), + B(Star), R(1), + B(LdaSmi), I8(3), + /* 116 E> */ B(StaNamedProperty), R(1), U8(1), U8(4), + /* 133 S> */ B(LdaGlobal), U8(0), U8(2), + B(Star), R(1), + B(LdaSmi), I8(4), + /* 137 E> */ B(StaNamedProperty), R(1), U8(2), U8(6), + /* 154 S> */ B(LdaGlobal), U8(3), U8(8), + B(Star), R(1), + /* 154 E> */ B(CallUndefinedReceiver0), R(1), U8(10), + /* 189 S> */ B(LdaNamedProperty), R(0), U8(4), U8(12), + /* 196 S> */ B(Return), +] +constant pool: [ + ONE_BYTE_INTERNALIZED_STRING_TYPE ["l"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["a"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["b"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["f2"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["callee"], +] +handlers: [ +] + diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/IIFEWithoutOneshotOpt.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/IIFEWithoutOneshotOpt.golden index f116bdc68f..efe9078eea 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/IIFEWithoutOneshotOpt.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/IIFEWithoutOneshotOpt.golden @@ -107,3 +107,186 @@ constant pool: [ handlers: [ ] +--- +snippet: " + + this.f0 = function() {}; + this.f1 = function(a) {}; + this.f2 = function(a, b) {}; + this.f3 = function(a, b, c) {}; + this.f4 = function(a, b, c, d) {}; + this.f5 = function(a, b, c, d, e) {}; + (function() { + this.f0(); + this.f1(1); + this.f2(1, 2); + this.f3(1, 2, 3); + this.f4(1, 2, 3, 4); + this.f5(1, 2, 3, 4, 5); + return arguments.callee; + })(); + +" +frame size: 8 +parameter count: 1 +bytecode array length: 144 +bytecodes: [ + B(CreateMappedArguments), + B(Star), R(0), + /* 237 E> */ B(StackCheck), + /* 255 S> */ B(LdaNamedProperty), R(this), U8(0), U8(0), + B(Star), R(1), + /* 255 E> */ B(CallProperty0), R(1), R(this), U8(2), + /* 274 S> */ B(LdaNamedProperty), R(this), U8(1), U8(4), + B(Star), R(1), + B(LdaSmi), I8(1), + B(Star), R(3), + /* 274 E> */ B(CallProperty1), R(1), R(this), R(3), U8(6), + /* 294 S> */ B(LdaNamedProperty), R(this), U8(2), U8(8), + B(Star), R(1), + B(LdaSmi), I8(1), + B(Star), R(3), + B(LdaSmi), I8(2), + B(Star), R(4), + /* 294 E> */ B(CallProperty2), R(1), R(this), R(3), R(4), U8(10), + /* 317 S> */ B(LdaNamedProperty), R(this), U8(3), U8(12), + B(Star), R(1), + B(LdaSmi), I8(1), + B(Star), R(3), + B(LdaSmi), I8(2), + B(Star), R(4), + B(LdaSmi), I8(3), + B(Star), R(5), + B(Mov), R(this), R(2), + /* 317 E> */ B(CallProperty), R(1), R(2), U8(4), U8(14), + /* 343 S> */ B(LdaNamedProperty), R(this), U8(4), U8(16), + B(Star), R(1), + B(LdaSmi), I8(1), + B(Star), R(3), + B(LdaSmi), I8(2), + B(Star), R(4), + B(LdaSmi), I8(3), + B(Star), R(5), + B(LdaSmi), I8(4), + B(Star), R(6), + B(Mov), R(this), R(2), + /* 343 E> */ B(CallProperty), R(1), R(2), U8(5), U8(18), + /* 372 S> */ B(LdaNamedProperty), R(this), U8(5), U8(20), + B(Star), R(1), + B(LdaSmi), I8(1), + B(Star), R(3), + B(LdaSmi), I8(2), + B(Star), R(4), + B(LdaSmi), I8(3), + B(Star), R(5), + B(LdaSmi), I8(4), + B(Star), R(6), + B(LdaSmi), I8(5), + B(Star), R(7), + B(Mov), R(this), R(2), + /* 372 E> */ B(CallProperty), R(1), R(2), U8(6), U8(22), + /* 416 S> */ B(LdaNamedProperty), R(0), U8(6), U8(24), + /* 423 S> */ B(Return), +] +constant pool: [ + ONE_BYTE_INTERNALIZED_STRING_TYPE ["f0"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["f1"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["f2"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["f3"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["f4"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["f5"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["callee"], +] +handlers: [ +] + +--- +snippet: " + + function f0() {} + function f1(a) {} + function f2(a, b) {} + function f3(a, b, c) {} + function f4(a, b, c, d) {} + function f5(a, b, c, d, e) {} + (function() { + f0(); + f1(1); + f2(1, 2); + f3(1, 2, 3); + f4(1, 2, 3, 4); + f5(1, 2, 3, 4, 5); + return arguments.callee; + })(); + +" +frame size: 7 +parameter count: 1 +bytecode array length: 126 +bytecodes: [ + B(CreateMappedArguments), + B(Star), R(0), + /* 189 E> */ B(StackCheck), + /* 202 S> */ B(LdaGlobal), U8(0), U8(0), + B(Star), R(1), + /* 202 E> */ B(CallUndefinedReceiver0), R(1), U8(2), + /* 216 S> */ B(LdaGlobal), U8(1), U8(4), + B(Star), R(1), + B(LdaSmi), I8(1), + B(Star), R(2), + /* 216 E> */ B(CallUndefinedReceiver1), R(1), R(2), U8(6), + /* 231 S> */ B(LdaGlobal), U8(2), U8(8), + B(Star), R(1), + B(LdaSmi), I8(1), + B(Star), R(2), + B(LdaSmi), I8(2), + B(Star), R(3), + /* 231 E> */ B(CallUndefinedReceiver2), R(1), R(2), R(3), U8(10), + /* 249 S> */ B(LdaGlobal), U8(3), U8(12), + B(Star), R(1), + B(LdaSmi), I8(1), + B(Star), R(2), + B(LdaSmi), I8(2), + B(Star), R(3), + B(LdaSmi), I8(3), + B(Star), R(4), + /* 249 E> */ B(CallUndefinedReceiver), R(1), R(2), U8(3), U8(14), + /* 270 S> */ B(LdaGlobal), U8(4), U8(16), + B(Star), R(1), + B(LdaSmi), I8(1), + B(Star), R(2), + B(LdaSmi), I8(2), + B(Star), R(3), + B(LdaSmi), I8(3), + B(Star), R(4), + B(LdaSmi), I8(4), + B(Star), R(5), + /* 270 E> */ B(CallUndefinedReceiver), R(1), R(2), U8(4), U8(18), + /* 294 S> */ B(LdaGlobal), U8(5), U8(20), + B(Star), R(1), + B(LdaSmi), I8(1), + B(Star), R(2), + B(LdaSmi), I8(2), + B(Star), R(3), + B(LdaSmi), I8(3), + B(Star), R(4), + B(LdaSmi), I8(4), + B(Star), R(5), + B(LdaSmi), I8(5), + B(Star), R(6), + /* 294 E> */ B(CallUndefinedReceiver), R(1), R(2), U8(5), U8(22), + /* 338 S> */ B(LdaNamedProperty), R(0), U8(6), U8(24), + /* 345 S> */ B(Return), +] +constant pool: [ + ONE_BYTE_INTERNALIZED_STRING_TYPE ["f0"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["f1"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["f2"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["f3"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["f4"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["f5"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["callee"], +] +handlers: [ +] + diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/NewAndSpread.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/NewAndSpread.golden index bdfb35c70b..056f9d7b84 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/NewAndSpread.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/NewAndSpread.golden @@ -86,7 +86,7 @@ snippet: " " frame size: 10 parameter count: 1 -bytecode array length: 127 +bytecode array length: 124 bytecodes: [ /* 30 E> */ B(StackCheck), B(LdaTheHole), @@ -101,37 +101,35 @@ bytecodes: [ B(Mov), R(4), R(0), B(Mov), R(0), R(1), /* 89 S> */ B(CreateArrayLiteral), U8(2), U8(1), U8(37), - B(Star), R(3), - B(LdaConstant), U8(3), B(Star), R(4), - /* 101 S> */ B(CreateArrayLiteral), U8(4), U8(7), U8(37), + B(LdaConstant), U8(3), + B(Star), R(3), + /* 101 S> */ B(CreateArrayLiteral), U8(4), U8(5), U8(37), B(Star), R(8), - B(LdaNamedProperty), R(8), U8(5), U8(8), + B(LdaNamedProperty), R(8), U8(5), U8(6), B(Star), R(9), - B(CallProperty0), R(9), R(8), U8(10), + B(CallProperty0), R(9), R(8), U8(8), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), B(Star), R(7), - B(LdaNamedProperty), R(7), U8(6), U8(12), + B(LdaNamedProperty), R(7), U8(6), U8(10), B(Star), R(6), - B(CallProperty0), R(6), R(7), U8(14), + B(CallProperty0), R(6), R(7), U8(12), B(Star), R(5), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(5), U8(1), - B(LdaNamedProperty), R(5), U8(7), U8(16), + B(LdaNamedProperty), R(5), U8(7), U8(14), B(JumpIfToBooleanTrue), U8(21), - B(LdaNamedProperty), R(5), U8(8), U8(18), + B(LdaNamedProperty), R(5), U8(8), U8(16), B(Star), R(5), - B(StaInArrayLiteral), R(3), R(4), U8(2), - B(Ldar), R(4), - B(Inc), U8(4), - B(Star), R(4), + B(StaInArrayLiteral), R(4), R(3), U8(3), + B(Ldar), R(3), + B(Inc), U8(2), + B(Star), R(3), B(JumpLoop), U8(35), I8(0), B(LdaSmi), I8(4), - B(StaInArrayLiteral), R(3), R(4), U8(2), - B(Ldar), R(4), - B(Inc), U8(4), - B(Star), R(4), + B(StaInArrayLiteral), R(4), R(3), U8(3), + B(Mov), R(4), R(3), B(CallJSRuntime), U8(%reflect_construct), R(2), U8(2), B(LdaUndefined), /* 116 S> */ B(Return), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/ObjectLiterals.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/ObjectLiterals.golden index fa64ffa2a4..a1f4d78f7c 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/ObjectLiterals.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/ObjectLiterals.golden @@ -246,7 +246,7 @@ bytecodes: [ B(Star), R(5), B(Mov), R(1), R(2), B(Mov), R(0), R(4), - /* 57 E> */ B(CallRuntime), U16(Runtime::kSetProperty), R(2), U8(4), + /* 57 E> */ B(CallRuntime), U16(Runtime::kSetKeyedProperty), R(2), U8(4), B(Ldar), R(2), /* 61 S> */ B(Return), ] diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/PropertyLoadStoreOneShot.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/PropertyLoadStoreOneShot.golden index 3bc175b7da..e6eacf6fd6 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/PropertyLoadStoreOneShot.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/PropertyLoadStoreOneShot.golden @@ -20,9 +20,9 @@ snippet: " l['a'] = l['b']; " -frame size: 7 +frame size: 4 parameter count: 1 -bytecode array length: 128 +bytecode array length: 77 bytecodes: [ /* 0 E> */ B(StackCheck), /* 7 S> */ B(LdaConstant), U8(0), @@ -33,46 +33,25 @@ bytecodes: [ /* 9 E> */ B(StaGlobal), U8(1), U8(0), /* 60 S> */ B(LdaGlobal), U8(1), U8(3), B(Star), R(1), - B(LdaConstant), U8(2), - B(Star), R(3), - B(Mov), R(1), R(2), - /* 65 E> */ B(InvokeIntrinsic), U8(Runtime::k_GetProperty), R(2), U8(2), + /* 65 E> */ B(LdaNamedPropertyNoFeedback), R(1), U8(2), B(Star), R(1), /* 73 E> */ B(LdaGlobal), U8(1), U8(3), B(Star), R(2), - B(LdaConstant), U8(3), - B(Star), R(4), - B(Mov), R(2), R(3), - /* 74 E> */ B(InvokeIntrinsic), U8(Runtime::k_GetProperty), R(3), U8(2), + /* 74 E> */ B(LdaNamedPropertyNoFeedback), R(2), U8(3), /* 71 E> */ B(Add), R(1), U8(2), /* 62 E> */ B(StaGlobal), U8(4), U8(5), /* 87 S> */ B(LdaGlobal), U8(1), U8(3), B(Star), R(1), B(LdaSmi), I8(7), - B(Star), R(4), - B(LdaConstant), U8(3), - B(Star), R(3), - B(LdaZero), - B(Star), R(5), - B(Mov), R(1), R(2), - /* 94 E> */ B(CallRuntime), U16(Runtime::kSetProperty), R(2), U8(4), + /* 94 E> */ B(StaNamedPropertyNoFeedback), R(1), U8(3), U8(0), /* 105 S> */ B(LdaGlobal), U8(1), U8(3), B(Star), R(1), /* 114 E> */ B(LdaGlobal), U8(1), U8(3), B(Star), R(2), - B(LdaConstant), U8(3), - B(Star), R(4), - B(Mov), R(2), R(3), - /* 115 E> */ B(InvokeIntrinsic), U8(Runtime::k_GetProperty), R(3), U8(2), + /* 115 E> */ B(LdaNamedPropertyNoFeedback), R(2), U8(3), B(Star), R(2), - B(LdaConstant), U8(2), - B(Star), R(4), - B(LdaZero), - B(Star), R(6), - B(Mov), R(1), R(3), - B(Mov), R(2), R(5), - /* 112 E> */ B(CallRuntime), U16(Runtime::kSetProperty), R(3), U8(4), - B(Mov), R(5), R(0), + /* 112 E> */ B(StaNamedPropertyNoFeedback), R(1), U8(2), U8(0), + B(Mov), R(2), R(0), B(Ldar), R(0), /* 128 S> */ B(Return), ] @@ -307,9 +286,9 @@ snippet: " } " -frame size: 7 +frame size: 4 parameter count: 1 -bytecode array length: 111 +bytecode array length: 75 bytecodes: [ /* 0 E> */ B(StackCheck), /* 7 S> */ B(LdaConstant), U8(0), @@ -320,40 +299,25 @@ bytecodes: [ /* 9 E> */ B(StaGlobal), U8(1), U8(0), /* 63 S> */ B(LdaGlobal), U8(1), U8(2), B(Star), R(1), - B(LdaConstant), U8(2), - B(Star), R(3), - B(Mov), R(1), R(2), - /* 68 E> */ B(InvokeIntrinsic), U8(Runtime::k_GetProperty), R(2), U8(2), + /* 68 E> */ B(LdaNamedPropertyNoFeedback), R(1), U8(2), B(Star), R(1), B(LdaSmi), I8(3), /* 74 E> */ B(TestLessThan), R(1), U8(4), - B(JumpIfFalse), U8(36), + B(JumpIfFalse), U8(22), /* 89 S> */ B(LdaGlobal), U8(1), U8(2), B(Star), R(1), B(LdaSmi), I8(3), B(Star), R(2), - B(LdaConstant), U8(2), - B(Star), R(4), - B(LdaZero), - B(Star), R(6), - B(Mov), R(1), R(3), - B(Mov), R(2), R(5), - /* 96 E> */ B(CallRuntime), U16(Runtime::kSetProperty), R(3), U8(4), - B(Mov), R(5), R(0), + /* 96 E> */ B(StaNamedPropertyNoFeedback), R(1), U8(2), U8(0), + B(Mov), R(2), R(0), B(Ldar), R(2), - B(Jump), U8(34), + B(Jump), U8(20), /* 124 S> */ B(LdaGlobal), U8(1), U8(2), B(Star), R(1), B(LdaSmi), I8(3), B(Star), R(2), - B(LdaConstant), U8(3), - B(Star), R(4), - B(LdaZero), - B(Star), R(6), - B(Mov), R(1), R(3), - B(Mov), R(2), R(5), - /* 131 E> */ B(CallRuntime), U16(Runtime::kSetProperty), R(3), U8(4), - B(Mov), R(5), R(0), + /* 131 E> */ B(StaNamedPropertyNoFeedback), R(1), U8(3), U8(0), + B(Mov), R(2), R(0), B(Ldar), R(2), B(Ldar), R(0), /* 150 S> */ B(Return), @@ -373,16 +337,16 @@ snippet: " a = [1.1, [2.2, 4.5]]; " -frame size: 3 +frame size: 5 parameter count: 1 bytecode array length: 20 bytecodes: [ /* 0 E> */ B(StackCheck), /* 7 S> */ B(LdaConstant), U8(0), - B(Star), R(1), + B(Star), R(3), B(LdaSmi), I8(4), - B(Star), R(2), - B(CallRuntime), U16(Runtime::kCreateArrayLiteralWithoutAllocationSite), R(1), U8(2), + B(Star), R(4), + B(CallRuntime), U16(Runtime::kCreateArrayLiteralWithoutAllocationSite), R(3), U8(2), /* 9 E> */ B(StaGlobal), U8(1), U8(0), B(Star), R(0), /* 36 S> */ B(Return), @@ -400,16 +364,16 @@ snippet: " b = []; " -frame size: 3 +frame size: 5 parameter count: 1 bytecode array length: 20 bytecodes: [ /* 0 E> */ B(StackCheck), /* 7 S> */ B(LdaConstant), U8(0), - B(Star), R(1), + B(Star), R(3), B(LdaSmi), I8(37), - B(Star), R(2), - B(CallRuntime), U16(Runtime::kCreateArrayLiteralWithoutAllocationSite), R(1), U8(2), + B(Star), R(4), + B(CallRuntime), U16(Runtime::kCreateArrayLiteralWithoutAllocationSite), R(3), U8(2), /* 9 E> */ B(StaGlobal), U8(1), U8(0), B(Star), R(0), /* 21 S> */ B(Return), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/PublicClassFields.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/PublicClassFields.golden index 4607d37d4b..cb09c45b1a 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/PublicClassFields.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/PublicClassFields.golden @@ -37,7 +37,7 @@ bytecodes: [ B(Star), R(5), B(LdaConstant), U8(1), B(Star), R(6), - B(LdaConstant), U8(3), + /* 60 S> */ B(LdaConstant), U8(3), B(StaCurrentContextSlot), U8(4), B(Star), R(9), B(Mov), R(5), R(7), @@ -59,7 +59,7 @@ bytecodes: [ B(Star), R(5), B(LdaConstant), U8(7), B(Star), R(6), - B(LdaConstant), U8(3), + /* 99 S> */ B(LdaConstant), U8(3), B(StaCurrentContextSlot), U8(4), B(Star), R(9), B(Mov), R(5), R(7), @@ -145,7 +145,7 @@ bytecodes: [ B(Star), R(7), B(LdaConstant), U8(1), B(Star), R(8), - B(LdaConstant), U8(5), + /* 77 S> */ B(LdaConstant), U8(5), B(StaCurrentContextSlot), U8(4), B(Star), R(11), B(Mov), R(7), R(9), @@ -175,7 +175,7 @@ bytecodes: [ B(Star), R(7), B(LdaConstant), U8(9), B(Star), R(8), - B(LdaConstant), U8(5), + /* 133 S> */ B(LdaConstant), U8(5), B(StaCurrentContextSlot), U8(4), B(Star), R(11), B(CreateClosure), U8(13), U8(7), U8(2), @@ -198,7 +198,7 @@ bytecodes: [ B(Star), R(7), B(LdaConstant), U8(16), B(Star), R(8), - B(LdaConstant), U8(5), + /* 256 S> */ B(LdaConstant), U8(5), B(StaCurrentContextSlot), U8(4), B(Star), R(11), B(Mov), R(7), R(9), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/StandardForLoop.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/StandardForLoop.golden index d870c4362f..849f7beba3 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/StandardForLoop.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/StandardForLoop.golden @@ -381,35 +381,32 @@ snippet: " " frame size: 12 parameter count: 1 -bytecode array length: 140 +bytecode array length: 144 bytecodes: [ /* 16 E> */ B(StackCheck), B(CallJSRuntime), U8(%async_function_promise_create), R(0), U8(0), - B(Star), R(3), + B(Star), R(0), B(Mov), R(context), R(6), B(Mov), R(context), R(7), /* 36 S> */ B(LdaZero), - B(Star), R(1), + B(Star), R(2), /* 41 S> */ B(LdaSmi), I8(10), - /* 41 E> */ B(TestLessThan), R(1), U8(0), + /* 41 E> */ B(TestLessThan), R(2), U8(0), B(JumpIfFalse), U8(15), /* 23 E> */ B(StackCheck), - /* 62 S> */ B(Mov), R(1), R(0), - /* 49 S> */ B(Ldar), R(0), + /* 62 S> */ B(Mov), R(2), R(1), + /* 49 S> */ B(Ldar), R(1), B(Inc), U8(1), - B(Star), R(1), + B(Star), R(2), B(JumpLoop), U8(17), I8(0), B(LdaUndefined), - B(Star), R(9), - B(Mov), R(3), R(8), - /* 49 E> */ B(InvokeIntrinsic), U8(Runtime::k_ResolvePromise), R(8), U8(2), + B(Star), R(5), B(LdaZero), B(Star), R(4), - B(Mov), R(3), R(5), - B(Jump), U8(55), - B(Jump), U8(39), + B(Jump), U8(56), + B(Jump), U8(40), B(Star), R(8), - B(CreateCatchContext), R(8), U8(0), + /* 49 E> */ B(CreateCatchContext), R(8), U8(0), B(Star), R(7), B(LdaTheHole), B(SetPendingMessage), @@ -419,32 +416,37 @@ bytecodes: [ B(Star), R(10), B(LdaFalse), B(Star), R(11), - B(Mov), R(3), R(9), + B(Mov), R(0), R(9), B(InvokeIntrinsic), U8(Runtime::k_RejectPromise), R(9), U8(3), B(PopContext), R(8), - B(LdaZero), + B(LdaSmi), I8(1), B(Star), R(4), - B(Mov), R(3), R(5), + B(Mov), R(0), R(5), B(Jump), U8(16), B(LdaSmi), I8(-1), B(Star), R(5), B(Star), R(4), B(Jump), U8(8), B(Star), R(5), - B(LdaSmi), I8(1), + B(LdaSmi), I8(2), B(Star), R(4), B(LdaTheHole), B(SetPendingMessage), B(Star), R(6), B(LdaFalse), B(Star), R(8), - B(Mov), R(3), R(7), + B(Mov), R(0), R(7), B(CallJSRuntime), U8(%async_function_promise_release), R(7), U8(2), B(Ldar), R(6), B(SetPendingMessage), B(Ldar), R(4), - B(SwitchOnSmiNoFeedback), U8(1), U8(2), I8(0), - B(Jump), U8(8), + B(SwitchOnSmiNoFeedback), U8(1), U8(3), I8(0), + B(Jump), U8(21), + B(Mov), R(0), R(7), + B(Mov), R(5), R(8), + B(InvokeIntrinsic), U8(Runtime::k_ResolvePromise), R(7), U8(2), + B(Ldar), R(0), + /* 67 S> */ B(Return), B(Ldar), R(5), /* 67 S> */ B(Return), B(Ldar), R(5), @@ -455,11 +457,12 @@ bytecodes: [ constant pool: [ SCOPE_INFO_TYPE, Smi [6], - Smi [9], + Smi [19], + Smi [22], ] handlers: [ - [10, 93, 101], - [13, 54, 56], + [10, 84, 92], + [13, 44, 46], ] --- @@ -471,53 +474,50 @@ snippet: " " frame size: 11 parameter count: 1 -bytecode array length: 191 +bytecode array length: 195 bytecodes: [ - B(SwitchOnGeneratorState), R(1), U8(0), U8(1), + B(SwitchOnGeneratorState), R(2), U8(0), U8(1), B(Mov), R(closure), R(3), B(Mov), R(this), R(4), B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(3), U8(2), - B(Star), R(1), + B(Star), R(2), /* 16 E> */ B(StackCheck), B(CallJSRuntime), U8(%async_function_promise_create), R(0), U8(0), - B(Star), R(2), + B(Star), R(0), B(Mov), R(context), R(5), B(Mov), R(context), R(6), /* 36 S> */ B(LdaZero), - B(Star), R(0), + B(Star), R(1), /* 41 S> */ B(LdaSmi), I8(10), - /* 41 E> */ B(TestLessThan), R(0), U8(0), + /* 41 E> */ B(TestLessThan), R(1), U8(0), B(JumpIfFalse), U8(50), /* 23 E> */ B(StackCheck), - /* 52 S> */ B(Mov), R(1), R(7), - B(Mov), R(0), R(8), - B(Mov), R(2), R(9), + /* 52 S> */ B(Mov), R(2), R(7), + B(Mov), R(1), R(8), + B(Mov), R(0), R(9), B(CallJSRuntime), U8(%async_function_await_uncaught), R(7), U8(3), - /* 52 E> */ B(SuspendGenerator), R(1), R(0), U8(7), U8(0), - B(ResumeGenerator), R(1), R(0), U8(7), + /* 52 E> */ B(SuspendGenerator), R(2), R(0), U8(7), U8(0), + B(ResumeGenerator), R(2), R(0), U8(7), B(Star), R(7), - B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(1), U8(1), + B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(2), U8(1), B(Star), R(8), B(LdaZero), B(TestReferenceEqual), R(8), B(JumpIfTrue), U8(5), B(Ldar), R(7), B(ReThrow), - /* 49 S> */ B(Ldar), R(0), + /* 49 S> */ B(Ldar), R(1), B(Inc), U8(1), - B(Star), R(0), + B(Star), R(1), B(JumpLoop), U8(52), I8(0), B(LdaUndefined), - B(Star), R(8), - B(Mov), R(2), R(7), - /* 49 E> */ B(InvokeIntrinsic), U8(Runtime::k_ResolvePromise), R(7), U8(2), + B(Star), R(4), B(LdaZero), B(Star), R(3), - B(Mov), R(2), R(4), - B(Jump), U8(55), - B(Jump), U8(39), + B(Jump), U8(56), + B(Jump), U8(40), B(Star), R(7), - B(CreateCatchContext), R(7), U8(1), + /* 49 E> */ B(CreateCatchContext), R(7), U8(1), B(Star), R(6), B(LdaTheHole), B(SetPendingMessage), @@ -527,32 +527,37 @@ bytecodes: [ B(Star), R(9), B(LdaFalse), B(Star), R(10), - B(Mov), R(2), R(8), + B(Mov), R(0), R(8), B(InvokeIntrinsic), U8(Runtime::k_RejectPromise), R(8), U8(3), B(PopContext), R(7), - B(LdaZero), + B(LdaSmi), I8(1), B(Star), R(3), - B(Mov), R(2), R(4), + B(Mov), R(0), R(4), B(Jump), U8(16), B(LdaSmi), I8(-1), B(Star), R(4), B(Star), R(3), B(Jump), U8(8), B(Star), R(4), - B(LdaSmi), I8(1), + B(LdaSmi), I8(2), B(Star), R(3), B(LdaTheHole), B(SetPendingMessage), B(Star), R(5), B(LdaTrue), B(Star), R(7), - B(Mov), R(2), R(6), + B(Mov), R(0), R(6), B(CallJSRuntime), U8(%async_function_promise_release), R(6), U8(2), B(Ldar), R(5), B(SetPendingMessage), B(Ldar), R(3), - B(SwitchOnSmiNoFeedback), U8(2), U8(2), I8(0), - B(Jump), U8(8), + B(SwitchOnSmiNoFeedback), U8(2), U8(3), I8(0), + B(Jump), U8(21), + B(Mov), R(0), R(6), + B(Mov), R(4), R(7), + B(InvokeIntrinsic), U8(Runtime::k_ResolvePromise), R(6), U8(2), + B(Ldar), R(0), + /* 61 S> */ B(Return), B(Ldar), R(4), /* 61 S> */ B(Return), B(Ldar), R(4), @@ -564,10 +569,11 @@ constant pool: [ Smi [58], SCOPE_INFO_TYPE, Smi [6], - Smi [9], + Smi [19], + Smi [22], ] handlers: [ - [26, 144, 152], - [29, 105, 107], + [26, 135, 143], + [29, 95, 97], ] diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/StaticClassFields.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/StaticClassFields.golden index fcf5e9ae9a..da5c922456 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/StaticClassFields.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/StaticClassFields.golden @@ -44,10 +44,10 @@ bytecodes: [ B(Star), R(5), B(LdaConstant), U8(1), B(Star), R(6), - B(LdaConstant), U8(3), + /* 60 S> */ B(LdaConstant), U8(3), B(StaCurrentContextSlot), U8(4), B(Star), R(9), - B(LdaConstant), U8(4), + /* 92 S> */ B(LdaConstant), U8(4), B(Star), R(10), B(LdaConstant), U8(5), B(TestEqualStrict), R(10), U8(1), @@ -79,10 +79,10 @@ bytecodes: [ B(Star), R(5), B(LdaConstant), U8(10), B(Star), R(6), - B(LdaConstant), U8(3), + /* 131 S> */ B(LdaConstant), U8(3), B(StaCurrentContextSlot), U8(4), B(Star), R(9), - B(LdaConstant), U8(4), + /* 176 S> */ B(LdaConstant), U8(4), B(Star), R(10), B(LdaConstant), U8(5), B(TestEqualStrict), R(10), U8(1), @@ -188,10 +188,10 @@ bytecodes: [ B(Star), R(7), B(LdaConstant), U8(1), B(Star), R(8), - B(LdaConstant), U8(5), + /* 77 S> */ B(LdaConstant), U8(5), B(StaCurrentContextSlot), U8(4), B(Star), R(11), - B(LdaConstant), U8(6), + /* 109 S> */ B(LdaConstant), U8(6), B(Star), R(12), B(LdaConstant), U8(7), B(TestEqualStrict), R(12), U8(2), @@ -231,10 +231,10 @@ bytecodes: [ B(Star), R(7), B(LdaConstant), U8(12), B(Star), R(8), - B(LdaConstant), U8(5), + /* 165 S> */ B(LdaConstant), U8(5), B(StaCurrentContextSlot), U8(4), B(Star), R(11), - B(LdaConstant), U8(6), + /* 210 S> */ B(LdaConstant), U8(6), B(Star), R(12), B(LdaConstant), U8(7), B(TestEqualStrict), R(12), U8(2), @@ -267,10 +267,10 @@ bytecodes: [ B(Star), R(7), B(LdaConstant), U8(20), B(Star), R(8), - B(LdaConstant), U8(5), + /* 333 S> */ B(LdaConstant), U8(5), B(StaCurrentContextSlot), U8(4), B(Star), R(11), - B(LdaConstant), U8(6), + /* 378 S> */ B(LdaConstant), U8(6), B(Star), R(12), B(LdaConstant), U8(7), B(TestEqualStrict), R(12), U8(2), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/SuperCallAndSpread.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/SuperCallAndSpread.golden index 39e41739e1..42238ac049 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/SuperCallAndSpread.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/SuperCallAndSpread.golden @@ -93,7 +93,7 @@ snippet: " " frame size: 13 parameter count: 1 -bytecode array length: 137 +bytecode array length: 130 bytecodes: [ B(CreateRestParameter), B(Star), R(2), @@ -103,55 +103,51 @@ bytecodes: [ /* 140 S> */ B(Ldar), R(closure), B(GetSuperConstructor), R(5), B(CreateEmptyArrayLiteral), U8(0), - B(Star), R(6), - B(LdaZero), B(Star), R(7), + B(LdaZero), + B(Star), R(6), B(LdaSmi), I8(1), - B(StaKeyedProperty), R(6), R(7), U8(1), - B(LdaConstant), U8(0), - /* 152 S> */ B(Star), R(7), - B(LdaNamedProperty), R(2), U8(1), U8(8), + B(StaInArrayLiteral), R(7), R(6), U8(1), + B(Ldar), R(6), + B(Inc), U8(3), + /* 152 S> */ B(Star), R(6), + B(LdaNamedProperty), R(2), U8(0), U8(4), B(Star), R(12), - B(CallProperty0), R(12), R(2), U8(10), + B(CallProperty0), R(12), R(2), U8(6), B(Mov), R(2), R(11), B(Mov), R(1), R(4), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), B(Star), R(10), - B(LdaNamedProperty), R(10), U8(2), U8(12), + B(LdaNamedProperty), R(10), U8(1), U8(8), B(Star), R(9), - B(CallProperty0), R(9), R(10), U8(14), + B(CallProperty0), R(9), R(10), U8(10), B(Star), R(8), B(JumpIfJSReceiver), U8(7), B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(8), U8(1), - B(LdaNamedProperty), R(8), U8(3), U8(16), + B(LdaNamedProperty), R(8), U8(2), U8(12), B(JumpIfToBooleanTrue), U8(21), - B(LdaNamedProperty), R(8), U8(4), U8(18), + B(LdaNamedProperty), R(8), U8(3), U8(14), B(Star), R(8), - B(StaInArrayLiteral), R(6), R(7), U8(3), - B(Ldar), R(7), - B(Inc), U8(5), - B(Star), R(7), + B(StaInArrayLiteral), R(7), R(6), U8(1), + B(Ldar), R(6), + B(Inc), U8(3), + B(Star), R(6), B(JumpLoop), U8(35), I8(0), B(LdaSmi), I8(1), - B(StaInArrayLiteral), R(6), R(7), U8(3), - B(Ldar), R(7), - B(Inc), U8(5), - B(Star), R(7), - B(Mov), R(5), R(8), - B(Mov), R(6), R(9), - B(Mov), R(0), R(10), - /* 140 E> */ B(CallJSRuntime), U8(%reflect_construct), R(8), U8(3), - B(Star), R(11), + B(StaInArrayLiteral), R(7), R(6), U8(1), + B(Mov), R(5), R(6), + B(Mov), R(0), R(8), + /* 140 E> */ B(CallJSRuntime), U8(%reflect_construct), R(6), U8(3), + B(Star), R(9), B(Ldar), R(this), B(ThrowSuperAlreadyCalledIfNotHole), - B(Mov), R(11), R(this), + B(Mov), R(9), R(this), B(Ldar), R(this), B(ThrowSuperNotCalledIfHole), /* 162 S> */ B(Return), ] constant pool: [ - Smi [1], SYMBOL_TYPE, ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], diff --git a/deps/v8/test/cctest/interpreter/interpreter-tester.cc b/deps/v8/test/cctest/interpreter/interpreter-tester.cc index acb06f2d8a..855e01e786 100644 --- a/deps/v8/test/cctest/interpreter/interpreter-tester.cc +++ b/deps/v8/test/cctest/interpreter/interpreter-tester.cc @@ -38,7 +38,7 @@ InterpreterTester::InterpreterTester(Isolate* isolate, const char* source, : InterpreterTester(isolate, source, MaybeHandle<BytecodeArray>(), MaybeHandle<FeedbackMetadata>(), filter) {} -InterpreterTester::~InterpreterTester() {} +InterpreterTester::~InterpreterTester() = default; Local<Message> InterpreterTester::CheckThrowsReturnMessage() { TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate_)); diff --git a/deps/v8/test/cctest/interpreter/interpreter-tester.h b/deps/v8/test/cctest/interpreter/interpreter-tester.h index d795b7ffcd..d670252242 100644 --- a/deps/v8/test/cctest/interpreter/interpreter-tester.h +++ b/deps/v8/test/cctest/interpreter/interpreter-tester.h @@ -36,7 +36,7 @@ class InterpreterCallable { public: InterpreterCallable(Isolate* isolate, Handle<JSFunction> function) : isolate_(isolate), function_(function) {} - virtual ~InterpreterCallable() {} + virtual ~InterpreterCallable() = default; MaybeHandle<Object> operator()(A... args) { return CallInterpreter(isolate_, function_, args...); diff --git a/deps/v8/test/cctest/interpreter/test-bytecode-generator.cc b/deps/v8/test/cctest/interpreter/test-bytecode-generator.cc index 0ec28d3653..e81b0cf981 100644 --- a/deps/v8/test/cctest/interpreter/test-bytecode-generator.cc +++ b/deps/v8/test/cctest/interpreter/test-bytecode-generator.cc @@ -627,6 +627,69 @@ TEST(IIFEWithOneshotOpt) { return arguments.callee; })(); )", + // CallNoFeedback instead of CallProperty + R"( + this.f0 = function() {}; + this.f1 = function(a) {}; + this.f2 = function(a, b) {}; + this.f3 = function(a, b, c) {}; + this.f4 = function(a, b, c, d) {}; + this.f5 = function(a, b, c, d, e) {}; + (function() { + this.f0(); + this.f1(1); + this.f2(1, 2); + this.f3(1, 2, 3); + this.f4(1, 2, 3, 4); + this.f5(1, 2, 3, 4, 5); + return arguments.callee; + })(); + )", + // CallNoFeedback instead of CallUndefinedReceiver + R"( + function f0() {} + function f1(a) {} + function f2(a, b) {} + function f3(a, b, c) {} + function f4(a, b, c, d) {} + function f5(a, b, c, d, e) {} + (function() { + f0(); + f1(1); + f2(1, 2); + f3(1, 2, 3); + f4(1, 2, 3, 4); + f5(1, 2, 3, 4, 5); + return arguments.callee; + })(); + )", + R"( + var t = 0; + function f2() {}; + if (t == 0) { + (function(){ + l = {}; + l.a = 3; + l.b = 4; + f2(); + return arguments.callee; + })(); + } + )", + // No one-shot opt for IIFE`s within a function + R"( + function f2() {}; + function f() { + return (function(){ + l = {}; + l.a = 3; + l.b = 4; + f2(); + return arguments.callee; + })(); + } + f(); + )", }; CHECK(CompareTexts(BuildActual(printer, snippets), LoadGolden("IIFEWithOneshotOpt.golden"))); @@ -663,6 +726,40 @@ TEST(IIFEWithoutOneshotOpt) { return arguments.callee; })(); )", + R"( + this.f0 = function() {}; + this.f1 = function(a) {}; + this.f2 = function(a, b) {}; + this.f3 = function(a, b, c) {}; + this.f4 = function(a, b, c, d) {}; + this.f5 = function(a, b, c, d, e) {}; + (function() { + this.f0(); + this.f1(1); + this.f2(1, 2); + this.f3(1, 2, 3); + this.f4(1, 2, 3, 4); + this.f5(1, 2, 3, 4, 5); + return arguments.callee; + })(); + )", + R"( + function f0() {} + function f1(a) {} + function f2(a, b) {} + function f3(a, b, c) {} + function f4(a, b, c, d) {} + function f5(a, b, c, d, e) {} + (function() { + f0(); + f1(1); + f2(1, 2); + f3(1, 2, 3); + f4(1, 2, 3, 4); + f5(1, 2, 3, 4, 5); + return arguments.callee; + })(); + )", }; CHECK(CompareTexts(BuildActual(printer, snippets), LoadGolden("IIFEWithoutOneshotOpt.golden"))); diff --git a/deps/v8/test/cctest/interpreter/test-interpreter-intrinsics.cc b/deps/v8/test/cctest/interpreter/test-interpreter-intrinsics.cc index 57d42e2a83..bfc42aa540 100644 --- a/deps/v8/test/cctest/interpreter/test-interpreter-intrinsics.cc +++ b/deps/v8/test/cctest/interpreter/test-interpreter-intrinsics.cc @@ -27,7 +27,7 @@ class InvokeIntrinsicHelper { template <class... A> Handle<Object> Invoke(A... args) { CHECK(IntrinsicsHelper::IsSupported(function_id_)); - BytecodeArrayBuilder builder(zone_, sizeof...(args), 0, 0); + BytecodeArrayBuilder builder(zone_, sizeof...(args), 0, nullptr); RegisterList reg_list = InterpreterTester::NewRegisterList( builder.Receiver().index(), sizeof...(args)); builder.CallRuntime(function_id_, reg_list).Return(); @@ -94,29 +94,6 @@ TEST(IsArray) { CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("42"))); } -TEST(IsJSProxy) { - HandleAndZoneScope handles; - - InvokeIntrinsicHelper helper(handles.main_isolate(), handles.main_zone(), - Runtime::kInlineIsJSProxy); - Factory* factory = handles.main_isolate()->factory(); - - CHECK_EQ(*factory->false_value(), - *helper.Invoke(helper.NewObject("new Date()"))); - CHECK_EQ(*factory->false_value(), - *helper.Invoke(helper.NewObject("(function() {})"))); - CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("([1])"))); - CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("({})"))); - CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("(/x/)"))); - CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.Undefined())); - CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.Null())); - CHECK_EQ(*factory->false_value(), - *helper.Invoke(helper.NewObject("'string'"))); - CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("42"))); - CHECK_EQ(*factory->true_value(), - *helper.Invoke(helper.NewObject("new Proxy({},{})"))); -} - TEST(IsTypedArray) { HandleAndZoneScope handles; @@ -198,15 +175,6 @@ TEST(IntrinsicAsStubCall) { HandleAndZoneScope handles; Isolate* isolate = handles.main_isolate(); Factory* factory = isolate->factory(); - InvokeIntrinsicHelper to_number_helper(isolate, handles.main_zone(), - Runtime::kInlineToNumber); - CHECK_EQ(Smi::FromInt(46), - *to_number_helper.Invoke(to_number_helper.NewObject("'46'"))); - - InvokeIntrinsicHelper to_integer_helper(isolate, handles.main_zone(), - Runtime::kInlineToInteger); - CHECK_EQ(Smi::FromInt(502), - *to_integer_helper.Invoke(to_integer_helper.NewObject("502.67"))); InvokeIntrinsicHelper has_property_helper(isolate, handles.main_zone(), Runtime::kInlineHasProperty); diff --git a/deps/v8/test/cctest/interpreter/test-interpreter.cc b/deps/v8/test/cctest/interpreter/test-interpreter.cc index c1898adf4e..65eee6f778 100644 --- a/deps/v8/test/cctest/interpreter/test-interpreter.cc +++ b/deps/v8/test/cctest/interpreter/test-interpreter.cc @@ -423,7 +423,8 @@ TEST(InterpreterBinaryOpsBigInt) { CHECK(return_value->IsBigInt()); MaybeObject* feedback = callable.vector()->Get(slot); CHECK(feedback->IsSmi()); - CHECK_EQ(BinaryOperationFeedback::kBigInt, feedback->ToSmi()->value()); + CHECK_EQ(BinaryOperationFeedback::kBigInt, + feedback->cast<Smi>()->value()); } } } @@ -543,7 +544,7 @@ TEST(InterpreterStringAdd) { MaybeObject* feedback = callable.vector()->Get(slot); CHECK(feedback->IsSmi()); - CHECK_EQ(test_cases[i].expected_feedback, feedback->ToSmi()->value()); + CHECK_EQ(test_cases[i].expected_feedback, feedback->cast<Smi>()->value()); } } @@ -748,7 +749,7 @@ TEST(InterpreterBinaryOpTypeFeedback) { Handle<Object> return_val = callable().ToHandleChecked(); MaybeObject* feedback0 = callable.vector()->Get(slot0); CHECK(feedback0->IsSmi()); - CHECK_EQ(test_case.feedback, feedback0->ToSmi()->value()); + CHECK_EQ(test_case.feedback, feedback0->cast<Smi>()->value()); CHECK(Object::Equals(isolate, test_case.result, return_val).ToChecked()); } } @@ -854,7 +855,7 @@ TEST(InterpreterBinaryOpSmiTypeFeedback) { Handle<Object> return_val = callable().ToHandleChecked(); MaybeObject* feedback0 = callable.vector()->Get(slot0); CHECK(feedback0->IsSmi()); - CHECK_EQ(test_case.feedback, feedback0->ToSmi()->value()); + CHECK_EQ(test_case.feedback, feedback0->cast<Smi>()->value()); CHECK(Object::Equals(isolate, test_case.result, return_val).ToChecked()); } } @@ -926,23 +927,23 @@ TEST(InterpreterUnaryOpFeedback) { MaybeObject* feedback0 = callable.vector()->Get(slot0); CHECK(feedback0->IsSmi()); CHECK_EQ(BinaryOperationFeedback::kSignedSmall, - feedback0->ToSmi()->value()); + feedback0->cast<Smi>()->value()); MaybeObject* feedback1 = callable.vector()->Get(slot1); CHECK(feedback1->IsSmi()); - CHECK_EQ(BinaryOperationFeedback::kNumber, feedback1->ToSmi()->value()); + CHECK_EQ(BinaryOperationFeedback::kNumber, feedback1->cast<Smi>()->value()); MaybeObject* feedback2 = callable.vector()->Get(slot2); CHECK(feedback2->IsSmi()); - CHECK_EQ(BinaryOperationFeedback::kNumber, feedback2->ToSmi()->value()); + CHECK_EQ(BinaryOperationFeedback::kNumber, feedback2->cast<Smi>()->value()); MaybeObject* feedback3 = callable.vector()->Get(slot3); CHECK(feedback3->IsSmi()); - CHECK_EQ(BinaryOperationFeedback::kBigInt, feedback3->ToSmi()->value()); + CHECK_EQ(BinaryOperationFeedback::kBigInt, feedback3->cast<Smi>()->value()); MaybeObject* feedback4 = callable.vector()->Get(slot4); CHECK(feedback4->IsSmi()); - CHECK_EQ(BinaryOperationFeedback::kAny, feedback4->ToSmi()->value()); + CHECK_EQ(BinaryOperationFeedback::kAny, feedback4->cast<Smi>()->value()); } } @@ -988,15 +989,15 @@ TEST(InterpreterBitwiseTypeFeedback) { MaybeObject* feedback0 = callable.vector()->Get(slot0); CHECK(feedback0->IsSmi()); CHECK_EQ(BinaryOperationFeedback::kSignedSmall, - feedback0->ToSmi()->value()); + feedback0->cast<Smi>()->value()); MaybeObject* feedback1 = callable.vector()->Get(slot1); CHECK(feedback1->IsSmi()); - CHECK_EQ(BinaryOperationFeedback::kNumber, feedback1->ToSmi()->value()); + CHECK_EQ(BinaryOperationFeedback::kNumber, feedback1->cast<Smi>()->value()); MaybeObject* feedback2 = callable.vector()->Get(slot2); CHECK(feedback2->IsSmi()); - CHECK_EQ(BinaryOperationFeedback::kAny, feedback2->ToSmi()->value()); + CHECK_EQ(BinaryOperationFeedback::kAny, feedback2->cast<Smi>()->value()); } } @@ -1818,7 +1819,7 @@ TEST(InterpreterSmiComparisons) { MaybeObject* feedback = callable.vector()->Get(slot); CHECK(feedback->IsSmi()); CHECK_EQ(CompareOperationFeedback::kSignedSmall, - feedback->ToSmi()->value()); + feedback->cast<Smi>()->value()); } } } @@ -1866,7 +1867,8 @@ TEST(InterpreterHeapNumberComparisons) { CompareC(comparison, inputs[i], inputs[j])); MaybeObject* feedback = callable.vector()->Get(slot); CHECK(feedback->IsSmi()); - CHECK_EQ(CompareOperationFeedback::kNumber, feedback->ToSmi()->value()); + CHECK_EQ(CompareOperationFeedback::kNumber, + feedback->cast<Smi>()->value()); } } } @@ -1908,7 +1910,8 @@ TEST(InterpreterBigIntComparisons) { CHECK(return_value->IsBoolean()); MaybeObject* feedback = callable.vector()->Get(slot); CHECK(feedback->IsSmi()); - CHECK_EQ(CompareOperationFeedback::kBigInt, feedback->ToSmi()->value()); + CHECK_EQ(CompareOperationFeedback::kBigInt, + feedback->cast<Smi>()->value()); } } } @@ -1959,7 +1962,7 @@ TEST(InterpreterStringComparisons) { Token::IsOrderedRelationalCompareOp(comparison) ? CompareOperationFeedback::kString : CompareOperationFeedback::kInternalizedString; - CHECK_EQ(expected_feedback, feedback->ToSmi()->value()); + CHECK_EQ(expected_feedback, feedback->cast<Smi>()->value()); } } } @@ -2072,7 +2075,7 @@ TEST(InterpreterMixedComparisons) { CHECK(feedback->IsSmi()); // Comparison with a number and string collects kAny feedback. CHECK_EQ(CompareOperationFeedback::kAny, - feedback->ToSmi()->value()); + feedback->cast<Smi>()->value()); } } } @@ -5046,6 +5049,35 @@ TEST(InterpreterWithNativeStack) { interpreter_entry_trampoline->InstructionStart()); } +TEST(InterpreterGetAndMaybeDeserializeBytecodeHandler) { + HandleAndZoneScope handles; + Isolate* isolate = handles.main_isolate(); + Interpreter* interpreter = isolate->interpreter(); + + // Test that single-width bytecode handlers deserializer correctly. + Code* wide_handler = interpreter->GetAndMaybeDeserializeBytecodeHandler( + Bytecode::kWide, OperandScale::kSingle); + + CHECK_EQ(wide_handler->builtin_index(), Builtins::kWideHandler); + + Code* add_handler = interpreter->GetAndMaybeDeserializeBytecodeHandler( + Bytecode::kAdd, OperandScale::kSingle); + + CHECK_EQ(add_handler->builtin_index(), Builtins::kAddHandler); + + // Test that double-width bytecode handlers deserializer correctly, including + // an illegal bytecode handler since there is no Wide.Wide handler. + Code* wide_wide_handler = interpreter->GetAndMaybeDeserializeBytecodeHandler( + Bytecode::kWide, OperandScale::kDouble); + + CHECK_EQ(wide_wide_handler->builtin_index(), Builtins::kIllegalHandler); + + Code* add_wide_handler = interpreter->GetAndMaybeDeserializeBytecodeHandler( + Bytecode::kAdd, OperandScale::kDouble); + + CHECK_EQ(add_wide_handler->builtin_index(), Builtins::kAddWideHandler); +} + } // namespace interpreter } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/interpreter/test-source-positions.cc b/deps/v8/test/cctest/interpreter/test-source-positions.cc index 8f2aae7e0b..2a8e354e54 100644 --- a/deps/v8/test/cctest/interpreter/test-source-positions.cc +++ b/deps/v8/test/cctest/interpreter/test-source-positions.cc @@ -49,7 +49,7 @@ struct TestCaseData { const char* arguments() const { return arguments_; } private: - TestCaseData(); + TestCaseData() = delete; const char* const script_; const char* const declaration_parameters_; diff --git a/deps/v8/test/cctest/libsampler/test-sampler.cc b/deps/v8/test/cctest/libsampler/test-sampler.cc index 2ec3b870df..462da988e4 100644 --- a/deps/v8/test/cctest/libsampler/test-sampler.cc +++ b/deps/v8/test/cctest/libsampler/test-sampler.cc @@ -55,7 +55,7 @@ class TestSampler : public Sampler { class TestApiCallbacks { public: - TestApiCallbacks() {} + TestApiCallbacks() = default; static void Getter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info) { diff --git a/deps/v8/test/cctest/parsing/test-preparser.cc b/deps/v8/test/cctest/parsing/test-preparser.cc index 473debec40..ecea6f6134 100644 --- a/deps/v8/test/cctest/parsing/test-preparser.cc +++ b/deps/v8/test/cctest/parsing/test-preparser.cc @@ -8,6 +8,7 @@ #include "src/objects-inl.h" #include "src/parsing/parse-info.h" #include "src/parsing/parsing.h" +#include "src/parsing/preparsed-scope-data-impl.h" #include "src/parsing/preparsed-scope-data.h" #include "test/cctest/cctest.h" @@ -747,8 +748,8 @@ TEST(PreParserScopeAnalysis) { // Parse the lazy function using the scope data. i::ParseInfo using_scope_data(isolate, shared); using_scope_data.set_lazy_compile(); - using_scope_data.consumed_preparsed_scope_data()->SetData( - isolate, produced_data_on_heap); + using_scope_data.set_consumed_preparsed_scope_data( + i::ConsumedPreParsedScopeData::For(isolate, produced_data_on_heap)); CHECK(i::parsing::ParseFunction(&using_scope_data, shared, isolate)); // Verify that we skipped at least one function inside that scope. @@ -814,7 +815,7 @@ TEST(ProducingAndConsumingByteData) { LocalContext env; i::Zone zone(isolate->allocator(), ZONE_NAME); - i::ProducedPreParsedScopeData::ByteData bytes(&zone); + i::PreParsedScopeDataBuilder::ByteData bytes(&zone); // Write some data. bytes.WriteUint32(1983); // This will be overwritten. bytes.WriteUint32(2147483647); @@ -841,32 +842,67 @@ TEST(ProducingAndConsumingByteData) { // End with a lonely quarter. bytes.WriteQuarter(2); - i::Handle<i::PodArray<uint8_t>> data_on_heap = bytes.Serialize(isolate); - i::ConsumedPreParsedScopeData::ByteData bytes_for_reading; - i::ConsumedPreParsedScopeData::ByteData::ReadingScope reading_scope( - &bytes_for_reading, *data_on_heap); + { + // Serialize as a ZoneConsumedPreParsedScopeData, and read back data. + i::ZonePreParsedScopeData zone_serialized(&zone, bytes.begin(), bytes.end(), + 0); + i::ZoneConsumedPreParsedScopeData::ByteData bytes_for_reading; + i::ZoneVectorWrapper wrapper(zone_serialized.byte_data()); + i::ZoneConsumedPreParsedScopeData::ByteData::ReadingScope reading_scope( + &bytes_for_reading, &wrapper); - // Read the data back. #ifdef DEBUG - CHECK_EQ(bytes_for_reading.ReadUint32(), 2017); + CHECK_EQ(bytes_for_reading.ReadUint32(), 2017); #else - CHECK_EQ(bytes_for_reading.ReadUint32(), 1983); + CHECK_EQ(bytes_for_reading.ReadUint32(), 1983); #endif - CHECK_EQ(bytes_for_reading.ReadUint32(), 2147483647); - CHECK_EQ(bytes_for_reading.ReadUint8(), 4); - CHECK_EQ(bytes_for_reading.ReadUint8(), 255); - CHECK_EQ(bytes_for_reading.ReadUint32(), 0); - CHECK_EQ(bytes_for_reading.ReadUint8(), 0); - CHECK_EQ(bytes_for_reading.ReadUint8(), 100); - CHECK_EQ(bytes_for_reading.ReadQuarter(), 3); - CHECK_EQ(bytes_for_reading.ReadQuarter(), 0); - CHECK_EQ(bytes_for_reading.ReadQuarter(), 2); - CHECK_EQ(bytes_for_reading.ReadQuarter(), 1); - CHECK_EQ(bytes_for_reading.ReadQuarter(), 0); - CHECK_EQ(bytes_for_reading.ReadUint8(), 50); - CHECK_EQ(bytes_for_reading.ReadQuarter(), 0); - CHECK_EQ(bytes_for_reading.ReadQuarter(), 1); - CHECK_EQ(bytes_for_reading.ReadQuarter(), 2); - CHECK_EQ(bytes_for_reading.ReadUint32(), 50); - CHECK_EQ(bytes_for_reading.ReadQuarter(), 2); + CHECK_EQ(bytes_for_reading.ReadUint32(), 2147483647); + CHECK_EQ(bytes_for_reading.ReadUint8(), 4); + CHECK_EQ(bytes_for_reading.ReadUint8(), 255); + CHECK_EQ(bytes_for_reading.ReadUint32(), 0); + CHECK_EQ(bytes_for_reading.ReadUint8(), 0); + CHECK_EQ(bytes_for_reading.ReadUint8(), 100); + CHECK_EQ(bytes_for_reading.ReadQuarter(), 3); + CHECK_EQ(bytes_for_reading.ReadQuarter(), 0); + CHECK_EQ(bytes_for_reading.ReadQuarter(), 2); + CHECK_EQ(bytes_for_reading.ReadQuarter(), 1); + CHECK_EQ(bytes_for_reading.ReadQuarter(), 0); + CHECK_EQ(bytes_for_reading.ReadUint8(), 50); + CHECK_EQ(bytes_for_reading.ReadQuarter(), 0); + CHECK_EQ(bytes_for_reading.ReadQuarter(), 1); + CHECK_EQ(bytes_for_reading.ReadQuarter(), 2); + CHECK_EQ(bytes_for_reading.ReadUint32(), 50); + CHECK_EQ(bytes_for_reading.ReadQuarter(), 2); + } + + { + // Serialize as an OnHeapConsumedPreParsedScopeData, and read back data. + i::Handle<i::PodArray<uint8_t>> data_on_heap = bytes.Serialize(isolate); + i::OnHeapConsumedPreParsedScopeData::ByteData bytes_for_reading; + i::OnHeapConsumedPreParsedScopeData::ByteData::ReadingScope reading_scope( + &bytes_for_reading, *data_on_heap); + +#ifdef DEBUG + CHECK_EQ(bytes_for_reading.ReadUint32(), 2017); +#else + CHECK_EQ(bytes_for_reading.ReadUint32(), 1983); +#endif + CHECK_EQ(bytes_for_reading.ReadUint32(), 2147483647); + CHECK_EQ(bytes_for_reading.ReadUint8(), 4); + CHECK_EQ(bytes_for_reading.ReadUint8(), 255); + CHECK_EQ(bytes_for_reading.ReadUint32(), 0); + CHECK_EQ(bytes_for_reading.ReadUint8(), 0); + CHECK_EQ(bytes_for_reading.ReadUint8(), 100); + CHECK_EQ(bytes_for_reading.ReadQuarter(), 3); + CHECK_EQ(bytes_for_reading.ReadQuarter(), 0); + CHECK_EQ(bytes_for_reading.ReadQuarter(), 2); + CHECK_EQ(bytes_for_reading.ReadQuarter(), 1); + CHECK_EQ(bytes_for_reading.ReadQuarter(), 0); + CHECK_EQ(bytes_for_reading.ReadUint8(), 50); + CHECK_EQ(bytes_for_reading.ReadQuarter(), 0); + CHECK_EQ(bytes_for_reading.ReadQuarter(), 1); + CHECK_EQ(bytes_for_reading.ReadQuarter(), 2); + CHECK_EQ(bytes_for_reading.ReadUint32(), 50); + CHECK_EQ(bytes_for_reading.ReadQuarter(), 2); + } } diff --git a/deps/v8/test/cctest/parsing/test-scanner-streams.cc b/deps/v8/test/cctest/parsing/test-scanner-streams.cc index a9dc4482ef..bb05231f08 100644 --- a/deps/v8/test/cctest/parsing/test-scanner-streams.cc +++ b/deps/v8/test/cctest/parsing/test-scanner-streams.cc @@ -40,7 +40,7 @@ class ChunkSource : public v8::ScriptCompiler::ExternalSourceStream { } chunks_.push_back({nullptr, 0}); } - ~ChunkSource() {} + ~ChunkSource() override = default; bool SetBookmark() override { return false; } void ResetToBookmark() override {} size_t GetMoreData(const uint8_t** src) override { @@ -61,15 +61,43 @@ class ChunkSource : public v8::ScriptCompiler::ExternalSourceStream { size_t current_; }; -class TestExternalResource : public v8::String::ExternalStringResource { +// Checks that Lock() / Unlock() pairs are balanced. Not thread-safe. +class LockChecker { + public: + LockChecker() : lock_depth_(0) {} + ~LockChecker() { CHECK_EQ(0, lock_depth_); } + + void Lock() const { lock_depth_++; } + + void Unlock() const { + CHECK_GT(lock_depth_, 0); + lock_depth_--; + } + + bool IsLocked() const { return lock_depth_ > 0; } + + int LockDepth() const { return lock_depth_; } + + protected: + mutable int lock_depth_; +}; + +class TestExternalResource : public v8::String::ExternalStringResource, + public LockChecker { public: explicit TestExternalResource(uint16_t* data, int length) - : data_(data), length_(static_cast<size_t>(length)) {} + : LockChecker(), data_(data), length_(static_cast<size_t>(length)) {} + + const uint16_t* data() const override { + CHECK(IsLocked()); + return data_; + } - ~TestExternalResource() {} + size_t length() const override { return length_; } - const uint16_t* data() const { return data_; } - size_t length() const { return length_; } + bool IsCacheable() const override { return false; } + void Lock() const override { LockChecker::Lock(); } + void Unlock() const override { LockChecker::Unlock(); } private: uint16_t* data_; @@ -77,13 +105,21 @@ class TestExternalResource : public v8::String::ExternalStringResource { }; class TestExternalOneByteResource - : public v8::String::ExternalOneByteStringResource { + : public v8::String::ExternalOneByteStringResource, + public LockChecker { public: TestExternalOneByteResource(const char* data, size_t length) : data_(data), length_(length) {} - const char* data() const { return data_; } - size_t length() const { return length_; } + const char* data() const override { + CHECK(IsLocked()); + return data_; + } + size_t length() const override { return length_; } + + bool IsCacheable() const override { return false; } + void Lock() const override { LockChecker::Lock(); } + void Unlock() const override { LockChecker::Unlock(); } private: const char* data_; @@ -101,6 +137,17 @@ const char unicode_utf8[] = const uint16_t unicode_ucs2[] = {97, 98, 99, 228, 10784, 55357, 56489, 100, 101, 102, 0}; +i::Handle<i::String> NewExternalTwoByteStringFromResource( + i::Isolate* isolate, TestExternalResource* resource) { + i::Factory* factory = isolate->factory(); + // String creation accesses the resource. + resource->Lock(); + i::Handle<i::String> uc16_string( + factory->NewExternalStringFromTwoByte(resource).ToHandleChecked()); + resource->Unlock(); + return uc16_string; +} + } // anonymous namespace TEST(Utf8StreamAsciiOnly) { @@ -108,7 +155,7 @@ TEST(Utf8StreamAsciiOnly) { ChunkSource chunk_source(chunks); std::unique_ptr<v8::internal::Utf16CharacterStream> stream( v8::internal::ScannerStream::For( - &chunk_source, v8::ScriptCompiler::StreamedSource::UTF8, nullptr)); + &chunk_source, v8::ScriptCompiler::StreamedSource::UTF8)); // Read the data without dying. v8::internal::uc32 c; @@ -126,7 +173,7 @@ TEST(Utf8StreamBOM) { ChunkSource chunk_source(chunks); std::unique_ptr<v8::internal::Utf16CharacterStream> stream( v8::internal::ScannerStream::For( - &chunk_source, v8::ScriptCompiler::StreamedSource::UTF8, nullptr)); + &chunk_source, v8::ScriptCompiler::StreamedSource::UTF8)); // Read the data without tripping over the BOM. for (size_t i = 0; unicode_ucs2[i]; i++) { @@ -160,7 +207,7 @@ TEST(Utf8SplitBOM) { ChunkSource chunk_source(chunks); std::unique_ptr<v8::internal::Utf16CharacterStream> stream( v8::internal::ScannerStream::For( - &chunk_source, v8::ScriptCompiler::StreamedSource::UTF8, nullptr)); + &chunk_source, v8::ScriptCompiler::StreamedSource::UTF8)); // Read the data without tripping over the BOM. for (size_t i = 0; unicode_ucs2[i]; i++) { @@ -176,7 +223,7 @@ TEST(Utf8SplitBOM) { ChunkSource chunk_source(chunks); std::unique_ptr<v8::internal::Utf16CharacterStream> stream( v8::internal::ScannerStream::For( - &chunk_source, v8::ScriptCompiler::StreamedSource::UTF8, nullptr)); + &chunk_source, v8::ScriptCompiler::StreamedSource::UTF8)); // Read the data without tripping over the BOM. for (size_t i = 0; unicode_ucs2[i]; i++) { @@ -191,7 +238,7 @@ TEST(Utf8SplitMultiBOM) { ChunkSource chunk_source(chunks); std::unique_ptr<i::Utf16CharacterStream> stream( v8::internal::ScannerStream::For( - &chunk_source, v8::ScriptCompiler::StreamedSource::UTF8, nullptr)); + &chunk_source, v8::ScriptCompiler::StreamedSource::UTF8)); // Read the data, ensuring we get exactly one of the two BOMs back. CHECK_EQ(0xFEFF, stream->Advance()); @@ -213,7 +260,7 @@ TEST(Utf8AdvanceUntil) { ChunkSource chunk_source(chunks); std::unique_ptr<v8::internal::Utf16CharacterStream> stream( v8::internal::ScannerStream::For( - &chunk_source, v8::ScriptCompiler::StreamedSource::UTF8, nullptr)); + &chunk_source, v8::ScriptCompiler::StreamedSource::UTF8)); int32_t res = stream->AdvanceUntil( [](int32_t c0_) { return unibrow::IsLineTerminator(c0_); }); @@ -232,14 +279,12 @@ TEST(AdvanceMatchAdvanceUntil) { std::unique_ptr<v8::internal::Utf16CharacterStream> stream_advance( v8::internal::ScannerStream::For( - &chunk_source_a, v8::ScriptCompiler::StreamedSource::UTF8, - nullptr)); + &chunk_source_a, v8::ScriptCompiler::StreamedSource::UTF8)); ChunkSource chunk_source_au(chunks); std::unique_ptr<v8::internal::Utf16CharacterStream> stream_advance_until( v8::internal::ScannerStream::For( - &chunk_source_au, v8::ScriptCompiler::StreamedSource::UTF8, - nullptr)); + &chunk_source_au, v8::ScriptCompiler::StreamedSource::UTF8)); int32_t au_c0_ = stream_advance_until->AdvanceUntil( [](int32_t c0_) { return unibrow::IsLineTerminator(c0_); }); @@ -281,7 +326,7 @@ TEST(Utf8AdvanceUntilOverChunkBoundaries) { ChunkSource chunk_source(chunks); std::unique_ptr<v8::internal::Utf16CharacterStream> stream( v8::internal::ScannerStream::For( - &chunk_source, v8::ScriptCompiler::StreamedSource::UTF8, nullptr)); + &chunk_source, v8::ScriptCompiler::StreamedSource::UTF8)); int32_t res = stream->AdvanceUntil( [](int32_t c0_) { return unibrow::IsLineTerminator(c0_); }); @@ -309,7 +354,7 @@ TEST(Utf8ChunkBoundaries) { ChunkSource chunk_source(chunks); std::unique_ptr<v8::internal::Utf16CharacterStream> stream( v8::internal::ScannerStream::For( - &chunk_source, v8::ScriptCompiler::StreamedSource::UTF8, nullptr)); + &chunk_source, v8::ScriptCompiler::StreamedSource::UTF8)); for (size_t i = 0; unicode_ucs2[i]; i++) { CHECK_EQ(unicode_ucs2[i], stream->Advance()); @@ -338,7 +383,7 @@ TEST(Utf8SingleByteChunks) { ChunkSource chunk_source(chunks); std::unique_ptr<v8::internal::Utf16CharacterStream> stream( v8::internal::ScannerStream::For( - &chunk_source, v8::ScriptCompiler::StreamedSource::UTF8, nullptr)); + &chunk_source, v8::ScriptCompiler::StreamedSource::UTF8)); for (size_t j = 0; unicode_ucs2[j]; j++) { CHECK_EQ(unicode_ucs2[j], stream->Advance()); @@ -400,6 +445,26 @@ void TestCharacterStream(const char* reference, i::Utf16CharacterStream* stream, CHECK_LT(stream->Advance(), 0); } +void TestCloneCharacterStream(const char* reference, + i::Utf16CharacterStream* stream, + unsigned length) { + std::unique_ptr<i::Utf16CharacterStream> clone = stream->Clone(); + + unsigned i; + unsigned halfway = length / 2; + // Advance original half way. + for (i = 0; i < halfway; i++) { + CHECK_EQU(i, stream->pos()); + CHECK_EQU(reference[i], stream->Advance()); + } + + // Test advancing original stream didn't affect the clone. + TestCharacterStream(reference, clone.get(), length, 0, length); + + // Test advancing clone didn't affect original stream. + TestCharacterStream(reference, stream, length, i, length); +} + #undef CHECK_EQU void TestCharacterStreams(const char* one_byte_source, unsigned length, @@ -419,7 +484,7 @@ void TestCharacterStreams(const char* one_byte_source, unsigned length, } TestExternalResource resource(uc16_buffer.get(), length); i::Handle<i::String> uc16_string( - factory->NewExternalStringFromTwoByte(&resource).ToHandleChecked()); + NewExternalTwoByteStringFromResource(isolate, &resource)); std::unique_ptr<i::Utf16CharacterStream> uc16_stream( i::ScannerStream::For(isolate, uc16_string, start, end)); TestCharacterStream(one_byte_source, uc16_stream.get(), length, start, end); @@ -480,14 +545,13 @@ void TestCharacterStreams(const char* one_byte_source, unsigned length, ChunkSource single_chunk(data, 1, data_end - data, false); std::unique_ptr<i::Utf16CharacterStream> one_byte_streaming_stream( i::ScannerStream::For(&single_chunk, - v8::ScriptCompiler::StreamedSource::ONE_BYTE, - nullptr)); + v8::ScriptCompiler::StreamedSource::ONE_BYTE)); TestCharacterStream(one_byte_source, one_byte_streaming_stream.get(), length, start, end); ChunkSource many_chunks(data, 1, data_end - data, true); one_byte_streaming_stream.reset(i::ScannerStream::For( - &many_chunks, v8::ScriptCompiler::StreamedSource::ONE_BYTE, nullptr)); + &many_chunks, v8::ScriptCompiler::StreamedSource::ONE_BYTE)); TestCharacterStream(one_byte_source, one_byte_streaming_stream.get(), length, start, end); } @@ -498,14 +562,14 @@ void TestCharacterStreams(const char* one_byte_source, unsigned length, const uint8_t* data_end = one_byte_vector.end(); ChunkSource chunks(data, 1, data_end - data, false); std::unique_ptr<i::Utf16CharacterStream> utf8_streaming_stream( - i::ScannerStream::For(&chunks, v8::ScriptCompiler::StreamedSource::UTF8, - nullptr)); + i::ScannerStream::For(&chunks, + v8::ScriptCompiler::StreamedSource::UTF8)); TestCharacterStream(one_byte_source, utf8_streaming_stream.get(), length, start, end); ChunkSource many_chunks(data, 1, data_end - data, true); utf8_streaming_stream.reset(i::ScannerStream::For( - &many_chunks, v8::ScriptCompiler::StreamedSource::UTF8, nullptr)); + &many_chunks, v8::ScriptCompiler::StreamedSource::UTF8)); TestCharacterStream(one_byte_source, utf8_streaming_stream.get(), length, start, end); } @@ -518,14 +582,14 @@ void TestCharacterStreams(const char* one_byte_source, unsigned length, reinterpret_cast<const uint8_t*>(two_byte_vector.end()); ChunkSource chunks(data, 2, data_end - data, false); std::unique_ptr<i::Utf16CharacterStream> two_byte_streaming_stream( - i::ScannerStream::For( - &chunks, v8::ScriptCompiler::StreamedSource::TWO_BYTE, nullptr)); + i::ScannerStream::For(&chunks, + v8::ScriptCompiler::StreamedSource::TWO_BYTE)); TestCharacterStream(one_byte_source, two_byte_streaming_stream.get(), length, start, end); ChunkSource many_chunks(data, 2, data_end - data, true); two_byte_streaming_stream.reset(i::ScannerStream::For( - &many_chunks, v8::ScriptCompiler::StreamedSource::TWO_BYTE, nullptr)); + &many_chunks, v8::ScriptCompiler::StreamedSource::TWO_BYTE)); TestCharacterStream(one_byte_source, two_byte_streaming_stream.get(), length, start, end); } @@ -567,7 +631,7 @@ TEST(Regress651333) { // 65533) instead of the incorrectly coded Latin1 char. ChunkSource chunks(bytes, 1, len, false); std::unique_ptr<i::Utf16CharacterStream> stream(i::ScannerStream::For( - &chunks, v8::ScriptCompiler::StreamedSource::UTF8, nullptr)); + &chunks, v8::ScriptCompiler::StreamedSource::UTF8)); for (size_t i = 0; i < len; i++) { CHECK_EQ(unicode[i], stream->Advance()); } @@ -581,7 +645,7 @@ void TestChunkStreamAgainstReference( for (size_t c = 0; c < unicode_expected.size(); ++c) { ChunkSource chunk_source(cases[c]); std::unique_ptr<i::Utf16CharacterStream> stream(i::ScannerStream::For( - &chunk_source, v8::ScriptCompiler::StreamedSource::UTF8, nullptr)); + &chunk_source, v8::ScriptCompiler::StreamedSource::UTF8)); for (size_t i = 0; i < unicode_expected[c].size(); i++) { CHECK_EQ(unicode_expected[c][i], stream->Advance()); } @@ -695,3 +759,98 @@ TEST(RelocatingCharacterStream) { CHECK_EQ('c', two_byte_string_stream->Advance()); CHECK_EQ('d', two_byte_string_stream->Advance()); } + +TEST(CloneCharacterStreams) { + v8::HandleScope handles(CcTest::isolate()); + v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); + v8::Context::Scope context_scope(context); + + i::Isolate* isolate = CcTest::i_isolate(); + i::Factory* factory = isolate->factory(); + + const char* one_byte_source = "abcdefghi"; + unsigned length = static_cast<unsigned>(strlen(one_byte_source)); + + // Check that cloning a character stream does not update + + // 2-byte external string + std::unique_ptr<i::uc16[]> uc16_buffer(new i::uc16[length]); + i::Vector<const i::uc16> two_byte_vector(uc16_buffer.get(), + static_cast<int>(length)); + { + for (unsigned i = 0; i < length; i++) { + uc16_buffer[i] = static_cast<i::uc16>(one_byte_source[i]); + } + TestExternalResource resource(uc16_buffer.get(), length); + i::Handle<i::String> uc16_string( + NewExternalTwoByteStringFromResource(isolate, &resource)); + std::unique_ptr<i::Utf16CharacterStream> uc16_stream( + i::ScannerStream::For(isolate, uc16_string, 0, length)); + + CHECK(resource.IsLocked()); + CHECK_EQ(1, resource.LockDepth()); + std::unique_ptr<i::Utf16CharacterStream> cloned = uc16_stream->Clone(); + CHECK_EQ(2, resource.LockDepth()); + uc16_stream = std::move(cloned); + CHECK_EQ(1, resource.LockDepth()); + + TestCloneCharacterStream(one_byte_source, uc16_stream.get(), length); + + // This avoids the GC from trying to free a stack allocated resource. + if (uc16_string->IsExternalString()) + i::Handle<i::ExternalTwoByteString>::cast(uc16_string) + ->SetResource(isolate, nullptr); + } + + // 1-byte external string + i::Vector<const uint8_t> one_byte_vector = + i::OneByteVector(one_byte_source, static_cast<int>(length)); + i::Handle<i::String> one_byte_string = + factory->NewStringFromOneByte(one_byte_vector).ToHandleChecked(); + { + TestExternalOneByteResource one_byte_resource(one_byte_source, length); + i::Handle<i::String> ext_one_byte_string( + factory->NewExternalStringFromOneByte(&one_byte_resource) + .ToHandleChecked()); + std::unique_ptr<i::Utf16CharacterStream> one_byte_stream( + i::ScannerStream::For(isolate, ext_one_byte_string, 0, length)); + TestCloneCharacterStream(one_byte_source, one_byte_stream.get(), length); + // This avoids the GC from trying to free a stack allocated resource. + if (ext_one_byte_string->IsExternalString()) + i::Handle<i::ExternalOneByteString>::cast(ext_one_byte_string) + ->SetResource(isolate, nullptr); + } + + // Relocatinable streams aren't clonable. + { + std::unique_ptr<i::Utf16CharacterStream> string_stream( + i::ScannerStream::For(isolate, one_byte_string, 0, length)); + CHECK(!string_stream->can_be_cloned()); + + i::Handle<i::String> two_byte_string = + factory->NewStringFromTwoByte(two_byte_vector).ToHandleChecked(); + std::unique_ptr<i::Utf16CharacterStream> two_byte_string_stream( + i::ScannerStream::For(isolate, two_byte_string, 0, length)); + CHECK(!two_byte_string_stream->can_be_cloned()); + } + + // Chunk sources currently not cloneable. + { + const char* chunks[] = {"1234", "\0"}; + ChunkSource chunk_source(chunks); + std::unique_ptr<i::Utf16CharacterStream> one_byte_streaming_stream( + i::ScannerStream::For(&chunk_source, + v8::ScriptCompiler::StreamedSource::ONE_BYTE)); + CHECK(!one_byte_streaming_stream->can_be_cloned()); + + std::unique_ptr<i::Utf16CharacterStream> utf8_streaming_stream( + i::ScannerStream::For(&chunk_source, + v8::ScriptCompiler::StreamedSource::UTF8)); + CHECK(!utf8_streaming_stream->can_be_cloned()); + + std::unique_ptr<i::Utf16CharacterStream> two_byte_streaming_stream( + i::ScannerStream::For(&chunk_source, + v8::ScriptCompiler::StreamedSource::TWO_BYTE)); + CHECK(!two_byte_streaming_stream->can_be_cloned()); + } +} diff --git a/deps/v8/test/cctest/print-extension.h b/deps/v8/test/cctest/print-extension.h index 922d116efd..a2d237d667 100644 --- a/deps/v8/test/cctest/print-extension.h +++ b/deps/v8/test/cctest/print-extension.h @@ -36,8 +36,8 @@ namespace internal { class PrintExtension : public v8::Extension { public: PrintExtension() : v8::Extension("v8/print", "native function print();") { } - virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( - v8::Isolate* isolate, v8::Local<v8::String> name); + v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( + v8::Isolate* isolate, v8::Local<v8::String> name) override; static void Print(const v8::FunctionCallbackInfo<v8::Value>& args); }; diff --git a/deps/v8/test/cctest/profiler-extension.h b/deps/v8/test/cctest/profiler-extension.h index dbc12f47a0..f2be3a1334 100644 --- a/deps/v8/test/cctest/profiler-extension.h +++ b/deps/v8/test/cctest/profiler-extension.h @@ -41,8 +41,8 @@ class ProfilerExtension : public v8::Extension { public: ProfilerExtension() : v8::Extension("v8/profiler", kSource) { } - virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( - v8::Isolate* isolate, v8::Local<v8::String> name); + v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( + v8::Isolate* isolate, v8::Local<v8::String> name) override; static void set_profiler(v8::CpuProfiler* profiler) { profiler_ = profiler; } static void set_profiler(CpuProfiler* profiler) { diff --git a/deps/v8/test/cctest/scope-test-helper.h b/deps/v8/test/cctest/scope-test-helper.h index 8c69307d3e..8dd49970a1 100644 --- a/deps/v8/test/cctest/scope-test-helper.h +++ b/deps/v8/test/cctest/scope-test-helper.h @@ -24,7 +24,7 @@ class ScopeTestHelper { baseline->AsDeclarationScope()->function_kind() == scope->AsDeclarationScope()->function_kind()); - if (!ProducedPreParsedScopeData::ScopeNeedsData(baseline)) { + if (!PreParsedScopeDataBuilder::ScopeNeedsData(baseline)) { return; } diff --git a/deps/v8/test/cctest/setup-isolate-for-tests.cc b/deps/v8/test/cctest/setup-isolate-for-tests.cc index ba9c4fb488..8aae2de769 100644 --- a/deps/v8/test/cctest/setup-isolate-for-tests.cc +++ b/deps/v8/test/cctest/setup-isolate-for-tests.cc @@ -4,8 +4,6 @@ #include "test/cctest/setup-isolate-for-tests.h" -#include "src/interpreter/setup-interpreter.h" - namespace v8 { namespace internal { @@ -15,13 +13,6 @@ void SetupIsolateDelegateForTests::SetupBuiltins(Isolate* isolate) { } } -void SetupIsolateDelegateForTests::SetupInterpreter( - interpreter::Interpreter* interpreter) { - if (create_heap_objects_) { - interpreter::SetupInterpreter::InstallBytecodeHandlers(interpreter); - } -} - bool SetupIsolateDelegateForTests::SetupHeap(Heap* heap) { if (create_heap_objects_) { return SetupHeapInternal(heap); diff --git a/deps/v8/test/cctest/setup-isolate-for-tests.h b/deps/v8/test/cctest/setup-isolate-for-tests.h index e3d34725f0..c026c04afd 100644 --- a/deps/v8/test/cctest/setup-isolate-for-tests.h +++ b/deps/v8/test/cctest/setup-isolate-for-tests.h @@ -14,12 +14,10 @@ class SetupIsolateDelegateForTests : public SetupIsolateDelegate { public: explicit SetupIsolateDelegateForTests(bool create_heap_objects) : SetupIsolateDelegate(create_heap_objects) {} - virtual ~SetupIsolateDelegateForTests() {} + ~SetupIsolateDelegateForTests() override = default; void SetupBuiltins(Isolate* isolate) override; - void SetupInterpreter(interpreter::Interpreter* interpreter) override; - bool SetupHeap(Heap* heap) override; }; diff --git a/deps/v8/test/cctest/test-accessors.cc b/deps/v8/test/cctest/test-accessors.cc index de1901b6d3..a6a02ba762 100644 --- a/deps/v8/test/cctest/test-accessors.cc +++ b/deps/v8/test/cctest/test-accessors.cc @@ -181,7 +181,7 @@ THREADED_TEST(GlobalVariableAccess) { templ->InstanceTemplate()->SetAccessor( v8_str("baz"), GetIntValue, SetIntValue, v8::External::New(isolate, &baz)); - LocalContext env(0, templ->InstanceTemplate()); + LocalContext env(nullptr, templ->InstanceTemplate()); v8_compile("foo = (++bar) + baz")->Run(env.local()).ToLocalChecked(); CHECK_EQ(-3, bar); CHECK_EQ(7, foo); diff --git a/deps/v8/test/cctest/test-allocation.cc b/deps/v8/test/cctest/test-allocation.cc index 139829dd2b..d5ba49c537 100644 --- a/deps/v8/test/cctest/test-allocation.cc +++ b/deps/v8/test/cctest/test-allocation.cc @@ -37,7 +37,7 @@ class AllocationPlatform : public TestPlatform { // Now that it's completely constructed, make this the current platform. i::V8::SetPlatformForTesting(this); } - virtual ~AllocationPlatform() = default; + ~AllocationPlatform() override = default; void OnCriticalMemoryPressure() override { oom_callback_called = true; } @@ -141,24 +141,20 @@ TEST(AlignedAllocOOM) { TEST(AllocVirtualMemoryOOM) { AllocationPlatform platform; CHECK(!platform.oom_callback_called); - v8::internal::VirtualMemory result; - bool success = - v8::internal::AllocVirtualMemory(GetHugeMemoryAmount(), nullptr, &result); + v8::internal::VirtualMemory result(v8::internal::GetPlatformPageAllocator(), + GetHugeMemoryAmount(), nullptr); // On a few systems, allocation somehow succeeds. - CHECK_IMPLIES(success, result.IsReserved()); - CHECK_IMPLIES(!success, !result.IsReserved() && platform.oom_callback_called); + CHECK_IMPLIES(!result.IsReserved(), platform.oom_callback_called); } TEST(AlignedAllocVirtualMemoryOOM) { AllocationPlatform platform; CHECK(!platform.oom_callback_called); - v8::internal::VirtualMemory result; - bool success = v8::internal::AlignedAllocVirtualMemory( - GetHugeMemoryAmount(), v8::internal::AllocatePageSize(), nullptr, - &result); + v8::internal::VirtualMemory result(v8::internal::GetPlatformPageAllocator(), + GetHugeMemoryAmount(), nullptr, + v8::internal::AllocatePageSize()); // On a few systems, allocation somehow succeeds. - CHECK_IMPLIES(success, result.IsReserved()); - CHECK_IMPLIES(!success, !result.IsReserved() && platform.oom_callback_called); + CHECK_IMPLIES(!result.IsReserved(), platform.oom_callback_called); } #endif // !defined(V8_USE_ADDRESS_SANITIZER) && !defined(MEMORY_SANITIZER) && diff --git a/deps/v8/test/cctest/test-api-accessors.cc b/deps/v8/test/cctest/test-api-accessors.cc index 5bda0432ea..7c0a7ee8cb 100644 --- a/deps/v8/test/cctest/test-api-accessors.cc +++ b/deps/v8/test/cctest/test-api-accessors.cc @@ -240,8 +240,12 @@ static void Getter(v8::Local<v8::Name> name, static void StringGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info) {} -static void Setter(v8::Local<v8::String> name, v8::Local<v8::Value> value, - const v8::PropertyCallbackInfo<void>& info) {} +static int set_accessor_call_count = 0; + +static void Setter(v8::Local<v8::Name> name, v8::Local<v8::Value> value, + const v8::PropertyCallbackInfo<void>& info) { + set_accessor_call_count++; +} } // namespace // Re-declaration of non-configurable accessors should throw. @@ -281,7 +285,7 @@ TEST(AccessorSetHasNoSideEffect) { obj->SetAccessor(context, v8_str("foo"), Getter).ToChecked(); CHECK(v8::debug::EvaluateGlobal(isolate, v8_str("obj.foo"), true).IsEmpty()); - obj->SetAccessor(context, v8_str("foo"), Getter, 0, + obj->SetAccessor(context, v8_str("foo"), Getter, nullptr, v8::MaybeLocal<v8::Value>(), v8::AccessControl::DEFAULT, v8::PropertyAttribute::None, v8::SideEffectType::kHasNoSideEffect) @@ -297,6 +301,65 @@ TEST(AccessorSetHasNoSideEffect) { .ToLocalChecked() ->Int32Value(env.local()) .FromJust()); + CHECK_EQ(0, set_accessor_call_count); +} + +// Set accessors can be whitelisted as side-effect-free via SetAccessor. +TEST(SetAccessorSetSideEffectReceiverCheck1) { + LocalContext env; + v8::Isolate* isolate = env->GetIsolate(); + v8::HandleScope scope(isolate); + + v8::Local<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate); + v8::Local<v8::Object> obj = templ->NewInstance(env.local()).ToLocalChecked(); + CHECK(env->Global()->Set(env.local(), v8_str("obj"), obj).FromJust()); + obj->SetAccessor(env.local(), v8_str("foo"), Getter, Setter, + v8::MaybeLocal<v8::Value>(), v8::AccessControl::DEFAULT, + v8::PropertyAttribute::None, + v8::SideEffectType::kHasNoSideEffect, + v8::SideEffectType::kHasSideEffectToReceiver) + .ToChecked(); + CHECK(v8::debug::EvaluateGlobal(isolate, v8_str("obj.foo"), true) + .ToLocalChecked() + ->Equals(env.local(), v8_str("return value")) + .FromJust()); + v8::TryCatch try_catch(isolate); + CHECK(v8::debug::EvaluateGlobal(isolate, v8_str("obj.foo = 1"), true) + .IsEmpty()); + CHECK(try_catch.HasCaught()); + CHECK_EQ(0, set_accessor_call_count); +} + +static void ConstructCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { +} + +TEST(SetAccessorSetSideEffectReceiverCheck2) { + LocalContext env; + v8::Isolate* isolate = env->GetIsolate(); + v8::HandleScope scope(isolate); + i::FLAG_enable_one_shot_optimization = false; + + v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New( + isolate, ConstructCallback, v8::Local<v8::Value>(), + v8::Local<v8::Signature>(), 0, v8::ConstructorBehavior::kAllow, + v8::SideEffectType::kHasNoSideEffect); + templ->InstanceTemplate()->SetAccessor( + v8_str("bar"), Getter, Setter, v8::Local<v8::Value>(), + v8::AccessControl::DEFAULT, v8::PropertyAttribute::None, + v8::Local<v8::AccessorSignature>(), + v8::SideEffectType::kHasSideEffectToReceiver, + v8::SideEffectType::kHasSideEffectToReceiver); + CHECK(env->Global() + ->Set(env.local(), v8_str("f"), + templ->GetFunction(env.local()).ToLocalChecked()) + .FromJust()); + CHECK(v8::debug::EvaluateGlobal(isolate, v8_str("new f().bar"), true) + .ToLocalChecked() + ->Equals(env.local(), v8_str("return value")) + .FromJust()); + v8::debug::EvaluateGlobal(isolate, v8_str("new f().bar = 1"), true) + .ToLocalChecked(); + CHECK_EQ(1, set_accessor_call_count); } // Accessors can be whitelisted as side-effect-free via SetNativeDataProperty. @@ -366,10 +429,10 @@ TEST(ObjectTemplateSetAccessorHasNoSideEffect) { v8::Local<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate); templ->SetAccessor(v8_str("foo"), StringGetter); - templ->SetAccessor(v8_str("foo2"), StringGetter, 0, v8::Local<v8::Value>(), - v8::AccessControl::DEFAULT, v8::PropertyAttribute::None, - v8::Local<v8::AccessorSignature>(), - v8::SideEffectType::kHasNoSideEffect); + templ->SetAccessor( + v8_str("foo2"), StringGetter, nullptr, v8::Local<v8::Value>(), + v8::AccessControl::DEFAULT, v8::PropertyAttribute::None, + v8::Local<v8::AccessorSignature>(), v8::SideEffectType::kHasNoSideEffect); v8::Local<v8::Object> obj = templ->NewInstance(env.local()).ToLocalChecked(); CHECK(env->Global()->Set(env.local(), v8_str("obj"), obj).FromJust()); @@ -395,7 +458,7 @@ TEST(ObjectTemplateSetNativePropertyHasNoSideEffect) { v8::Local<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate); templ->SetNativeDataProperty(v8_str("foo"), Getter); templ->SetNativeDataProperty( - v8_str("foo2"), Getter, 0, v8::Local<v8::Value>(), + v8_str("foo2"), Getter, nullptr, v8::Local<v8::Value>(), v8::PropertyAttribute::None, v8::Local<v8::AccessorSignature>(), v8::AccessControl::DEFAULT, v8::SideEffectType::kHasNoSideEffect); v8::Local<v8::Object> obj = templ->NewInstance(env.local()).ToLocalChecked(); diff --git a/deps/v8/test/cctest/test-api-interceptors.cc b/deps/v8/test/cctest/test-api-interceptors.cc index 9d9138670e..3604af020f 100644 --- a/deps/v8/test/cctest/test-api-interceptors.cc +++ b/deps/v8/test/cctest/test-api-interceptors.cc @@ -393,11 +393,11 @@ void QueryCallback(Local<Name> property, // Examples that show when the query callback is triggered. THREADED_TEST(QueryInterceptor) { - v8::HandleScope scope(CcTest::isolate()); - v8::Local<v8::FunctionTemplate> templ = - v8::FunctionTemplate::New(CcTest::isolate()); + v8::Isolate* isolate = CcTest::isolate(); + v8::HandleScope scope(isolate); + v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); templ->InstanceTemplate()->SetHandler( - v8::NamedPropertyHandlerConfiguration(0, 0, QueryCallback)); + v8::NamedPropertyHandlerConfiguration(nullptr, nullptr, QueryCallback)); LocalContext env; env->Global() ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local()) @@ -430,43 +430,37 @@ THREADED_TEST(QueryInterceptor) { CHECK(v8_compile("obj.propertyIsEnumerable('enum');") ->Run(env.local()) .ToLocalChecked() - ->BooleanValue(env.local()) - .FromJust()); + ->BooleanValue(isolate)); CHECK_EQ(4, query_counter_int); CHECK(!v8_compile("obj.propertyIsEnumerable('not_enum');") ->Run(env.local()) .ToLocalChecked() - ->BooleanValue(env.local()) - .FromJust()); + ->BooleanValue(isolate)); CHECK_EQ(5, query_counter_int); CHECK(v8_compile("obj.hasOwnProperty('enum');") ->Run(env.local()) .ToLocalChecked() - ->BooleanValue(env.local()) - .FromJust()); + ->BooleanValue(isolate)); CHECK_EQ(5, query_counter_int); CHECK(v8_compile("obj.hasOwnProperty('not_enum');") ->Run(env.local()) .ToLocalChecked() - ->BooleanValue(env.local()) - .FromJust()); + ->BooleanValue(isolate)); CHECK_EQ(5, query_counter_int); CHECK(!v8_compile("obj.hasOwnProperty('x');") ->Run(env.local()) .ToLocalChecked() - ->BooleanValue(env.local()) - .FromJust()); + ->BooleanValue(isolate)); CHECK_EQ(6, query_counter_int); CHECK(!v8_compile("obj.propertyIsEnumerable('undef');") ->Run(env.local()) .ToLocalChecked() - ->BooleanValue(env.local()) - .FromJust()); + ->BooleanValue(isolate)); CHECK_EQ(7, query_counter_int); v8_compile("Object.defineProperty(obj, 'enum', {value: 42});") @@ -737,7 +731,8 @@ THREADED_TEST(DefinerCallbackGetAndDefine) { v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(CcTest::isolate()); templ->InstanceTemplate()->SetHandler(v8::NamedPropertyHandlerConfiguration( - GetterCallbackOrder, SetterCallback, 0, 0, 0, DefinerCallbackOrder)); + GetterCallbackOrder, SetterCallback, nullptr, nullptr, nullptr, + DefinerCallbackOrder)); LocalContext env; env->Global() ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local()) @@ -834,15 +829,15 @@ THREADED_TEST(InterceptorHasOwnProperty) { v8::Local<Value> value = CompileRun( "var o = new constructor();" "o.hasOwnProperty('ostehaps');"); - CHECK(!value->BooleanValue(context.local()).FromJust()); + CHECK(!value->BooleanValue(isolate)); value = CompileRun( "o.ostehaps = 42;" "o.hasOwnProperty('ostehaps');"); - CHECK(value->BooleanValue(context.local()).FromJust()); + CHECK(value->BooleanValue(isolate)); value = CompileRun( "var p = new constructor();" "p.hasOwnProperty('ostehaps');"); - CHECK(!value->BooleanValue(context.local()).FromJust()); + CHECK(!value->BooleanValue(isolate)); } @@ -876,7 +871,7 @@ THREADED_TEST(InterceptorHasOwnPropertyCausingGC) { "var o = new constructor();" "o.__proto__ = new String(x);" "o.hasOwnProperty('ostehaps');"); - CHECK(!value->BooleanValue(context.local()).FromJust()); + CHECK(!value->BooleanValue(isolate)); } @@ -886,8 +881,8 @@ static void CheckInterceptorLoadIC( v8::Isolate* isolate = CcTest::isolate(); v8::HandleScope scope(isolate); v8::Local<v8::ObjectTemplate> templ = ObjectTemplate::New(isolate); - templ->SetHandler(v8::NamedPropertyHandlerConfiguration(getter, 0, 0, 0, 0, - v8_str("data"))); + templ->SetHandler(v8::NamedPropertyHandlerConfiguration( + getter, nullptr, nullptr, nullptr, nullptr, v8_str("data"))); LocalContext context; context->Global() ->Set(context.local(), v8_str("o"), @@ -1353,7 +1348,7 @@ THREADED_TEST(InterceptorLoadGlobalICGlobalWithInterceptor) { " f();" "};" "f();"); - CHECK(value->BooleanValue(context.local()).FromJust()); + CHECK(value->BooleanValue(isolate)); value = CompileRun( "var f = function() { " @@ -1368,7 +1363,7 @@ THREADED_TEST(InterceptorLoadGlobalICGlobalWithInterceptor) { " f();" "};" "f();"); - CHECK(value->BooleanValue(context.local()).FromJust()); + CHECK(value->BooleanValue(isolate)); value = CompileRun( "var f = function() { " @@ -1383,7 +1378,7 @@ THREADED_TEST(InterceptorLoadGlobalICGlobalWithInterceptor) { " f();" "};" "f();"); - CHECK(value->BooleanValue(context.local()).FromJust()); + CHECK(value->BooleanValue(isolate)); } // Test load of a non-existing global through prototype chain when a global @@ -1454,8 +1449,8 @@ THREADED_TEST(InterceptorStoreIC) { v8::HandleScope scope(isolate); v8::Local<v8::ObjectTemplate> templ = ObjectTemplate::New(isolate); templ->SetHandler(v8::NamedPropertyHandlerConfiguration( - InterceptorLoadICGetter, InterceptorStoreICSetter, 0, 0, 0, - v8_str("data"))); + InterceptorLoadICGetter, InterceptorStoreICSetter, nullptr, nullptr, + nullptr, v8_str("data"))); LocalContext context; context->Global() ->Set(context.local(), v8_str("o"), @@ -1574,11 +1569,11 @@ THREADED_TEST(GenericInterceptorDoesSeeSymbols) { THREADED_TEST(NamedPropertyHandlerGetter) { echo_named_call_count = 0; - v8::HandleScope scope(CcTest::isolate()); - v8::Local<v8::FunctionTemplate> templ = - v8::FunctionTemplate::New(CcTest::isolate()); + v8::Isolate* isolate = CcTest::isolate(); + v8::HandleScope scope(isolate); + v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); templ->InstanceTemplate()->SetHandler(v8::NamedPropertyHandlerConfiguration( - EchoNamedProperty, 0, 0, 0, 0, v8_str("data"))); + EchoNamedProperty, nullptr, nullptr, nullptr, nullptr, v8_str("data"))); LocalContext env; env->Global() ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local()) @@ -1591,7 +1586,7 @@ THREADED_TEST(NamedPropertyHandlerGetter) { CHECK_EQ(1, echo_named_call_count); const char* code = "var str = 'oddle'; obj[str] + obj.poddle;"; v8::Local<Value> str = CompileRun(code); - String::Utf8Value value(CcTest::isolate(), str); + String::Utf8Value value(isolate, str); CHECK_EQ(0, strcmp(*value, "oddlepoddle")); // Check default behavior CHECK_EQ(10, v8_compile("obj.flob = 10;") @@ -1602,13 +1597,11 @@ THREADED_TEST(NamedPropertyHandlerGetter) { CHECK(v8_compile("'myProperty' in obj") ->Run(env.local()) .ToLocalChecked() - ->BooleanValue(env.local()) - .FromJust()); + ->BooleanValue(isolate)); CHECK(v8_compile("delete obj.myProperty") ->Run(env.local()) .ToLocalChecked() - ->BooleanValue(env.local()) - .FromJust()); + ->BooleanValue(isolate)); } namespace { @@ -1650,7 +1643,8 @@ THREADED_TEST(PropertyDefinerCallback) { v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(CcTest::isolate()); templ->InstanceTemplate()->SetHandler(v8::NamedPropertyHandlerConfiguration( - 0, 0, 0, 0, 0, NotInterceptingPropertyDefineCallback)); + nullptr, nullptr, nullptr, nullptr, nullptr, + NotInterceptingPropertyDefineCallback)); env->Global() ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local()) .ToLocalChecked() @@ -1672,7 +1666,8 @@ THREADED_TEST(PropertyDefinerCallback) { v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(CcTest::isolate()); templ->InstanceTemplate()->SetHandler(v8::NamedPropertyHandlerConfiguration( - 0, 0, 0, 0, 0, CheckDescriptorInDefineCallback)); + nullptr, nullptr, nullptr, nullptr, nullptr, + CheckDescriptorInDefineCallback)); env->Global() ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local()) .ToLocalChecked() @@ -1699,7 +1694,8 @@ THREADED_TEST(PropertyDefinerCallback) { v8::FunctionTemplate::New(CcTest::isolate()); templ2->InstanceTemplate()->SetHandler( v8::NamedPropertyHandlerConfiguration( - 0, 0, 0, 0, 0, InterceptingPropertyDefineCallback)); + nullptr, nullptr, nullptr, nullptr, nullptr, + InterceptingPropertyDefineCallback)); env->Global() ->Set(env.local(), v8_str("obj"), templ2->GetFunction(env.local()) .ToLocalChecked() @@ -1759,7 +1755,8 @@ THREADED_TEST(PropertyDefinerCallbackIndexed) { v8::FunctionTemplate::New(CcTest::isolate()); templ->InstanceTemplate()->SetHandler( v8::IndexedPropertyHandlerConfiguration( - 0, 0, 0, 0, 0, NotInterceptingPropertyDefineCallbackIndexed)); + nullptr, nullptr, nullptr, nullptr, nullptr, + NotInterceptingPropertyDefineCallbackIndexed)); env->Global() ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local()) .ToLocalChecked() @@ -1782,7 +1779,8 @@ THREADED_TEST(PropertyDefinerCallbackIndexed) { v8::FunctionTemplate::New(CcTest::isolate()); templ->InstanceTemplate()->SetHandler( v8::IndexedPropertyHandlerConfiguration( - 0, 0, 0, 0, 0, CheckDescriptorInDefineCallbackIndexed)); + nullptr, nullptr, nullptr, nullptr, nullptr, + CheckDescriptorInDefineCallbackIndexed)); env->Global() ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local()) .ToLocalChecked() @@ -1809,7 +1807,8 @@ THREADED_TEST(PropertyDefinerCallbackIndexed) { v8::FunctionTemplate::New(CcTest::isolate()); templ2->InstanceTemplate()->SetHandler( v8::IndexedPropertyHandlerConfiguration( - 0, 0, 0, 0, 0, InterceptingPropertyDefineCallbackIndexed)); + nullptr, nullptr, nullptr, nullptr, nullptr, + InterceptingPropertyDefineCallbackIndexed)); env->Global() ->Set(env.local(), v8_str("obj"), templ2->GetFunction(env.local()) .ToLocalChecked() @@ -1831,12 +1830,13 @@ THREADED_TEST(PropertyDefinerCallbackIndexed) { // Test that freeze() is intercepted. THREADED_TEST(PropertyDefinerCallbackForFreeze) { - v8::HandleScope scope(CcTest::isolate()); + v8::Isolate* isolate = CcTest::isolate(); + v8::HandleScope scope(isolate); LocalContext env; - v8::Local<v8::FunctionTemplate> templ = - v8::FunctionTemplate::New(CcTest::isolate()); + v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); templ->InstanceTemplate()->SetHandler(v8::NamedPropertyHandlerConfiguration( - 0, 0, 0, 0, 0, InterceptingPropertyDefineCallback)); + nullptr, nullptr, nullptr, nullptr, nullptr, + InterceptingPropertyDefineCallback)); env->Global() ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local()) .ToLocalChecked() @@ -1851,8 +1851,7 @@ THREADED_TEST(PropertyDefinerCallbackForFreeze) { CHECK(v8_compile(code) ->Run(env.local()) .ToLocalChecked() - ->BooleanValue(env.local()) - .FromJust()); + ->BooleanValue(isolate)); } // Check that the descriptor passed to the callback is enumerable. @@ -1878,7 +1877,8 @@ THREADED_TEST(PropertyDefinerCallbackEnumerable) { v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(CcTest::isolate()); templ->InstanceTemplate()->SetHandler(v8::NamedPropertyHandlerConfiguration( - 0, 0, 0, 0, 0, CheckEnumerablePropertyDefineCallback)); + nullptr, nullptr, nullptr, nullptr, nullptr, + CheckEnumerablePropertyDefineCallback)); env->Global() ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local()) .ToLocalChecked() @@ -1918,7 +1918,8 @@ THREADED_TEST(PropertyDefinerCallbackConfigurable) { v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(CcTest::isolate()); templ->InstanceTemplate()->SetHandler(v8::NamedPropertyHandlerConfiguration( - 0, 0, 0, 0, 0, CheckConfigurablePropertyDefineCallback)); + nullptr, nullptr, nullptr, nullptr, nullptr, + CheckConfigurablePropertyDefineCallback)); env->Global() ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local()) .ToLocalChecked() @@ -1954,7 +1955,8 @@ THREADED_TEST(PropertyDefinerCallbackWritable) { v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(CcTest::isolate()); templ->InstanceTemplate()->SetHandler(v8::NamedPropertyHandlerConfiguration( - 0, 0, 0, 0, 0, CheckWritablePropertyDefineCallback)); + nullptr, nullptr, nullptr, nullptr, nullptr, + CheckWritablePropertyDefineCallback)); env->Global() ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local()) .ToLocalChecked() @@ -1989,7 +1991,8 @@ THREADED_TEST(PropertyDefinerCallbackWithGetter) { v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(CcTest::isolate()); templ->InstanceTemplate()->SetHandler(v8::NamedPropertyHandlerConfiguration( - 0, 0, 0, 0, 0, CheckGetterPropertyDefineCallback)); + nullptr, nullptr, nullptr, nullptr, nullptr, + CheckGetterPropertyDefineCallback)); env->Global() ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local()) .ToLocalChecked() @@ -2024,7 +2027,8 @@ THREADED_TEST(PropertyDefinerCallbackWithSetter) { v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(CcTest::isolate()); templ->InstanceTemplate()->SetHandler(v8::NamedPropertyHandlerConfiguration( - 0, 0, 0, 0, 0, CheckSetterPropertyDefineCallback)); + nullptr, nullptr, nullptr, nullptr, nullptr, + CheckSetterPropertyDefineCallback)); env->Global() ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local()) .ToLocalChecked() @@ -2068,7 +2072,8 @@ THREADED_TEST(PropertyDescriptorCallback) { v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(CcTest::isolate()); templ->InstanceTemplate()->SetHandler(v8::NamedPropertyHandlerConfiguration( - 0, 0, EmptyPropertyDescriptorCallback, 0, 0, 0)); + nullptr, nullptr, EmptyPropertyDescriptorCallback, nullptr, nullptr, + nullptr)); env->Global() ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local()) .ToLocalChecked() @@ -2090,7 +2095,8 @@ THREADED_TEST(PropertyDescriptorCallback) { v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(CcTest::isolate()); templ->InstanceTemplate()->SetHandler(v8::NamedPropertyHandlerConfiguration( - 0, 0, InterceptingPropertyDescriptorCallback, 0, 0, 0)); + nullptr, nullptr, InterceptingPropertyDescriptorCallback, nullptr, + nullptr, nullptr)); env->Global() ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local()) .ToLocalChecked() @@ -2129,7 +2135,7 @@ THREADED_TEST(IndexedPropertyHandlerGetter) { v8::HandleScope scope(isolate); v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); templ->InstanceTemplate()->SetHandler(v8::IndexedPropertyHandlerConfiguration( - EchoIndexedProperty, 0, 0, 0, 0, v8_num(637))); + EchoIndexedProperty, nullptr, nullptr, nullptr, nullptr, v8_num(637))); LocalContext env; env->Global() ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local()) @@ -2285,7 +2291,7 @@ THREADED_TEST(PrePropertyHandler) { v8::HandleScope scope(isolate); v8::Local<v8::FunctionTemplate> desc = v8::FunctionTemplate::New(isolate); desc->InstanceTemplate()->SetHandler(v8::NamedPropertyHandlerConfiguration( - PrePropertyHandlerGet, 0, PrePropertyHandlerQuery)); + PrePropertyHandlerGet, nullptr, PrePropertyHandlerQuery)); is_bootstrapping = true; LocalContext env(nullptr, desc->InstanceTemplate()); is_bootstrapping = false; @@ -2909,8 +2915,8 @@ THREADED_TEST(IndexedInterceptorUnboxedDoubleWithIndexedAccessor) { v8::HandleScope scope(isolate); Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); templ->SetHandler(v8::IndexedPropertyHandlerConfiguration( - UnboxedDoubleIndexedPropertyGetter, UnboxedDoubleIndexedPropertySetter, 0, - 0, UnboxedDoubleIndexedPropertyEnumerator)); + UnboxedDoubleIndexedPropertyGetter, UnboxedDoubleIndexedPropertySetter, + nullptr, nullptr, UnboxedDoubleIndexedPropertyEnumerator)); LocalContext context; context->Global() ->Set(context.local(), v8_str("obj"), @@ -2971,7 +2977,7 @@ THREADED_TEST(IndexedInterceptorSloppyArgsWithIndexedAccessor) { v8::HandleScope scope(isolate); Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); templ->SetHandler(v8::IndexedPropertyHandlerConfiguration( - SloppyIndexedPropertyGetter, 0, 0, 0, + SloppyIndexedPropertyGetter, nullptr, nullptr, nullptr, SloppyArgsIndexedPropertyEnumerator)); LocalContext context; context->Global() @@ -4113,7 +4119,7 @@ THREADED_TEST(InterceptorICReferenceErrors) { templ->SetHandler( v8::NamedPropertyHandlerConfiguration(InterceptorICRefErrorGetter)); is_bootstrapping = true; - LocalContext context(0, templ, v8::Local<Value>()); + LocalContext context(nullptr, templ, v8::Local<Value>()); is_bootstrapping = false; call_ic_function2 = v8_compile("function h(x) { return x; }; h") ->Run(context.local()) @@ -4126,7 +4132,7 @@ THREADED_TEST(InterceptorICReferenceErrors) { " return false;" "};" "f();"); - CHECK(value->BooleanValue(context.local()).FromJust()); + CHECK(value->BooleanValue(isolate)); interceptor_call_count = 0; value = CompileRun( "function g() {" @@ -4136,7 +4142,7 @@ THREADED_TEST(InterceptorICReferenceErrors) { " return false;" "};" "g();"); - CHECK(value->BooleanValue(context.local()).FromJust()); + CHECK(value->BooleanValue(isolate)); } @@ -4169,7 +4175,7 @@ THREADED_TEST(InterceptorICGetterExceptions) { templ->SetHandler( v8::NamedPropertyHandlerConfiguration(InterceptorICExceptionGetter)); is_bootstrapping = true; - LocalContext context(0, templ, v8::Local<Value>()); + LocalContext context(nullptr, templ, v8::Local<Value>()); is_bootstrapping = false; call_ic_function3 = v8_compile("function h(x) { return x; }; h") ->Run(context.local()) @@ -4182,7 +4188,7 @@ THREADED_TEST(InterceptorICGetterExceptions) { " return false;" "};" "f();"); - CHECK(value->BooleanValue(context.local()).FromJust()); + CHECK(value->BooleanValue(isolate)); interceptor_ic_exception_get_count = 0; value = CompileRun( "function f() {" @@ -4192,7 +4198,7 @@ THREADED_TEST(InterceptorICGetterExceptions) { " return false;" "};" "f();"); - CHECK(value->BooleanValue(context.local()).FromJust()); + CHECK(value->BooleanValue(isolate)); } @@ -4215,9 +4221,9 @@ THREADED_TEST(InterceptorICSetterExceptions) { v8::Isolate* isolate = CcTest::isolate(); v8::HandleScope scope(isolate); v8::Local<v8::ObjectTemplate> templ = ObjectTemplate::New(isolate); - templ->SetHandler( - v8::NamedPropertyHandlerConfiguration(0, InterceptorICExceptionSetter)); - LocalContext context(0, templ, v8::Local<Value>()); + templ->SetHandler(v8::NamedPropertyHandlerConfiguration( + nullptr, InterceptorICExceptionSetter)); + LocalContext context(nullptr, templ, v8::Local<Value>()); v8::Local<Value> value = CompileRun( "function f() {" " for (var i = 0; i < 100; i++) {" @@ -4226,7 +4232,7 @@ THREADED_TEST(InterceptorICSetterExceptions) { " return false;" "};" "f();"); - CHECK(value->BooleanValue(context.local()).FromJust()); + CHECK(value->BooleanValue(isolate)); } @@ -4236,7 +4242,7 @@ THREADED_TEST(NullNamedInterceptor) { v8::HandleScope scope(isolate); v8::Local<v8::ObjectTemplate> templ = ObjectTemplate::New(isolate); templ->SetHandler(v8::NamedPropertyHandlerConfiguration( - static_cast<v8::GenericNamedPropertyGetterCallback>(0))); + static_cast<v8::GenericNamedPropertyGetterCallback>(nullptr))); LocalContext context; templ->Set(CcTest::isolate(), "x", v8_num(42)); v8::Local<v8::Object> obj = @@ -4254,7 +4260,7 @@ THREADED_TEST(NullIndexedInterceptor) { v8::HandleScope scope(isolate); v8::Local<v8::ObjectTemplate> templ = ObjectTemplate::New(isolate); templ->SetHandler(v8::IndexedPropertyHandlerConfiguration( - static_cast<v8::IndexedPropertyGetterCallback>(0))); + static_cast<v8::IndexedPropertyGetterCallback>(nullptr))); LocalContext context; templ->Set(CcTest::isolate(), "42", v8_num(42)); v8::Local<v8::Object> obj = diff --git a/deps/v8/test/cctest/test-api.cc b/deps/v8/test/cctest/test-api.cc index 1b74ecfd70..9eb73fab7e 100644 --- a/deps/v8/test/cctest/test-api.cc +++ b/deps/v8/test/cctest/test-api.cc @@ -445,18 +445,14 @@ class TestResource: public String::ExternalStringResource { while (data[length_]) ++length_; } - ~TestResource() { + ~TestResource() override { if (owning_data_) i::DeleteArray(data_); if (counter_ != nullptr) ++*counter_; } - const uint16_t* data() const { - return data_; - } + const uint16_t* data() const override { return data_; } - size_t length() const { - return length_; - } + size_t length() const override { return length_; } private: uint16_t* data_; @@ -475,18 +471,14 @@ class TestOneByteResource : public String::ExternalOneByteStringResource { length_(strlen(data) - offset), counter_(counter) {} - ~TestOneByteResource() { + ~TestOneByteResource() override { i::DeleteArray(orig_data_); if (counter_ != nullptr) ++*counter_; } - const char* data() const { - return data_; - } + const char* data() const override { return data_; } - size_t length() const { - return length_; - } + size_t length() const override { return length_; } private: const char* orig_data_; @@ -692,10 +684,10 @@ TEST(MakingExternalUnalignedOneByteString) { // Trigger GCs and force evacuation. CcTest::CollectAllGarbage(); - CcTest::CollectAllGarbage(i::Heap::kReduceMemoryFootprintMask); + CcTest::heap()->CollectAllGarbage(i::Heap::kReduceMemoryFootprintMask, + i::GarbageCollectionReason::kTesting); } - THREADED_TEST(UsingExternalString) { i::Factory* factory = CcTest::i_isolate()->factory(); { @@ -744,8 +736,8 @@ THREADED_TEST(UsingExternalOneByteString) { class RandomLengthResource : public v8::String::ExternalStringResource { public: explicit RandomLengthResource(int length) : length_(length) {} - virtual const uint16_t* data() const { return string_; } - virtual size_t length() const { return length_; } + const uint16_t* data() const override { return string_; } + size_t length() const override { return length_; } private: uint16_t string_[10]; @@ -757,8 +749,8 @@ class RandomLengthOneByteResource : public v8::String::ExternalOneByteStringResource { public: explicit RandomLengthOneByteResource(int length) : length_(length) {} - virtual const char* data() const { return string_; } - virtual size_t length() const { return length_; } + const char* data() const override { return string_; } + size_t length() const override { return length_; } private: char string_[10]; @@ -847,7 +839,7 @@ class TestOneByteResourceWithDisposeControl : public TestOneByteResource { TestOneByteResourceWithDisposeControl(const char* data, bool dispose) : TestOneByteResource(data, &dispose_count), dispose_(dispose) {} - void Dispose() { + void Dispose() override { ++dispose_calls; if (dispose_) delete this; } @@ -1296,8 +1288,7 @@ THREADED_PROFILED_TEST(FastReturnValues) { fast_return_value_bool = i == 0; value = TestFastReturnValues<bool>(); CHECK(value->IsBoolean()); - CHECK_EQ(fast_return_value_bool, - value->ToBoolean(env.local()).ToLocalChecked()->Value()); + CHECK_EQ(fast_return_value_bool, value->BooleanValue(isolate)); } // check oddballs ReturnValueOddball oddballs[] = { @@ -1392,8 +1383,7 @@ static void TestExternalPointerWrapping() { " for (var i = 0; i < 13; i++) obj.func();\n" "}\n" "foo(), true") - ->BooleanValue(env.local()) - .FromJust()); + ->BooleanValue(isolate)); } @@ -1782,7 +1772,6 @@ THREADED_TEST(NumberObject) { } THREADED_TEST(BigIntObject) { - v8::internal::FLAG_harmony_bigint = true; LocalContext env; v8::Isolate* isolate = env->GetIsolate(); v8::HandleScope scope(isolate); @@ -1803,7 +1792,7 @@ THREADED_TEST(BigIntObject) { CHECK(new_unboxed_bigint->IsBigInt()); // Test functionality inherited from v8::Value. - CHECK(unboxed_bigint->BooleanValue(context).ToChecked()); + CHECK(unboxed_bigint->BooleanValue(isolate)); v8::Local<v8::String> string = unboxed_bigint->ToString(context).ToLocalChecked(); CHECK_EQ(0, strcmp("42", *v8::String::Utf8Value(isolate, string))); @@ -1840,48 +1829,49 @@ THREADED_TEST(BooleanObject) { THREADED_TEST(PrimitiveAndWrappedBooleans) { LocalContext env; - v8::HandleScope scope(env->GetIsolate()); + v8::Isolate* isolate = env->GetIsolate(); + v8::HandleScope scope(isolate); - Local<Value> primitive_false = Boolean::New(env->GetIsolate(), false); + Local<Value> primitive_false = Boolean::New(isolate, false); CHECK(primitive_false->IsBoolean()); CHECK(!primitive_false->IsBooleanObject()); - CHECK(!primitive_false->BooleanValue(env.local()).FromJust()); + CHECK(!primitive_false->BooleanValue(isolate)); CHECK(!primitive_false->IsTrue()); CHECK(primitive_false->IsFalse()); - Local<Value> false_value = BooleanObject::New(env->GetIsolate(), false); + Local<Value> false_value = BooleanObject::New(isolate, false); CHECK(!false_value->IsBoolean()); CHECK(false_value->IsBooleanObject()); - CHECK(false_value->BooleanValue(env.local()).FromJust()); + CHECK(false_value->BooleanValue(isolate)); CHECK(!false_value->IsTrue()); CHECK(!false_value->IsFalse()); Local<BooleanObject> false_boolean_object = false_value.As<BooleanObject>(); CHECK(!false_boolean_object->IsBoolean()); CHECK(false_boolean_object->IsBooleanObject()); - CHECK(false_boolean_object->BooleanValue(env.local()).FromJust()); + CHECK(false_boolean_object->BooleanValue(isolate)); CHECK(!false_boolean_object->ValueOf()); CHECK(!false_boolean_object->IsTrue()); CHECK(!false_boolean_object->IsFalse()); - Local<Value> primitive_true = Boolean::New(env->GetIsolate(), true); + Local<Value> primitive_true = Boolean::New(isolate, true); CHECK(primitive_true->IsBoolean()); CHECK(!primitive_true->IsBooleanObject()); - CHECK(primitive_true->BooleanValue(env.local()).FromJust()); + CHECK(primitive_true->BooleanValue(isolate)); CHECK(primitive_true->IsTrue()); CHECK(!primitive_true->IsFalse()); - Local<Value> true_value = BooleanObject::New(env->GetIsolate(), true); + Local<Value> true_value = BooleanObject::New(isolate, true); CHECK(!true_value->IsBoolean()); CHECK(true_value->IsBooleanObject()); - CHECK(true_value->BooleanValue(env.local()).FromJust()); + CHECK(true_value->BooleanValue(isolate)); CHECK(!true_value->IsTrue()); CHECK(!true_value->IsFalse()); Local<BooleanObject> true_boolean_object = true_value.As<BooleanObject>(); CHECK(!true_boolean_object->IsBoolean()); CHECK(true_boolean_object->IsBooleanObject()); - CHECK(true_boolean_object->BooleanValue(env.local()).FromJust()); + CHECK(true_boolean_object->BooleanValue(isolate)); CHECK(true_boolean_object->ValueOf()); CHECK(!true_boolean_object->IsTrue()); CHECK(!true_boolean_object->IsFalse()); @@ -1937,22 +1927,21 @@ THREADED_TEST(Boolean) { v8::Local<v8::Boolean> f = v8::False(isolate); CHECK(!f->Value()); v8::Local<v8::Primitive> u = v8::Undefined(isolate); - CHECK(!u->BooleanValue(env.local()).FromJust()); + CHECK(!u->BooleanValue(isolate)); v8::Local<v8::Primitive> n = v8::Null(isolate); - CHECK(!n->BooleanValue(env.local()).FromJust()); + CHECK(!n->BooleanValue(isolate)); v8::Local<String> str1 = v8_str(""); - CHECK(!str1->BooleanValue(env.local()).FromJust()); + CHECK(!str1->BooleanValue(isolate)); v8::Local<String> str2 = v8_str("x"); - CHECK(str2->BooleanValue(env.local()).FromJust()); - CHECK(!v8::Number::New(isolate, 0)->BooleanValue(env.local()).FromJust()); - CHECK(v8::Number::New(isolate, -1)->BooleanValue(env.local()).FromJust()); - CHECK(v8::Number::New(isolate, 1)->BooleanValue(env.local()).FromJust()); - CHECK(v8::Number::New(isolate, 42)->BooleanValue(env.local()).FromJust()); + CHECK(str2->BooleanValue(isolate)); + CHECK(!v8::Number::New(isolate, 0)->BooleanValue(isolate)); + CHECK(v8::Number::New(isolate, -1)->BooleanValue(isolate)); + CHECK(v8::Number::New(isolate, 1)->BooleanValue(isolate)); + CHECK(v8::Number::New(isolate, 42)->BooleanValue(isolate)); CHECK(!v8_compile("NaN") ->Run(env.local()) .ToLocalChecked() - ->BooleanValue(env.local()) - .FromJust()); + ->BooleanValue(isolate)); } @@ -1979,7 +1968,7 @@ THREADED_TEST(GlobalPrototype) { v8::Local<ObjectTemplate> templ = func_templ->InstanceTemplate(); templ->Set(isolate, "x", v8_num(200)); templ->SetAccessor(v8_str("m"), GetM); - LocalContext env(0, templ); + LocalContext env(nullptr, templ); v8::Local<Script> script(v8_compile("dummy()")); v8::Local<Value> result(script->Run(env.local()).ToLocalChecked()); CHECK_EQ(13.4, result->NumberValue(env.local()).FromJust()); @@ -2010,10 +1999,10 @@ THREADED_TEST(ObjectTemplate) { templ1->NewInstance(env.local()).ToLocalChecked(); CHECK(class_name->StrictEquals(instance1->GetConstructorName())); CHECK(env->Global()->Set(env.local(), v8_str("p"), instance1).FromJust()); - CHECK(CompileRun("(p.x == 10)")->BooleanValue(env.local()).FromJust()); - CHECK(CompileRun("(p.y == 13)")->BooleanValue(env.local()).FromJust()); - CHECK(CompileRun("(p.foo() == 42)")->BooleanValue(env.local()).FromJust()); - CHECK(CompileRun("(p.foo == acc)")->BooleanValue(env.local()).FromJust()); + CHECK(CompileRun("(p.x == 10)")->BooleanValue(isolate)); + CHECK(CompileRun("(p.y == 13)")->BooleanValue(isolate)); + CHECK(CompileRun("(p.foo() == 42)")->BooleanValue(isolate)); + CHECK(CompileRun("(p.foo == acc)")->BooleanValue(isolate)); // Ensure that foo become a data field. CompileRun("p.foo = function() {}"); Local<v8::FunctionTemplate> fun2 = v8::FunctionTemplate::New(isolate); @@ -2026,41 +2015,37 @@ THREADED_TEST(ObjectTemplate) { Local<v8::Object> instance2 = templ2->NewInstance(env.local()).ToLocalChecked(); CHECK(env->Global()->Set(env.local(), v8_str("q"), instance2).FromJust()); - CHECK(CompileRun("(q.nirk == 123)")->BooleanValue(env.local()).FromJust()); - CHECK(CompileRun("(q.a == 12)")->BooleanValue(env.local()).FromJust()); - CHECK(CompileRun("(q.b.x == 10)")->BooleanValue(env.local()).FromJust()); - CHECK(CompileRun("(q.b.y == 13)")->BooleanValue(env.local()).FromJust()); - CHECK(CompileRun("(q.b.foo() == 42)")->BooleanValue(env.local()).FromJust()); - CHECK(CompileRun("(q.b.foo === acc)")->BooleanValue(env.local()).FromJust()); - CHECK(CompileRun("(q.b !== p)")->BooleanValue(env.local()).FromJust()); - CHECK(CompileRun("(q.acc == 42)")->BooleanValue(env.local()).FromJust()); - CHECK(CompileRun("(q.bar() == 42)")->BooleanValue(env.local()).FromJust()); - CHECK(CompileRun("(q.bar == acc)")->BooleanValue(env.local()).FromJust()); + CHECK(CompileRun("(q.nirk == 123)")->BooleanValue(isolate)); + CHECK(CompileRun("(q.a == 12)")->BooleanValue(isolate)); + CHECK(CompileRun("(q.b.x == 10)")->BooleanValue(isolate)); + CHECK(CompileRun("(q.b.y == 13)")->BooleanValue(isolate)); + CHECK(CompileRun("(q.b.foo() == 42)")->BooleanValue(isolate)); + CHECK(CompileRun("(q.b.foo === acc)")->BooleanValue(isolate)); + CHECK(CompileRun("(q.b !== p)")->BooleanValue(isolate)); + CHECK(CompileRun("(q.acc == 42)")->BooleanValue(isolate)); + CHECK(CompileRun("(q.bar() == 42)")->BooleanValue(isolate)); + CHECK(CompileRun("(q.bar == acc)")->BooleanValue(isolate)); instance2 = templ2->NewInstance(env.local()).ToLocalChecked(); CHECK(env->Global()->Set(env.local(), v8_str("q2"), instance2).FromJust()); - CHECK(CompileRun("(q2.nirk == 123)")->BooleanValue(env.local()).FromJust()); - CHECK(CompileRun("(q2.a == 12)")->BooleanValue(env.local()).FromJust()); - CHECK(CompileRun("(q2.b.x == 10)")->BooleanValue(env.local()).FromJust()); - CHECK(CompileRun("(q2.b.y == 13)")->BooleanValue(env.local()).FromJust()); - CHECK(CompileRun("(q2.b.foo() == 42)")->BooleanValue(env.local()).FromJust()); - CHECK(CompileRun("(q2.b.foo === acc)")->BooleanValue(env.local()).FromJust()); - CHECK(CompileRun("(q2.acc == 42)")->BooleanValue(env.local()).FromJust()); - CHECK(CompileRun("(q2.bar() == 42)")->BooleanValue(env.local()).FromJust()); - CHECK(CompileRun("(q2.bar === acc)")->BooleanValue(env.local()).FromJust()); - - CHECK(CompileRun("(q.b !== q2.b)")->BooleanValue(env.local()).FromJust()); - CHECK(CompileRun("q.b.x = 17; (q2.b.x == 10)") - ->BooleanValue(env.local()) - .FromJust()); + CHECK(CompileRun("(q2.nirk == 123)")->BooleanValue(isolate)); + CHECK(CompileRun("(q2.a == 12)")->BooleanValue(isolate)); + CHECK(CompileRun("(q2.b.x == 10)")->BooleanValue(isolate)); + CHECK(CompileRun("(q2.b.y == 13)")->BooleanValue(isolate)); + CHECK(CompileRun("(q2.b.foo() == 42)")->BooleanValue(isolate)); + CHECK(CompileRun("(q2.b.foo === acc)")->BooleanValue(isolate)); + CHECK(CompileRun("(q2.acc == 42)")->BooleanValue(isolate)); + CHECK(CompileRun("(q2.bar() == 42)")->BooleanValue(isolate)); + CHECK(CompileRun("(q2.bar === acc)")->BooleanValue(isolate)); + + CHECK(CompileRun("(q.b !== q2.b)")->BooleanValue(isolate)); + CHECK(CompileRun("q.b.x = 17; (q2.b.x == 10)")->BooleanValue(isolate)); CHECK(CompileRun("desc1 = Object.getOwnPropertyDescriptor(q, 'acc');" "(desc1.get === acc)") - ->BooleanValue(env.local()) - .FromJust()); + ->BooleanValue(isolate)); CHECK(CompileRun("desc2 = Object.getOwnPropertyDescriptor(q2, 'acc');" "(desc2.get === acc)") - ->BooleanValue(env.local()) - .FromJust()); + ->BooleanValue(isolate)); } THREADED_TEST(IntegerValue) { @@ -2380,27 +2365,20 @@ THREADED_TEST(DescriptorInheritance) { // Checks right __proto__ chain. CHECK(CompileRun("base1.prototype.__proto__ == s.prototype") - ->BooleanValue(env.local()) - .FromJust()); + ->BooleanValue(isolate)); CHECK(CompileRun("base2.prototype.__proto__ == s.prototype") - ->BooleanValue(env.local()) - .FromJust()); + ->BooleanValue(isolate)); CHECK(v8_compile("s.prototype.PI == 3.14") ->Run(env.local()) .ToLocalChecked() - ->BooleanValue(env.local()) - .FromJust()); + ->BooleanValue(isolate)); // Instance accessor should not be visible on function object or its prototype + CHECK(CompileRun("s.knurd == undefined")->BooleanValue(isolate)); + CHECK(CompileRun("s.prototype.knurd == undefined")->BooleanValue(isolate)); CHECK( - CompileRun("s.knurd == undefined")->BooleanValue(env.local()).FromJust()); - CHECK(CompileRun("s.prototype.knurd == undefined") - ->BooleanValue(env.local()) - .FromJust()); - CHECK(CompileRun("base1.prototype.knurd == undefined") - ->BooleanValue(env.local()) - .FromJust()); + CompileRun("base1.prototype.knurd == undefined")->BooleanValue(isolate)); CHECK(env->Global() ->Set(env.local(), v8_str("obj"), base1->GetFunction(env.local()) @@ -2410,9 +2388,9 @@ THREADED_TEST(DescriptorInheritance) { .FromJust()); CHECK_EQ(17.2, CompileRun("obj.flabby()")->NumberValue(env.local()).FromJust()); - CHECK(CompileRun("'flabby' in obj")->BooleanValue(env.local()).FromJust()); + CHECK(CompileRun("'flabby' in obj")->BooleanValue(isolate)); CHECK_EQ(15.2, CompileRun("obj.knurd")->NumberValue(env.local()).FromJust()); - CHECK(CompileRun("'knurd' in obj")->BooleanValue(env.local()).FromJust()); + CHECK(CompileRun("'knurd' in obj")->BooleanValue(isolate)); CHECK_EQ(20.1, CompileRun("obj.v1")->NumberValue(env.local()).FromJust()); CHECK(env->Global() @@ -2423,9 +2401,9 @@ THREADED_TEST(DescriptorInheritance) { .FromJust()); CHECK_EQ(17.2, CompileRun("obj2.flabby()")->NumberValue(env.local()).FromJust()); - CHECK(CompileRun("'flabby' in obj2")->BooleanValue(env.local()).FromJust()); + CHECK(CompileRun("'flabby' in obj2")->BooleanValue(isolate)); CHECK_EQ(15.2, CompileRun("obj2.knurd")->NumberValue(env.local()).FromJust()); - CHECK(CompileRun("'knurd' in obj2")->BooleanValue(env.local()).FromJust()); + CHECK(CompileRun("'knurd' in obj2")->BooleanValue(isolate)); CHECK_EQ(10.1, CompileRun("obj2.v2")->NumberValue(env.local()).FromJust()); // base1 and base2 cannot cross reference to each's prototype @@ -4643,7 +4621,7 @@ void TestGlobalValueMap() { } CHECK_EQ(initial_handle_count + 1, global_handles->global_handles_count()); if (map.IsWeak()) { - CcTest::CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); + CcTest::PreciseCollectAllGarbage(); } else { map.Clear(); } @@ -5247,22 +5225,6 @@ THREADED_TEST(Array) { CHECK_EQ(27u, array->Length()); array = v8::Array::New(context->GetIsolate(), -27); CHECK_EQ(0u, array->Length()); - - std::vector<Local<Value>> vector = {v8_num(1), v8_num(2), v8_num(3)}; - array = v8::Array::New(context->GetIsolate(), vector.data(), vector.size()); - CHECK_EQ(vector.size(), array->Length()); - CHECK_EQ(1, arr->Get(context.local(), 0) - .ToLocalChecked() - ->Int32Value(context.local()) - .FromJust()); - CHECK_EQ(2, arr->Get(context.local(), 1) - .ToLocalChecked() - ->Int32Value(context.local()) - .FromJust()); - CHECK_EQ(3, arr->Get(context.local(), 2) - .ToLocalChecked() - ->Int32Value(context.local()) - .FromJust()); } @@ -5283,7 +5245,7 @@ THREADED_TEST(Vector) { v8::HandleScope scope(isolate); Local<ObjectTemplate> global = ObjectTemplate::New(isolate); global->Set(v8_str("f"), v8::FunctionTemplate::New(isolate, HandleF)); - LocalContext context(0, global); + LocalContext context(nullptr, global); const char* fun = "f()"; Local<v8::Array> a0 = CompileRun(fun).As<v8::Array>(); @@ -5672,13 +5634,44 @@ THREADED_TEST(isNumberType) { obj = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked(); CHECK(obj->IsInt32()); CHECK(obj->IsUint32()); - // Positive zero + // Negative zero CompileRun("var obj = -0.0;"); obj = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked(); CHECK(!obj->IsInt32()); CHECK(!obj->IsUint32()); } +THREADED_TEST(IntegerType) { + LocalContext env; + v8::HandleScope scope(env->GetIsolate()); + Local<Value> result; + + // Small positive integer + result = CompileRun("42;"); + CHECK(result->IsNumber()); + CHECK_EQ(42, result.As<v8::Integer>()->Value()); + // Small negative integer + result = CompileRun("-42;"); + CHECK(result->IsNumber()); + CHECK_EQ(-42, result.As<v8::Integer>()->Value()); + // Positive non-int32 integer + result = CompileRun("1099511627776;"); + CHECK(result->IsNumber()); + CHECK_EQ(1099511627776, result.As<v8::Integer>()->Value()); + // Negative non-int32 integer + result = CompileRun("-1099511627776;"); + CHECK(result->IsNumber()); + CHECK_EQ(-1099511627776, result.As<v8::Integer>()->Value()); + // Positive non-integer + result = CompileRun("3.14;"); + CHECK(result->IsNumber()); + CHECK_EQ(3, result.As<v8::Integer>()->Value()); + // Negative non-integer + result = CompileRun("-3.14;"); + CHECK(result->IsNumber()); + CHECK_EQ(-3, result.As<v8::Integer>()->Value()); +} + static void CheckUncle(v8::Isolate* isolate, v8::TryCatch* try_catch) { CHECK(try_catch->HasCaught()); String::Utf8Value str_value(isolate, try_catch->Exception()); @@ -5760,7 +5753,7 @@ THREADED_TEST(APICatch) { Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); templ->Set(v8_str("ThrowFromC"), v8::FunctionTemplate::New(isolate, ThrowFromC)); - LocalContext context(0, templ); + LocalContext context(nullptr, templ); CompileRun( "var thrown = false;" "try {" @@ -5771,7 +5764,7 @@ THREADED_TEST(APICatch) { Local<Value> thrown = context->Global() ->Get(context.local(), v8_str("thrown")) .ToLocalChecked(); - CHECK(thrown->BooleanValue(context.local()).FromJust()); + CHECK(thrown->BooleanValue(isolate)); } @@ -5781,7 +5774,7 @@ THREADED_TEST(APIThrowTryCatch) { Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); templ->Set(v8_str("ThrowFromC"), v8::FunctionTemplate::New(isolate, ThrowFromC)); - LocalContext context(0, templ); + LocalContext context(nullptr, templ); v8::TryCatch try_catch(isolate); CompileRun("ThrowFromC();"); CHECK(try_catch.HasCaught()); @@ -5800,7 +5793,7 @@ TEST(TryCatchInTryFinally) { v8::HandleScope scope(isolate); Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); templ->Set(v8_str("CCatcher"), v8::FunctionTemplate::New(isolate, CCatcher)); - LocalContext context(0, templ); + LocalContext context(nullptr, templ); Local<Value> result = CompileRun( "try {" " try {" @@ -5966,7 +5959,7 @@ TEST(APIThrowMessage) { Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); templ->Set(v8_str("ThrowFromC"), v8::FunctionTemplate::New(isolate, ThrowFromC)); - LocalContext context(0, templ); + LocalContext context(nullptr, templ); CompileRun("ThrowFromC();"); CHECK(message_received); isolate->RemoveMessageListeners(receive_message); @@ -5981,7 +5974,7 @@ TEST(APIThrowMessageAndVerboseTryCatch) { Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); templ->Set(v8_str("ThrowFromC"), v8::FunctionTemplate::New(isolate, ThrowFromC)); - LocalContext context(0, templ); + LocalContext context(nullptr, templ); v8::TryCatch try_catch(isolate); try_catch.SetVerbose(true); Local<Value> result = CompileRun("ThrowFromC();"); @@ -6013,7 +6006,7 @@ THREADED_TEST(ExternalScriptException) { Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); templ->Set(v8_str("ThrowFromC"), v8::FunctionTemplate::New(isolate, ThrowFromC)); - LocalContext context(0, templ); + LocalContext context(nullptr, templ); v8::TryCatch try_catch(isolate); Local<Value> result = CompileRun("ThrowFromC(); throw 'panama';"); @@ -6066,8 +6059,9 @@ void CThrowCountDown(const v8::FunctionCallbackInfo<v8::Value>& args) { void JSCheck(const v8::FunctionCallbackInfo<v8::Value>& args) { ApiTestFuzzer::Fuzz(); CHECK_EQ(3, args.Length()); - v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext(); - bool equality = args[0]->BooleanValue(context).FromJust(); + v8::Isolate* isolate = args.GetIsolate(); + v8::Local<v8::Context> context = isolate->GetCurrentContext(); + bool equality = args[0]->BooleanValue(isolate); int count = args[1]->Int32Value(context).FromJust(); int expected = args[2]->Int32Value(context).FromJust(); if (equality) { @@ -6121,7 +6115,7 @@ TEST(ExceptionOrder) { templ->Set(v8_str("check"), v8::FunctionTemplate::New(isolate, JSCheck)); templ->Set(v8_str("CThrowCountDown"), v8::FunctionTemplate::New(isolate, CThrowCountDown)); - LocalContext context(0, templ); + LocalContext context(nullptr, templ); CompileRun( "function JSThrowCountDown(count, jsInterval, cInterval, expected) {" " if (count == 0) throw 'FromJS';" @@ -6186,7 +6180,7 @@ THREADED_TEST(ThrowValues) { v8::HandleScope scope(isolate); Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); templ->Set(v8_str("Throw"), v8::FunctionTemplate::New(isolate, ThrowValue)); - LocalContext context(0, templ); + LocalContext context(nullptr, templ); v8::Local<v8::Array> result = v8::Local<v8::Array>::Cast( CompileRun("function Run(obj) {" " try {" @@ -6380,7 +6374,7 @@ TEST(TryCatchMixedNesting) { Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); templ->Set(v8_str("TryCatchMixedNestingHelper"), v8::FunctionTemplate::New(isolate, TryCatchMixedNestingHelper)); - LocalContext context(0, templ); + LocalContext context(nullptr, templ); CompileRunWithOrigin("TryCatchMixedNestingHelper();\n", "outer", 1, 1); TryCatchMixedNestingCheck(&try_catch); } @@ -6402,7 +6396,7 @@ TEST(TryCatchNative) { Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); templ->Set(v8_str("TryCatchNativeHelper"), v8::FunctionTemplate::New(isolate, TryCatchNativeHelper)); - LocalContext context(0, templ); + LocalContext context(nullptr, templ); CompileRun("TryCatchNativeHelper();"); CHECK(!try_catch.HasCaught()); } @@ -6427,7 +6421,7 @@ TEST(TryCatchNativeReset) { Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); templ->Set(v8_str("TryCatchNativeResetHelper"), v8::FunctionTemplate::New(isolate, TryCatchNativeResetHelper)); - LocalContext context(0, templ); + LocalContext context(nullptr, templ); CompileRun("TryCatchNativeResetHelper();"); CHECK(!try_catch.HasCaught()); } @@ -6630,7 +6624,7 @@ THREADED_TEST(DefinePropertyOnAPIAccessor) { "obj, 'x');" "prop.configurable;"); Local<Value> result = script_desc->Run(context.local()).ToLocalChecked(); - CHECK(result->BooleanValue(context.local()).FromJust()); + CHECK(result->BooleanValue(isolate)); // Redefine get - but still configurable Local<Script> script_define = v8_compile( @@ -6643,7 +6637,7 @@ THREADED_TEST(DefinePropertyOnAPIAccessor) { // Check that the accessor is still configurable result = script_desc->Run(context.local()).ToLocalChecked(); - CHECK(result->BooleanValue(context.local()).FromJust()); + CHECK(result->BooleanValue(isolate)); // Redefine to a non-configurable script_define = v8_compile( @@ -6654,7 +6648,7 @@ THREADED_TEST(DefinePropertyOnAPIAccessor) { result = script_define->Run(context.local()).ToLocalChecked(); CHECK(result->Equals(context.local(), v8_num(43)).FromJust()); result = script_desc->Run(context.local()).ToLocalChecked(); - CHECK(!result->BooleanValue(context.local()).FromJust()); + CHECK(!result->BooleanValue(isolate)); // Make sure that it is not possible to redefine again v8::TryCatch try_catch(isolate); @@ -6683,7 +6677,7 @@ THREADED_TEST(DefinePropertyOnDefineGetterSetter) { "obj, 'x');" "prop.configurable;"); Local<Value> result = script_desc->Run(context.local()).ToLocalChecked(); - CHECK(result->BooleanValue(context.local()).FromJust()); + CHECK(result->BooleanValue(isolate)); Local<Script> script_define = v8_compile( "var desc = {get: function(){return 42; }," @@ -6694,7 +6688,7 @@ THREADED_TEST(DefinePropertyOnDefineGetterSetter) { CHECK(result->Equals(context.local(), v8_num(42)).FromJust()); result = script_desc->Run(context.local()).ToLocalChecked(); - CHECK(result->BooleanValue(context.local()).FromJust()); + CHECK(result->BooleanValue(isolate)); script_define = v8_compile( "var desc = {get: function(){return 43; }," @@ -6705,7 +6699,7 @@ THREADED_TEST(DefinePropertyOnDefineGetterSetter) { CHECK(result->Equals(context.local(), v8_num(43)).FromJust()); result = script_desc->Run(context.local()).ToLocalChecked(); - CHECK(!result->BooleanValue(context.local()).FromJust()); + CHECK(!result->BooleanValue(isolate)); v8::TryCatch try_catch(isolate); CHECK(script_define->Run(context.local()).IsEmpty()); @@ -7007,7 +7001,7 @@ THREADED_TEST(MultiContexts) { Local<String> password = v8_str("Password"); // Create an environment - LocalContext context0(0, templ); + LocalContext context0(nullptr, templ); context0->SetSecurityToken(password); v8::Local<v8::Object> global0 = context0->Global(); CHECK(global0->Set(context0.local(), v8_str("custom"), v8_num(1234)) @@ -7018,7 +7012,7 @@ THREADED_TEST(MultiContexts) { .FromJust()); // Create an independent environment - LocalContext context1(0, templ); + LocalContext context1(nullptr, templ); context1->SetSecurityToken(password); v8::Local<v8::Object> global1 = context1->Global(); CHECK(global1->Set(context1.local(), v8_str("custom"), v8_num(1234)) @@ -7034,7 +7028,7 @@ THREADED_TEST(MultiContexts) { .FromJust()); // Now create a new context with the old global - LocalContext context2(0, templ, global1); + LocalContext context2(nullptr, templ, global1); context2->SetSecurityToken(password); v8::Local<v8::Object> global2 = context2->Global(); CHECK(global1->Equals(context2.local(), global2).FromJust()); @@ -7290,7 +7284,7 @@ THREADED_TEST(GlobalObjectTemplate) { Local<ObjectTemplate> global_template = ObjectTemplate::New(isolate); global_template->Set(v8_str("JSNI_Log"), v8::FunctionTemplate::New(isolate, HandleLogDelegator)); - v8::Local<Context> context = Context::New(isolate, 0, global_template); + v8::Local<Context> context = Context::New(isolate, nullptr, global_template); Context::Scope context_scope(context); CompileRun("JSNI_Log('LOG')"); } @@ -7377,8 +7371,9 @@ TEST(ExtensionWithSourceLength) { v8::HandleScope handle_scope(CcTest::isolate()); i::ScopedVector<char> extension_name(32); i::SNPrintF(extension_name, "ext #%d", source_len); - v8::RegisterExtension(new Extension( - extension_name.start(), kEmbeddedExtensionSource, 0, 0, source_len)); + v8::RegisterExtension(new Extension(extension_name.start(), + kEmbeddedExtensionSource, 0, nullptr, + source_len)); const char* extension_names[1] = {extension_name.start()}; v8::ExtensionConfiguration extensions(1, extension_names); v8::Local<Context> context = Context::New(CcTest::isolate(), &extensions); @@ -7537,8 +7532,8 @@ class NativeFunctionExtension : public Extension { v8::FunctionCallback fun = &Echo) : Extension(name, source), function_(fun) {} - virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( - v8::Isolate* isolate, v8::Local<v8::String> name) { + v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( + v8::Isolate* isolate, v8::Local<v8::String> name) override { return v8::FunctionTemplate::New(isolate, function_); } @@ -7668,8 +7663,8 @@ static void CallFun(const v8::FunctionCallbackInfo<v8::Value>& args) { class FunctionExtension : public Extension { public: FunctionExtension() : Extension("functiontest", kExtensionTestScript) {} - virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( - v8::Isolate* isolate, v8::Local<String> name); + v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( + v8::Isolate* isolate, v8::Local<String> name) override; }; @@ -8013,7 +8008,7 @@ void v8::internal::heap::HeapTester::ResetWeakHandle(bool global_gc) { object_a.handle.Reset(iso, a); object_b.handle.Reset(iso, b); if (global_gc) { - CcTest::CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); + CcTest::PreciseCollectAllGarbage(); } else { CcTest::CollectGarbage(i::NEW_SPACE); } @@ -8039,7 +8034,7 @@ void v8::internal::heap::HeapTester::ResetWeakHandle(bool global_gc) { #endif } if (global_gc) { - CcTest::CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); + CcTest::PreciseCollectAllGarbage(); } else { CcTest::CollectGarbage(i::NEW_SPACE); } @@ -8639,8 +8634,8 @@ THREADED_TEST(StringWrite) { CHECK_EQ(0, str->WriteOneByte(isolate, nullptr, 0, 0, String::NO_NULL_TERMINATION)); - CHECK_EQ(0, - str->WriteUtf8(isolate, nullptr, 0, 0, String::NO_NULL_TERMINATION)); + CHECK_EQ(0, str->WriteUtf8(isolate, nullptr, 0, nullptr, + String::NO_NULL_TERMINATION)); CHECK_EQ(0, str->Write(isolate, nullptr, 0, 0, String::NO_NULL_TERMINATION)); } @@ -8946,6 +8941,49 @@ THREADED_TEST(ToArrayIndex) { CHECK(index.IsEmpty()); } +static v8::MaybeLocal<Value> PrepareStackTrace42(v8::Local<Context> context, + v8::Local<Value> error, + v8::Local<StackTrace> trace) { + return v8::Number::New(context->GetIsolate(), 42); +} + +static v8::MaybeLocal<Value> PrepareStackTraceThrow( + v8::Local<Context> context, v8::Local<Value> error, + v8::Local<StackTrace> trace) { + v8::Isolate* isolate = context->GetIsolate(); + v8::Local<String> message = v8_str("42"); + isolate->ThrowException(v8::Exception::Error(message)); + return v8::MaybeLocal<Value>(); +} + +THREADED_TEST(IsolatePrepareStackTrace) { + LocalContext context; + v8::Isolate* isolate = context->GetIsolate(); + v8::HandleScope scope(isolate); + + isolate->SetPrepareStackTraceCallback(PrepareStackTrace42); + + v8::Local<Value> v = CompileRun("new Error().stack"); + + CHECK(v->IsNumber()); + CHECK_EQ(v.As<v8::Number>()->Int32Value(context.local()).FromJust(), 42); +} + +THREADED_TEST(IsolatePrepareStackTraceThrow) { + LocalContext context; + v8::Isolate* isolate = context->GetIsolate(); + v8::HandleScope scope(isolate); + + isolate->SetPrepareStackTraceCallback(PrepareStackTraceThrow); + + v8::Local<Value> v = CompileRun("try { new Error().stack } catch (e) { e }"); + + CHECK(v->IsNativeError()); + + v8::Local<String> message = v8::Exception::CreateMessage(isolate, v)->Get(); + + CHECK(message->StrictEquals(v8_str("Uncaught Error: 42"))); +} THREADED_TEST(ErrorConstruction) { LocalContext context; @@ -9297,7 +9335,7 @@ TEST(TryCatchFinallyStoresMessageUsingTryCatchHandler) { Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); templ->Set(v8_str("CEvaluate"), v8::FunctionTemplate::New(isolate, CEvaluate)); - LocalContext context(0, templ); + LocalContext context(nullptr, templ); v8::TryCatch try_catch(isolate); CompileRun("try {" " CEvaluate('throw 1;');" @@ -9741,7 +9779,7 @@ TEST(ContextDetachGlobal) { env2->DetachGlobal(); v8::Local<Context> env3 = Context::New( - env1->GetIsolate(), 0, v8::Local<v8::ObjectTemplate>(), global2); + env1->GetIsolate(), nullptr, v8::Local<v8::ObjectTemplate>(), global2); env3->SetSecurityToken(v8_str("bar")); env3->Enter(); @@ -9821,7 +9859,7 @@ TEST(DetachGlobal) { // Reuse global2 for env3. v8::Local<Context> env3 = Context::New( - env1->GetIsolate(), 0, v8::Local<v8::ObjectTemplate>(), global2); + env1->GetIsolate(), nullptr, v8::Local<v8::ObjectTemplate>(), global2); CHECK(global2->Equals(env1.local(), env3->Global()).FromJust()); // Start by using the same security token for env3 as for env1 and env2. @@ -9907,8 +9945,8 @@ TEST(DetachedAccesses) { CHECK(v8_str("env2_x")->Equals(env1.local(), result).FromJust()); // Reattach env2's proxy - env2 = Context::New(env1->GetIsolate(), 0, v8::Local<v8::ObjectTemplate>(), - env2_global); + env2 = Context::New(env1->GetIsolate(), nullptr, + v8::Local<v8::ObjectTemplate>(), env2_global); env2->SetSecurityToken(foo); { v8::Context::Scope scope(env2); @@ -10259,12 +10297,9 @@ TEST(AccessControlES5) { CHECK(global1->Set(context1, v8_str("other"), global0).FromJust()); // Regression test for issue 1154. - CHECK(CompileRun("Object.keys(other).length == 1") - ->BooleanValue(context1) - .FromJust()); + CHECK(CompileRun("Object.keys(other).length == 1")->BooleanValue(isolate)); CHECK(CompileRun("Object.keys(other)[0] == 'accessible_prop'") - ->BooleanValue(context1) - .FromJust()); + ->BooleanValue(isolate)); CHECK(CompileRun("other.blocked_prop").IsEmpty()); // Regression test for issue 1027. @@ -10354,12 +10389,12 @@ THREADED_TEST(AccessControlGetOwnPropertyNames) { value = CompileRun( "var names = Object.getOwnPropertyNames(other);" "names.length == 1 && names[0] == 'accessible_prop';"); - CHECK(value->BooleanValue(context1).FromJust()); + CHECK(value->BooleanValue(isolate)); value = CompileRun( "var names = Object.getOwnPropertyNames(object);" "names.length == 1 && names[0] == 'accessible_prop';"); - CHECK(value->BooleanValue(context1).FromJust()); + CHECK(value->BooleanValue(isolate)); context1->Exit(); context0->Exit(); @@ -10412,12 +10447,12 @@ THREADED_TEST(CrossDomainAccessors) { func_template->PrototypeTemplate(); // Add an accessor to proto that's accessible by cross-domain JS code. - proto_template->SetAccessor(v8_str("accessible"), ConstTenGetter, 0, + proto_template->SetAccessor(v8_str("accessible"), ConstTenGetter, nullptr, v8::Local<Value>(), v8::ALL_CAN_READ); // Add an accessor that is not accessible by cross-domain JS code. - global_template->SetAccessor(v8_str("unreachable"), UnreachableGetter, 0, - v8::Local<Value>(), v8::DEFAULT); + global_template->SetAccessor(v8_str("unreachable"), UnreachableGetter, + nullptr, v8::Local<Value>(), v8::DEFAULT); v8::Local<Context> context0 = Context::New(isolate, nullptr, global_template); context0->Enter(); @@ -10555,7 +10590,7 @@ TEST(AccessControlIC) { // Force obj into slow case. value = CompileRun("delete obj.prop"); - CHECK(value->BooleanValue(context1).FromJust()); + CHECK(value->BooleanValue(isolate)); // Force inline caches into dictionary probing mode. CompileRun("var o = { x: 0 }; delete o.x; testProp(o);"); // Test that the named access check is called. @@ -10873,7 +10908,7 @@ THREADED_TEST(ShadowObject) { Local<Value> value = CompileRun("this.propertyIsEnumerable(0)"); CHECK(value->IsBoolean()); - CHECK(!value->BooleanValue(context.local()).FromJust()); + CHECK(!value->BooleanValue(isolate)); value = CompileRun("x"); CHECK_EQ(12, value->Int32Value(context.local()).FromJust()); @@ -11335,8 +11370,7 @@ THREADED_TEST(FunctionReadOnlyPrototype) { " descriptor = Object.getOwnPropertyDescriptor(func1, 'prototype');" " return (descriptor['writable'] == false);" "})()") - ->BooleanValue(context.local()) - .FromJust()); + ->BooleanValue(isolate)); CHECK_EQ( 42, CompileRun("func1.prototype.x")->Int32Value(context.local()).FromJust()); @@ -11357,8 +11391,7 @@ THREADED_TEST(FunctionReadOnlyPrototype) { " descriptor = Object.getOwnPropertyDescriptor(func2, 'prototype');" " return (descriptor['writable'] == true);" "})()") - ->BooleanValue(context.local()) - .FromJust()); + ->BooleanValue(isolate)); CHECK_EQ( 42, CompileRun("func2.prototype.x")->Int32Value(context.local()).FromJust()); @@ -11405,9 +11438,7 @@ THREADED_TEST(FunctionRemovePrototype) { Local<v8::Function> fun = t1->GetFunction(context.local()).ToLocalChecked(); CHECK(!fun->IsConstructor()); CHECK(context->Global()->Set(context.local(), v8_str("fun"), fun).FromJust()); - CHECK(!CompileRun("'prototype' in fun") - ->BooleanValue(context.local()) - .FromJust()); + CHECK(!CompileRun("'prototype' in fun")->BooleanValue(isolate)); v8::TryCatch try_catch(isolate); CompileRun("new fun()"); @@ -11460,7 +11491,7 @@ THREADED_TEST(Constructor) { i::Handle<i::JSReceiver> obj(v8::Utils::OpenHandle(*inst)); CHECK(obj->IsJSObject()); Local<Value> value = CompileRun("(new Fun()).constructor === Fun"); - CHECK(value->BooleanValue(context.local()).FromJust()); + CHECK(value->BooleanValue(isolate)); } @@ -13022,17 +13053,16 @@ THREADED_TEST(Overriding) { // Add 'h' as an accessor to the proto template with ReadOnly attributes // so 'h' can be shadowed on the instance object. Local<ObjectTemplate> child_proto_templ = child_templ->PrototypeTemplate(); - child_proto_templ->SetAccessor(v8_str("h"), ParentGetter, 0, + child_proto_templ->SetAccessor(v8_str("h"), ParentGetter, nullptr, v8::Local<Value>(), v8::DEFAULT, v8::ReadOnly); // Add 'i' as an accessor to the instance template with ReadOnly attributes // but the attribute does not have effect because it is duplicated with // nullptr setter. - child_instance_templ->SetAccessor(v8_str("i"), ChildGetter, 0, + child_instance_templ->SetAccessor(v8_str("i"), ChildGetter, nullptr, v8::Local<Value>(), v8::DEFAULT, v8::ReadOnly); - // Instantiate the child template. Local<v8::Object> instance = child_templ->GetFunction(context.local()) .ToLocalChecked() @@ -13475,9 +13505,9 @@ THREADED_TEST(IsConstructCall) { templ->GetFunction(context.local()).ToLocalChecked()) .FromJust()); Local<Value> value = v8_compile("f()")->Run(context.local()).ToLocalChecked(); - CHECK(!value->BooleanValue(context.local()).FromJust()); + CHECK(!value->BooleanValue(isolate)); value = v8_compile("new f()")->Run(context.local()).ToLocalChecked(); - CHECK(value->BooleanValue(context.local()).FromJust()); + CHECK(value->BooleanValue(isolate)); } static void NewTargetHandler(const v8::FunctionCallbackInfo<v8::Value>& args) { @@ -13625,7 +13655,7 @@ TEST(ObjectProtoToStringES6) { CHECK(value->IsString() && \ value->Equals(context.local(), v8_str("[object " #expected "]")) \ .FromJust()); \ - } while (0) + } while (false) TEST_TOSTRINGTAG(Array, Object, Object); TEST_TOSTRINGTAG(Object, Arguments, Arguments); @@ -13664,7 +13694,7 @@ TEST(ObjectProtoToStringES6) { CHECK(value->IsString() && \ value->Equals(context.local(), v8_str("[object " #expected "]")) \ .FromJust()); \ - } while (0) + } while (false) #define TEST_TOSTRINGTAG_TYPES(tagValue) \ TEST_TOSTRINGTAG(Array, tagValue, Array); \ @@ -13701,7 +13731,7 @@ TEST(ObjectProtoToStringES6) { obj = v8::Object::New(isolate); obj.As<v8::Object>() ->SetAccessor(context.local(), toStringTag, - SymbolAccessorGetterReturnsDefault, 0, v8_str("Test")) + SymbolAccessorGetterReturnsDefault, nullptr, v8_str("Test")) .FromJust(); { TryCatch try_catch(isolate); @@ -14163,7 +14193,7 @@ static void CheckSurvivingGlobalObjectsCount(int expected) { // been marked at that point. Therefore some of the maps are not // collected until the second garbage collection. CcTest::CollectAllGarbage(); - CcTest::CollectAllGarbage(i::Heap::kMakeHeapIterableMask); + CcTest::CollectAllGarbage(); int count = GetGlobalObjectsCount(); CHECK_EQ(expected, count); } @@ -14260,9 +14290,7 @@ TEST(WeakCallbackApi) { handle->SetWeak<v8::Persistent<v8::Object>>( handle, WeakApiCallback, v8::WeakCallbackType::kParameter); } - reinterpret_cast<i::Isolate*>(isolate)->heap()->CollectAllGarbage( - i::Heap::kAbortIncrementalMarkingMask, - i::GarbageCollectionReason::kTesting); + CcTest::PreciseCollectAllGarbage(); // Verify disposed. CHECK_EQ(initial_handles, globals->global_handles_count()); } @@ -15170,7 +15198,7 @@ THREADED_TEST(TryCatchSourceInfoForEOSError) { CHECK(v8::Script::Compile(context.local(), v8_str("!\n")).IsEmpty()); CHECK(try_catch.HasCaught()); v8::Local<v8::Message> message = try_catch.Message(); - CHECK_EQ(1, message->GetLineNumber(context.local()).FromJust()); + CHECK_EQ(2, message->GetLineNumber(context.local()).FromJust()); CHECK_EQ(0, message->GetStartColumn(context.local()).FromJust()); } @@ -15776,10 +15804,10 @@ class OneByteVectorResource : public v8::String::ExternalOneByteStringResource { public: explicit OneByteVectorResource(i::Vector<const char> vector) : data_(vector) {} - virtual ~OneByteVectorResource() {} - virtual size_t length() const { return data_.length(); } - virtual const char* data() const { return data_.start(); } - virtual void Dispose() {} + ~OneByteVectorResource() override = default; + size_t length() const override { return data_.length(); } + const char* data() const override { return data_.start(); } + void Dispose() override {} private: i::Vector<const char> data_; @@ -15790,10 +15818,10 @@ class UC16VectorResource : public v8::String::ExternalStringResource { public: explicit UC16VectorResource(i::Vector<const i::uc16> vector) : data_(vector) {} - virtual ~UC16VectorResource() {} - virtual size_t length() const { return data_.length(); } - virtual const i::uc16* data() const { return data_.start(); } - virtual void Dispose() {} + ~UC16VectorResource() override = default; + size_t length() const override { return data_.length(); } + const i::uc16* data() const override { return data_.start(); } + void Dispose() override {} private: i::Vector<const i::uc16> data_; @@ -15962,7 +15990,7 @@ class RegExpInterruptionThread : public v8::base::Thread { explicit RegExpInterruptionThread(v8::Isolate* isolate) : Thread(Options("TimeoutThread")), isolate_(isolate) {} - virtual void Run() { + void Run() override { for (v8::base::Relaxed_Store(®exp_interruption_data.loop_count, 0); v8::base::Relaxed_Load(®exp_interruption_data.loop_count) < 7; v8::base::Relaxed_AtomicIncrement(®exp_interruption_data.loop_count, @@ -16034,7 +16062,7 @@ TEST(ReadOnlyPropertyInGlobalProto) { v8::Isolate* isolate = CcTest::isolate(); v8::HandleScope scope(isolate); v8::Local<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate); - LocalContext context(0, templ); + LocalContext context(nullptr, templ); v8::Local<v8::Object> global = context->Global(); v8::Local<v8::Object> global_proto = v8::Local<v8::Object>::Cast( global->Get(context.local(), v8_str("__proto__")).ToLocalChecked()); @@ -16629,9 +16657,9 @@ static void ObjectWithExternalArrayTestHelper(Local<Context> context, i::ExternalArrayType array_type, int64_t low, int64_t high) { i::Handle<i::JSReceiver> jsobj = v8::Utils::OpenHandle(*obj); - i::Isolate* isolate = jsobj->GetIsolate(); - obj->Set(context, v8_str("field"), - v8::Int32::New(reinterpret_cast<v8::Isolate*>(isolate), 1503)) + v8::Isolate* v8_isolate = context->GetIsolate(); + i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); + obj->Set(context, v8_str("field"), v8::Int32::New(v8_isolate, 1503)) .FromJust(); CHECK(context->Global()->Set(context, v8_str("ext_array"), obj).FromJust()); v8::Local<v8::Value> result = CompileRun("ext_array.field"); @@ -16751,7 +16779,7 @@ static void ObjectWithExternalArrayTestHelper(Local<Context> context, "caught_exception;", element_count); result = CompileRun(test_buf.start()); - CHECK(!result->BooleanValue(context).FromJust()); + CHECK(!result->BooleanValue(v8_isolate)); // Make sure out-of-range stores do not throw. i::SNPrintF(test_buf, @@ -16764,7 +16792,7 @@ static void ObjectWithExternalArrayTestHelper(Local<Context> context, "caught_exception;", element_count); result = CompileRun(test_buf.start()); - CHECK(!result->BooleanValue(context).FromJust()); + CHECK(!result->BooleanValue(v8_isolate)); // Check other boundary conditions, values and operations. result = CompileRun("for (var i = 0; i < 8; i++) {" @@ -16856,7 +16884,7 @@ static void ObjectWithExternalArrayTestHelper(Local<Context> context, unsigned_data : (is_pixel_data ? pixel_data : signed_data))); result = CompileRun(test_buf.start()); - CHECK(result->BooleanValue(context).FromJust()); + CHECK(result->BooleanValue(v8_isolate)); } i::Handle<ExternalArrayClass> array( @@ -17485,7 +17513,7 @@ TEST(CaptureStackTrace) { Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); templ->Set(v8_str("AnalyzeStackInNativeCode"), v8::FunctionTemplate::New(isolate, AnalyzeStackInNativeCode)); - LocalContext context(0, templ); + LocalContext context(nullptr, templ); // Test getting OVERVIEW information. Should ignore information that is not // script name, function name, line number, and column offset. @@ -17899,6 +17927,7 @@ int promise_reject_msg_column_number = -1; int promise_reject_line_number = -1; int promise_reject_column_number = -1; int promise_reject_frame_count = -1; +bool promise_reject_is_shared_cross_origin = false; void PromiseRejectCallback(v8::PromiseRejectMessage reject_message) { v8::Local<v8::Object> global = CcTest::global(); @@ -17920,6 +17949,8 @@ void PromiseRejectCallback(v8::PromiseRejectMessage reject_message) { message->GetLineNumber(context).FromJust(); promise_reject_msg_column_number = message->GetStartColumn(context).FromJust() + 1; + promise_reject_is_shared_cross_origin = + message->IsSharedCrossOrigin(); if (!stack_trace.IsEmpty()) { promise_reject_frame_count = stack_trace->GetFrameCount(); @@ -18350,6 +18381,67 @@ TEST(PromiseRejectCallback) { CHECK_EQ(7, promise_reject_msg_column_number); } +TEST(PromiseRejectIsSharedCrossOrigin) { + LocalContext env; + v8::Isolate* isolate = env->GetIsolate(); + v8::HandleScope scope(isolate); + + isolate->SetPromiseRejectCallback(PromiseRejectCallback); + + ResetPromiseStates(); + + // Create promise p0. + CompileRun( + "var reject; \n" + "var p0 = new Promise( \n" + " function(res, rej) { \n" + " reject = rej; \n" + " } \n" + "); \n"); + CHECK(!GetPromise("p0")->HasHandler()); + CHECK_EQ(0, promise_reject_counter); + CHECK_EQ(0, promise_revoke_counter); + // Not set because it's not yet rejected. + CHECK(!promise_reject_is_shared_cross_origin); + + // Reject p0. + CompileRun("reject('ppp');"); + CHECK_EQ(1, promise_reject_counter); + CHECK_EQ(0, promise_revoke_counter); + // Not set because the ScriptOriginOptions is from the script. + CHECK(!promise_reject_is_shared_cross_origin); + + ResetPromiseStates(); + + // Create promise p1 + CompileRun( + "var reject; \n" + "var p1 = new Promise( \n" + " function(res, rej) { \n" + " reject = rej; \n" + " } \n" + "); \n"); + CHECK(!GetPromise("p1")->HasHandler()); + CHECK_EQ(0, promise_reject_counter); + CHECK_EQ(0, promise_revoke_counter); + // Not set because it's not yet rejected. + CHECK(!promise_reject_is_shared_cross_origin); + + // Add resolve handler (and default reject handler) to p1. + CompileRun("var p2 = p1.then(function(){});"); + CHECK(GetPromise("p1")->HasHandler()); + CHECK(!GetPromise("p2")->HasHandler()); + CHECK_EQ(0, promise_reject_counter); + CHECK_EQ(0, promise_revoke_counter); + + // Reject p1. + CompileRun("reject('ppp');"); + CHECK_EQ(1, promise_reject_counter); + CHECK_EQ(0, promise_revoke_counter); + // Set because the event is from an empty script. + CHECK(promise_reject_is_shared_cross_origin); +} + void PromiseRejectCallbackConstructError( v8::PromiseRejectMessage reject_message) { v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext(); @@ -18403,7 +18495,7 @@ TEST(SourceURLInStackTrace) { templ->Set(v8_str("AnalyzeStackOfEvalWithSourceURL"), v8::FunctionTemplate::New(isolate, AnalyzeStackOfEvalWithSourceURL)); - LocalContext context(0, templ); + LocalContext context(nullptr, templ); const char *source = "function outer() {\n" @@ -18447,7 +18539,7 @@ TEST(ScriptIdInStackTrace) { Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); templ->Set(v8_str("AnalyzeScriptIdInStack"), v8::FunctionTemplate::New(isolate, AnalyzeScriptIdInStack)); - LocalContext context(0, templ); + LocalContext context(nullptr, templ); v8::Local<v8::String> scriptSource = v8_str( "function foo() {\n" @@ -18486,7 +18578,7 @@ TEST(InlineScriptWithSourceURLInStackTrace) { templ->Set(v8_str("AnalyzeStackOfInlineScriptWithSourceURL"), v8::FunctionTemplate::New( CcTest::isolate(), AnalyzeStackOfInlineScriptWithSourceURL)); - LocalContext context(0, templ); + LocalContext context(nullptr, templ); const char *source = "function outer() {\n" @@ -18901,7 +18993,7 @@ TEST(DynamicWithSourceURLInStackTrace) { templ->Set(v8_str("AnalyzeStackOfDynamicScriptWithSourceURL"), v8::FunctionTemplate::New( CcTest::isolate(), AnalyzeStackOfDynamicScriptWithSourceURL)); - LocalContext context(0, templ); + LocalContext context(nullptr, templ); const char *source = "function outer() {\n" @@ -19202,7 +19294,7 @@ TEST(NumberOfNativeContexts) { } for (size_t i = 0; i < kNumTestContexts; i++) { context[i].Reset(); - CcTest::CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); + CcTest::PreciseCollectAllGarbage(); CcTest::isolate()->GetHeapStatistics(&heap_statistics); CHECK_EQ(kNumTestContexts - i - 1u, heap_statistics.number_of_native_contexts()); @@ -19228,7 +19320,7 @@ TEST(NumberOfDetachedContexts) { } for (size_t i = 0; i < kNumTestContexts; i++) { context[i].Reset(); - CcTest::CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); + CcTest::PreciseCollectAllGarbage(); CcTest::isolate()->GetHeapStatistics(&heap_statistics); CHECK_EQ(kNumTestContexts - i - 1u, heap_statistics.number_of_detached_contexts()); @@ -19243,8 +19335,8 @@ class VisitorImpl : public v8::ExternalResourceVisitor { found_resource_[i] = false; } } - virtual ~VisitorImpl() {} - virtual void VisitExternalString(v8::Local<v8::String> string) { + ~VisitorImpl() override = default; + void VisitExternalString(v8::Local<v8::String> string) override { if (!string->IsExternal()) { CHECK(string->IsExternalOneByte()); return; @@ -19772,7 +19864,8 @@ THREADED_TEST(FunctionGetInferredName) { THREADED_TEST(FunctionGetDebugName) { LocalContext env; - v8::HandleScope scope(env->GetIsolate()); + v8::Isolate* isolate = env->GetIsolate(); + v8::HandleScope scope(isolate); const char* code = "var error = false;" "function a() { this.x = 1; };" @@ -19823,7 +19916,7 @@ THREADED_TEST(FunctionGetDebugName) { .ToLocalChecked(); v8::Local<v8::Value> error = env->Global()->Get(env.local(), v8_str("error")).ToLocalChecked(); - CHECK(!error->BooleanValue(env.local()).FromJust()); + CHECK(!error->BooleanValue(isolate)); const char* functions[] = {"a", "display_a", "b", "display_b", "c", "c", @@ -19840,20 +19933,20 @@ THREADED_TEST(FunctionGetDebugName) { v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( env->Global() ->Get(env.local(), - v8::String::NewFromUtf8(env->GetIsolate(), functions[i * 2], + v8::String::NewFromUtf8(isolate, functions[i * 2], v8::NewStringType::kNormal) .ToLocalChecked()) .ToLocalChecked()); CHECK_EQ(0, strcmp(functions[i * 2 + 1], - *v8::String::Utf8Value(env->GetIsolate(), - f->GetDebugName()))); + *v8::String::Utf8Value(isolate, f->GetDebugName()))); } } THREADED_TEST(FunctionGetDisplayName) { LocalContext env; - v8::HandleScope scope(env->GetIsolate()); + v8::Isolate* isolate = env->GetIsolate(); + v8::HandleScope scope(isolate); const char* code = "var error = false;" "function a() { this.x = 1; };" "a.displayName = 'display_a';" @@ -19907,18 +20000,17 @@ THREADED_TEST(FunctionGetDisplayName) { env->Global()->Get(env.local(), v8_str("f")).ToLocalChecked()); v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( env->Global()->Get(env.local(), v8_str("g")).ToLocalChecked()); - CHECK(!error->BooleanValue(env.local()).FromJust()); - CHECK_EQ(0, strcmp("display_a", *v8::String::Utf8Value(env->GetIsolate(), - a->GetDisplayName()))); - CHECK_EQ(0, strcmp("display_b", *v8::String::Utf8Value(env->GetIsolate(), - b->GetDisplayName()))); + CHECK(!error->BooleanValue(isolate)); + CHECK_EQ(0, strcmp("display_a", + *v8::String::Utf8Value(isolate, a->GetDisplayName()))); + CHECK_EQ(0, strcmp("display_b", + *v8::String::Utf8Value(isolate, b->GetDisplayName()))); CHECK(c->GetDisplayName()->IsUndefined()); CHECK(d->GetDisplayName()->IsUndefined()); CHECK(e->GetDisplayName()->IsUndefined()); CHECK(f->GetDisplayName()->IsUndefined()); - CHECK_EQ( - 0, strcmp("set_in_runtime", *v8::String::Utf8Value(env->GetIsolate(), - g->GetDisplayName()))); + CHECK_EQ(0, strcmp("set_in_runtime", + *v8::String::Utf8Value(isolate, g->GetDisplayName()))); } @@ -20313,7 +20405,7 @@ void PrologueCallbackAlloc(v8::Isolate* isolate, Local<Object> obj = Object::New(isolate); CHECK(!obj.IsEmpty()); - CcTest::CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); + CcTest::PreciseCollectAllGarbage(); } @@ -20332,7 +20424,7 @@ void EpilogueCallbackAlloc(v8::Isolate* isolate, Local<Object> obj = Object::New(isolate); CHECK(!obj.IsEmpty()); - CcTest::CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); + CcTest::PreciseCollectAllGarbage(); } @@ -20455,7 +20547,7 @@ TEST(GCCallbacks) { CHECK_EQ(0, epilogue_call_count_alloc); isolate->AddGCPrologueCallback(PrologueCallbackAlloc); isolate->AddGCEpilogueCallback(EpilogueCallbackAlloc); - CcTest::CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); + CcTest::PreciseCollectAllGarbage(); CHECK_EQ(1, prologue_call_count_alloc); CHECK_EQ(1, epilogue_call_count_alloc); isolate->RemoveGCPrologueCallback(PrologueCallbackAlloc); @@ -20998,7 +21090,7 @@ class IsolateThread : public v8::base::Thread { explicit IsolateThread(int fib_limit) : Thread(Options("IsolateThread")), fib_limit_(fib_limit), result_(0) {} - void Run() { + void Run() override { v8::Isolate::CreateParams create_params; create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); v8::Isolate* isolate = v8::Isolate::New(create_params); @@ -21078,7 +21170,7 @@ class InitDefaultIsolateThread : public v8::base::Thread { testCase_(testCase), result_(false) {} - void Run() { + void Run() override { v8::Isolate::CreateParams create_params; create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); switch (testCase_) { @@ -21268,8 +21360,8 @@ class Visitor42 : public v8::PersistentHandleVisitor { explicit Visitor42(v8::Persistent<v8::Object>* object) : counter_(0), object_(object) { } - virtual void VisitPersistentHandle(Persistent<Value>* value, - uint16_t class_id) { + void VisitPersistentHandle(Persistent<Value>* value, + uint16_t class_id) override { if (class_id != 42) return; CHECK_EQ(42, value->WrapperClassId()); v8::Isolate* isolate = CcTest::isolate(); @@ -21765,7 +21857,7 @@ TEST(HasOwnProperty) { { // Check named query interceptors. Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); templ->SetHandler(v8::NamedPropertyHandlerConfiguration( - 0, 0, HasOwnPropertyNamedPropertyQuery)); + nullptr, nullptr, HasOwnPropertyNamedPropertyQuery)); Local<Object> instance = templ->NewInstance(env.local()).ToLocalChecked(); CHECK(instance->HasOwnProperty(env.local(), v8_str("foo")).FromJust()); CHECK(!instance->HasOwnProperty(env.local(), v8_str("bar")).FromJust()); @@ -21773,7 +21865,7 @@ TEST(HasOwnProperty) { { // Check indexed query interceptors. Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); templ->SetHandler(v8::IndexedPropertyHandlerConfiguration( - 0, 0, HasOwnPropertyIndexedPropertyQuery)); + nullptr, nullptr, HasOwnPropertyIndexedPropertyQuery)); Local<Object> instance = templ->NewInstance(env.local()).ToLocalChecked(); CHECK(instance->HasOwnProperty(env.local(), v8_str("42")).FromJust()); CHECK(instance->HasOwnProperty(env.local(), 42).FromJust()); @@ -21790,7 +21882,7 @@ TEST(HasOwnProperty) { { // Check that query wins on disagreement. Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); templ->SetHandler(v8::NamedPropertyHandlerConfiguration( - HasOwnPropertyNamedPropertyGetter, 0, + HasOwnPropertyNamedPropertyGetter, nullptr, HasOwnPropertyNamedPropertyQuery2)); Local<Object> instance = templ->NewInstance(env.local()).ToLocalChecked(); CHECK(!instance->HasOwnProperty(env.local(), v8_str("foo")).FromJust()); @@ -21806,7 +21898,7 @@ TEST(HasOwnProperty) { "var dyn_string = 'this string ';" "dyn_string += 'does not exist elsewhere';" "({}).hasOwnProperty.call(obj, dyn_string)"; - CHECK(CompileRun(src)->BooleanValue(env.local()).FromJust()); + CHECK(CompileRun(src)->BooleanValue(isolate)); } } @@ -21824,14 +21916,14 @@ TEST(IndexedInterceptorWithStringProto) { .FromJust()); CompileRun("var s = new String('foobar'); obj.__proto__ = s;"); // These should be intercepted. - CHECK(CompileRun("42 in obj")->BooleanValue(context.local()).FromJust()); - CHECK(CompileRun("'42' in obj")->BooleanValue(context.local()).FromJust()); + CHECK(CompileRun("42 in obj")->BooleanValue(isolate)); + CHECK(CompileRun("'42' in obj")->BooleanValue(isolate)); // These should fall through to the String prototype. - CHECK(CompileRun("0 in obj")->BooleanValue(context.local()).FromJust()); - CHECK(CompileRun("'0' in obj")->BooleanValue(context.local()).FromJust()); + CHECK(CompileRun("0 in obj")->BooleanValue(isolate)); + CHECK(CompileRun("'0' in obj")->BooleanValue(isolate)); // And these should both fail. - CHECK(!CompileRun("32 in obj")->BooleanValue(context.local()).FromJust()); - CHECK(!CompileRun("'32' in obj")->BooleanValue(context.local()).FromJust()); + CHECK(!CompileRun("32 in obj")->BooleanValue(isolate)); + CHECK(!CompileRun("'32' in obj")->BooleanValue(isolate)); } @@ -22008,7 +22100,7 @@ static int CountLiveMapsInMapCache(i::Context* context) { int length = map_cache->length(); int count = 0; for (int i = 0; i < length; i++) { - if (map_cache->Get(i)->IsWeakHeapObject()) count++; + if (map_cache->Get(i)->IsWeak()) count++; } return count; } @@ -22034,7 +22126,7 @@ THREADED_TEST(Regress1516) { CHECK_LE(1, elements); // We have to abort incremental marking here to abandon black pages. - CcTest::CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); + CcTest::PreciseCollectAllGarbage(); CHECK_GT(elements, CountLiveMapsInMapCache(CcTest::i_isolate()->context())); } @@ -23585,7 +23677,7 @@ THREADED_TEST(JSONStringifyObjectWithGap) { class ThreadInterruptTest { public: ThreadInterruptTest() : sem_(0), sem_value_(0) { } - ~ThreadInterruptTest() {} + ~ThreadInterruptTest() = default; void RunTest() { InterruptThread i_thread(this); @@ -23603,7 +23695,7 @@ class ThreadInterruptTest { explicit InterruptThread(ThreadInterruptTest* test) : Thread(Options("InterruptThread")), test_(test) {} - virtual void Run() { + void Run() override { struct sigaction action; // Ensure that we'll enter waiting condition @@ -23798,8 +23890,9 @@ TEST(AccessCheckThrows) { CheckCorrectThrow("JSON.stringify(other)"); CheckCorrectThrow("has_own_property(other, 'x')"); CheckCorrectThrow("%GetProperty(other, 'x')"); - CheckCorrectThrow("%SetProperty(other, 'x', 'foo', 0)"); + CheckCorrectThrow("%SetKeyedProperty(other, 'x', 'foo', 0)"); CheckCorrectThrow("%AddNamedProperty(other, 'x', 'foo', 1)"); + CheckCorrectThrow("%SetNamedProperty(other, 'y', 'foo', 1)"); STATIC_ASSERT(static_cast<int>(i::LanguageMode::kSloppy) == 0); STATIC_ASSERT(static_cast<int>(i::LanguageMode::kStrict) == 1); CheckCorrectThrow("%DeleteProperty(other, 'x', 0)"); // 0 == SLOPPY @@ -23932,7 +24025,7 @@ class RequestInterruptTestBase { should_continue_(true) { } - virtual ~RequestInterruptTestBase() { } + virtual ~RequestInterruptTestBase() = default; virtual void StartInterruptThread() = 0; @@ -23987,9 +24080,7 @@ class RequestInterruptTestBaseWithSimpleInterrupt public: RequestInterruptTestBaseWithSimpleInterrupt() : i_thread(this) { } - virtual void StartInterruptThread() { - i_thread.Start(); - } + void StartInterruptThread() override { i_thread.Start(); } private: class InterruptThread : public v8::base::Thread { @@ -23997,7 +24088,7 @@ class RequestInterruptTestBaseWithSimpleInterrupt explicit InterruptThread(RequestInterruptTestBase* test) : Thread(Options("RequestInterruptTest")), test_(test) {} - virtual void Run() { + void Run() override { test_->sem_.Wait(); test_->isolate_->RequestInterrupt(&OnInterrupt, test_); } @@ -24018,7 +24109,7 @@ class RequestInterruptTestBaseWithSimpleInterrupt class RequestInterruptTestWithFunctionCall : public RequestInterruptTestBaseWithSimpleInterrupt { public: - virtual void TestBody() { + void TestBody() override { Local<Function> func = Function::New(env_.local(), ShouldContinueCallback, v8::External::New(isolate_, this)) .ToLocalChecked(); @@ -24034,7 +24125,7 @@ class RequestInterruptTestWithFunctionCall class RequestInterruptTestWithMethodCall : public RequestInterruptTestBaseWithSimpleInterrupt { public: - virtual void TestBody() { + void TestBody() override { v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate_); v8::Local<v8::Template> proto = t->PrototypeTemplate(); proto->Set(v8_str("shouldContinue"), @@ -24053,7 +24144,7 @@ class RequestInterruptTestWithMethodCall class RequestInterruptTestWithAccessor : public RequestInterruptTestBaseWithSimpleInterrupt { public: - virtual void TestBody() { + void TestBody() override { v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate_); v8::Local<v8::Template> proto = t->PrototypeTemplate(); proto->SetAccessorProperty(v8_str("shouldContinue"), FunctionTemplate::New( @@ -24071,7 +24162,7 @@ class RequestInterruptTestWithAccessor class RequestInterruptTestWithNativeAccessor : public RequestInterruptTestBaseWithSimpleInterrupt { public: - virtual void TestBody() { + void TestBody() override { v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate_); t->InstanceTemplate()->SetNativeDataProperty( v8_str("shouldContinue"), &ShouldContinueNativeGetter, nullptr, @@ -24099,7 +24190,7 @@ class RequestInterruptTestWithNativeAccessor class RequestInterruptTestWithMethodCallAndInterceptor : public RequestInterruptTestBaseWithSimpleInterrupt { public: - virtual void TestBody() { + void TestBody() override { v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate_); v8::Local<v8::Template> proto = t->PrototypeTemplate(); proto->Set(v8_str("shouldContinue"), @@ -24126,7 +24217,7 @@ class RequestInterruptTestWithMethodCallAndInterceptor class RequestInterruptTestWithMathAbs : public RequestInterruptTestBaseWithSimpleInterrupt { public: - virtual void TestBody() { + void TestBody() override { env_->Global() ->Set(env_.local(), v8_str("WakeUpInterruptor"), Function::New(env_.local(), WakeUpInterruptorCallback, @@ -24164,9 +24255,7 @@ class RequestInterruptTestWithMathAbs private: static void WakeUpInterruptorCallback( const v8::FunctionCallbackInfo<Value>& info) { - if (!info[0] - ->BooleanValue(info.GetIsolate()->GetCurrentContext()) - .FromJust()) { + if (!info[0]->BooleanValue(info.GetIsolate())) { return; } @@ -24220,11 +24309,9 @@ class RequestMultipleInterrupts : public RequestInterruptTestBase { public: RequestMultipleInterrupts() : i_thread(this), counter_(0) {} - virtual void StartInterruptThread() { - i_thread.Start(); - } + void StartInterruptThread() override { i_thread.Start(); } - virtual void TestBody() { + void TestBody() override { Local<Function> func = Function::New(env_.local(), ShouldContinueCallback, v8::External::New(isolate_, this)) .ToLocalChecked(); @@ -24242,7 +24329,7 @@ class RequestMultipleInterrupts : public RequestInterruptTestBase { explicit InterruptThread(RequestMultipleInterrupts* test) : Thread(Options("RequestInterruptTest")), test_(test) {} - virtual void Run() { + void Run() override { test_->sem_.Wait(); for (int i = 0; i < NUM_INTERRUPTS; i++) { test_->isolate_->RequestInterrupt(&OnInterrupt, test_); @@ -24369,7 +24456,8 @@ TEST(Regress239669) { v8::Isolate* isolate = context->GetIsolate(); v8::HandleScope scope(isolate); Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); - templ->SetAccessor(v8_str("x"), 0, SetterWhichExpectsThisAndHolderToDiffer); + templ->SetAccessor(v8_str("x"), nullptr, + SetterWhichExpectsThisAndHolderToDiffer); CHECK(context->Global() ->Set(context.local(), v8_str("P"), templ->NewInstance(context.local()).ToLocalChecked()) @@ -25591,7 +25679,7 @@ class TestSourceStream : public v8::ScriptCompiler::ExternalSourceStream { public: explicit TestSourceStream(const char** chunks) : chunks_(chunks), index_(0) {} - virtual size_t GetMoreData(const uint8_t** src) { + size_t GetMoreData(const uint8_t** src) override { // Unlike in real use cases, this function will never block. if (chunks_[index_] == nullptr) { return 0; @@ -26466,58 +26554,6 @@ TEST(TurboAsmDisablesNeuter) { CHECK(!result->IsNeuterable()); } -TEST(GetPrototypeAccessControl) { - i::FLAG_allow_natives_syntax = true; - v8::Isolate* isolate = CcTest::isolate(); - v8::HandleScope handle_scope(isolate); - LocalContext env; - - v8::Local<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New(isolate); - obj_template->SetAccessCheckCallback(AccessAlwaysBlocked); - - CHECK(env->Global() - ->Set(env.local(), v8_str("prohibited"), - obj_template->NewInstance(env.local()).ToLocalChecked()) - .FromJust()); - - CHECK(CompileRun( - "function f() { return %_GetPrototype(prohibited); }" - "%OptimizeFunctionOnNextCall(f);" - "f();")->IsNull()); -} - - -TEST(GetPrototypeHidden) { - i::FLAG_allow_natives_syntax = true; - v8::Isolate* isolate = CcTest::isolate(); - v8::HandleScope handle_scope(isolate); - LocalContext env; - - Local<FunctionTemplate> t = FunctionTemplate::New(isolate); - t->SetHiddenPrototype(true); - Local<Object> proto = t->GetFunction(env.local()) - .ToLocalChecked() - ->NewInstance(env.local()) - .ToLocalChecked(); - Local<Object> object = Object::New(isolate); - Local<Object> proto2 = Object::New(isolate); - object->SetPrototype(env.local(), proto).FromJust(); - proto->SetPrototype(env.local(), proto2).FromJust(); - - CHECK(env->Global()->Set(env.local(), v8_str("object"), object).FromJust()); - CHECK(env->Global()->Set(env.local(), v8_str("proto"), proto).FromJust()); - CHECK(env->Global()->Set(env.local(), v8_str("proto2"), proto2).FromJust()); - - v8::Local<v8::Value> result = CompileRun("%_GetPrototype(object)"); - CHECK(result->Equals(env.local(), proto2).FromJust()); - - result = CompileRun( - "function f() { return %_GetPrototype(object); }" - "%OptimizeFunctionOnNextCall(f);" - "f()"); - CHECK(result->Equals(env.local(), proto2).FromJust()); -} - TEST(ClassPrototypeCreationContext) { v8::Isolate* isolate = CcTest::isolate(); @@ -27146,35 +27182,32 @@ THREADED_TEST(ReceiverConversionForAccessors) { Local<v8::Object> instance = templ->NewInstance(env.local()).ToLocalChecked(); CHECK(env->Global()->Set(env.local(), v8_str("p"), instance).FromJust()); - CHECK(CompileRun("(p.acc == 42)")->BooleanValue(env.local()).FromJust()); - CHECK(CompileRun("(p.acc = 7) == 7")->BooleanValue(env.local()).FromJust()); + CHECK(CompileRun("(p.acc == 42)")->BooleanValue(isolate)); + CHECK(CompileRun("(p.acc = 7) == 7")->BooleanValue(isolate)); CHECK(!CompileRun("Number.prototype.__proto__ = p;" "var a = 1;") .IsEmpty()); - CHECK(CompileRun("(a.acc == 42)")->BooleanValue(env.local()).FromJust()); - CHECK(CompileRun("(a.acc = 7) == 7")->BooleanValue(env.local()).FromJust()); + CHECK(CompileRun("(a.acc == 42)")->BooleanValue(isolate)); + CHECK(CompileRun("(a.acc = 7) == 7")->BooleanValue(isolate)); CHECK(!CompileRun("Boolean.prototype.__proto__ = p;" "var a = true;") .IsEmpty()); - CHECK(CompileRun("(a.acc == 42)")->BooleanValue(env.local()).FromJust()); - CHECK(CompileRun("(a.acc = 7) == 7")->BooleanValue(env.local()).FromJust()); + CHECK(CompileRun("(a.acc == 42)")->BooleanValue(isolate)); + CHECK(CompileRun("(a.acc = 7) == 7")->BooleanValue(isolate)); CHECK(!CompileRun("String.prototype.__proto__ = p;" "var a = 'foo';") .IsEmpty()); - CHECK(CompileRun("(a.acc == 42)")->BooleanValue(env.local()).FromJust()); - CHECK(CompileRun("(a.acc = 7) == 7")->BooleanValue(env.local()).FromJust()); + CHECK(CompileRun("(a.acc == 42)")->BooleanValue(isolate)); + CHECK(CompileRun("(a.acc = 7) == 7")->BooleanValue(isolate)); - CHECK(CompileRun("acc.call(1) == 42")->BooleanValue(env.local()).FromJust()); - CHECK(CompileRun("acc.call(true)==42")->BooleanValue(env.local()).FromJust()); - CHECK(CompileRun("acc.call('aa')==42")->BooleanValue(env.local()).FromJust()); - CHECK( - CompileRun("acc.call(null) == 42")->BooleanValue(env.local()).FromJust()); - CHECK(CompileRun("acc.call(undefined) == 42") - ->BooleanValue(env.local()) - .FromJust()); + CHECK(CompileRun("acc.call(1) == 42")->BooleanValue(isolate)); + CHECK(CompileRun("acc.call(true)==42")->BooleanValue(isolate)); + CHECK(CompileRun("acc.call('aa')==42")->BooleanValue(isolate)); + CHECK(CompileRun("acc.call(null) == 42")->BooleanValue(isolate)); + CHECK(CompileRun("acc.call(undefined) == 42")->BooleanValue(isolate)); } class FutexInterruptionThread : public v8::base::Thread { @@ -27182,7 +27215,7 @@ class FutexInterruptionThread : public v8::base::Thread { explicit FutexInterruptionThread(v8::Isolate* isolate) : Thread(Options("FutexInterruptionThread")), isolate_(isolate) {} - virtual void Run() { + void Run() override { // Wait a bit before terminating. v8::base::OS::Sleep(v8::base::TimeDelta::FromMilliseconds(100)); isolate_->TerminateExecution(); @@ -27622,7 +27655,7 @@ class MemoryPressureThread : public v8::base::Thread { isolate_(isolate), level_(level) {} - virtual void Run() { isolate_->MemoryPressureNotification(level_); } + void Run() override { isolate_->MemoryPressureNotification(level_); } private: v8::Isolate* isolate_; @@ -27679,13 +27712,13 @@ TEST(SetIntegrityLevel) { CHECK(context->Global()->Set(context.local(), v8_str("o"), obj).FromJust()); v8::Local<v8::Value> is_frozen = CompileRun("Object.isFrozen(o)"); - CHECK(!is_frozen->BooleanValue(context.local()).FromJust()); + CHECK(!is_frozen->BooleanValue(isolate)); CHECK(obj->SetIntegrityLevel(context.local(), v8::IntegrityLevel::kFrozen) .FromJust()); is_frozen = CompileRun("Object.isFrozen(o)"); - CHECK(is_frozen->BooleanValue(context.local()).FromJust()); + CHECK(is_frozen->BooleanValue(isolate)); } TEST(PrivateForApiIsNumber) { @@ -27851,7 +27884,7 @@ THREADED_TEST(ImmutableProtoGlobal) { v8::HandleScope handle_scope(isolate); Local<ObjectTemplate> global_template = ObjectTemplate::New(isolate); global_template->SetImmutableProto(); - v8::Local<Context> context = Context::New(isolate, 0, global_template); + v8::Local<Context> context = Context::New(isolate, nullptr, global_template); Context::Scope context_scope(context); v8::Local<Value> result = CompileRun( "global = this;" @@ -27871,7 +27904,7 @@ THREADED_TEST(MutableProtoGlobal) { v8::Isolate* isolate = CcTest::isolate(); v8::HandleScope handle_scope(isolate); Local<ObjectTemplate> global_template = ObjectTemplate::New(isolate); - v8::Local<Context> context = Context::New(isolate, 0, global_template); + v8::Local<Context> context = Context::New(isolate, nullptr, global_template); Context::Scope context_scope(context); v8::Local<Value> result = CompileRun( "global = this;" @@ -28445,7 +28478,7 @@ class StopAtomicsWaitThread : public v8::base::Thread { explicit StopAtomicsWaitThread(AtomicsWaitCallbackInfo* info) : Thread(Options("StopAtomicsWaitThread")), info_(info) {} - virtual void Run() { + void Run() override { CHECK_NOT_NULL(info_->wake_handle); info_->wake_handle->Wake(); } @@ -28778,216 +28811,28 @@ TEST(TestSetWasmThreadsEnabledCallback) { CHECK(i_isolate->AreWasmThreadsEnabled(i_context)); } -TEST(PreviewSetIteratorEntriesWithDeleted) { +TEST(TestGetEmbeddedCodeRange) { LocalContext env; - v8::HandleScope handle_scope(env->GetIsolate()); - v8::Local<v8::Context> context = env.local(); + v8::Isolate* isolate = env->GetIsolate(); + i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); - { - // Create set, delete entry, create iterator, preview. - v8::Local<v8::Object> iterator = - CompileRun("var set = new Set([1,2,3]); set.delete(1); set.keys()") - ->ToObject(context) - .ToLocalChecked(); - bool is_key; - v8::Local<v8::Array> entries = - iterator->PreviewEntries(&is_key).ToLocalChecked(); - CHECK(!is_key); - CHECK_EQ(2, entries->Length()); - CHECK_EQ(2, entries->Get(context, 0) - .ToLocalChecked() - ->Int32Value(context) - .FromJust()); - CHECK_EQ(3, entries->Get(context, 1) - .ToLocalChecked() - ->Int32Value(context) - .FromJust()); - } - { - // Create set, create iterator, delete entry, preview. - v8::Local<v8::Object> iterator = - CompileRun("var set = new Set([1,2,3]); set.keys()") - ->ToObject(context) - .ToLocalChecked(); - CompileRun("set.delete(1);"); - bool is_key; - v8::Local<v8::Array> entries = - iterator->PreviewEntries(&is_key).ToLocalChecked(); - CHECK(!is_key); - CHECK_EQ(2, entries->Length()); - CHECK_EQ(2, entries->Get(context, 0) - .ToLocalChecked() - ->Int32Value(context) - .FromJust()); - CHECK_EQ(3, entries->Get(context, 1) - .ToLocalChecked() - ->Int32Value(context) - .FromJust()); - } - { - // Create set, create iterator, delete entry, iterate, preview. - v8::Local<v8::Object> iterator = - CompileRun("var set = new Set([1,2,3]); var it = set.keys(); it") - ->ToObject(context) - .ToLocalChecked(); - CompileRun("set.delete(1); it.next();"); - bool is_key; - v8::Local<v8::Array> entries = - iterator->PreviewEntries(&is_key).ToLocalChecked(); - CHECK(!is_key); - CHECK_EQ(1, entries->Length()); - CHECK_EQ(3, entries->Get(context, 0) - .ToLocalChecked() - ->Int32Value(context) - .FromJust()); - } - { - // Create set, create iterator, delete entry, iterate until empty, preview. - v8::Local<v8::Object> iterator = - CompileRun("var set = new Set([1,2,3]); var it = set.keys(); it") - ->ToObject(context) - .ToLocalChecked(); - CompileRun("set.delete(1); it.next(); it.next();"); - bool is_key; - v8::Local<v8::Array> entries = - iterator->PreviewEntries(&is_key).ToLocalChecked(); - CHECK(!is_key); - CHECK_EQ(0, entries->Length()); - } - { - // Create set, create iterator, delete entry, iterate, trigger rehash, - // preview. - v8::Local<v8::Object> iterator = - CompileRun("var set = new Set([1,2,3]); var it = set.keys(); it") - ->ToObject(context) - .ToLocalChecked(); - CompileRun("set.delete(1); it.next();"); - CompileRun("for (var i = 4; i < 20; i++) set.add(i);"); - bool is_key; - v8::Local<v8::Array> entries = - iterator->PreviewEntries(&is_key).ToLocalChecked(); - CHECK(!is_key); - CHECK_EQ(17, entries->Length()); - for (uint32_t i = 0; i < 17; i++) { - CHECK_EQ(i + 3, entries->Get(context, i) - .ToLocalChecked() - ->Int32Value(context) - .FromJust()); - } - } -} + v8::MemoryRange builtins_range = isolate->GetEmbeddedCodeRange(); -TEST(PreviewMapIteratorEntriesWithDeleted) { - LocalContext env; - v8::HandleScope handle_scope(env->GetIsolate()); - v8::Local<v8::Context> context = env.local(); + // Check that each off-heap builtin is within the builtins code range. + if (i::FLAG_embedded_builtins) { + for (int id = 0; id < i::Builtins::builtin_count; id++) { + if (!i::Builtins::IsIsolateIndependent(id)) continue; + i::Code* builtin = i_isolate->builtins()->builtin(id); + i::Address start = builtin->InstructionStart(); + i::Address end = start + builtin->InstructionSize(); - { - // Create map, delete entry, create iterator, preview. - v8::Local<v8::Object> iterator = CompileRun( - "var map = new Map();" - "var key = {}; map.set(key, 1);" - "map.set({}, 2); map.set({}, 3);" - "map.delete(key);" - "map.values()") - ->ToObject(context) - .ToLocalChecked(); - bool is_key; - v8::Local<v8::Array> entries = - iterator->PreviewEntries(&is_key).ToLocalChecked(); - CHECK(!is_key); - CHECK_EQ(2, entries->Length()); - CHECK_EQ(2, entries->Get(context, 0) - .ToLocalChecked() - ->Int32Value(context) - .FromJust()); - CHECK_EQ(3, entries->Get(context, 1) - .ToLocalChecked() - ->Int32Value(context) - .FromJust()); - } - { - // Create map, create iterator, delete entry, preview. - v8::Local<v8::Object> iterator = CompileRun( - "var map = new Map();" - "var key = {}; map.set(key, 1);" - "map.set({}, 2); map.set({}, 3);" - "map.values()") - ->ToObject(context) - .ToLocalChecked(); - CompileRun("map.delete(key);"); - bool is_key; - v8::Local<v8::Array> entries = - iterator->PreviewEntries(&is_key).ToLocalChecked(); - CHECK(!is_key); - CHECK_EQ(2, entries->Length()); - CHECK_EQ(2, entries->Get(context, 0) - .ToLocalChecked() - ->Int32Value(context) - .FromJust()); - CHECK_EQ(3, entries->Get(context, 1) - .ToLocalChecked() - ->Int32Value(context) - .FromJust()); - } - { - // Create map, create iterator, delete entry, iterate, preview. - v8::Local<v8::Object> iterator = CompileRun( - "var map = new Map();" - "var key = {}; map.set(key, 1);" - "map.set({}, 2); map.set({}, 3);" - "var it = map.values(); it") - ->ToObject(context) - .ToLocalChecked(); - CompileRun("map.delete(key); it.next();"); - bool is_key; - v8::Local<v8::Array> entries = - iterator->PreviewEntries(&is_key).ToLocalChecked(); - CHECK(!is_key); - CHECK_EQ(1, entries->Length()); - CHECK_EQ(3, entries->Get(context, 0) - .ToLocalChecked() - ->Int32Value(context) - .FromJust()); - } - { - // Create map, create iterator, delete entry, iterate until empty, preview. - v8::Local<v8::Object> iterator = CompileRun( - "var map = new Map();" - "var key = {}; map.set(key, 1);" - "map.set({}, 2); map.set({}, 3);" - "var it = map.values(); it") - ->ToObject(context) - .ToLocalChecked(); - CompileRun("map.delete(key); it.next(); it.next();"); - bool is_key; - v8::Local<v8::Array> entries = - iterator->PreviewEntries(&is_key).ToLocalChecked(); - CHECK(!is_key); - CHECK_EQ(0, entries->Length()); - } - { - // Create map, create iterator, delete entry, iterate, trigger rehash, - // preview. - v8::Local<v8::Object> iterator = CompileRun( - "var map = new Map();" - "var key = {}; map.set(key, 1);" - "map.set({}, 2); map.set({}, 3);" - "var it = map.values(); it") - ->ToObject(context) - .ToLocalChecked(); - CompileRun("map.delete(key); it.next();"); - CompileRun("for (var i = 4; i < 20; i++) map.set({}, i);"); - bool is_key; - v8::Local<v8::Array> entries = - iterator->PreviewEntries(&is_key).ToLocalChecked(); - CHECK(!is_key); - CHECK_EQ(17, entries->Length()); - for (uint32_t i = 0; i < 17; i++) { - CHECK_EQ(i + 3, entries->Get(context, i) - .ToLocalChecked() - ->Int32Value(context) - .FromJust()); + i::Address builtins_start = + reinterpret_cast<i::Address>(builtins_range.start); + CHECK(start >= builtins_start && + end < builtins_start + builtins_range.length_in_bytes); } + } else { + CHECK_EQ(nullptr, builtins_range.start); + CHECK_EQ(0, builtins_range.length_in_bytes); } } diff --git a/deps/v8/test/cctest/test-assembler-arm64.cc b/deps/v8/test/cctest/test-assembler-arm64.cc index c0f8e171c7..f2ca5c01e5 100644 --- a/deps/v8/test/cctest/test-assembler-arm64.cc +++ b/deps/v8/test/cctest/test-assembler-arm64.cc @@ -209,7 +209,8 @@ static void InitializeVM() { __ Ret(); \ __ GetCode(masm.isolate(), nullptr); -#define TEARDOWN() CHECK(v8::internal::FreePages(buf, allocated)); +#define TEARDOWN() \ + CHECK(v8::internal::FreePages(GetPlatformPageAllocator(), buf, allocated)); #endif // ifdef USE_SIMULATOR. @@ -15068,9 +15069,6 @@ TEST(default_nan_double) { TEST(call_no_relocation) { - Address call_start; - Address return_address; - INIT_V8(); SETUP(); @@ -15091,9 +15089,7 @@ TEST(call_no_relocation) { __ Push(lr, xzr); { Assembler::BlockConstPoolScope scope(&masm); - call_start = buf_addr + __ pc_offset(); __ Call(buf_addr + function.pos(), RelocInfo::NONE); - return_address = buf_addr + __ pc_offset(); } __ Pop(xzr, lr); END(); diff --git a/deps/v8/test/cctest/test-assembler-mips64.cc b/deps/v8/test/cctest/test-assembler-mips64.cc index 785ffa2fa3..ebae2e9ed5 100644 --- a/deps/v8/test/cctest/test-assembler-mips64.cc +++ b/deps/v8/test/cctest/test-assembler-mips64.cc @@ -85,7 +85,7 @@ TEST(MIPS1) { Label L, C; __ mov(a1, a0); - __ li(v0, 0); + __ li(v0, 0l); __ b(&C); __ nop(); @@ -2316,7 +2316,7 @@ TEST(movt_movd) { __ Lw(t1, MemOperand(a0, offsetof(TestFloat, fcsr))); __ cfc1(t0, FCSR); __ ctc1(t1, FCSR); - __ li(t2, 0x0); + __ li(t2, 0x0l); __ mtc1(t2, f12); __ mtc1(t2, f10); __ Sdc1(f10, MemOperand(a0, offsetof(TestFloat, dstdold))); @@ -5421,7 +5421,7 @@ uint64_t run_jic(int16_t offset) { Label get_program_counter, stop_execution; __ push(ra); - __ li(v0, 0); + __ li(v0, 0l); __ li(t1, 0x66); __ addiu(v0, v0, 0x1); // <-- offset = -32 @@ -5496,7 +5496,7 @@ uint64_t run_beqzc(int32_t value, int32_t offset) { v8::internal::CodeObjectRequired::kYes); Label stop_execution; - __ li(v0, 0); + __ li(v0, 0l); __ li(t1, 0x66); __ addiu(v0, v0, 0x1); // <-- offset = -8 @@ -5755,7 +5755,7 @@ uint64_t run_jialc(int16_t offset) { Label main_block, get_program_counter; __ push(ra); - __ li(v0, 0); + __ li(v0, 0l); __ beq(v0, v0, &main_block); __ nop(); @@ -5980,8 +5980,8 @@ int64_t run_bc(int32_t offset) { Label continue_1, stop_execution; __ push(ra); - __ li(v0, 0); - __ li(t8, 0); + __ li(v0, 0l); + __ li(t8, 0l); __ li(t9, 2); // Condition for the stopping execution. for (int32_t i = -100; i <= -11; ++i) { @@ -6060,8 +6060,8 @@ int64_t run_balc(int32_t offset) { Label continue_1, stop_execution; __ push(ra); - __ li(v0, 0); - __ li(t8, 0); + __ li(v0, 0l); + __ li(t8, 0l); __ li(t9, 2); // Condition for stopping execution. __ beq(t8, t8, &continue_1); @@ -7072,7 +7072,7 @@ void run_msa_ctc_cfc(uint64_t value) { MSAControlRegister msareg = {kMSACSRRegister}; __ li(t0, value); - __ li(t2, 0); + __ li(t2, 0l); __ cfcmsa(t1, msareg); __ ctcmsa(msareg, t0); __ cfcmsa(t2, msareg); diff --git a/deps/v8/test/cctest/test-assembler-x64.cc b/deps/v8/test/cctest/test-assembler-x64.cc index 7ecef4429c..a340322bd6 100644 --- a/deps/v8/test/cctest/test-assembler-x64.cc +++ b/deps/v8/test/cctest/test-assembler-x64.cc @@ -1068,7 +1068,7 @@ TEST(AssemblerX64FMA_sd) { // - xmm0 * xmm1 + xmm2 __ movaps(xmm3, xmm0); __ mulsd(xmm3, xmm1); - __ Move(xmm4, (uint64_t)1 << 63); + __ Move(xmm4, static_cast<uint64_t>(1) << 63); __ xorpd(xmm3, xmm4); __ addsd(xmm3, xmm2); // Expected result in xmm3 @@ -1117,7 +1117,7 @@ TEST(AssemblerX64FMA_sd) { // - xmm0 * xmm1 - xmm2 __ movaps(xmm3, xmm0); __ mulsd(xmm3, xmm1); - __ Move(xmm4, (uint64_t)1 << 63); + __ Move(xmm4, static_cast<uint64_t>(1) << 63); __ xorpd(xmm3, xmm4); __ subsd(xmm3, xmm2); // Expected result in xmm3 @@ -1294,7 +1294,7 @@ TEST(AssemblerX64FMA_ss) { // - xmm0 * xmm1 + xmm2 __ movaps(xmm3, xmm0); __ mulss(xmm3, xmm1); - __ Move(xmm4, (uint32_t)1 << 31); + __ Move(xmm4, static_cast<uint32_t>(1) << 31); __ xorps(xmm3, xmm4); __ addss(xmm3, xmm2); // Expected result in xmm3 @@ -1343,7 +1343,7 @@ TEST(AssemblerX64FMA_ss) { // - xmm0 * xmm1 - xmm2 __ movaps(xmm3, xmm0); __ mulss(xmm3, xmm1); - __ Move(xmm4, (uint32_t)1 << 31); + __ Move(xmm4, static_cast<uint32_t>(1) << 31); __ xorps(xmm3, xmm4); __ subss(xmm3, xmm2); // Expected result in xmm3 diff --git a/deps/v8/test/cctest/test-circular-queue.cc b/deps/v8/test/cctest/test-circular-queue.cc index a5bcb486af..85ab4c4fad 100644 --- a/deps/v8/test/cctest/test-circular-queue.cc +++ b/deps/v8/test/cctest/test-circular-queue.cc @@ -113,7 +113,7 @@ class ProducerThread: public v8::base::Thread { value_(value), finished_(finished) {} - virtual void Run() { + void Run() override { for (Record i = value_; i < value_ + records_per_chunk_; ++i) { Record* rec = reinterpret_cast<Record*>(scq_->StartEnqueue()); CHECK(rec); diff --git a/deps/v8/test/cctest/test-code-stub-assembler.cc b/deps/v8/test/cctest/test-code-stub-assembler.cc index 2036e13450..ffe9200eee 100644 --- a/deps/v8/test/cctest/test-code-stub-assembler.cc +++ b/deps/v8/test/cctest/test-code-stub-assembler.cc @@ -907,9 +907,12 @@ TEST(TransitionLookup) { } } - CHECK(root_map->raw_transitions()->ToStrongHeapObject()->IsTransitionArray()); + CHECK(root_map->raw_transitions() + ->GetHeapObjectAssumeStrong() + ->IsTransitionArray()); Handle<TransitionArray> transitions( - TransitionArray::cast(root_map->raw_transitions()->ToStrongHeapObject()), + TransitionArray::cast( + root_map->raw_transitions()->GetHeapObjectAssumeStrong()), isolate); DCHECK(transitions->IsSortedNoDuplicates()); @@ -2495,7 +2498,7 @@ TEST(CreatePromiseGetCapabilitiesExecutorContext) { Node* const context = m.Parameter(kNumParams + 2); Node* const native_context = m.LoadNativeContext(context); - Node* const map = m.LoadRoot(Heap::kPromiseCapabilityMapRootIndex); + Node* const map = m.LoadRoot(RootIndex::kPromiseCapabilityMap); Node* const capability = m.AllocateStruct(map); m.StoreObjectFieldNoWriteBarrier( capability, PromiseCapability::kPromiseOffset, m.UndefinedConstant()); @@ -3495,6 +3498,37 @@ TEST(TestCallBuiltinIndirectLoad) { Handle<String>::cast(result.ToHandleChecked()))); } +TEST(TestGotoIfDebugExecutionModeChecksSideEffects) { + Isolate* isolate(CcTest::InitIsolateOnce()); + CodeAssemblerTester asm_tester(isolate, 0); + { + CodeStubAssembler m(asm_tester.state()); + Label is_true(&m), is_false(&m); + m.GotoIfDebugExecutionModeChecksSideEffects(&is_true); + m.Goto(&is_false); + m.BIND(&is_false); + m.Return(m.BooleanConstant(false)); + + m.BIND(&is_true); + m.Return(m.BooleanConstant(true)); + } + + FunctionTester ft(asm_tester.GenerateCode(), 0); + + CHECK(isolate->debug_execution_mode() != DebugInfo::kSideEffects); + + Handle<Object> result = ft.Call().ToHandleChecked(); + CHECK(result->IsBoolean()); + CHECK_EQ(false, result->BooleanValue(isolate)); + + isolate->debug()->StartSideEffectCheckMode(); + CHECK(isolate->debug_execution_mode() == DebugInfo::kSideEffects); + + result = ft.Call().ToHandleChecked(); + CHECK(result->IsBoolean()); + CHECK_EQ(true, result->BooleanValue(isolate)); +} + } // namespace compiler } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/test-code-stubs-ia32.cc b/deps/v8/test/cctest/test-code-stubs-ia32.cc index 54f53e57c3..d9bfe9bb17 100644 --- a/deps/v8/test/cctest/test-code-stubs-ia32.cc +++ b/deps/v8/test/cctest/test-code-stubs-ia32.cc @@ -67,7 +67,7 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate, // Save registers make sure they don't get clobbered. int reg_num = 0; for (; reg_num < Register::kNumRegisters; ++reg_num) { - if (RegisterConfiguration::Default()->IsAllocatableGeneralCode(reg_num)) { + if (GetRegConfig()->IsAllocatableGeneralCode(reg_num)) { Register reg = Register::from_code(reg_num); if (reg != esp && reg != ebp && reg != destination_reg) { __ push(reg); @@ -88,7 +88,7 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate, // Make sure no registers have been unexpectedly clobbered for (--reg_num; reg_num >= 0; --reg_num) { - if (RegisterConfiguration::Default()->IsAllocatableGeneralCode(reg_num)) { + if (GetRegConfig()->IsAllocatableGeneralCode(reg_num)) { Register reg = Register::from_code(reg_num); if (reg != esp && reg != ebp && reg != destination_reg) { __ cmp(reg, MemOperand(esp, 0)); diff --git a/deps/v8/test/cctest/test-compiler.cc b/deps/v8/test/cctest/test-compiler.cc index 63904e086f..76ce276c06 100644 --- a/deps/v8/test/cctest/test-compiler.cc +++ b/deps/v8/test/cctest/test-compiler.cc @@ -55,7 +55,7 @@ static void SetGlobalProperty(const char* name, Object* value) { isolate->factory()->InternalizeUtf8String(name); Handle<JSObject> global(isolate->context()->global_object(), isolate); Runtime::SetObjectProperty(isolate, global, internalized_name, object, - LanguageMode::kSloppy) + LanguageMode::kSloppy, StoreOrigin::kMaybeKeyed) .Check(); } @@ -318,7 +318,7 @@ TEST(FeedbackVectorPreservedAcrossRecompiles) { MaybeObject* object = feedback_vector->Get(slot_for_a); { HeapObject* heap_object; - CHECK(object->ToWeakHeapObject(&heap_object)); + CHECK(object->GetHeapObjectIfWeak(&heap_object)); CHECK(heap_object->IsJSFunction()); } @@ -330,7 +330,7 @@ TEST(FeedbackVectorPreservedAcrossRecompiles) { object = f->feedback_vector()->Get(slot_for_a); { HeapObject* heap_object; - CHECK(object->ToWeakHeapObject(&heap_object)); + CHECK(object->GetHeapObjectIfWeak(&heap_object)); CHECK(heap_object->IsJSFunction()); } } @@ -676,7 +676,7 @@ void TestCompileFunctionInContextToStringImpl() { V8_Fatal(__FILE__, __LINE__, \ "Unexpected exception thrown during %s:\n\t%s\n", op, *error); \ } \ - } while (0) + } while (false) { // NOLINT CcTest::InitializeVM(); @@ -766,11 +766,6 @@ void TestCompileFunctionInContextToStringImpl() { #undef CHECK_NOT_CAUGHT } -TEST(CompileFunctionInContextHarmonyFunctionToString) { - v8::internal::FLAG_harmony_function_tostring = true; - TestCompileFunctionInContextToStringImpl(); -} - TEST(CompileFunctionInContextFunctionToString) { TestCompileFunctionInContextToStringImpl(); } diff --git a/deps/v8/test/cctest/test-cpu-profiler.cc b/deps/v8/test/cctest/test-cpu-profiler.cc index e08bec375e..75af3f6d98 100644 --- a/deps/v8/test/cctest/test-cpu-profiler.cc +++ b/deps/v8/test/cctest/test-cpu-profiler.cc @@ -40,7 +40,6 @@ #include "src/objects-inl.h" #include "src/profiler/cpu-profiler-inl.h" #include "src/profiler/profiler-listener.h" -#include "src/source-position-table.h" #include "src/utils.h" #include "test/cctest/cctest.h" #include "test/cctest/profiler-extension.h" @@ -2545,61 +2544,6 @@ TEST(MultipleProfilers) { profiler2->StopProfiling("2"); } -int GetSourcePositionEntryCount(i::Isolate* isolate, const char* source) { - i::Handle<i::JSFunction> function = i::Handle<i::JSFunction>::cast( - v8::Utils::OpenHandle(*CompileRun(source))); - if (function->IsInterpreted()) return -1; - i::Handle<i::Code> code(function->code(), isolate); - i::SourcePositionTableIterator iterator( - ByteArray::cast(code->source_position_table())); - int count = 0; - while (!iterator.done()) { - count++; - iterator.Advance(); - } - return count; -} - -UNINITIALIZED_TEST(DetailedSourcePositionAPI) { - i::FLAG_detailed_line_info = false; - i::FLAG_allow_natives_syntax = true; - v8::Isolate::CreateParams create_params; - create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); - v8::Isolate* isolate = v8::Isolate::New(create_params); - - const char* source = - "function fib(i) {" - " if (i <= 1) return 1; " - " return fib(i - 1) +" - " fib(i - 2);" - "}" - "fib(5);" - "%OptimizeFunctionOnNextCall(fib);" - "fib(5);" - "fib"; - { - v8::Isolate::Scope isolate_scope(isolate); - v8::HandleScope handle_scope(isolate); - v8::Local<v8::Context> context = v8::Context::New(isolate); - v8::Context::Scope context_scope(context); - i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); - - CHECK(!i_isolate->NeedsDetailedOptimizedCodeLineInfo()); - - int non_detailed_positions = GetSourcePositionEntryCount(i_isolate, source); - - v8::CpuProfiler::UseDetailedSourcePositionsForProfiling(isolate); - CHECK(i_isolate->NeedsDetailedOptimizedCodeLineInfo()); - - int detailed_positions = GetSourcePositionEntryCount(i_isolate, source); - - CHECK((non_detailed_positions == -1 && detailed_positions == -1) || - non_detailed_positions < detailed_positions); - } - - isolate->Dispose(); -} - } // namespace test_cpu_profiler } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/test-date.cc b/deps/v8/test/cctest/test-date.cc index 61545d7859..d1d8efe26c 100644 --- a/deps/v8/test/cctest/test-date.cc +++ b/deps/v8/test/cctest/test-date.cc @@ -44,7 +44,7 @@ class DateCacheMock: public DateCache { : local_offset_(local_offset), rules_(rules), rules_count_(rules_count) {} protected: - virtual int GetDaylightSavingsOffsetFromOS(int64_t time_sec) { + int GetDaylightSavingsOffsetFromOS(int64_t time_sec) override { int days = DaysFromTime(time_sec * 1000); int time_in_day_sec = TimeInDay(time_sec * 1000, days) / 1000; int year, month, day; @@ -53,7 +53,7 @@ class DateCacheMock: public DateCache { return rule == nullptr ? 0 : rule->offset_sec * 1000; } - virtual int GetLocalOffsetFromOS(int64_t time_sec, bool is_utc) { + int GetLocalOffsetFromOS(int64_t time_sec, bool is_utc) override { return local_offset_ + GetDaylightSavingsOffsetFromOS(time_sec); } diff --git a/deps/v8/test/cctest/test-debug.cc b/deps/v8/test/cctest/test-debug.cc index f678b8ca6f..2e2128e50b 100644 --- a/deps/v8/test/cctest/test-debug.cc +++ b/deps/v8/test/cctest/test-debug.cc @@ -161,7 +161,7 @@ void CheckDebuggerUnloaded() { // Collect garbage to ensure weak handles are cleared. CcTest::CollectAllGarbage(); - CcTest::CollectAllGarbage(Heap::kMakeHeapIterableMask); + CcTest::CollectAllGarbage(); // Iterate the heap and check that there are no debugger related objects left. HeapIterator iterator(CcTest::heap()); @@ -189,8 +189,9 @@ int break_point_hit_count = 0; int break_point_hit_count_deoptimize = 0; class DebugEventCounter : public v8::debug::DebugDelegate { public: - void BreakProgramRequested(v8::Local<v8::Context>, - const std::vector<v8::debug::BreakpointId>&) { + void BreakProgramRequested( + v8::Local<v8::Context>, + const std::vector<v8::debug::BreakpointId>&) override { break_point_hit_count++; // Perform a full deoptimization when the specified number of // breaks have been hit. @@ -211,8 +212,9 @@ class DebugEventCounter : public v8::debug::DebugDelegate { // Debug event handler which performs a garbage collection. class DebugEventBreakPointCollectGarbage : public v8::debug::DebugDelegate { public: - void BreakProgramRequested(v8::Local<v8::Context>, - const std::vector<v8::debug::BreakpointId>&) { + void BreakProgramRequested( + v8::Local<v8::Context>, + const std::vector<v8::debug::BreakpointId>&) override { // Perform a garbage collection when break point is hit and continue. Based // on the number of break points hit either scavenge or mark compact // collector is used. @@ -231,8 +233,9 @@ class DebugEventBreakPointCollectGarbage : public v8::debug::DebugDelegate { // collector to have the heap verified. class DebugEventBreak : public v8::debug::DebugDelegate { public: - void BreakProgramRequested(v8::Local<v8::Context>, - const std::vector<v8::debug::BreakpointId>&) { + void BreakProgramRequested( + v8::Local<v8::Context>, + const std::vector<v8::debug::BreakpointId>&) override { // Count the number of breaks. break_point_hit_count++; @@ -255,8 +258,9 @@ int max_break_point_hit_count = 0; bool terminate_after_max_break_point_hit = false; class DebugEventBreakMax : public v8::debug::DebugDelegate { public: - void BreakProgramRequested(v8::Local<v8::Context>, - const std::vector<v8::debug::BreakpointId>&) { + void BreakProgramRequested( + v8::Local<v8::Context>, + const std::vector<v8::debug::BreakpointId>&) override { v8::Isolate* v8_isolate = CcTest::isolate(); v8::internal::Isolate* isolate = CcTest::i_isolate(); if (break_point_hit_count < max_break_point_hit_count) { @@ -2999,9 +3003,9 @@ int event_listener_hit_count = 0; class EmptyExternalStringResource : public v8::String::ExternalStringResource { public: EmptyExternalStringResource() { empty_[0] = 0; } - virtual ~EmptyExternalStringResource() {} - virtual size_t length() const { return empty_.length(); } - virtual const uint16_t* data() const { return empty_.start(); } + ~EmptyExternalStringResource() override = default; + size_t length() const override { return empty_.length(); } + const uint16_t* data() const override { return empty_.start(); } private: ::v8::internal::EmbeddedVector<uint16_t, 1> empty_; @@ -3064,8 +3068,8 @@ class ContextCheckEventListener : public v8::debug::DebugDelegate { } void ExceptionThrown(v8::Local<v8::Context> paused_context, v8::Local<v8::Value> exception, - v8::Local<v8::Value> promise, - bool is_uncaught) override { + v8::Local<v8::Value> promise, bool is_uncaught, + v8::debug::ExceptionType) override { CheckContext(); } bool IsFunctionBlackboxed(v8::Local<v8::debug::Script> script, @@ -3677,7 +3681,7 @@ class TerminationThread : public v8::base::Thread { explicit TerminationThread(v8::Isolate* isolate) : Thread(Options("terminator")), isolate_(isolate) {} - virtual void Run() { + void Run() override { terminate_requested_semaphore.Wait(); isolate_->TerminateExecution(); terminate_fired_semaphore.Signal(); @@ -3712,7 +3716,7 @@ class ArchiveRestoreThread : public v8::base::Thread, spawn_count_(spawn_count), break_count_(0) {} - virtual void Run() { + void Run() override { v8::Locker locker(isolate_); isolate_->Enter(); @@ -3743,8 +3747,9 @@ class ArchiveRestoreThread : public v8::base::Thread, isolate_->Exit(); } - void BreakProgramRequested(v8::Local<v8::Context> context, - const std::vector<v8::debug::BreakpointId>&) { + void BreakProgramRequested( + v8::Local<v8::Context> context, + const std::vector<v8::debug::BreakpointId>&) override { auto stack_traces = v8::debug::StackTraceIterator::Create(isolate_); if (!stack_traces->Done()) { v8::debug::Location location = stack_traces->GetSourceLocation(); @@ -3833,8 +3838,8 @@ class DebugEventExpectNoException : 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) override { + v8::Local<v8::Value> promise, bool is_uncaught, + v8::debug::ExceptionType) override { CHECK(false); } }; diff --git a/deps/v8/test/cctest/test-decls.cc b/deps/v8/test/cctest/test-decls.cc index f0e8080275..8b59fe5960 100644 --- a/deps/v8/test/cctest/test-decls.cc +++ b/deps/v8/test/cctest/test-decls.cc @@ -123,11 +123,9 @@ void DeclarationContext::InitializeIfNeeded() { Local<FunctionTemplate> function = FunctionTemplate::New(isolate); Local<Value> data = External::New(CcTest::isolate(), this); GetHolder(function)->SetHandler(v8::NamedPropertyHandlerConfiguration( - &HandleGet, &HandleSet, &HandleQuery, 0, 0, data)); - Local<Context> context = Context::New(isolate, - 0, - function->InstanceTemplate(), - Local<Value>()); + &HandleGet, &HandleSet, &HandleQuery, nullptr, nullptr, data)); + Local<Context> context = Context::New( + isolate, nullptr, function->InstanceTemplate(), Local<Value>()); context_.Reset(isolate, context); context->Enter(); is_initialized_ = true; @@ -256,7 +254,7 @@ TEST(Unknown) { class AbsentPropertyContext: public DeclarationContext { protected: - virtual v8::Local<Integer> Query(Local<Name> key) { + v8::Local<Integer> Query(Local<Name> key) override { return v8::Local<Integer>(); } }; @@ -306,7 +304,7 @@ class AppearingPropertyContext: public DeclarationContext { AppearingPropertyContext() : state_(DECLARE) { } protected: - virtual v8::Local<Integer> Query(Local<Name> key) { + v8::Local<Integer> Query(Local<Name> key) override { switch (state_) { case DECLARE: // Force declaration by returning that the @@ -361,13 +359,13 @@ class ExistsInPrototypeContext: public DeclarationContext { public: ExistsInPrototypeContext() { InitializeIfNeeded(); } protected: - virtual v8::Local<Integer> Query(Local<Name> key) { + v8::Local<Integer> Query(Local<Name> key) override { // Let it seem that the property exists in the prototype object. return Integer::New(isolate(), v8::None); } // Use the prototype as the holder for the interceptors. - virtual Local<ObjectTemplate> GetHolder(Local<FunctionTemplate> function) { + Local<ObjectTemplate> GetHolder(Local<FunctionTemplate> function) override { return function->PrototypeTemplate(); } }; @@ -404,13 +402,13 @@ TEST(ExistsInPrototype) { class AbsentInPrototypeContext: public DeclarationContext { protected: - virtual v8::Local<Integer> Query(Local<Name> key) { + v8::Local<Integer> Query(Local<Name> key) override { // Let it seem that the property is absent in the prototype object. return Local<Integer>(); } // Use the prototype as the holder for the interceptors. - virtual Local<ObjectTemplate> GetHolder(Local<FunctionTemplate> function) { + Local<ObjectTemplate> GetHolder(Local<FunctionTemplate> function) override { return function->PrototypeTemplate(); } }; @@ -439,13 +437,13 @@ class ExistsInHiddenPrototypeContext: public DeclarationContext { } protected: - virtual v8::Local<Integer> Query(Local<Name> key) { + v8::Local<Integer> Query(Local<Name> key) override { // Let it seem that the property exists in the hidden prototype object. return Integer::New(isolate(), v8::None); } // Install the hidden prototype after the global object has been created. - virtual void PostInitializeContext(Local<Context> context) { + void PostInitializeContext(Local<Context> context) override { Local<Object> global_object = context->Global(); Local<Object> hidden_proto = hidden_proto_->GetFunction(context) .ToLocalChecked() @@ -457,7 +455,7 @@ class ExistsInHiddenPrototypeContext: public DeclarationContext { } // Use the hidden prototype as the holder for the interceptors. - virtual Local<ObjectTemplate> GetHolder(Local<FunctionTemplate> function) { + Local<ObjectTemplate> GetHolder(Local<FunctionTemplate> function) override { return hidden_proto_->InstanceTemplate(); } diff --git a/deps/v8/test/cctest/test-deoptimization.cc b/deps/v8/test/cctest/test-deoptimization.cc index 0d86f135ea..544a0f587d 100644 --- a/deps/v8/test/cctest/test-deoptimization.cc +++ b/deps/v8/test/cctest/test-deoptimization.cc @@ -95,15 +95,6 @@ class AllowNativesSyntaxNoInlining { bool turbo_inlining_; }; - -// Abort any ongoing incremental marking to make sure that all weak global -// handle callbacks are processed. -static void NonIncrementalGC(i::Isolate* isolate) { - isolate->heap()->CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask, - i::GarbageCollectionReason::kTesting); -} - - static Handle<JSFunction> GetJSFunction(v8::Local<v8::Context> context, const char* property_name) { v8::Local<v8::Function> fun = v8::Local<v8::Function>::Cast( @@ -127,7 +118,7 @@ TEST(DeoptimizeSimple) { "function f() { g(); };" "f();"); } - NonIncrementalGC(CcTest::i_isolate()); + CcTest::CollectAllGarbage(); CHECK_EQ(1, env->Global() ->Get(env.local(), v8_str("count")) @@ -147,7 +138,7 @@ TEST(DeoptimizeSimple) { "function f(x) { if (x) { g(); } else { return } };" "f(true);"); } - NonIncrementalGC(CcTest::i_isolate()); + CcTest::CollectAllGarbage(); CHECK_EQ(1, env->Global() ->Get(env.local(), v8_str("count")) @@ -174,7 +165,7 @@ TEST(DeoptimizeSimpleWithArguments) { "function f(x, y, z) { g(1,x); y+z; };" "f(1, \"2\", false);"); } - NonIncrementalGC(CcTest::i_isolate()); + CcTest::CollectAllGarbage(); CHECK_EQ(1, env->Global() ->Get(env.local(), v8_str("count")) @@ -195,7 +186,7 @@ TEST(DeoptimizeSimpleWithArguments) { "function f(x, y, z) { if (x) { g(x, y); } else { return y + z; } };" "f(true, 1, \"2\");"); } - NonIncrementalGC(CcTest::i_isolate()); + CcTest::CollectAllGarbage(); CHECK_EQ(1, env->Global() ->Get(env.local(), v8_str("count")) @@ -223,7 +214,7 @@ TEST(DeoptimizeSimpleNested) { "function g(z) { count++; %DeoptimizeFunction(f); return z;}" "function f(x,y,z) { return h(x, y, g(z)); };" "result = f(1, 2, 3);"); - NonIncrementalGC(CcTest::i_isolate()); + CcTest::CollectAllGarbage(); CHECK_EQ(1, env->Global() ->Get(env.local(), v8_str("count")) @@ -257,7 +248,7 @@ TEST(DeoptimizeRecursive) { "function f(x) { calls++; if (x > 0) { f(x - 1); } else { g(); } };" "f(10);"); } - NonIncrementalGC(CcTest::i_isolate()); + CcTest::CollectAllGarbage(); CHECK_EQ(1, env->Global() ->Get(env.local(), v8_str("count")) @@ -300,7 +291,7 @@ TEST(DeoptimizeMultiple) { "function f1(x) { return f2(x + 1, x + 1) + x; };" "result = f1(1);"); } - NonIncrementalGC(CcTest::i_isolate()); + CcTest::CollectAllGarbage(); CHECK_EQ(1, env->Global() ->Get(env.local(), v8_str("count")) @@ -330,7 +321,7 @@ TEST(DeoptimizeConstructor) { "function f() { g(); };" "result = new f() instanceof f;"); } - NonIncrementalGC(CcTest::i_isolate()); + CcTest::CollectAllGarbage(); CHECK_EQ(1, env->Global() ->Get(env.local(), v8_str("count")) @@ -354,7 +345,7 @@ TEST(DeoptimizeConstructor) { "result = new f(1, 2);" "result = result.x + result.y;"); } - NonIncrementalGC(CcTest::i_isolate()); + CcTest::CollectAllGarbage(); CHECK_EQ(1, env->Global() ->Get(env.local(), v8_str("count")) @@ -392,7 +383,7 @@ TEST(DeoptimizeConstructorMultiple) { "function f1(x) { this.result = new f2(x + 1, x + 1).result + x; };" "result = new f1(1).result;"); } - NonIncrementalGC(CcTest::i_isolate()); + CcTest::CollectAllGarbage(); CHECK_EQ(1, env->Global() ->Get(env.local(), v8_str("count")) @@ -453,7 +444,7 @@ UNINITIALIZED_TEST(DeoptimizeBinaryOperationADDString) { "deopt = true;" "var result = f('a+', new X());"); } - NonIncrementalGC(i_isolate); + CcTest::CollectAllGarbage(i_isolate); CHECK(!GetJSFunction(env.local(), "f")->IsOptimized()); CHECK_EQ(1, env->Global() @@ -513,7 +504,7 @@ static void TestDeoptimizeBinaryOpHelper(LocalContext* env, // Call f and force deoptimization while processing the binary operation. CompileRun("deopt = true;" "var result = f(7, new X());"); - NonIncrementalGC(i_isolate); + CcTest::CollectAllGarbage(i_isolate); CHECK(!GetJSFunction((*env).local(), "f")->IsOptimized()); } @@ -718,7 +709,7 @@ UNINITIALIZED_TEST(DeoptimizeCompare) { "deopt = true;" "var result = f('a', new X());"); } - NonIncrementalGC(i_isolate); + CcTest::CollectAllGarbage(i_isolate); CHECK(!GetJSFunction(env.local(), "f")->IsOptimized()); CHECK_EQ(1, env->Global() @@ -729,8 +720,7 @@ UNINITIALIZED_TEST(DeoptimizeCompare) { CHECK_EQ(true, env->Global() ->Get(env.local(), v8_str("result")) .ToLocalChecked() - ->BooleanValue(env.local()) - .FromJust()); + ->BooleanValue(isolate)); CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(i_isolate)); } isolate->Exit(); @@ -817,7 +807,7 @@ UNINITIALIZED_TEST(DeoptimizeLoadICStoreIC) { "f2(new X(), 'z');" "g2(new X(), 'z');"); } - NonIncrementalGC(i_isolate); + CcTest::CollectAllGarbage(i_isolate); CHECK(!GetJSFunction(env.local(), "f1")->IsOptimized()); CHECK(!GetJSFunction(env.local(), "g1")->IsOptimized()); @@ -919,7 +909,7 @@ UNINITIALIZED_TEST(DeoptimizeLoadICStoreICNested) { "deopt = true;" "var result = f1(new X());"); } - NonIncrementalGC(i_isolate); + CcTest::CollectAllGarbage(i_isolate); CHECK(!GetJSFunction(env.local(), "f1")->IsOptimized()); CHECK(!GetJSFunction(env.local(), "g1")->IsOptimized()); diff --git a/deps/v8/test/cctest/test-disasm-mips64.cc b/deps/v8/test/cctest/test-disasm-mips64.cc index 29497fd9d6..1b0bdcc270 100644 --- a/deps/v8/test/cctest/test-disasm-mips64.cc +++ b/deps/v8/test/cctest/test-disasm-mips64.cc @@ -1177,19 +1177,6 @@ TEST(Type3) { COMPARE_PC_REL_COMPACT(bgtz(a0, 32767), "1c807fff bgtz a0, 32767", 32767); - int64_t pc_region; - GET_PC_REGION(pc_region); - - int64_t target = pc_region | 0x4; - COMPARE_PC_JUMP(j(target), "08000001 j ", target); - target = pc_region | 0xFFFFFFC; - COMPARE_PC_JUMP(j(target), "0bffffff j ", target); - - target = pc_region | 0x4; - COMPARE_PC_JUMP(jal(target), "0c000001 jal ", target); - target = pc_region | 0xFFFFFFC; - COMPARE_PC_JUMP(jal(target), "0fffffff jal ", target); - VERIFY_RUN(); } diff --git a/deps/v8/test/cctest/test-disasm-x64.cc b/deps/v8/test/cctest/test-disasm-x64.cc index c42606485c..1e530c3ce2 100644 --- a/deps/v8/test/cctest/test-disasm-x64.cc +++ b/deps/v8/test/cctest/test-disasm-x64.cc @@ -142,8 +142,11 @@ TEST(DisasmX64) { __ shll_cl(Operand(rdi, rax, times_4, 100)); __ shll(rdx, Immediate(1)); __ shll(rdx, Immediate(6)); - __ bts(Operand(rdx, 0), rcx); - __ bts(Operand(rbx, rcx, times_4, 0), rcx); + __ btq(Operand(rdx, 0), rcx); + __ btsq(Operand(rdx, 0), rcx); + __ btsq(Operand(rbx, rcx, times_4, 0), rcx); + __ btsq(rcx, Immediate(13)); + __ btrq(rcx, Immediate(13)); __ nop(); __ pushq(Immediate(12)); __ pushq(Immediate(23456)); @@ -267,7 +270,6 @@ TEST(DisasmX64) { __ xorq(rdx, Immediate(12345)); __ xorq(rdx, Operand(rbx, rcx, times_8, 10000)); - __ bts(Operand(rbx, rcx, times_8, 10000), rdx); __ pshufw(xmm5, xmm1, 3); __ hlt(); __ int3(); diff --git a/deps/v8/test/cctest/test-feedback-vector.cc b/deps/v8/test/cctest/test-feedback-vector.cc index b809854270..80ae82d799 100644 --- a/deps/v8/test/cctest/test-feedback-vector.cc +++ b/deps/v8/test/cctest/test-feedback-vector.cc @@ -96,7 +96,7 @@ TEST(VectorStructure) { FeedbackMetadata::GetSlotSize(FeedbackSlotKind::kCreateClosure)); FeedbackSlot slot = helper.slot(1); FeedbackCell* cell = - FeedbackCell::cast(vector->Get(slot)->ToStrongHeapObject()); + FeedbackCell::cast(vector->Get(slot)->GetHeapObjectAssumeStrong()); CHECK_EQ(cell->value(), *factory->undefined_value()); } } @@ -203,7 +203,7 @@ TEST(VectorCallFeedback) { CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); HeapObject* heap_object; - CHECK(nexus.GetFeedback()->ToWeakHeapObject(&heap_object)); + CHECK(nexus.GetFeedback()->GetHeapObjectIfWeak(&heap_object)); CHECK_EQ(*foo, heap_object); CcTest::CollectAllGarbage(); @@ -228,7 +228,7 @@ TEST(VectorCallFeedbackForArray) { CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); HeapObject* heap_object; - CHECK(nexus.GetFeedback()->ToWeakHeapObject(&heap_object)); + CHECK(nexus.GetFeedback()->GetHeapObjectIfWeak(&heap_object)); CHECK_EQ(*isolate->array_function(), heap_object); CcTest::CollectAllGarbage(); @@ -236,6 +236,68 @@ TEST(VectorCallFeedbackForArray) { CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); } +size_t GetFeedbackVectorLength(Isolate* isolate, const char* src, + bool with_oneshot_opt) { + i::FLAG_enable_one_shot_optimization = with_oneshot_opt; + i::Handle<i::Object> i_object = v8::Utils::OpenHandle(*CompileRun(src)); + i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(i_object); + Handle<FeedbackVector> feedback_vector = + Handle<FeedbackVector>(f->feedback_vector(), isolate); + return feedback_vector->length(); +} + +TEST(OneShotCallICSlotCount) { + if (i::FLAG_always_opt) return; + CcTest::InitializeVM(); + LocalContext context; + v8::HandleScope scope(context->GetIsolate()); + Isolate* isolate = CcTest::i_isolate(); + i::FLAG_compilation_cache = false; + + const char* no_call = R"( + function f1() {}; + function f2() {}; + (function() { + return arguments.callee; + })(); + )"; + // len = 2 * 1 ldaNamed property + CHECK_EQ(GetFeedbackVectorLength(isolate, no_call, false), 2); + // no slots of named property loads/stores in one shot + CHECK_EQ(GetFeedbackVectorLength(isolate, no_call, true), 0); + + const char* single_call = R"( + function f1() {}; + function f2() {}; + (function() { + f1(); + return arguments.callee; + })(); + )"; + // len = 2 * 1 ldaNamed Slot + 2 * 1 CachedGlobalSlot + 2 * 1 CallICSlot + CHECK_EQ(GetFeedbackVectorLength(isolate, single_call, false), 6); + // len = 2 * 1 CachedGlobalSlot + CHECK_EQ(GetFeedbackVectorLength(isolate, single_call, true), 2); + + const char* multiple_calls = R"( + function f1() {}; + function f2() {}; + (function() { + f1(); + f2(); + f1(); + f2(); + return arguments.callee; + })(); + )"; + // len = 2 * 1 ldaNamedSlot + 2 * 2 CachedGlobalSlot (one for each unique + // function) + 2 * 4 CallICSlot (one for each function call) + CHECK_EQ(GetFeedbackVectorLength(isolate, multiple_calls, false), 14); + // CachedGlobalSlot (one for each unique function) + // len = 2 * 2 CachedGlobalSlot (one for each unique function) + CHECK_EQ(GetFeedbackVectorLength(isolate, multiple_calls, true), 4); +} + TEST(VectorCallCounts) { if (i::FLAG_always_opt) return; CcTest::InitializeVM(); @@ -284,7 +346,7 @@ TEST(VectorConstructCounts) { FeedbackNexus nexus(feedback_vector, slot); CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); - CHECK(feedback_vector->Get(slot)->IsWeakHeapObject()); + CHECK(feedback_vector->Get(slot)->IsWeak()); CompileRun("f(Foo); f(Foo);"); CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); diff --git a/deps/v8/test/cctest/test-field-type-tracking.cc b/deps/v8/test/cctest/test-field-type-tracking.cc index 4e37103558..f40dbe83bd 100644 --- a/deps/v8/test/cctest/test-field-type-tracking.cc +++ b/deps/v8/test/cctest/test-field-type-tracking.cc @@ -370,9 +370,8 @@ class Expectations { heap_type); Handle<String> name = MakeName("prop", property_index); - return Map::TransitionToDataProperty( - isolate_, map, name, value, attributes, constness, - Object::CERTAINLY_NOT_STORE_FROM_KEYED); + return Map::TransitionToDataProperty(isolate_, map, name, value, attributes, + constness, StoreOrigin::kNamed); } Handle<Map> TransitionToDataConstant(Handle<Map> map, @@ -383,9 +382,9 @@ class Expectations { SetDataConstant(property_index, attributes, value); Handle<String> name = MakeName("prop", property_index); - return Map::TransitionToDataProperty( - isolate_, map, name, value, attributes, PropertyConstness::kConst, - Object::CERTAINLY_NOT_STORE_FROM_KEYED); + return Map::TransitionToDataProperty(isolate_, map, name, value, attributes, + PropertyConstness::kConst, + StoreOrigin::kNamed); } Handle<Map> FollowDataTransition(Handle<Map> map, @@ -657,7 +656,9 @@ static void TestGeneralizeField(int detach_property_at_index, CanonicalHandleScope canonical(isolate); JSHeapBroker broker(isolate, &zone); CompilationDependencies dependencies(isolate, &zone); - dependencies.DependOnFieldType(MapRef(&broker, map), property_index); + MapRef map_ref(&broker, map); + map_ref.SerializeOwnDescriptors(); + dependencies.DependOnFieldType(map_ref, property_index); Handle<Map> field_owner(map->FindFieldOwner(isolate, property_index), isolate); @@ -1029,7 +1030,9 @@ static void TestReconfigureDataFieldAttribute_GeneralizeField( CanonicalHandleScope canonical(isolate); JSHeapBroker broker(isolate, &zone); CompilationDependencies dependencies(isolate, &zone); - dependencies.DependOnFieldType(MapRef(&broker, map), kSplitProp); + MapRef map_ref(&broker, map); + map_ref.SerializeOwnDescriptors(); + dependencies.DependOnFieldType(map_ref, kSplitProp); // Reconfigure attributes of property |kSplitProp| of |map2| to NONE, which // should generalize representations in |map1|. @@ -1113,7 +1116,9 @@ static void TestReconfigureDataFieldAttribute_GeneralizeFieldTrivial( CanonicalHandleScope canonical(isolate); JSHeapBroker broker(isolate, &zone); CompilationDependencies dependencies(isolate, &zone); - dependencies.DependOnFieldType(MapRef(&broker, map), kSplitProp); + MapRef map_ref(&broker, map); + map_ref.SerializeOwnDescriptors(); + dependencies.DependOnFieldType(map_ref, kSplitProp); // Reconfigure attributes of property |kSplitProp| of |map2| to NONE, which // should generalize representations in |map1|. @@ -1794,7 +1799,9 @@ static void TestReconfigureElementsKind_GeneralizeField( CanonicalHandleScope canonical(isolate); JSHeapBroker broker(isolate, &zone); CompilationDependencies dependencies(isolate, &zone); - dependencies.DependOnFieldType(MapRef(&broker, map), kDiffProp); + MapRef map_ref(&broker, map); + map_ref.SerializeOwnDescriptors(); + dependencies.DependOnFieldType(map_ref, kDiffProp); // Reconfigure elements kinds of |map2|, which should generalize // representations in |map|. @@ -1889,7 +1896,9 @@ static void TestReconfigureElementsKind_GeneralizeFieldTrivial( CanonicalHandleScope canonical(isolate); JSHeapBroker broker(isolate, &zone); CompilationDependencies dependencies(isolate, &zone); - dependencies.DependOnFieldType(MapRef(&broker, map), kDiffProp); + MapRef map_ref(&broker, map); + map_ref.SerializeOwnDescriptors(); + dependencies.DependOnFieldType(map_ref, kDiffProp); // Reconfigure elements kinds of |map2|, which should generalize // representations in |map|. diff --git a/deps/v8/test/cctest/test-heap-profiler.cc b/deps/v8/test/cctest/test-heap-profiler.cc index e4e5f4c8dc..257ef1c723 100644 --- a/deps/v8/test/cctest/test-heap-profiler.cc +++ b/deps/v8/test/cctest/test-heap-profiler.cc @@ -157,12 +157,9 @@ static Optional<SourceLocation> GetLocation(const v8::HeapSnapshot* s, const v8::HeapGraphNode* node) { const i::HeapSnapshot* snapshot = reinterpret_cast<const i::HeapSnapshot*>(s); const std::vector<SourceLocation>& locations = snapshot->locations(); - const int index = - const_cast<i::HeapEntry*>(reinterpret_cast<const i::HeapEntry*>(node)) - ->index(); - + const i::HeapEntry* entry = reinterpret_cast<const i::HeapEntry*>(node); for (const auto& loc : locations) { - if (loc.entry_index == index) { + if (loc.entry_index == entry->index()) { return Optional<SourceLocation>(loc); } } @@ -223,7 +220,7 @@ static bool ValidateSnapshot(const v8::HeapSnapshot* snapshot, int depth = 3) { entry->value = reinterpret_cast<void*>(ref_count + 1); } uint32_t unretained_entries_count = 0; - std::vector<i::HeapEntry>& entries = heap_snapshot->entries(); + std::deque<i::HeapEntry>& entries = heap_snapshot->entries(); for (i::HeapEntry& entry : entries) { v8::base::HashMap::Entry* map_entry = visited.Lookup( reinterpret_cast<void*>(&entry), @@ -506,9 +503,6 @@ TEST(HeapSnapshotHeapNumbers) { } TEST(HeapSnapshotHeapBigInts) { - // TODO(luoe): remove flag when it is on by default. - v8::internal::FLAG_harmony_bigint = true; - LocalContext env; v8::HandleScope scope(env->GetIsolate()); v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); @@ -686,7 +680,7 @@ TEST(HeapSnapshotWeakCollection) { ++weak_entries; } } - CHECK_EQ(1, weak_entries); // Key is the only weak. + CHECK_EQ(2, weak_entries); // Key and value are weak. const v8::HeapGraphNode* wm_s = GetProperty(env->GetIsolate(), wm, v8::HeapGraphEdge::kProperty, "str"); CHECK(wm_s); @@ -1003,21 +997,6 @@ TEST(HeapEntryIdsAndGC) { CHECK_EQ(b1->GetId(), b2->GetId()); } - -TEST(HeapSnapshotRootPreservedAfterSorting) { - LocalContext env; - v8::HandleScope scope(env->GetIsolate()); - v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); - const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); - CHECK(ValidateSnapshot(snapshot)); - const v8::HeapGraphNode* root1 = snapshot->GetRoot(); - const_cast<i::HeapSnapshot*>(reinterpret_cast<const i::HeapSnapshot*>( - snapshot))->GetSortedEntriesList(); - const v8::HeapGraphNode* root2 = snapshot->GetRoot(); - CHECK_EQ(root1, root2); -} - - namespace { class TestJSONStream : public v8::OutputStream { @@ -1025,9 +1004,9 @@ class TestJSONStream : public v8::OutputStream { TestJSONStream() : eos_signaled_(0), abort_countdown_(-1) {} explicit TestJSONStream(int abort_countdown) : eos_signaled_(0), abort_countdown_(abort_countdown) {} - virtual ~TestJSONStream() {} - virtual void EndOfStream() { ++eos_signaled_; } - virtual WriteResult WriteAsciiChunk(char* buffer, int chars_written) { + ~TestJSONStream() override = default; + void EndOfStream() override { ++eos_signaled_; } + WriteResult WriteAsciiChunk(char* buffer, int chars_written) override { if (abort_countdown_ > 0) --abort_countdown_; if (abort_countdown_ == 0) return kAbort; CHECK_GT(chars_written, 0); @@ -1053,8 +1032,9 @@ class OneByteResource : public v8::String::ExternalOneByteStringResource { explicit OneByteResource(i::Vector<char> string) : data_(string.start()) { length_ = string.length(); } - virtual const char* data() const { return data_; } - virtual size_t length() const { return length_; } + const char* data() const override { return data_; } + size_t length() const override { return length_; } + private: const char* data_; size_t length_; @@ -1215,20 +1195,15 @@ class TestStatsStream : public v8::OutputStream { intervals_count_(0), first_interval_index_(-1) { } TestStatsStream(const TestStatsStream& stream) - : v8::OutputStream(stream), - eos_signaled_(stream.eos_signaled_), - updates_written_(stream.updates_written_), - entries_count_(stream.entries_count_), - entries_size_(stream.entries_size_), - intervals_count_(stream.intervals_count_), - first_interval_index_(stream.first_interval_index_) { } - virtual ~TestStatsStream() {} - virtual void EndOfStream() { ++eos_signaled_; } - virtual WriteResult WriteAsciiChunk(char* buffer, int chars_written) { + + = default; + ~TestStatsStream() override = default; + void EndOfStream() override { ++eos_signaled_; } + WriteResult WriteAsciiChunk(char* buffer, int chars_written) override { UNREACHABLE(); } - virtual WriteResult WriteHeapStatsChunk(v8::HeapStatsUpdate* buffer, - int updates_written) { + WriteResult WriteHeapStatsChunk(v8::HeapStatsUpdate* buffer, + int updates_written) override { ++intervals_count_; CHECK(updates_written); updates_written_ += updates_written; @@ -1533,7 +1508,7 @@ class TestActivityControl : public v8::ActivityControl { total_(0), abort_count_(abort_count), reported_finish_(false) {} - ControlOption ReportProgressValue(int done, int total) { + ControlOption ReportProgressValue(int done, int total) override { done_ = done; total_ = total; CHECK_LE(done_, total_); @@ -1610,7 +1585,7 @@ class EmbedderGraphBuilder : public v8::PersistentHandleVisitor { public: explicit Group(const char* name) : Node(name, 0) {} // v8::EmbedderGraph::EmbedderNode - bool IsRootNode() { return true; } + bool IsRootNode() override { return true; } }; EmbedderGraphBuilder(v8::Isolate* isolate, v8::EmbedderGraph* graph) @@ -1784,7 +1759,7 @@ TEST(DeleteHeapSnapshot) { class NameResolver : public v8::HeapProfiler::ObjectNameResolver { public: - virtual const char* GetName(v8::Local<v8::Object> object) { + const char* GetName(v8::Local<v8::Object> object) override { return "Global object name"; } }; @@ -3062,7 +3037,7 @@ class EmbedderRootNode : public EmbedderNode { public: explicit EmbedderRootNode(const char* name) : EmbedderNode(name, 0) {} // Graph::Node override. - bool IsRootNode() { return true; } + bool IsRootNode() override { return true; } }; // Used to pass the global object to the BuildEmbedderGraph callback. @@ -3900,45 +3875,3 @@ TEST(WeakReference) { const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); CHECK(ValidateSnapshot(snapshot)); } - -TEST(Bug8373_1) { - LocalContext env; - v8::HandleScope scope(env->GetIsolate()); - v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); - - heap_profiler->StartSamplingHeapProfiler(100); - - heap_profiler->TakeHeapSnapshot(); - // Causes the StringsStorage to be deleted. - heap_profiler->DeleteAllHeapSnapshots(); - - // Triggers an allocation sample that tries to use the StringsStorage. - for (int i = 0; i < 2 * 1024; ++i) { - CompileRun( - "new Array(64);" - "new Uint8Array(16);"); - } - - heap_profiler->StopSamplingHeapProfiler(); -} - -TEST(Bug8373_2) { - LocalContext env; - v8::HandleScope scope(env->GetIsolate()); - v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); - - heap_profiler->StartTrackingHeapObjects(true); - - heap_profiler->TakeHeapSnapshot(); - // Causes the StringsStorage to be deleted. - heap_profiler->DeleteAllHeapSnapshots(); - - // Triggers an allocations that try to use the StringsStorage. - for (int i = 0; i < 2 * 1024; ++i) { - CompileRun( - "new Array(64);" - "new Uint8Array(16);"); - } - - heap_profiler->StopTrackingHeapObjects(); -} diff --git a/deps/v8/test/cctest/test-inobject-slack-tracking.cc b/deps/v8/test/cctest/test-inobject-slack-tracking.cc index 0e850b1682..9255dc04b0 100644 --- a/deps/v8/test/cctest/test-inobject-slack-tracking.cc +++ b/deps/v8/test/cctest/test-inobject-slack-tracking.cc @@ -1143,8 +1143,6 @@ TEST(SubclassArrayBuiltinNoInlineNew) { TEST(SubclassTypedArrayBuiltin) { // Avoid eventual completion of in-object slack tracking. FLAG_always_opt = false; - // Make BigInt64Array/BigUint64Array available for testing. - FLAG_harmony_bigint = true; CcTest::InitializeVM(); v8::HandleScope scope(CcTest::isolate()); diff --git a/deps/v8/test/cctest/test-inspector.cc b/deps/v8/test/cctest/test-inspector.cc index 8986c3c488..6dd2aefb9e 100644 --- a/deps/v8/test/cctest/test-inspector.cc +++ b/deps/v8/test/cctest/test-inspector.cc @@ -20,7 +20,7 @@ namespace { class NoopChannel : public V8Inspector::Channel { public: - virtual ~NoopChannel() {} + ~NoopChannel() override = default; void sendResponse(int callId, std::unique_ptr<StringBuffer> message) override {} void sendNotification(std::unique_ptr<StringBuffer> message) override {} diff --git a/deps/v8/test/cctest/test-intl.cc b/deps/v8/test/cctest/test-intl.cc index 950fbe3d30..3359a3878b 100644 --- a/deps/v8/test/cctest/test-intl.cc +++ b/deps/v8/test/cctest/test-intl.cc @@ -4,10 +4,10 @@ #ifdef V8_INTL_SUPPORT -#include "src/builtins/builtins-intl.h" #include "src/lookup.h" #include "src/objects-inl.h" #include "src/objects/intl-objects.h" +#include "src/objects/js-number-format.h" #include "test/cctest/cctest.h" namespace v8 { @@ -125,8 +125,7 @@ TEST(GetStringOption) { Handle<String> key = isolate->factory()->NewStringFromAsciiChecked("foo"); v8::internal::LookupIterator it(isolate, options, key); CHECK(Object::SetProperty(&it, Handle<Smi>(Smi::FromInt(42), isolate), - LanguageMode::kStrict, - AllocationMemento::MAY_BE_STORE_FROM_KEYED) + LanguageMode::kStrict, StoreOrigin::kMaybeKeyed) .FromJust()); { @@ -209,52 +208,26 @@ TEST(GetBoolOption) { } } -bool ScriptTagWasRemoved(std::string locale, std::string expected) { - std::string without_script_tag; - bool didShorten = Intl::RemoveLocaleScriptTag(locale, &without_script_tag); - return didShorten && expected == without_script_tag; -} - -bool ScriptTagWasNotRemoved(std::string locale) { - std::string without_script_tag; - bool didShorten = Intl::RemoveLocaleScriptTag(locale, &without_script_tag); - return !didShorten && without_script_tag.empty(); -} - -TEST(RemoveLocaleScriptTag) { - CHECK(ScriptTagWasRemoved("aa_Bbbb_CC", "aa_CC")); - CHECK(ScriptTagWasRemoved("aaa_Bbbb_CC", "aaa_CC")); - - CHECK(ScriptTagWasNotRemoved("aa")); - CHECK(ScriptTagWasNotRemoved("aaa")); - CHECK(ScriptTagWasNotRemoved("aa_CC")); - CHECK(ScriptTagWasNotRemoved("aa_Bbb_CC")); - CHECK(ScriptTagWasNotRemoved("aa_1bbb_CC")); -} - TEST(GetAvailableLocales) { std::set<std::string> locales; - locales = Intl::GetAvailableLocales(IcuService::kBreakIterator); + locales = Intl::GetAvailableLocales(ICUService::kBreakIterator); CHECK(locales.count("en-US")); CHECK(!locales.count("abcdefg")); - locales = Intl::GetAvailableLocales(IcuService::kCollator); - CHECK(locales.count("en-US")); - - locales = Intl::GetAvailableLocales(IcuService::kDateFormat); + locales = Intl::GetAvailableLocales(ICUService::kCollator); CHECK(locales.count("en-US")); - locales = Intl::GetAvailableLocales(IcuService::kNumberFormat); + locales = Intl::GetAvailableLocales(ICUService::kDateFormat); CHECK(locales.count("en-US")); - locales = Intl::GetAvailableLocales(IcuService::kPluralRules); + locales = Intl::GetAvailableLocales(ICUService::kNumberFormat); CHECK(locales.count("en-US")); - locales = Intl::GetAvailableLocales(IcuService::kResourceBundle); + locales = Intl::GetAvailableLocales(ICUService::kPluralRules); CHECK(locales.count("en-US")); - locales = Intl::GetAvailableLocales(IcuService::kRelativeDateTimeFormatter); + locales = Intl::GetAvailableLocales(ICUService::kRelativeDateTimeFormatter); CHECK(locales.count("en-US")); } diff --git a/deps/v8/test/cctest/test-javascript-arm64.cc b/deps/v8/test/cctest/test-javascript-arm64.cc index 3b1f1a1d12..428726fdc7 100644 --- a/deps/v8/test/cctest/test-javascript-arm64.cc +++ b/deps/v8/test/cctest/test-javascript-arm64.cc @@ -46,7 +46,7 @@ namespace test_javascript_arm64 { static void ExpectBoolean(Local<v8::Context> context, bool expected, Local<Value> result) { CHECK(result->IsBoolean()); - CHECK_EQ(expected, result->BooleanValue(context).FromJust()); + CHECK_EQ(expected, result->BooleanValue(context->GetIsolate())); } static void ExpectInt32(Local<v8::Context> context, int32_t expected, diff --git a/deps/v8/test/cctest/test-lockers.cc b/deps/v8/test/cctest/test-lockers.cc index dec279e781..5a4dcd588e 100644 --- a/deps/v8/test/cctest/test-lockers.cc +++ b/deps/v8/test/cctest/test-lockers.cc @@ -51,7 +51,7 @@ class DeoptimizeCodeThread : public v8::base::Thread { context_(isolate, context), source_(trigger) {} - void Run() { + void Run() override { v8::Locker locker(isolate_); isolate_->Enter(); v8::HandleScope handle_scope(isolate_); @@ -290,7 +290,7 @@ class KangarooThread : public v8::base::Thread { isolate_(isolate), context_(isolate, context) {} - void Run() { + void Run() override { { v8::Locker locker(isolate_); v8::Isolate::Scope isolate_scope(isolate_); @@ -362,7 +362,7 @@ class JoinableThread { thread_(this) { } - virtual ~JoinableThread() {} + virtual ~JoinableThread() = default; void Start() { thread_.Start(); @@ -382,7 +382,7 @@ class JoinableThread { : Thread(Options(joinable_thread->name_)), joinable_thread_(joinable_thread) {} - virtual void Run() { + void Run() override { joinable_thread_->Run(); joinable_thread_->semaphore_.Signal(); } @@ -408,7 +408,7 @@ class IsolateLockingThreadWithLocalContext : public JoinableThread { isolate_(isolate) { } - virtual void Run() { + void Run() override { v8::Locker locker(isolate_); v8::Isolate::Scope isolate_scope(isolate_); v8::HandleScope handle_scope(isolate_); @@ -460,7 +460,7 @@ class IsolateNestedLockingThread : public JoinableThread { explicit IsolateNestedLockingThread(v8::Isolate* isolate) : JoinableThread("IsolateNestedLocking"), isolate_(isolate) { } - virtual void Run() { + void Run() override { v8::Locker lock(isolate_); v8::Isolate::Scope isolate_scope(isolate_); v8::HandleScope handle_scope(isolate_); @@ -508,7 +508,7 @@ class SeparateIsolatesLocksNonexclusiveThread : public JoinableThread { isolate1_(isolate1), isolate2_(isolate2) { } - virtual void Run() { + void Run() override { v8::Locker lock(isolate1_); v8::Isolate::Scope isolate_scope(isolate1_); v8::HandleScope handle_scope(isolate1_); @@ -556,7 +556,7 @@ class LockIsolateAndCalculateFibSharedContextThread : public JoinableThread { isolate_(isolate), context_(isolate, context) {} - virtual void Run() { + void Run() override { v8::Locker lock(isolate_); v8::Isolate::Scope isolate_scope(isolate_); v8::HandleScope handle_scope(isolate_); @@ -577,7 +577,7 @@ class LockerUnlockerThread : public JoinableThread { isolate_(isolate) { } - virtual void Run() { + void Run() override { isolate_->DiscardThreadSpecificMetadata(); // No-op { v8::Locker lock(isolate_); @@ -637,7 +637,7 @@ class LockTwiceAndUnlockThread : public JoinableThread { isolate_(isolate) { } - virtual void Run() { + void Run() override { v8::Locker lock(isolate_); v8::Isolate::Scope isolate_scope(isolate_); v8::HandleScope handle_scope(isolate_); @@ -697,7 +697,7 @@ class LockAndUnlockDifferentIsolatesThread : public JoinableThread { isolate2_(isolate2) { } - virtual void Run() { + void Run() override { std::unique_ptr<LockIsolateAndCalculateFibSharedContextThread> thread; v8::Locker lock1(isolate1_); CHECK(v8::Locker::IsLocked(isolate1_)); @@ -760,7 +760,7 @@ class LockUnlockLockThread : public JoinableThread { isolate_(isolate), context_(isolate, context) {} - virtual void Run() { + void Run() override { v8::Locker lock1(isolate_); CHECK(v8::Locker::IsLocked(isolate_)); CHECK(!v8::Locker::IsLocked(CcTest::isolate())); @@ -827,7 +827,7 @@ class LockUnlockLockDefaultIsolateThread : public JoinableThread { : JoinableThread("LockUnlockLockDefaultIsolateThread"), context_(CcTest::isolate(), context) {} - virtual void Run() { + void Run() override { v8::Locker lock1(CcTest::isolate()); { v8::Isolate::Scope isolate_scope(CcTest::isolate()); @@ -914,7 +914,7 @@ class IsolateGenesisThread : public JoinableThread { extension_names_(extension_names) {} - virtual void Run() { + void Run() override { v8::Isolate::CreateParams create_params; create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); v8::Isolate* isolate = v8::Isolate::New(create_params); diff --git a/deps/v8/test/cctest/test-log.cc b/deps/v8/test/cctest/test-log.cc index 9ac73af3e5..f7774b7bda 100644 --- a/deps/v8/test/cctest/test-log.cc +++ b/deps/v8/test/cctest/test-log.cc @@ -155,12 +155,16 @@ class ScopedLoggerInitializer { start = IndexOfLine({search_term}, start); if (start == std::string::npos) break; std::vector<std::string> columns = Split(log_.at(start), ','); - CHECK_LT(address_column, columns.size()); + ++start; // Skip the found line. + // TODO(crbug.com/v8/8084): These two continue lines should really be + // errors. But on Windows the log is sometimes mysteriously cut off at the + // end. If the cut-off point happens to fall in the address field, the + // conditions will be triggered. + if (address_column >= columns.size()) continue; uintptr_t address = strtoll(columns.at(address_column).c_str(), nullptr, 16); - CHECK_GT(address, 0); + if (address == 0) continue; result.insert(address); - ++start; // Skip the found line. } return result; } @@ -259,9 +263,9 @@ class SimpleExternalString : public v8::String::ExternalStringResource { for (int i = 0; i < utf_source_.length(); ++i) utf_source_[i] = source[i]; } - virtual ~SimpleExternalString() {} - virtual size_t length() const { return utf_source_.length(); } - virtual const uint16_t* data() const { return utf_source_.start(); } + ~SimpleExternalString() override = default; + size_t length() const override { return utf_source_.length(); } + const uint16_t* data() const override { return utf_source_.start(); } private: i::ScopedVector<uint16_t> utf_source_; }; @@ -428,8 +432,7 @@ TEST(EquivalenceOfLoggingAndTraversal) { " (function a(j) { return function b() { return j; } })(100);\n" "})(this);"); logger.logger()->StopProfiler(); - reinterpret_cast<i::Isolate*>(isolate)->heap()->CollectAllGarbage( - i::Heap::kMakeHeapIterableMask, i::GarbageCollectionReason::kTesting); + CcTest::PreciseCollectAllGarbage(); logger.StringEvent("test-logging-done", ""); // Iterate heap to find compiled functions, will write to log. @@ -555,6 +558,8 @@ TEST(Issue539892) { TEST(LogAll) { SETUP_FLAGS(); i::FLAG_log_all = true; + i::FLAG_turbo_inlining = false; + i::FLAG_enable_one_shot_optimization = false; v8::Isolate::CreateParams create_params; create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); v8::Isolate* isolate = v8::Isolate::New(create_params); @@ -580,7 +585,9 @@ TEST(LogAll) { CHECK(logger.ContainsLine({"api,v8::Script::Run"})); CHECK(logger.ContainsLine({"code-creation,LazyCompile,", "testAddFn"})); if (i::FLAG_opt && !i::FLAG_always_opt) { - CHECK(logger.ContainsLine({"code-deopt,", "soft"})); + CHECK(logger.ContainsLine({"code-deopt,", "not a Smi"})); + if (i::FLAG_enable_one_shot_optimization) + CHECK(logger.ContainsLine({"code-deopt,", "DeoptimizeNow"})); CHECK(logger.ContainsLine({"timer-event-start", "V8.DeoptimizeCode"})); CHECK(logger.ContainsLine({"timer-event-end", "V8.DeoptimizeCode"})); } diff --git a/deps/v8/test/cctest/test-macro-assembler-mips.cc b/deps/v8/test/cctest/test-macro-assembler-mips.cc index 18404d6629..97ddda12c5 100644 --- a/deps/v8/test/cctest/test-macro-assembler-mips.cc +++ b/deps/v8/test/cctest/test-macro-assembler-mips.cc @@ -703,7 +703,7 @@ TEST(min_max_nan) { auto handle_dnan = [masm](FPURegister dst, Label* nan, Label* back) { __ bind(nan); - __ LoadRoot(t8, Heap::kNanValueRootIndex); + __ LoadRoot(t8, RootIndex::kNanValue); __ Ldc1(dst, FieldMemOperand(t8, HeapNumber::kValueOffset)); __ Branch(back); }; diff --git a/deps/v8/test/cctest/test-macro-assembler-mips64.cc b/deps/v8/test/cctest/test-macro-assembler-mips64.cc index 9a6e319363..b2aea23920 100644 --- a/deps/v8/test/cctest/test-macro-assembler-mips64.cc +++ b/deps/v8/test/cctest/test-macro-assembler-mips64.cc @@ -944,7 +944,7 @@ TEST(min_max_nan) { auto handle_dnan = [masm](FPURegister dst, Label* nan, Label* back) { __ bind(nan); - __ LoadRoot(t8, Heap::kNanValueRootIndex); + __ LoadRoot(t8, RootIndex::kNanValue); __ Ldc1(dst, FieldMemOperand(t8, HeapNumber::kValueOffset)); __ Branch(back); }; diff --git a/deps/v8/test/cctest/test-mementos.cc b/deps/v8/test/cctest/test-mementos.cc index 59653ccd73..3690752f13 100644 --- a/deps/v8/test/cctest/test-mementos.cc +++ b/deps/v8/test/cctest/test-mementos.cc @@ -67,7 +67,7 @@ TEST(Regress340063) { // Call GC to see if we can handle a poisonous memento right after the // current new space top pointer. - CcTest::CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); + CcTest::PreciseCollectAllGarbage(); } @@ -84,7 +84,7 @@ TEST(Regress470390) { // Call GC to see if we can handle a poisonous memento right after the // current new space top pointer. - CcTest::CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); + CcTest::PreciseCollectAllGarbage(); } diff --git a/deps/v8/test/cctest/test-parsing.cc b/deps/v8/test/cctest/test-parsing.cc index 72e3711405..942d597ccc 100644 --- a/deps/v8/test/cctest/test-parsing.cc +++ b/deps/v8/test/cctest/test-parsing.cc @@ -71,6 +71,326 @@ void MockUseCounterCallback(v8::Isolate* isolate, } // namespace +TEST(IsContextualKeyword) { + for (int i = 0; i < Token::NUM_TOKENS; i++) { + Token::Value token = static_cast<Token::Value>(i); + CHECK_EQ(Token::TypeForTesting(token) == 'C', + Token::IsContextualKeyword(token)); + } +} + +bool TokenIsAnyIdentifier(Token::Value token) { + switch (token) { + case Token::IDENTIFIER: + case Token::ASYNC: + case Token::AWAIT: + case Token::YIELD: + case Token::LET: + case Token::STATIC: + case Token::FUTURE_STRICT_RESERVED_WORD: + case Token::ESCAPED_STRICT_RESERVED_WORD: + case Token::ENUM: + return true; + default: + return false; + } +} + +TEST(AnyIdentifierToken) { + for (int i = 0; i < Token::NUM_TOKENS; i++) { + Token::Value token = static_cast<Token::Value>(i); + CHECK_EQ(TokenIsAnyIdentifier(token), Token::IsAnyIdentifier(token)); + } +} + +bool TokenIsIdentifier(Token::Value token, LanguageMode language_mode, + bool is_generator, bool disallow_await) { + switch (token) { + case Token::IDENTIFIER: + case Token::ASYNC: + return true; + case Token::YIELD: + return !is_generator && is_sloppy(language_mode); + case Token::AWAIT: + return !disallow_await; + case Token::LET: + case Token::STATIC: + case Token::FUTURE_STRICT_RESERVED_WORD: + case Token::ESCAPED_STRICT_RESERVED_WORD: + return is_sloppy(language_mode); + default: + return false; + } + UNREACHABLE(); +} + +TEST(IsIdentifierToken) { + for (int i = 0; i < Token::NUM_TOKENS; i++) { + Token::Value token = static_cast<Token::Value>(i); + for (size_t raw_language_mode = 0; raw_language_mode < LanguageModeSize; + raw_language_mode++) { + LanguageMode mode = static_cast<LanguageMode>(raw_language_mode); + for (int is_generator = 0; is_generator < 2; is_generator++) { + for (int disallow_await = 0; disallow_await < 2; disallow_await++) { + CHECK_EQ( + TokenIsIdentifier(token, mode, is_generator, disallow_await), + Token::IsIdentifier(token, mode, is_generator, disallow_await)); + } + } + } + } +} + +bool TokenIsStrictReservedWord(Token::Value token) { + switch (token) { + case Token::LET: + case Token::STATIC: + case Token::FUTURE_STRICT_RESERVED_WORD: + case Token::ESCAPED_STRICT_RESERVED_WORD: + return true; + default: + return false; + } + UNREACHABLE(); +} + +TEST(IsStrictReservedWord) { + for (int i = 0; i < Token::NUM_TOKENS; i++) { + Token::Value token = static_cast<Token::Value>(i); + CHECK_EQ(TokenIsStrictReservedWord(token), + Token::IsStrictReservedWord(token)); + } +} + +bool TokenIsLiteral(Token::Value token) { + switch (token) { + case Token::NULL_LITERAL: + case Token::TRUE_LITERAL: + case Token::FALSE_LITERAL: + case Token::NUMBER: + case Token::SMI: + case Token::BIGINT: + case Token::STRING: + return true; + default: + return false; + } + UNREACHABLE(); +} + +TEST(IsLiteralToken) { + for (int i = 0; i < Token::NUM_TOKENS; i++) { + Token::Value token = static_cast<Token::Value>(i); + CHECK_EQ(TokenIsLiteral(token), Token::IsLiteral(token)); + } +} +bool TokenIsAssignmentOp(Token::Value token) { + switch (token) { + case Token::INIT: + case Token::ASSIGN: +#define T(name, string, precedence) case Token::name: + BINARY_OP_TOKEN_LIST(T, EXPAND_BINOP_ASSIGN_TOKEN) +#undef T + return true; + default: + return false; + } +} + +TEST(AssignmentOp) { + for (int i = 0; i < Token::NUM_TOKENS; i++) { + Token::Value token = static_cast<Token::Value>(i); + CHECK_EQ(TokenIsAssignmentOp(token), Token::IsAssignmentOp(token)); + } +} + +bool TokenIsBinaryOp(Token::Value token) { + switch (token) { + case Token::COMMA: + case Token::OR: + case Token::AND: +#define T(name, string, precedence) case Token::name: + BINARY_OP_TOKEN_LIST(T, EXPAND_BINOP_TOKEN) +#undef T + return true; + default: + return false; + } +} + +TEST(BinaryOp) { + for (int i = 0; i < Token::NUM_TOKENS; i++) { + Token::Value token = static_cast<Token::Value>(i); + CHECK_EQ(TokenIsBinaryOp(token), Token::IsBinaryOp(token)); + } +} + +bool TokenIsCompareOp(Token::Value token) { + switch (token) { + case Token::EQ: + case Token::EQ_STRICT: + case Token::NE: + case Token::NE_STRICT: + case Token::LT: + case Token::GT: + case Token::LTE: + case Token::GTE: + case Token::INSTANCEOF: + case Token::IN: + return true; + default: + return false; + } +} + +TEST(CompareOp) { + for (int i = 0; i < Token::NUM_TOKENS; i++) { + Token::Value token = static_cast<Token::Value>(i); + CHECK_EQ(TokenIsCompareOp(token), Token::IsCompareOp(token)); + } +} + +bool TokenIsOrderedRelationalCompareOp(Token::Value token) { + switch (token) { + case Token::LT: + case Token::GT: + case Token::LTE: + case Token::GTE: + return true; + default: + return false; + } +} + +TEST(IsOrderedRelationalCompareOp) { + for (int i = 0; i < Token::NUM_TOKENS; i++) { + Token::Value token = static_cast<Token::Value>(i); + CHECK_EQ(TokenIsOrderedRelationalCompareOp(token), + Token::IsOrderedRelationalCompareOp(token)); + } +} + +bool TokenIsEqualityOp(Token::Value token) { + switch (token) { + case Token::EQ: + case Token::EQ_STRICT: + return true; + default: + return false; + } +} + +TEST(IsEqualityOp) { + for (int i = 0; i < Token::NUM_TOKENS; i++) { + Token::Value token = static_cast<Token::Value>(i); + CHECK_EQ(TokenIsEqualityOp(token), Token::IsEqualityOp(token)); + } +} + +bool TokenIsBitOp(Token::Value token) { + switch (token) { + case Token::BIT_OR: + case Token::BIT_XOR: + case Token::BIT_AND: + case Token::SHL: + case Token::SAR: + case Token::SHR: + case Token::BIT_NOT: + return true; + default: + return false; + } +} + +TEST(IsBitOp) { + for (int i = 0; i < Token::NUM_TOKENS; i++) { + Token::Value token = static_cast<Token::Value>(i); + CHECK_EQ(TokenIsBitOp(token), Token::IsBitOp(token)); + } +} + +bool TokenIsUnaryOp(Token::Value token) { + switch (token) { + case Token::NOT: + case Token::BIT_NOT: + case Token::DELETE: + case Token::TYPEOF: + case Token::VOID: + case Token::ADD: + case Token::SUB: + return true; + default: + return false; + } +} + +TEST(IsUnaryOp) { + for (int i = 0; i < Token::NUM_TOKENS; i++) { + Token::Value token = static_cast<Token::Value>(i); + CHECK_EQ(TokenIsUnaryOp(token), Token::IsUnaryOp(token)); + } +} + +bool TokenIsCountOp(Token::Value token) { + switch (token) { + case Token::INC: + case Token::DEC: + return true; + default: + return false; + } +} + +TEST(IsCountOp) { + for (int i = 0; i < Token::NUM_TOKENS; i++) { + Token::Value token = static_cast<Token::Value>(i); + CHECK_EQ(TokenIsCountOp(token), Token::IsCountOp(token)); + } +} + +bool TokenIsShiftOp(Token::Value token) { + switch (token) { + case Token::SHL: + case Token::SAR: + case Token::SHR: + return true; + default: + return false; + } +} + +TEST(IsShiftOp) { + for (int i = 0; i < Token::NUM_TOKENS; i++) { + Token::Value token = static_cast<Token::Value>(i); + CHECK_EQ(TokenIsShiftOp(token), Token::IsShiftOp(token)); + } +} + +bool TokenIsTrivialExpressionToken(Token::Value token) { + switch (token) { + case Token::SMI: + case Token::NUMBER: + case Token::BIGINT: + case Token::NULL_LITERAL: + case Token::TRUE_LITERAL: + case Token::FALSE_LITERAL: + case Token::STRING: + case Token::IDENTIFIER: + case Token::THIS: + return true; + default: + return false; + } +} + +TEST(IsTrivialExpressionToken) { + for (int i = 0; i < Token::NUM_TOKENS; i++) { + Token::Value token = static_cast<Token::Value>(i); + CHECK_EQ(TokenIsTrivialExpressionToken(token), + Token::IsTrivialExpressionToken(token)); + } +} + TEST(ScanKeywords) { struct KeywordToken { const char* keyword; @@ -253,8 +573,8 @@ class ScriptResource : public v8::String::ExternalOneByteStringResource { ScriptResource(const char* data, size_t length) : data_(data), length_(length) { } - const char* data() const { return data_; } - size_t length() const { return length_; } + const char* data() const override { return data_; } + size_t length() const override { return length_; } private: const char* data_; @@ -1230,8 +1550,10 @@ void TestParserSyncWithFlags(i::Handle<i::String> source, "However, the preparser succeeded", source->ToCString().get(), message_string->ToCString().get()); } - // Check that preparser and parser produce the same error. - if (test_preparser && !ignore_error_msg) { + // Check that preparser and parser produce the same error, except for cases + // where we do not track errors in the preparser. + if (test_preparser && !ignore_error_msg && + !pending_error_handler.ErrorUnidentifiableByPreParser()) { i::Handle<i::String> preparser_message = pending_error_handler.FormatErrorMessageForTest(CcTest::i_isolate()); if (!i::String::Equals(isolate, message_string, preparser_message)) { @@ -1721,7 +2043,7 @@ TEST(ErrorsFutureStrictReservedWords) { {"() => {", "}"}, {nullptr, nullptr}}; const char* invalid_statements[] = { - FUTURE_STRICT_RESERVED_LEX_BINDINGS("let") nullptr}; + FUTURE_STRICT_RESERVED_LEX_BINDINGS(let) nullptr}; RunParserSyncTest(non_strict_contexts, invalid_statements, kError); } @@ -2280,7 +2602,7 @@ TEST(OptionalCatchBinding) { {"try {", "} catch ({e}) { }"}, {"try {} catch ({e}) {", "}"}, {"function f() {", "}"}, - { NULL, NULL } + { nullptr, nullptr } }; const char* statement_data[] = { @@ -2288,7 +2610,7 @@ TEST(OptionalCatchBinding) { "try { } catch { } finally { }", "try { let e; } catch { let e; }", "try { let e; } catch { let e; } finally { let e; }", - NULL + nullptr }; // clang-format on @@ -2301,7 +2623,7 @@ TEST(OptionalCatchBindingInDoExpression) { // clang-format off const char* context_data[][2] = { {"((x = (eval(''), do {", "}))=>{})()"}, - { NULL, NULL } + { nullptr, nullptr } }; const char* statement_data[] = { @@ -2309,12 +2631,12 @@ TEST(OptionalCatchBindingInDoExpression) { "try { } catch { } finally { }", "try { let e; } catch { let e; }", "try { let e; } catch { let e; } finally { let e; }", - NULL + nullptr }; // clang-format on static const ParserFlag do_and_catch_flags[] = {kAllowHarmonyDoExpressions}; - RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, + RunParserSyncTest(context_data, statement_data, kSuccess, nullptr, 0, do_and_catch_flags, arraysize(do_and_catch_flags)); } @@ -3240,272 +3562,276 @@ TEST(MaybeAssignedInsideLoop) { std::vector<unsigned> top; // Can't use {} in initializers below. Input module_and_script_tests[] = { - {1, "for (j=x; j<10; ++j) { foo = j }", top}, - {1, "for (j=x; j<10; ++j) { [foo] = [j] }", top}, - {1, "for (j=x; j<10; ++j) { var foo = j }", top}, - {1, "for (j=x; j<10; ++j) { var [foo] = [j] }", top}, - {0, "for (j=x; j<10; ++j) { let foo = j }", {0}}, - {0, "for (j=x; j<10; ++j) { let [foo] = [j] }", {0}}, - {0, "for (j=x; j<10; ++j) { const foo = j }", {0}}, - {0, "for (j=x; j<10; ++j) { const [foo] = [j] }", {0}}, - {0, "for (j=x; j<10; ++j) { function foo() {return j} }", {0}}, - - {1, "for ({j}=x; j<10; ++j) { foo = j }", top}, - {1, "for ({j}=x; j<10; ++j) { [foo] = [j] }", top}, - {1, "for ({j}=x; j<10; ++j) { var foo = j }", top}, - {1, "for ({j}=x; j<10; ++j) { var [foo] = [j] }", top}, - {0, "for ({j}=x; j<10; ++j) { let foo = j }", {0}}, - {0, "for ({j}=x; j<10; ++j) { let [foo] = [j] }", {0}}, - {0, "for ({j}=x; j<10; ++j) { const foo = j }", {0}}, - {0, "for ({j}=x; j<10; ++j) { const [foo] = [j] }", {0}}, - {0, "for ({j}=x; j<10; ++j) { function foo() {return j} }", {0}}, - - {1, "for (var j=x; j<10; ++j) { foo = j }", top}, - {1, "for (var j=x; j<10; ++j) { [foo] = [j] }", top}, - {1, "for (var j=x; j<10; ++j) { var foo = j }", top}, - {1, "for (var j=x; j<10; ++j) { var [foo] = [j] }", top}, - {0, "for (var j=x; j<10; ++j) { let foo = j }", {0}}, - {0, "for (var j=x; j<10; ++j) { let [foo] = [j] }", {0}}, - {0, "for (var j=x; j<10; ++j) { const foo = j }", {0}}, - {0, "for (var j=x; j<10; ++j) { const [foo] = [j] }", {0}}, - {0, "for (var j=x; j<10; ++j) { function foo() {return j} }", {0}}, - - {1, "for (var {j}=x; j<10; ++j) { foo = j }", top}, - {1, "for (var {j}=x; j<10; ++j) { [foo] = [j] }", top}, - {1, "for (var {j}=x; j<10; ++j) { var foo = j }", top}, - {1, "for (var {j}=x; j<10; ++j) { var [foo] = [j] }", top}, - {0, "for (var {j}=x; j<10; ++j) { let foo = j }", {0}}, - {0, "for (var {j}=x; j<10; ++j) { let [foo] = [j] }", {0}}, - {0, "for (var {j}=x; j<10; ++j) { const foo = j }", {0}}, - {0, "for (var {j}=x; j<10; ++j) { const [foo] = [j] }", {0}}, - {0, "for (var {j}=x; j<10; ++j) { function foo() {return j} }", {0}}, - - {1, "for (let j=x; j<10; ++j) { foo = j }", top}, - {1, "for (let j=x; j<10; ++j) { [foo] = [j] }", top}, - {1, "for (let j=x; j<10; ++j) { var foo = j }", top}, - {1, "for (let j=x; j<10; ++j) { var [foo] = [j] }", top}, - {0, "for (let j=x; j<10; ++j) { let foo = j }", {0, 0}}, - {0, "for (let j=x; j<10; ++j) { let [foo] = [j] }", {0, 0, 0}}, - {0, "for (let j=x; j<10; ++j) { const foo = j }", {0, 0}}, - {0, "for (let j=x; j<10; ++j) { const [foo] = [j] }", {0, 0, 0}}, - {0, "for (let j=x; j<10; ++j) { function foo() {return j} }", {0, 0, 0}}, - - {1, "for (let {j}=x; j<10; ++j) { foo = j }", top}, - {1, "for (let {j}=x; j<10; ++j) { [foo] = [j] }", top}, - {1, "for (let {j}=x; j<10; ++j) { var foo = j }", top}, - {1, "for (let {j}=x; j<10; ++j) { var [foo] = [j] }", top}, - {0, "for (let {j}=x; j<10; ++j) { let foo = j }", {0, 0}}, - {0, "for (let {j}=x; j<10; ++j) { let [foo] = [j] }", {0, 0, 0}}, - {0, "for (let {j}=x; j<10; ++j) { const foo = j }", {0, 0}}, - {0, "for (let {j}=x; j<10; ++j) { const [foo] = [j] }", {0, 0, 0}}, - {0, "for (let {j}=x; j<10; ++j) { function foo(){return j} }", {0, 0, 0}}, - - {1, "for (j of x) { foo = j }", top}, - {1, "for (j of x) { [foo] = [j] }", top}, - {1, "for (j of x) { var foo = j }", top}, - {1, "for (j of x) { var [foo] = [j] }", top}, - {0, "for (j of x) { let foo = j }", {1}}, - {0, "for (j of x) { let [foo] = [j] }", {1}}, - {0, "for (j of x) { const foo = j }", {1}}, - {0, "for (j of x) { const [foo] = [j] }", {1}}, - {0, "for (j of x) { function foo() {return j} }", {1}}, - - {1, "for ({j} of x) { foo = j }", top}, - {1, "for ({j} of x) { [foo] = [j] }", top}, - {1, "for ({j} of x) { var foo = j }", top}, - {1, "for ({j} of x) { var [foo] = [j] }", top}, - {0, "for ({j} of x) { let foo = j }", {1}}, - {0, "for ({j} of x) { let [foo] = [j] }", {1}}, - {0, "for ({j} of x) { const foo = j }", {1}}, - {0, "for ({j} of x) { const [foo] = [j] }", {1}}, - {0, "for ({j} of x) { function foo() {return j} }", {1}}, - - {1, "for (var j of x) { foo = j }", top}, - {1, "for (var j of x) { [foo] = [j] }", top}, - {1, "for (var j of x) { var foo = j }", top}, - {1, "for (var j of x) { var [foo] = [j] }", top}, - {0, "for (var j of x) { let foo = j }", {1}}, - {0, "for (var j of x) { let [foo] = [j] }", {1}}, - {0, "for (var j of x) { const foo = j }", {1}}, - {0, "for (var j of x) { const [foo] = [j] }", {1}}, - {0, "for (var j of x) { function foo() {return j} }", {1}}, - - {1, "for (var {j} of x) { foo = j }", top}, - {1, "for (var {j} of x) { [foo] = [j] }", top}, - {1, "for (var {j} of x) { var foo = j }", top}, - {1, "for (var {j} of x) { var [foo] = [j] }", top}, - {0, "for (var {j} of x) { let foo = j }", {1}}, - {0, "for (var {j} of x) { let [foo] = [j] }", {1}}, - {0, "for (var {j} of x) { const foo = j }", {1}}, - {0, "for (var {j} of x) { const [foo] = [j] }", {1}}, - {0, "for (var {j} of x) { function foo() {return j} }", {1}}, - - {1, "for (let j of x) { foo = j }", top}, - {1, "for (let j of x) { [foo] = [j] }", top}, - {1, "for (let j of x) { var foo = j }", top}, - {1, "for (let j of x) { var [foo] = [j] }", top}, - {0, "for (let j of x) { let foo = j }", {0, 1, 0}}, - {0, "for (let j of x) { let [foo] = [j] }", {0, 1, 0}}, - {0, "for (let j of x) { const foo = j }", {0, 1, 0}}, - {0, "for (let j of x) { const [foo] = [j] }", {0, 1, 0}}, - {0, "for (let j of x) { function foo() {return j} }", {0, 1, 0}}, - - {1, "for (let {j} of x) { foo = j }", top}, - {1, "for (let {j} of x) { [foo] = [j] }", top}, - {1, "for (let {j} of x) { var foo = j }", top}, - {1, "for (let {j} of x) { var [foo] = [j] }", top}, - {0, "for (let {j} of x) { let foo = j }", {0, 1, 0}}, - {0, "for (let {j} of x) { let [foo] = [j] }", {0, 1, 0}}, - {0, "for (let {j} of x) { const foo = j }", {0, 1, 0}}, - {0, "for (let {j} of x) { const [foo] = [j] }", {0, 1, 0}}, - {0, "for (let {j} of x) { function foo() {return j} }", {0, 1, 0}}, - - {1, "for (const j of x) { foo = j }", top}, - {1, "for (const j of x) { [foo] = [j] }", top}, - {1, "for (const j of x) { var foo = j }", top}, - {1, "for (const j of x) { var [foo] = [j] }", top}, - {0, "for (const j of x) { let foo = j }", {0, 1, 0}}, - {0, "for (const j of x) { let [foo] = [j] }", {0, 1, 0}}, - {0, "for (const j of x) { const foo = j }", {0, 1, 0}}, - {0, "for (const j of x) { const [foo] = [j] }", {0, 1, 0}}, - {0, "for (const j of x) { function foo() {return j} }", {0, 1, 0}}, - - {1, "for (const {j} of x) { foo = j }", top}, - {1, "for (const {j} of x) { [foo] = [j] }", top}, - {1, "for (const {j} of x) { var foo = j }", top}, - {1, "for (const {j} of x) { var [foo] = [j] }", top}, - {0, "for (const {j} of x) { let foo = j }", {0, 1, 0}}, - {0, "for (const {j} of x) { let [foo] = [j] }", {0, 1, 0}}, - {0, "for (const {j} of x) { const foo = j }", {0, 1, 0}}, - {0, "for (const {j} of x) { const [foo] = [j] }", {0, 1, 0}}, - {0, "for (const {j} of x) { function foo() {return j} }", {0, 1, 0}}, - - {1, "for (j in x) { foo = j }", top}, - {1, "for (j in x) { [foo] = [j] }", top}, - {1, "for (j in x) { var foo = j }", top}, - {1, "for (j in x) { var [foo] = [j] }", top}, - {0, "for (j in x) { let foo = j }", {0}}, - {0, "for (j in x) { let [foo] = [j] }", {0}}, - {0, "for (j in x) { const foo = j }", {0}}, - {0, "for (j in x) { const [foo] = [j] }", {0}}, - {0, "for (j in x) { function foo() {return j} }", {0}}, - - {1, "for ({j} in x) { foo = j }", top}, - {1, "for ({j} in x) { [foo] = [j] }", top}, - {1, "for ({j} in x) { var foo = j }", top}, - {1, "for ({j} in x) { var [foo] = [j] }", top}, - {0, "for ({j} in x) { let foo = j }", {0}}, - {0, "for ({j} in x) { let [foo] = [j] }", {0}}, - {0, "for ({j} in x) { const foo = j }", {0}}, - {0, "for ({j} in x) { const [foo] = [j] }", {0}}, - {0, "for ({j} in x) { function foo() {return j} }", {0}}, - - {1, "for (var j in x) { foo = j }", top}, - {1, "for (var j in x) { [foo] = [j] }", top}, - {1, "for (var j in x) { var foo = j }", top}, - {1, "for (var j in x) { var [foo] = [j] }", top}, - {0, "for (var j in x) { let foo = j }", {0}}, - {0, "for (var j in x) { let [foo] = [j] }", {0}}, - {0, "for (var j in x) { const foo = j }", {0}}, - {0, "for (var j in x) { const [foo] = [j] }", {0}}, - {0, "for (var j in x) { function foo() {return j} }", {0}}, - - {1, "for (var {j} in x) { foo = j }", top}, - {1, "for (var {j} in x) { [foo] = [j] }", top}, - {1, "for (var {j} in x) { var foo = j }", top}, - {1, "for (var {j} in x) { var [foo] = [j] }", top}, - {0, "for (var {j} in x) { let foo = j }", {0}}, - {0, "for (var {j} in x) { let [foo] = [j] }", {0}}, - {0, "for (var {j} in x) { const foo = j }", {0}}, - {0, "for (var {j} in x) { const [foo] = [j] }", {0}}, - {0, "for (var {j} in x) { function foo() {return j} }", {0}}, - - {1, "for (let j in x) { foo = j }", top}, - {1, "for (let j in x) { [foo] = [j] }", top}, - {1, "for (let j in x) { var foo = j }", top}, - {1, "for (let j in x) { var [foo] = [j] }", top}, - {0, "for (let j in x) { let foo = j }", {0, 0, 0}}, - {0, "for (let j in x) { let [foo] = [j] }", {0, 0, 0}}, - {0, "for (let j in x) { const foo = j }", {0, 0, 0}}, - {0, "for (let j in x) { const [foo] = [j] }", {0, 0, 0}}, - {0, "for (let j in x) { function foo() {return j} }", {0, 0, 0}}, - - {1, "for (let {j} in x) { foo = j }", top}, - {1, "for (let {j} in x) { [foo] = [j] }", top}, - {1, "for (let {j} in x) { var foo = j }", top}, - {1, "for (let {j} in x) { var [foo] = [j] }", top}, - {0, "for (let {j} in x) { let foo = j }", {0, 0, 0}}, - {0, "for (let {j} in x) { let [foo] = [j] }", {0, 0, 0}}, - {0, "for (let {j} in x) { const foo = j }", {0, 0, 0}}, - {0, "for (let {j} in x) { const [foo] = [j] }", {0, 0, 0}}, - {0, "for (let {j} in x) { function foo() {return j} }", {0, 0, 0}}, - - {1, "for (const j in x) { foo = j }", top}, - {1, "for (const j in x) { [foo] = [j] }", top}, - {1, "for (const j in x) { var foo = j }", top}, - {1, "for (const j in x) { var [foo] = [j] }", top}, - {0, "for (const j in x) { let foo = j }", {0, 0, 0}}, - {0, "for (const j in x) { let [foo] = [j] }", {0, 0, 0}}, - {0, "for (const j in x) { const foo = j }", {0, 0, 0}}, - {0, "for (const j in x) { const [foo] = [j] }", {0, 0, 0}}, - {0, "for (const j in x) { function foo() {return j} }", {0, 0, 0}}, - - {1, "for (const {j} in x) { foo = j }", top}, - {1, "for (const {j} in x) { [foo] = [j] }", top}, - {1, "for (const {j} in x) { var foo = j }", top}, - {1, "for (const {j} in x) { var [foo] = [j] }", top}, - {0, "for (const {j} in x) { let foo = j }", {0, 0, 0}}, - {0, "for (const {j} in x) { let [foo] = [j] }", {0, 0, 0}}, - {0, "for (const {j} in x) { const foo = j }", {0, 0, 0}}, - {0, "for (const {j} in x) { const [foo] = [j] }", {0, 0, 0}}, - {0, "for (const {j} in x) { function foo() {return j} }", {0, 0, 0}}, - - {1, "while (j) { foo = j }", top}, - {1, "while (j) { [foo] = [j] }", top}, - {1, "while (j) { var foo = j }", top}, - {1, "while (j) { var [foo] = [j] }", top}, - {0, "while (j) { let foo = j }", {0}}, - {0, "while (j) { let [foo] = [j] }", {0}}, - {0, "while (j) { const foo = j }", {0}}, - {0, "while (j) { const [foo] = [j] }", {0}}, - {0, "while (j) { function foo() {return j} }", {0}}, - - {1, "do { foo = j } while (j)", top}, - {1, "do { [foo] = [j] } while (j)", top}, - {1, "do { var foo = j } while (j)", top}, - {1, "do { var [foo] = [j] } while (j)", top}, - {0, "do { let foo = j } while (j)", {0}}, - {0, "do { let [foo] = [j] } while (j)", {0}}, - {0, "do { const foo = j } while (j)", {0}}, - {0, "do { const [foo] = [j] } while (j)", {0}}, - {0, "do { function foo() {return j} } while (j)", {0}}, + {true, "for (j=x; j<10; ++j) { foo = j }", top}, + {true, "for (j=x; j<10; ++j) { [foo] = [j] }", top}, + {true, "for (j=x; j<10; ++j) { var foo = j }", top}, + {true, "for (j=x; j<10; ++j) { var [foo] = [j] }", top}, + {false, "for (j=x; j<10; ++j) { let foo = j }", {0}}, + {false, "for (j=x; j<10; ++j) { let [foo] = [j] }", {0}}, + {false, "for (j=x; j<10; ++j) { const foo = j }", {0}}, + {false, "for (j=x; j<10; ++j) { const [foo] = [j] }", {0}}, + {false, "for (j=x; j<10; ++j) { function foo() {return j} }", {0}}, + + {true, "for ({j}=x; j<10; ++j) { foo = j }", top}, + {true, "for ({j}=x; j<10; ++j) { [foo] = [j] }", top}, + {true, "for ({j}=x; j<10; ++j) { var foo = j }", top}, + {true, "for ({j}=x; j<10; ++j) { var [foo] = [j] }", top}, + {false, "for ({j}=x; j<10; ++j) { let foo = j }", {0}}, + {false, "for ({j}=x; j<10; ++j) { let [foo] = [j] }", {0}}, + {false, "for ({j}=x; j<10; ++j) { const foo = j }", {0}}, + {false, "for ({j}=x; j<10; ++j) { const [foo] = [j] }", {0}}, + {false, "for ({j}=x; j<10; ++j) { function foo() {return j} }", {0}}, + + {true, "for (var j=x; j<10; ++j) { foo = j }", top}, + {true, "for (var j=x; j<10; ++j) { [foo] = [j] }", top}, + {true, "for (var j=x; j<10; ++j) { var foo = j }", top}, + {true, "for (var j=x; j<10; ++j) { var [foo] = [j] }", top}, + {false, "for (var j=x; j<10; ++j) { let foo = j }", {0}}, + {false, "for (var j=x; j<10; ++j) { let [foo] = [j] }", {0}}, + {false, "for (var j=x; j<10; ++j) { const foo = j }", {0}}, + {false, "for (var j=x; j<10; ++j) { const [foo] = [j] }", {0}}, + {false, "for (var j=x; j<10; ++j) { function foo() {return j} }", {0}}, + + {true, "for (var {j}=x; j<10; ++j) { foo = j }", top}, + {true, "for (var {j}=x; j<10; ++j) { [foo] = [j] }", top}, + {true, "for (var {j}=x; j<10; ++j) { var foo = j }", top}, + {true, "for (var {j}=x; j<10; ++j) { var [foo] = [j] }", top}, + {false, "for (var {j}=x; j<10; ++j) { let foo = j }", {0}}, + {false, "for (var {j}=x; j<10; ++j) { let [foo] = [j] }", {0}}, + {false, "for (var {j}=x; j<10; ++j) { const foo = j }", {0}}, + {false, "for (var {j}=x; j<10; ++j) { const [foo] = [j] }", {0}}, + {false, "for (var {j}=x; j<10; ++j) { function foo() {return j} }", {0}}, + + {true, "for (let j=x; j<10; ++j) { foo = j }", top}, + {true, "for (let j=x; j<10; ++j) { [foo] = [j] }", top}, + {true, "for (let j=x; j<10; ++j) { var foo = j }", top}, + {true, "for (let j=x; j<10; ++j) { var [foo] = [j] }", top}, + {false, "for (let j=x; j<10; ++j) { let foo = j }", {0, 0}}, + {false, "for (let j=x; j<10; ++j) { let [foo] = [j] }", {0, 0, 0}}, + {false, "for (let j=x; j<10; ++j) { const foo = j }", {0, 0}}, + {false, "for (let j=x; j<10; ++j) { const [foo] = [j] }", {0, 0, 0}}, + {false, + "for (let j=x; j<10; ++j) { function foo() {return j} }", + {0, 0, 0}}, + + {true, "for (let {j}=x; j<10; ++j) { foo = j }", top}, + {true, "for (let {j}=x; j<10; ++j) { [foo] = [j] }", top}, + {true, "for (let {j}=x; j<10; ++j) { var foo = j }", top}, + {true, "for (let {j}=x; j<10; ++j) { var [foo] = [j] }", top}, + {false, "for (let {j}=x; j<10; ++j) { let foo = j }", {0, 0}}, + {false, "for (let {j}=x; j<10; ++j) { let [foo] = [j] }", {0, 0, 0}}, + {false, "for (let {j}=x; j<10; ++j) { const foo = j }", {0, 0}}, + {false, "for (let {j}=x; j<10; ++j) { const [foo] = [j] }", {0, 0, 0}}, + {false, + "for (let {j}=x; j<10; ++j) { function foo(){return j} }", + {0, 0, 0}}, + + {true, "for (j of x) { foo = j }", top}, + {true, "for (j of x) { [foo] = [j] }", top}, + {true, "for (j of x) { var foo = j }", top}, + {true, "for (j of x) { var [foo] = [j] }", top}, + {false, "for (j of x) { let foo = j }", {1}}, + {false, "for (j of x) { let [foo] = [j] }", {1}}, + {false, "for (j of x) { const foo = j }", {1}}, + {false, "for (j of x) { const [foo] = [j] }", {1}}, + {false, "for (j of x) { function foo() {return j} }", {1}}, + + {true, "for ({j} of x) { foo = j }", top}, + {true, "for ({j} of x) { [foo] = [j] }", top}, + {true, "for ({j} of x) { var foo = j }", top}, + {true, "for ({j} of x) { var [foo] = [j] }", top}, + {false, "for ({j} of x) { let foo = j }", {1}}, + {false, "for ({j} of x) { let [foo] = [j] }", {1}}, + {false, "for ({j} of x) { const foo = j }", {1}}, + {false, "for ({j} of x) { const [foo] = [j] }", {1}}, + {false, "for ({j} of x) { function foo() {return j} }", {1}}, + + {true, "for (var j of x) { foo = j }", top}, + {true, "for (var j of x) { [foo] = [j] }", top}, + {true, "for (var j of x) { var foo = j }", top}, + {true, "for (var j of x) { var [foo] = [j] }", top}, + {false, "for (var j of x) { let foo = j }", {1}}, + {false, "for (var j of x) { let [foo] = [j] }", {1}}, + {false, "for (var j of x) { const foo = j }", {1}}, + {false, "for (var j of x) { const [foo] = [j] }", {1}}, + {false, "for (var j of x) { function foo() {return j} }", {1}}, + + {true, "for (var {j} of x) { foo = j }", top}, + {true, "for (var {j} of x) { [foo] = [j] }", top}, + {true, "for (var {j} of x) { var foo = j }", top}, + {true, "for (var {j} of x) { var [foo] = [j] }", top}, + {false, "for (var {j} of x) { let foo = j }", {1}}, + {false, "for (var {j} of x) { let [foo] = [j] }", {1}}, + {false, "for (var {j} of x) { const foo = j }", {1}}, + {false, "for (var {j} of x) { const [foo] = [j] }", {1}}, + {false, "for (var {j} of x) { function foo() {return j} }", {1}}, + + {true, "for (let j of x) { foo = j }", top}, + {true, "for (let j of x) { [foo] = [j] }", top}, + {true, "for (let j of x) { var foo = j }", top}, + {true, "for (let j of x) { var [foo] = [j] }", top}, + {false, "for (let j of x) { let foo = j }", {0, 1, 0}}, + {false, "for (let j of x) { let [foo] = [j] }", {0, 1, 0}}, + {false, "for (let j of x) { const foo = j }", {0, 1, 0}}, + {false, "for (let j of x) { const [foo] = [j] }", {0, 1, 0}}, + {false, "for (let j of x) { function foo() {return j} }", {0, 1, 0}}, + + {true, "for (let {j} of x) { foo = j }", top}, + {true, "for (let {j} of x) { [foo] = [j] }", top}, + {true, "for (let {j} of x) { var foo = j }", top}, + {true, "for (let {j} of x) { var [foo] = [j] }", top}, + {false, "for (let {j} of x) { let foo = j }", {0, 1, 0}}, + {false, "for (let {j} of x) { let [foo] = [j] }", {0, 1, 0}}, + {false, "for (let {j} of x) { const foo = j }", {0, 1, 0}}, + {false, "for (let {j} of x) { const [foo] = [j] }", {0, 1, 0}}, + {false, "for (let {j} of x) { function foo() {return j} }", {0, 1, 0}}, + + {true, "for (const j of x) { foo = j }", top}, + {true, "for (const j of x) { [foo] = [j] }", top}, + {true, "for (const j of x) { var foo = j }", top}, + {true, "for (const j of x) { var [foo] = [j] }", top}, + {false, "for (const j of x) { let foo = j }", {0, 1, 0}}, + {false, "for (const j of x) { let [foo] = [j] }", {0, 1, 0}}, + {false, "for (const j of x) { const foo = j }", {0, 1, 0}}, + {false, "for (const j of x) { const [foo] = [j] }", {0, 1, 0}}, + {false, "for (const j of x) { function foo() {return j} }", {0, 1, 0}}, + + {true, "for (const {j} of x) { foo = j }", top}, + {true, "for (const {j} of x) { [foo] = [j] }", top}, + {true, "for (const {j} of x) { var foo = j }", top}, + {true, "for (const {j} of x) { var [foo] = [j] }", top}, + {false, "for (const {j} of x) { let foo = j }", {0, 1, 0}}, + {false, "for (const {j} of x) { let [foo] = [j] }", {0, 1, 0}}, + {false, "for (const {j} of x) { const foo = j }", {0, 1, 0}}, + {false, "for (const {j} of x) { const [foo] = [j] }", {0, 1, 0}}, + {false, "for (const {j} of x) { function foo() {return j} }", {0, 1, 0}}, + + {true, "for (j in x) { foo = j }", top}, + {true, "for (j in x) { [foo] = [j] }", top}, + {true, "for (j in x) { var foo = j }", top}, + {true, "for (j in x) { var [foo] = [j] }", top}, + {false, "for (j in x) { let foo = j }", {0}}, + {false, "for (j in x) { let [foo] = [j] }", {0}}, + {false, "for (j in x) { const foo = j }", {0}}, + {false, "for (j in x) { const [foo] = [j] }", {0}}, + {false, "for (j in x) { function foo() {return j} }", {0}}, + + {true, "for ({j} in x) { foo = j }", top}, + {true, "for ({j} in x) { [foo] = [j] }", top}, + {true, "for ({j} in x) { var foo = j }", top}, + {true, "for ({j} in x) { var [foo] = [j] }", top}, + {false, "for ({j} in x) { let foo = j }", {0}}, + {false, "for ({j} in x) { let [foo] = [j] }", {0}}, + {false, "for ({j} in x) { const foo = j }", {0}}, + {false, "for ({j} in x) { const [foo] = [j] }", {0}}, + {false, "for ({j} in x) { function foo() {return j} }", {0}}, + + {true, "for (var j in x) { foo = j }", top}, + {true, "for (var j in x) { [foo] = [j] }", top}, + {true, "for (var j in x) { var foo = j }", top}, + {true, "for (var j in x) { var [foo] = [j] }", top}, + {false, "for (var j in x) { let foo = j }", {0}}, + {false, "for (var j in x) { let [foo] = [j] }", {0}}, + {false, "for (var j in x) { const foo = j }", {0}}, + {false, "for (var j in x) { const [foo] = [j] }", {0}}, + {false, "for (var j in x) { function foo() {return j} }", {0}}, + + {true, "for (var {j} in x) { foo = j }", top}, + {true, "for (var {j} in x) { [foo] = [j] }", top}, + {true, "for (var {j} in x) { var foo = j }", top}, + {true, "for (var {j} in x) { var [foo] = [j] }", top}, + {false, "for (var {j} in x) { let foo = j }", {0}}, + {false, "for (var {j} in x) { let [foo] = [j] }", {0}}, + {false, "for (var {j} in x) { const foo = j }", {0}}, + {false, "for (var {j} in x) { const [foo] = [j] }", {0}}, + {false, "for (var {j} in x) { function foo() {return j} }", {0}}, + + {true, "for (let j in x) { foo = j }", top}, + {true, "for (let j in x) { [foo] = [j] }", top}, + {true, "for (let j in x) { var foo = j }", top}, + {true, "for (let j in x) { var [foo] = [j] }", top}, + {false, "for (let j in x) { let foo = j }", {0, 0, 0}}, + {false, "for (let j in x) { let [foo] = [j] }", {0, 0, 0}}, + {false, "for (let j in x) { const foo = j }", {0, 0, 0}}, + {false, "for (let j in x) { const [foo] = [j] }", {0, 0, 0}}, + {false, "for (let j in x) { function foo() {return j} }", {0, 0, 0}}, + + {true, "for (let {j} in x) { foo = j }", top}, + {true, "for (let {j} in x) { [foo] = [j] }", top}, + {true, "for (let {j} in x) { var foo = j }", top}, + {true, "for (let {j} in x) { var [foo] = [j] }", top}, + {false, "for (let {j} in x) { let foo = j }", {0, 0, 0}}, + {false, "for (let {j} in x) { let [foo] = [j] }", {0, 0, 0}}, + {false, "for (let {j} in x) { const foo = j }", {0, 0, 0}}, + {false, "for (let {j} in x) { const [foo] = [j] }", {0, 0, 0}}, + {false, "for (let {j} in x) { function foo() {return j} }", {0, 0, 0}}, + + {true, "for (const j in x) { foo = j }", top}, + {true, "for (const j in x) { [foo] = [j] }", top}, + {true, "for (const j in x) { var foo = j }", top}, + {true, "for (const j in x) { var [foo] = [j] }", top}, + {false, "for (const j in x) { let foo = j }", {0, 0, 0}}, + {false, "for (const j in x) { let [foo] = [j] }", {0, 0, 0}}, + {false, "for (const j in x) { const foo = j }", {0, 0, 0}}, + {false, "for (const j in x) { const [foo] = [j] }", {0, 0, 0}}, + {false, "for (const j in x) { function foo() {return j} }", {0, 0, 0}}, + + {true, "for (const {j} in x) { foo = j }", top}, + {true, "for (const {j} in x) { [foo] = [j] }", top}, + {true, "for (const {j} in x) { var foo = j }", top}, + {true, "for (const {j} in x) { var [foo] = [j] }", top}, + {false, "for (const {j} in x) { let foo = j }", {0, 0, 0}}, + {false, "for (const {j} in x) { let [foo] = [j] }", {0, 0, 0}}, + {false, "for (const {j} in x) { const foo = j }", {0, 0, 0}}, + {false, "for (const {j} in x) { const [foo] = [j] }", {0, 0, 0}}, + {false, "for (const {j} in x) { function foo() {return j} }", {0, 0, 0}}, + + {true, "while (j) { foo = j }", top}, + {true, "while (j) { [foo] = [j] }", top}, + {true, "while (j) { var foo = j }", top}, + {true, "while (j) { var [foo] = [j] }", top}, + {false, "while (j) { let foo = j }", {0}}, + {false, "while (j) { let [foo] = [j] }", {0}}, + {false, "while (j) { const foo = j }", {0}}, + {false, "while (j) { const [foo] = [j] }", {0}}, + {false, "while (j) { function foo() {return j} }", {0}}, + + {true, "do { foo = j } while (j)", top}, + {true, "do { [foo] = [j] } while (j)", top}, + {true, "do { var foo = j } while (j)", top}, + {true, "do { var [foo] = [j] } while (j)", top}, + {false, "do { let foo = j } while (j)", {0}}, + {false, "do { let [foo] = [j] } while (j)", {0}}, + {false, "do { const foo = j } while (j)", {0}}, + {false, "do { const [foo] = [j] } while (j)", {0}}, + {false, "do { function foo() {return j} } while (j)", {0}}, }; Input script_only_tests[] = { - {1, "for (j=x; j<10; ++j) { function foo() {return j} }", top}, - {1, "for ({j}=x; j<10; ++j) { function foo() {return j} }", top}, - {1, "for (var j=x; j<10; ++j) { function foo() {return j} }", top}, - {1, "for (var {j}=x; j<10; ++j) { function foo() {return j} }", top}, - {1, "for (let j=x; j<10; ++j) { function foo() {return j} }", top}, - {1, "for (let {j}=x; j<10; ++j) { function foo() {return j} }", top}, - {1, "for (j of x) { function foo() {return j} }", top}, - {1, "for ({j} of x) { function foo() {return j} }", top}, - {1, "for (var j of x) { function foo() {return j} }", top}, - {1, "for (var {j} of x) { function foo() {return j} }", top}, - {1, "for (let j of x) { function foo() {return j} }", top}, - {1, "for (let {j} of x) { function foo() {return j} }", top}, - {1, "for (const j of x) { function foo() {return j} }", top}, - {1, "for (const {j} of x) { function foo() {return j} }", top}, - {1, "for (j in x) { function foo() {return j} }", top}, - {1, "for ({j} in x) { function foo() {return j} }", top}, - {1, "for (var j in x) { function foo() {return j} }", top}, - {1, "for (var {j} in x) { function foo() {return j} }", top}, - {1, "for (let j in x) { function foo() {return j} }", top}, - {1, "for (let {j} in x) { function foo() {return j} }", top}, - {1, "for (const j in x) { function foo() {return j} }", top}, - {1, "for (const {j} in x) { function foo() {return j} }", top}, - {1, "while (j) { function foo() {return j} }", top}, - {1, "do { function foo() {return j} } while (j)", top}, + {true, "for (j=x; j<10; ++j) { function foo() {return j} }", top}, + {true, "for ({j}=x; j<10; ++j) { function foo() {return j} }", top}, + {true, "for (var j=x; j<10; ++j) { function foo() {return j} }", top}, + {true, "for (var {j}=x; j<10; ++j) { function foo() {return j} }", top}, + {true, "for (let j=x; j<10; ++j) { function foo() {return j} }", top}, + {true, "for (let {j}=x; j<10; ++j) { function foo() {return j} }", top}, + {true, "for (j of x) { function foo() {return j} }", top}, + {true, "for ({j} of x) { function foo() {return j} }", top}, + {true, "for (var j of x) { function foo() {return j} }", top}, + {true, "for (var {j} of x) { function foo() {return j} }", top}, + {true, "for (let j of x) { function foo() {return j} }", top}, + {true, "for (let {j} of x) { function foo() {return j} }", top}, + {true, "for (const j of x) { function foo() {return j} }", top}, + {true, "for (const {j} of x) { function foo() {return j} }", top}, + {true, "for (j in x) { function foo() {return j} }", top}, + {true, "for ({j} in x) { function foo() {return j} }", top}, + {true, "for (var j in x) { function foo() {return j} }", top}, + {true, "for (var {j} in x) { function foo() {return j} }", top}, + {true, "for (let j in x) { function foo() {return j} }", top}, + {true, "for (let {j} in x) { function foo() {return j} }", top}, + {true, "for (const j in x) { function foo() {return j} }", top}, + {true, "for (const {j} in x) { function foo() {return j} }", top}, + {true, "while (j) { function foo() {return j} }", top}, + {true, "do { function foo() {return j} } while (j)", top}, }; for (unsigned i = 0; i < arraysize(module_and_script_tests); ++i) { diff --git a/deps/v8/test/cctest/test-platform.cc b/deps/v8/test/cctest/test-platform.cc index e7ad2d84f1..e4ab19f05f 100644 --- a/deps/v8/test/cctest/test-platform.cc +++ b/deps/v8/test/cctest/test-platform.cc @@ -29,7 +29,7 @@ void GetStackPointer(const v8::FunctionCallbackInfo<v8::Value>& args) { #elif V8_HOST_ARCH_MIPS64 __asm__ __volatile__("sd $sp, %0" : "=g"(sp_addr)); #elif defined(__s390x__) || defined(_ARCH_S390X) - __asm__ __volatile__("stg 15, %0" : "=m"(sp_addr)); + __asm__ __volatile__("stg %%r15, %0" : "=m"(sp_addr)); #elif defined(__s390__) || defined(_ARCH_S390) __asm__ __volatile__("st 15, %0" : "=m"(sp_addr)); #elif defined(__PPC64__) || defined(_ARCH_PPC64) diff --git a/deps/v8/test/cctest/test-poison-disasm-arm.cc b/deps/v8/test/cctest/test-poison-disasm-arm.cc new file mode 100644 index 0000000000..7a3238eea1 --- /dev/null +++ b/deps/v8/test/cctest/test-poison-disasm-arm.cc @@ -0,0 +1,123 @@ +// 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. + +// The C++ style guide recommends using <re2> instead of <regex>. However, the +// former isn't available in V8. +#include <regex> // NOLINT(build/c++11) + +#include "src/api-inl.h" +#include "src/disassembler.h" +#include "src/objects-inl.h" +#include "test/cctest/cctest.h" + +namespace v8 { +namespace internal { + +std::string DisassembleFunction(const char* function) { + v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext(); + Handle<JSFunction> f = Handle<JSFunction>::cast( + v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast( + CcTest::global()->Get(context, v8_str(function)).ToLocalChecked()))); + + Address begin = f->code()->raw_instruction_start(); + Address end = f->code()->raw_instruction_end(); + Isolate* isolate = CcTest::i_isolate(); + std::ostringstream os; + Disassembler::Decode(isolate, &os, reinterpret_cast<byte*>(begin), + reinterpret_cast<byte*>(end), + CodeReference(handle(f->code(), isolate))); + return os.str(); +} + +TEST(DisasmPoisonMonomorphicLoad) { +#ifdef ENABLE_DISASSEMBLER + if (i::FLAG_always_opt || !i::FLAG_opt) return; + + i::FLAG_allow_natives_syntax = true; + i::FLAG_untrusted_code_mitigations = true; + + CcTest::InitializeVM(); + v8::HandleScope scope(CcTest::isolate()); + + CompileRun( + "function mono(o) { return o.x; };" + "mono({ x : 1 });" + "mono({ x : 1 });" + "%OptimizeFunctionOnNextCall(mono);" + "mono({ x : 1 });"); + + std::string start("0x[0-9a-f]+ +[0-9a-f]+ +[0-9a-f]+ +"); + std::regex map_load_re(start + "ldr r([0-9]+), \\[r([0-9]+), #-1\\]"); + std::regex load_const_re(start + "ldr r([0-9]+), \\[pc, .*"); + std::regex cmp_re(start + "cmp r([0-9]+), r([0-9]+)"); + std::regex bne_re(start + "bne(.*)"); + std::regex eorne_re(start + "eorne r([0-9]+), r([0-9]+), r([0-9]+)"); + std::regex csdb_re(start + "csdb"); + std::regex load_field_re(start + + "ldr r([0-9]+), \\[r([0-9]+), #\\+[0-9]+\\]"); + std::regex mask_re(start + "and r([0-9]+), r([0-9]+), r([0-9]+)"); + + std::string poison_reg = "9"; + + std::smatch match; + std::string line; + std::istringstream reader(DisassembleFunction("mono")); + bool poisoning_sequence_found = false; + while (std::getline(reader, line)) { + if (std::regex_match(line, match, map_load_re)) { + std::string map_reg = match[1]; + std::string object_reg = match[2]; + // Matches that the property access sequence is instrumented with + // poisoning. We match the following sequence: + // + // ldr r1, [r0, #-1] ; load map + // ldr r2, [pc, #+104] ; load expected map constant + // cmp r1, r2 ; compare maps + // bne ... ; deopt if different + // eorne r9, r9, r9 ; update the poison + // csdb ; speculation barrier + // ldr r0, [r0, #+11] ; load the field + // and r0, r0, r9 ; apply the poison + + CHECK(std::getline(reader, line)); + CHECK(std::regex_match(line, match, load_const_re)); + + CHECK(std::getline(reader, line)); + CHECK(std::regex_match(line, match, cmp_re)); + CHECK_EQ(match[1], map_reg); + + CHECK(std::getline(reader, line)); + CHECK(std::regex_match(line, match, bne_re)); + + CHECK(std::getline(reader, line)); + CHECK(std::regex_match(line, match, eorne_re)); + CHECK_EQ(match[1], poison_reg); + CHECK_EQ(match[2], poison_reg); + CHECK_EQ(match[3], poison_reg); + + CHECK(std::getline(reader, line)); + CHECK(std::regex_match(line, match, csdb_re)); + + CHECK(std::getline(reader, line)); + CHECK(std::regex_match(line, match, load_field_re)); + CHECK_EQ(match[2], object_reg); + std::string field_reg = match[1]; + + CHECK(std::getline(reader, line)); + CHECK(std::regex_match(line, match, mask_re)); + CHECK_EQ(match[1], field_reg); + CHECK_EQ(match[2], field_reg); + CHECK_EQ(match[3], poison_reg); + + poisoning_sequence_found = true; + break; + } + } + + CHECK(poisoning_sequence_found); +#endif // ENABLE_DISASSEMBLER +} + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-regexp.cc b/deps/v8/test/cctest/test-regexp.cc index c65714a930..301aaf2968 100644 --- a/deps/v8/test/cctest/test-regexp.cc +++ b/deps/v8/test/cctest/test-regexp.cc @@ -1968,7 +1968,7 @@ class UncachedExternalString public: const char* data() const override { return "abcdefghijklmnopqrstuvwxyz"; } size_t length() const override { return 26; } - bool IsCompressible() const override { return true; } + bool IsCacheable() const override { return false; } }; TEST(UncachedExternalString) { @@ -1978,9 +1978,9 @@ TEST(UncachedExternalString) { v8::Local<v8::String> external = v8::String::NewExternalOneByte(isolate, new UncachedExternalString()) .ToLocalChecked(); - CHECK( - v8::Utils::OpenHandle(*external)->map() == - ReadOnlyRoots(CcTest::i_isolate()).short_external_one_byte_string_map()); + CHECK(v8::Utils::OpenHandle(*external)->map() == + ReadOnlyRoots(CcTest::i_isolate()) + .uncached_external_one_byte_string_map()); v8::Local<v8::Object> global = env->Global(); global->Set(env.local(), v8_str("external"), external).FromJust(); CompileRun("var re = /y(.)/; re.test('ab');"); diff --git a/deps/v8/test/cctest/test-roots.cc b/deps/v8/test/cctest/test-roots.cc index f99b9df399..7dcbe998cd 100644 --- a/deps/v8/test/cctest/test-roots.cc +++ b/deps/v8/test/cctest/test-roots.cc @@ -18,57 +18,16 @@ AllocationSpace GetSpaceFromObject(Object* object) { } } // namespace -#define CHECK_IN_RO_SPACE(name) \ - HeapObject* name = roots.name(); \ +#define CHECK_IN_RO_SPACE(type, name, CamelName) \ + HeapObject* name = roots.name(); \ CHECK_EQ(RO_SPACE, GetSpaceFromObject(name)); // The following tests check that all the roots accessible via ReadOnlyRoots are // in RO_SPACE. -TEST(TestStrongReadOnlyRoots) { +TEST(TestReadOnlyRoots) { ReadOnlyRoots roots(CcTest::i_isolate()); -#define TEST_ROOT(type, name, camel_name) CHECK_IN_RO_SPACE(name) - STRONG_READ_ONLY_ROOT_LIST(TEST_ROOT) -#undef TEST_ROOT -} - -TEST(TestInternalizedStrings) { - ReadOnlyRoots roots(CcTest::i_isolate()); - -#define TEST_ROOT(name, str) CHECK_IN_RO_SPACE(name) - INTERNALIZED_STRING_LIST(TEST_ROOT) -#undef TEST_ROOT -} - -TEST(TestPrivateSymbols) { - ReadOnlyRoots roots(CcTest::i_isolate()); - - PRIVATE_SYMBOL_LIST(CHECK_IN_RO_SPACE) -} - -TEST(TestPublicSymbols) { - ReadOnlyRoots roots(CcTest::i_isolate()); - -#define TEST_ROOT(name, description) CHECK_IN_RO_SPACE(name) - PUBLIC_SYMBOL_LIST(TEST_ROOT) - WELL_KNOWN_SYMBOL_LIST(TEST_ROOT) -#undef TEST_ROOT -} - -TEST(TestStructMaps) { - ReadOnlyRoots roots(CcTest::i_isolate()); - -#define TEST_ROOT(NAME, Name, name) CHECK_IN_RO_SPACE(name##_map) - STRUCT_LIST(TEST_ROOT) -#undef TEST_ROOT -} - -TEST(TestAllocationSiteMaps) { - ReadOnlyRoots roots(CcTest::i_isolate()); - -#define TEST_ROOT(NAME, Name, Size, name) CHECK_IN_RO_SPACE(name##_map) - ALLOCATION_SITE_LIST(TEST_ROOT) -#undef TEST_ROOT + READ_ONLY_ROOT_LIST(CHECK_IN_RO_SPACE) } #undef CHECK_IN_RO_SPACE @@ -82,7 +41,6 @@ bool IsInitiallyMutable(Factory* factory, Address object_address) { V(detached_contexts) \ V(feedback_vectors_for_profiling_tools) \ V(materialized_objects) \ - V(microtask_queue) \ V(noscript_shared_function_infos) \ V(retained_maps) \ V(retaining_path_targets) \ @@ -101,7 +59,7 @@ bool IsInitiallyMutable(Factory* factory, Address object_address) { // The CHECK_EQ line is there just to ensure that the root is publicly // accessible from Heap, but ultimately the factory is used as it provides // handles that have the address in the root table. -#define CHECK_NOT_IN_RO_SPACE(name) \ +#define CHECK_NOT_IN_RO_SPACE(type, name, CamelName) \ Handle<Object> name = factory->name(); \ CHECK_EQ(*name, heap->name()); \ if (name->IsHeapObject() && IsInitiallyMutable(factory, name.address())) \ @@ -115,18 +73,7 @@ TEST(TestHeapRootsNotReadOnly) { Factory* factory = CcTest::i_isolate()->factory(); Heap* heap = CcTest::i_isolate()->heap(); -#define TEST_ROOT(type, name, camel_name) CHECK_NOT_IN_RO_SPACE(name) - MUTABLE_ROOT_LIST(TEST_ROOT) -#undef TEST_ROOT -} - -TEST(TestAccessorInfosNotReadOnly) { - Factory* factory = CcTest::i_isolate()->factory(); - Heap* heap = CcTest::i_isolate()->heap(); - -#define TEST_ROOT(name, AccessorName) CHECK_NOT_IN_RO_SPACE(name##_accessor) - ACCESSOR_INFO_LIST(TEST_ROOT) -#undef TEST_ROOT + MUTABLE_ROOT_LIST(CHECK_NOT_IN_RO_SPACE) } #undef CHECK_NOT_IN_RO_SPACE diff --git a/deps/v8/test/cctest/test-sampler-api.cc b/deps/v8/test/cctest/test-sampler-api.cc index a73c9765df..eec773e0de 100644 --- a/deps/v8/test/cctest/test-sampler-api.cc +++ b/deps/v8/test/cctest/test-sampler-api.cc @@ -17,7 +17,7 @@ class Sample { public: enum { kFramesLimit = 255 }; - Sample() {} + Sample() = default; typedef const void* const* const_iterator; const_iterator begin() const { return data_.start(); } diff --git a/deps/v8/test/cctest/test-serialize.cc b/deps/v8/test/cctest/test-serialize.cc index d3fd665a66..848678d43f 100644 --- a/deps/v8/test/cctest/test-serialize.cc +++ b/deps/v8/test/cctest/test-serialize.cc @@ -785,6 +785,17 @@ TEST(CustomSnapshotDataBlob1) { delete[] data1.data; // We can dispose of the snapshot blob now. } +TEST(SnapshotChecksum) { + DisableAlwaysOpt(); + const char* source1 = "function f() { return 42; }"; + + v8::StartupData data1 = CreateSnapshotDataBlob(source1); + CHECK(i::Snapshot::VerifyChecksum(&data1)); + const_cast<char*>(data1.data)[142] = data1.data[142] ^ 4; // Flip a bit. + CHECK(!i::Snapshot::VerifyChecksum(&data1)); + delete[] data1.data; // We can dispose of the snapshot blob now. +} + struct InternalFieldData { uint32_t data; }; @@ -1301,7 +1312,7 @@ TEST(CustomSnapshotDataBlobWithWarmup) { CHECK(IsCompiled("Math.abs")); CHECK(!IsCompiled("g")); CHECK(IsCompiled("String.raw")); - CHECK(!IsCompiled("Array.prototype.lastIndexOf")); + CHECK(IsCompiled("Array.prototype.lastIndexOf")); CHECK_EQ(5, CompileRun("a")->Int32Value(context).FromJust()); } isolate->Dispose(); @@ -1821,9 +1832,9 @@ class SerializerOneByteResource public: SerializerOneByteResource(const char* data, size_t length) : data_(data), length_(length), dispose_count_(0) {} - virtual const char* data() const { return data_; } - virtual size_t length() const { return length_; } - virtual void Dispose() { dispose_count_++; } + const char* data() const override { return data_; } + size_t length() const override { return length_; } + void Dispose() override { dispose_count_++; } int dispose_count() { return dispose_count_; } private: @@ -1837,11 +1848,11 @@ class SerializerTwoByteResource : public v8::String::ExternalStringResource { public: SerializerTwoByteResource(const char* data, size_t length) : data_(AsciiToTwoByteString(data)), length_(length), dispose_count_(0) {} - ~SerializerTwoByteResource() { DeleteArray<const uint16_t>(data_); } + ~SerializerTwoByteResource() override { DeleteArray<const uint16_t>(data_); } - virtual const uint16_t* data() const { return data_; } - virtual size_t length() const { return length_; } - virtual void Dispose() { dispose_count_++; } + const uint16_t* data() const override { return data_; } + size_t length() const override { return length_; } + void Dispose() override { dispose_count_++; } int dispose_count() { return dispose_count_; } private: @@ -3582,11 +3593,10 @@ void CheckSFIsAreWeak(WeakFixedArray* sfis, Isolate* isolate) { for (int i = 0; i < sfis->length(); ++i) { MaybeObject* maybe_object = sfis->Get(i); HeapObject* heap_object; - CHECK(maybe_object->IsWeakHeapObject() || - maybe_object->IsClearedWeakHeapObject() || - (maybe_object->ToStrongHeapObject(&heap_object) && + CHECK(maybe_object->IsWeakOrCleared() || + (maybe_object->GetHeapObjectIfStrong(&heap_object) && heap_object->IsUndefined(isolate))); - if (maybe_object->IsWeakHeapObject()) { + if (maybe_object->IsWeak()) { ++no_of_weak; } } diff --git a/deps/v8/test/cctest/test-smi-lexicographic-compare.cc b/deps/v8/test/cctest/test-smi-lexicographic-compare.cc new file mode 100644 index 0000000000..58617fd5c2 --- /dev/null +++ b/deps/v8/test/cctest/test-smi-lexicographic-compare.cc @@ -0,0 +1,79 @@ +// 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 <set> + +#include "src/objects-inl.h" +#include "src/v8.h" +#include "test/cctest/cctest.h" + +namespace v8 { +namespace internal { + +namespace { + +void AddSigned(std::set<Smi*>& smis, int64_t x) { + if (!Smi::IsValid(x)) return; + + smis.insert(Smi::FromInt(static_cast<int>(x))); + smis.insert(Smi::FromInt(static_cast<int>(-x))); +} + +// Uses std::lexicographical_compare twice to convert the result to -1, 0 or 1. +int ExpectedCompareResult(Smi* a, Smi* b) { + std::string str_a = std::to_string(a->value()); + std::string str_b = std::to_string(b->value()); + bool expected_a_lt_b = std::lexicographical_compare( + str_a.begin(), str_a.end(), str_b.begin(), str_b.end()); + bool expected_b_lt_a = std::lexicographical_compare( + str_b.begin(), str_b.end(), str_a.begin(), str_a.end()); + + if (!expected_a_lt_b && !expected_b_lt_a) { + return 0; + } else if (expected_a_lt_b) { + return -1; + } else { + CHECK(expected_b_lt_a); + return 1; + } +} + +bool Test(Isolate* isolate, Smi* a, Smi* b) { + int actual = Smi::LexicographicCompare(isolate, a, b)->value(); + int expected = ExpectedCompareResult(a, b); + + return actual == expected; +} + +} // namespace + +TEST(TestSmiLexicographicCompare) { + Isolate* isolate = CcTest::InitIsolateOnce(); + HandleScope scope(isolate); + + std::set<Smi*> smis; + + for (int64_t xb = 1; xb <= Smi::kMaxValue; xb *= 10) { + for (int64_t xf = 0; xf <= 9; ++xf) { + for (int64_t xo = -1; xo <= 1; ++xo) { + AddSigned(smis, xb * xf + xo); + } + } + } + + for (int64_t yb = 1; yb <= Smi::kMaxValue; yb *= 2) { + for (int64_t yo = -2; yo <= 2; ++yo) { + AddSigned(smis, yb + yo); + } + } + + for (Smi* a : smis) { + for (Smi* b : smis) { + CHECK(Test(isolate, a, b)); + } + } +} + +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/test-strings.cc b/deps/v8/test/cctest/test-strings.cc index 2c66421831..9326c347ec 100644 --- a/deps/v8/test/cctest/test-strings.cc +++ b/deps/v8/test/cctest/test-strings.cc @@ -105,9 +105,9 @@ static const int SUPER_DEEP_DEPTH = 80 * 1024; class Resource: public v8::String::ExternalStringResource { public: Resource(const uc16* data, size_t length): data_(data), length_(length) {} - ~Resource() { i::DeleteArray(data_); } - virtual const uint16_t* data() const { return data_; } - virtual size_t length() const { return length_; } + ~Resource() override { i::DeleteArray(data_); } + const uint16_t* data() const override { return data_; } + size_t length() const override { return length_; } private: const uc16* data_; @@ -119,9 +119,9 @@ class OneByteResource : public v8::String::ExternalOneByteStringResource { public: OneByteResource(const char* data, size_t length) : data_(data), length_(length) {} - ~OneByteResource() { i::DeleteArray(data_); } - virtual const char* data() const { return data_; } - virtual size_t length() const { return length_; } + ~OneByteResource() override { i::DeleteArray(data_); } + const char* data() const override { return data_; } + size_t length() const override { return length_; } private: const char* data_; @@ -1108,6 +1108,98 @@ TEST(JSONStringifySliceMadeExternal) { CompileRun("JSON.stringify(slice)")))); } +TEST(JSONStringifyWellFormed) { + FLAG_harmony_json_stringify = true; + CcTest::InitializeVM(); + v8::HandleScope handle_scope(CcTest::isolate()); + v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext(); + + // Test some leading surrogates (U+D800 to U+DBFF). + { // U+D800 + CHECK_EQ( + 0, strcmp("\"\\ud800\"", *v8::String::Utf8Value( + CcTest::isolate(), + CompileRun("JSON.stringify('\\uD800')")))); + v8::Local<v8::String> json = v8_str("\"\\ud800\""); + v8::Local<v8::Value> parsed = + v8::JSON::Parse(context, json).ToLocalChecked(); + CHECK(v8::JSON::Stringify(context, parsed) + .ToLocalChecked() + ->Equals(context, json) + .FromJust()); + } + + { // U+DAAA + CHECK_EQ( + 0, strcmp("\"\\udaaa\"", *v8::String::Utf8Value( + CcTest::isolate(), + CompileRun("JSON.stringify('\\uDAAA')")))); + v8::Local<v8::String> json = v8_str("\"\\udaaa\""); + v8::Local<v8::Value> parsed = + v8::JSON::Parse(context, json).ToLocalChecked(); + CHECK(v8::JSON::Stringify(context, parsed) + .ToLocalChecked() + ->Equals(context, json) + .FromJust()); + } + + { // U+DBFF + CHECK_EQ( + 0, strcmp("\"\\udbff\"", *v8::String::Utf8Value( + CcTest::isolate(), + CompileRun("JSON.stringify('\\uDBFF')")))); + v8::Local<v8::String> json = v8_str("\"\\udbff\""); + v8::Local<v8::Value> parsed = + v8::JSON::Parse(context, json).ToLocalChecked(); + CHECK(v8::JSON::Stringify(context, parsed) + .ToLocalChecked() + ->Equals(context, json) + .FromJust()); + } + + // Test some trailing surrogates (U+DC00 to U+DFFF). + { // U+DC00 + CHECK_EQ( + 0, strcmp("\"\\udc00\"", *v8::String::Utf8Value( + CcTest::isolate(), + CompileRun("JSON.stringify('\\uDC00')")))); + v8::Local<v8::String> json = v8_str("\"\\udc00\""); + v8::Local<v8::Value> parsed = + v8::JSON::Parse(context, json).ToLocalChecked(); + CHECK(v8::JSON::Stringify(context, parsed) + .ToLocalChecked() + ->Equals(context, json) + .FromJust()); + } + + { // U+DDDD + CHECK_EQ( + 0, strcmp("\"\\udddd\"", *v8::String::Utf8Value( + CcTest::isolate(), + CompileRun("JSON.stringify('\\uDDDD')")))); + v8::Local<v8::String> json = v8_str("\"\\udddd\""); + v8::Local<v8::Value> parsed = + v8::JSON::Parse(context, json).ToLocalChecked(); + CHECK(v8::JSON::Stringify(context, parsed) + .ToLocalChecked() + ->Equals(context, json) + .FromJust()); + } + + { // U+DFFF + CHECK_EQ( + 0, strcmp("\"\\udfff\"", *v8::String::Utf8Value( + CcTest::isolate(), + CompileRun("JSON.stringify('\\uDFFF')")))); + v8::Local<v8::String> json = v8_str("\"\\udfff\""); + v8::Local<v8::Value> parsed = + v8::JSON::Parse(context, json).ToLocalChecked(); + CHECK(v8::JSON::Stringify(context, parsed) + .ToLocalChecked() + ->Equals(context, json) + .FromJust()); + } +} TEST(CachedHashOverflow) { CcTest::InitializeVM(); @@ -1186,9 +1278,9 @@ class OneByteVectorResource : public v8::String::ExternalOneByteStringResource { public: explicit OneByteVectorResource(i::Vector<const char> vector) : data_(vector) {} - virtual ~OneByteVectorResource() {} - virtual size_t length() const { return data_.length(); } - virtual const char* data() const { return data_.start(); } + ~OneByteVectorResource() override = default; + size_t length() const override { return data_.length(); } + const char* data() const override { return data_.start(); } private: i::Vector<const char> data_; }; @@ -1464,15 +1556,15 @@ TEST(Latin1IgnoreCase) { class DummyResource: public v8::String::ExternalStringResource { public: - virtual const uint16_t* data() const { return nullptr; } - virtual size_t length() const { return 1 << 30; } + const uint16_t* data() const override { return nullptr; } + size_t length() const override { return 1 << 30; } }; class DummyOneByteResource: public v8::String::ExternalOneByteStringResource { public: - virtual const char* data() const { return nullptr; } - virtual size_t length() const { return 1 << 30; } + const char* data() const override { return nullptr; } + size_t length() const override { return 1 << 30; } }; diff --git a/deps/v8/test/cctest/test-thread-termination.cc b/deps/v8/test/cctest/test-thread-termination.cc index 902295447b..16a18c51d0 100644 --- a/deps/v8/test/cctest/test-thread-termination.cc +++ b/deps/v8/test/cctest/test-thread-termination.cc @@ -166,7 +166,7 @@ class TerminatorThread : public v8::base::Thread { explicit TerminatorThread(i::Isolate* isolate) : Thread(Options("TerminatorThread")), isolate_(reinterpret_cast<v8::Isolate*>(isolate)) {} - void Run() { + void Run() override { semaphore->Wait(); CHECK(!isolate_->IsExecutionTerminating()); isolate_->TerminateExecution(); @@ -800,7 +800,7 @@ class TerminatorSleeperThread : public v8::base::Thread { : Thread(Options("TerminatorSlepperThread")), isolate_(isolate), sleep_ms_(sleep_ms) {} - void Run() { + void Run() override { v8::base::OS::Sleep(v8::base::TimeDelta::FromMilliseconds(sleep_ms_)); CHECK(!isolate_->IsExecutionTerminating()); isolate_->TerminateExecution(); diff --git a/deps/v8/test/cctest/test-threads.cc b/deps/v8/test/cctest/test-threads.cc index d5c94eff0d..aaecababd2 100644 --- a/deps/v8/test/cctest/test-threads.cc +++ b/deps/v8/test/cctest/test-threads.cc @@ -43,7 +43,7 @@ class ThreadIdValidationThread : public v8::base::Thread { thread_to_start_(thread_to_start), semaphore_(semaphore) {} - void Run() { + void Run() override { i::ThreadId thread_id = i::ThreadId::Current(); for (int i = 0; i < thread_no_; i++) { CHECK(!(*refs_)[i].Equals(thread_id)); diff --git a/deps/v8/test/cctest/test-trace-event.cc b/deps/v8/test/cctest/test-trace-event.cc index 10b837aaed..f73641d9cf 100644 --- a/deps/v8/test/cctest/test-trace-event.cc +++ b/deps/v8/test/cctest/test-trace-event.cc @@ -39,7 +39,7 @@ typedef std::vector<MockTraceObject*> MockTraceObjectList; class MockTracingController : public v8::TracingController { public: MockTracingController() = default; - ~MockTracingController() { + ~MockTracingController() override { for (size_t i = 0; i < trace_object_list_.size(); ++i) { delete trace_object_list_[i]; } @@ -98,7 +98,7 @@ class MockTracingPlatform : public TestPlatform { // Now that it's completely constructed, make this the current platform. i::V8::SetPlatformForTesting(this); } - virtual ~MockTracingPlatform() {} + ~MockTracingPlatform() override = default; v8::TracingController* GetTracingController() override { return &tracing_controller_; @@ -289,7 +289,6 @@ TEST(BuiltinsIsTraceCategoryEnabled) { v8::Isolate* isolate = CcTest::isolate(); v8::HandleScope handle_scope(isolate); - v8::Local<v8::Context> context = isolate->GetCurrentContext(); LocalContext env; v8::Local<v8::Object> binding = env->GetExtrasBindingObject(); @@ -308,7 +307,7 @@ TEST(BuiltinsIsTraceCategoryEnabled) { .ToLocalChecked() .As<v8::Boolean>(); - CHECK(result->BooleanValue(context).ToChecked()); + CHECK(result->BooleanValue(isolate)); } { @@ -318,7 +317,7 @@ TEST(BuiltinsIsTraceCategoryEnabled) { .ToLocalChecked() .As<v8::Boolean>(); - CHECK(!result->BooleanValue(context).ToChecked()); + CHECK(!result->BooleanValue(isolate)); } { @@ -328,7 +327,7 @@ TEST(BuiltinsIsTraceCategoryEnabled) { .ToLocalChecked() .As<v8::Boolean>(); - CHECK(result->BooleanValue(context).ToChecked()); + CHECK(result->BooleanValue(isolate)); } } @@ -362,7 +361,7 @@ TEST(BuiltinsTrace) { .ToLocalChecked() .As<v8::Boolean>(); - CHECK(!result->BooleanValue(context).ToChecked()); + CHECK(!result->BooleanValue(isolate)); CHECK_EQ(0, GET_TRACE_OBJECTS_LIST->size()); } @@ -381,7 +380,7 @@ TEST(BuiltinsTrace) { .ToLocalChecked() .As<v8::Boolean>(); - CHECK(result->BooleanValue(context).ToChecked()); + CHECK(result->BooleanValue(isolate)); CHECK_EQ(1, GET_TRACE_OBJECTS_LIST->size()); CHECK_EQ(123, GET_TRACE_OBJECT(0)->id); @@ -405,7 +404,7 @@ TEST(BuiltinsTrace) { .ToLocalChecked() .As<v8::Boolean>(); - CHECK(result->BooleanValue(context).ToChecked()); + CHECK(result->BooleanValue(isolate)); CHECK_EQ(2, GET_TRACE_OBJECTS_LIST->size()); CHECK_EQ(123, GET_TRACE_OBJECT(1)->id); diff --git a/deps/v8/test/cctest/test-typedarrays.cc b/deps/v8/test/cctest/test-typedarrays.cc index b574fdd94a..a0f9385bf1 100644 --- a/deps/v8/test/cctest/test-typedarrays.cc +++ b/deps/v8/test/cctest/test-typedarrays.cc @@ -86,8 +86,6 @@ TEST(AllocateNotExternal) { void TestSpeciesProtector(char* code, bool invalidates_species_protector = true) { - // Make BigInt64Array/BigUint64Array available for testing. - FLAG_harmony_bigint = true; v8::Isolate::CreateParams create_params; create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); std::string typed_array_constructors[] = { diff --git a/deps/v8/test/cctest/test-usecounters.cc b/deps/v8/test/cctest/test-usecounters.cc index 5e37991252..4c6c72a28d 100644 --- a/deps/v8/test/cctest/test-usecounters.cc +++ b/deps/v8/test/cctest/test-usecounters.cc @@ -60,6 +60,27 @@ TEST(AssigmentExpressionLHSIsCall) { use_counts[v8::Isolate::kAssigmentExpressionLHSIsCallInStrict] = 0; } +TEST(AtomicsWakeAndAtomicsNotify) { + v8::Isolate* isolate = CcTest::isolate(); + v8::HandleScope scope(isolate); + LocalContext env; + int use_counts[v8::Isolate::kUseCounterFeatureCount] = {}; + global_use_counts = use_counts; + i::FLAG_harmony_sharedarraybuffer = true; + CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback); + + CompileRun("Atomics.wake(new Int32Array(new SharedArrayBuffer(16)), 0);"); + CHECK_EQ(1, use_counts[v8::Isolate::kAtomicsWake]); + CHECK_EQ(0, use_counts[v8::Isolate::kAtomicsNotify]); + + use_counts[v8::Isolate::kAtomicsWake] = 0; + use_counts[v8::Isolate::kAtomicsNotify] = 0; + + CompileRun("Atomics.notify(new Int32Array(new SharedArrayBuffer(16)), 0);"); + CHECK_EQ(0, use_counts[v8::Isolate::kAtomicsWake]); + CHECK_EQ(1, use_counts[v8::Isolate::kAtomicsNotify]); +} + } // namespace test_usecounters } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/test-weakmaps.cc b/deps/v8/test/cctest/test-weakmaps.cc index 08d7bea874..b6fe4e7597 100644 --- a/deps/v8/test/cctest/test-weakmaps.cc +++ b/deps/v8/test/cctest/test-weakmaps.cc @@ -88,7 +88,7 @@ TEST(Weakness) { CHECK_EQ(2, EphemeronHashTable::cast(weakmap->table())->NumberOfElements()); // Force a full GC. - CcTest::CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); + CcTest::PreciseCollectAllGarbage(); CHECK_EQ(0, NumberOfWeakCalls); CHECK_EQ(2, EphemeronHashTable::cast(weakmap->table())->NumberOfElements()); CHECK_EQ( @@ -101,7 +101,7 @@ TEST(Weakness) { &WeakPointerCallback, v8::WeakCallbackType::kParameter); CHECK(global_handles->IsWeak(key.location())); - CcTest::CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); + CcTest::PreciseCollectAllGarbage(); CHECK_EQ(1, NumberOfWeakCalls); CHECK_EQ(0, EphemeronHashTable::cast(weakmap->table())->NumberOfElements()); CHECK_EQ( @@ -138,7 +138,7 @@ TEST(Shrinking) { CHECK_EQ(32, EphemeronHashTable::cast(weakmap->table())->NumberOfElements()); CHECK_EQ( 0, EphemeronHashTable::cast(weakmap->table())->NumberOfDeletedElements()); - CcTest::CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); + CcTest::PreciseCollectAllGarbage(); CHECK_EQ(0, EphemeronHashTable::cast(weakmap->table())->NumberOfElements()); CHECK_EQ( 32, diff --git a/deps/v8/test/cctest/test-weaksets.cc b/deps/v8/test/cctest/test-weaksets.cc index 8a3c1323a3..763a809f87 100644 --- a/deps/v8/test/cctest/test-weaksets.cc +++ b/deps/v8/test/cctest/test-weaksets.cc @@ -99,7 +99,7 @@ TEST(WeakSet_Weakness) { CHECK_EQ(1, EphemeronHashTable::cast(weakset->table())->NumberOfElements()); // Force a full GC. - CcTest::CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); + CcTest::PreciseCollectAllGarbage(); CHECK_EQ(0, NumberOfWeakCalls); CHECK_EQ(1, EphemeronHashTable::cast(weakset->table())->NumberOfElements()); CHECK_EQ( @@ -112,7 +112,7 @@ TEST(WeakSet_Weakness) { &WeakPointerCallback, v8::WeakCallbackType::kParameter); CHECK(global_handles->IsWeak(key.location())); - CcTest::CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); + CcTest::PreciseCollectAllGarbage(); CHECK_EQ(1, NumberOfWeakCalls); CHECK_EQ(0, EphemeronHashTable::cast(weakset->table())->NumberOfElements()); CHECK_EQ( @@ -149,7 +149,7 @@ TEST(WeakSet_Shrinking) { CHECK_EQ(32, EphemeronHashTable::cast(weakset->table())->NumberOfElements()); CHECK_EQ( 0, EphemeronHashTable::cast(weakset->table())->NumberOfDeletedElements()); - CcTest::CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); + CcTest::PreciseCollectAllGarbage(); CHECK_EQ(0, EphemeronHashTable::cast(weakset->table())->NumberOfElements()); CHECK_EQ( 32, diff --git a/deps/v8/test/cctest/testcfg.py b/deps/v8/test/cctest/testcfg.py index d79d6e4eb4..562f44098a 100644 --- a/deps/v8/test/cctest/testcfg.py +++ b/deps/v8/test/cctest/testcfg.py @@ -66,6 +66,18 @@ class TestCase(testcase.TestCase): def _get_files_params(self): return [self.path] + def _get_resources(self): + # Bytecode-generator tests are the only ones requiring extra files on + # Android. + parts = self.name.split('/') + if parts[0] == 'test-bytecode-generator': + expectation_file = os.path.join( + self.suite.root, 'interpreter', 'bytecode_expectations', + '%s.golden' % parts[1]) + if os.path.exists(expectation_file): + return [expectation_file] + return [] + def GetSuite(*args, **kwargs): return TestSuite(*args, **kwargs) diff --git a/deps/v8/test/cctest/torque/test-torque.cc b/deps/v8/test/cctest/torque/test-torque.cc index 439fe043b8..c339aa4134 100644 --- a/deps/v8/test/cctest/torque/test-torque.cc +++ b/deps/v8/test/cctest/torque/test-torque.cc @@ -259,6 +259,33 @@ TEST(TestGenericOverload) { ft.Call(); } +TEST(TestLogicalOperators) { + Isolate* isolate(CcTest::InitIsolateOnce()); + CodeAssemblerTester asm_tester(isolate, 0); + TestBuiltinsFromDSLAssembler m(asm_tester.state()); + { + m.TestLogicalOperators(); + m.Return(m.UndefinedConstant()); + } + FunctionTester ft(asm_tester.GenerateCode(), 0); + ft.Call(); +} + +TEST(TestOtherwiseAndLabels) { + Isolate* isolate(CcTest::InitIsolateOnce()); + CodeAssemblerTester asm_tester(isolate, 0); + TestBuiltinsFromDSLAssembler m(asm_tester.state()); + { + m.TestOtherwiseWithCode1(); + m.TestOtherwiseWithCode2(); + m.TestOtherwiseWithCode3(); + m.TestForwardLabel(); + m.Return(m.UndefinedConstant()); + } + FunctionTester ft(asm_tester.GenerateCode(), 0); + ft.Call(); +} + } // namespace compiler } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/trace-extension.h b/deps/v8/test/cctest/trace-extension.h index bfebd34c06..385f0c23c2 100644 --- a/deps/v8/test/cctest/trace-extension.h +++ b/deps/v8/test/cctest/trace-extension.h @@ -38,8 +38,8 @@ namespace internal { class TraceExtension : public v8::Extension { public: TraceExtension() : v8::Extension("v8/trace", kSource) { } - virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( - v8::Isolate* isolate, v8::Local<v8::String> name); + v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( + v8::Isolate* isolate, v8::Local<v8::String> name) override; static void Trace(const v8::FunctionCallbackInfo<v8::Value>& args); static void JSTrace(const v8::FunctionCallbackInfo<v8::Value>& args); static void JSEntrySP(const v8::FunctionCallbackInfo<v8::Value>& args); diff --git a/deps/v8/test/cctest/unicode-helpers.cc b/deps/v8/test/cctest/unicode-helpers.cc new file mode 100644 index 0000000000..524e5936fc --- /dev/null +++ b/deps/v8/test/cctest/unicode-helpers.cc @@ -0,0 +1,31 @@ +// 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 "test/cctest/unicode-helpers.h" + +int Ucs2CharLength(unibrow::uchar c) { + if (c == unibrow::Utf8::kIncomplete || c == unibrow::Utf8::kBufferEmpty) { + return 0; + } else if (c < 0xFFFF) { + return 1; + } else { + return 2; + } +} + +int Utf8LengthHelper(const char* s) { + unibrow::Utf8::Utf8IncrementalBuffer buffer(unibrow::Utf8::kBufferEmpty); + unibrow::Utf8::State state = unibrow::Utf8::State::kAccept; + + int length = 0; + size_t i = 0; + while (s[i] != '\0') { + unibrow::uchar tmp = + unibrow::Utf8::ValueOfIncremental(s[i], &i, &state, &buffer); + length += Ucs2CharLength(tmp); + } + unibrow::uchar tmp = unibrow::Utf8::ValueOfIncrementalFinish(&state); + length += Ucs2CharLength(tmp); + return length; +} diff --git a/deps/v8/test/cctest/unicode-helpers.h b/deps/v8/test/cctest/unicode-helpers.h index ca75fb65d7..06c3fcd8ea 100644 --- a/deps/v8/test/cctest/unicode-helpers.h +++ b/deps/v8/test/cctest/unicode-helpers.h @@ -7,30 +7,7 @@ #include "src/unicode.h" -static int Ucs2CharLength(unibrow::uchar c) { - if (c == unibrow::Utf8::kIncomplete || c == unibrow::Utf8::kBufferEmpty) { - return 0; - } else if (c < 0xFFFF) { - return 1; - } else { - return 2; - } -} - -static int Utf8LengthHelper(const char* s) { - unibrow::Utf8::Utf8IncrementalBuffer buffer(unibrow::Utf8::kBufferEmpty); - unibrow::Utf8::State state = unibrow::Utf8::State::kAccept; - - int length = 0; - size_t i = 0; - while (s[i] != '\0') { - unibrow::uchar tmp = - unibrow::Utf8::ValueOfIncremental(s[i], &i, &state, &buffer); - length += Ucs2CharLength(tmp); - } - unibrow::uchar tmp = unibrow::Utf8::ValueOfIncrementalFinish(&state); - length += Ucs2CharLength(tmp); - return length; -} +int Ucs2CharLength(unibrow::uchar c); +int Utf8LengthHelper(const char* s); #endif // V8_CCTEST_UNICODE_HELPERS_H_ diff --git a/deps/v8/test/cctest/wasm/test-c-wasm-entry.cc b/deps/v8/test/cctest/wasm/test-c-wasm-entry.cc index e56060bdd9..ca6662c90c 100644 --- a/deps/v8/test/cctest/wasm/test-c-wasm-entry.cc +++ b/deps/v8/test/cctest/wasm/test-c-wasm-entry.cc @@ -62,10 +62,11 @@ class CWasmEntryArgTester { Handle<Object> buffer_obj(reinterpret_cast<Object*>(arg_buffer.data()), isolate_); CHECK(!buffer_obj->IsHeapObject()); - Handle<Object> call_args[]{ - Handle<Object>::cast(isolate_->factory()->NewForeign( - wasm_code_->instruction_start(), TENURED)), - runner_.builder().instance_object(), buffer_obj}; + Handle<Object> code_entry_obj( + reinterpret_cast<Object*>(wasm_code_->instruction_start()), isolate_); + CHECK(!code_entry_obj->IsHeapObject()); + Handle<Object> call_args[]{code_entry_obj, + runner_.builder().instance_object(), buffer_obj}; static_assert( arraysize(call_args) == compiler::CWasmEntryParameters::kNumParameters, "adapt this test"); 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 96877fd571..8eddaa0224 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-atomics.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-atomics.cc @@ -32,24 +32,12 @@ void RunU32BinOp(ExecutionTier execution_tier, WasmOpcode wasm_op, } } -WASM_EXEC_TEST(I32AtomicAdd) { - RunU32BinOp(execution_tier, kExprI32AtomicAdd, Add); -} -WASM_EXEC_TEST(I32AtomicSub) { - RunU32BinOp(execution_tier, kExprI32AtomicSub, Sub); -} -WASM_EXEC_TEST(I32AtomicAnd) { - RunU32BinOp(execution_tier, kExprI32AtomicAnd, And); -} -WASM_EXEC_TEST(I32AtomicOr) { - RunU32BinOp(execution_tier, kExprI32AtomicOr, Or); -} -WASM_EXEC_TEST(I32AtomicXor) { - RunU32BinOp(execution_tier, kExprI32AtomicXor, Xor); -} -WASM_EXEC_TEST(I32AtomicExchange) { - RunU32BinOp(execution_tier, kExprI32AtomicExchange, Exchange); -} +#define TEST_OPERATION(Name) \ + WASM_EXEC_TEST(I32Atomic##Name) { \ + RunU32BinOp(execution_tier, kExprI32Atomic##Name, Name); \ + } +OPERATION_LIST(TEST_OPERATION) +#undef TEST_OPERATION void RunU16BinOp(ExecutionTier tier, WasmOpcode wasm_op, Uint16BinOp expected_op) { @@ -73,24 +61,12 @@ void RunU16BinOp(ExecutionTier tier, WasmOpcode wasm_op, } } -WASM_EXEC_TEST(I32AtomicAdd16U) { - RunU16BinOp(execution_tier, kExprI32AtomicAdd16U, Add); -} -WASM_EXEC_TEST(I32AtomicSub16U) { - RunU16BinOp(execution_tier, kExprI32AtomicSub16U, Sub); -} -WASM_EXEC_TEST(I32AtomicAnd16U) { - RunU16BinOp(execution_tier, kExprI32AtomicAnd16U, And); -} -WASM_EXEC_TEST(I32AtomicOr16U) { - RunU16BinOp(execution_tier, kExprI32AtomicOr16U, Or); -} -WASM_EXEC_TEST(I32AtomicXor16U) { - RunU16BinOp(execution_tier, kExprI32AtomicXor16U, Xor); -} -WASM_EXEC_TEST(I32AtomicExchange16U) { - RunU16BinOp(execution_tier, kExprI32AtomicExchange16U, Exchange); -} +#define TEST_OPERATION(Name) \ + WASM_EXEC_TEST(I32Atomic##Name##16U) { \ + RunU16BinOp(execution_tier, kExprI32Atomic##Name##16U, Name); \ + } +OPERATION_LIST(TEST_OPERATION) +#undef TEST_OPERATION void RunU8BinOp(ExecutionTier execution_tier, WasmOpcode wasm_op, Uint8BinOp expected_op) { @@ -113,24 +89,12 @@ void RunU8BinOp(ExecutionTier execution_tier, WasmOpcode wasm_op, } } -WASM_EXEC_TEST(I32AtomicAdd8U) { - RunU8BinOp(execution_tier, kExprI32AtomicAdd8U, Add); -} -WASM_EXEC_TEST(I32AtomicSub8U) { - RunU8BinOp(execution_tier, kExprI32AtomicSub8U, Sub); -} -WASM_EXEC_TEST(I32AtomicAnd8U) { - RunU8BinOp(execution_tier, kExprI32AtomicAnd8U, And); -} -WASM_EXEC_TEST(I32AtomicOr8U) { - RunU8BinOp(execution_tier, kExprI32AtomicOr8U, Or); -} -WASM_EXEC_TEST(I32AtomicXor8U) { - RunU8BinOp(execution_tier, kExprI32AtomicXor8U, Xor); -} -WASM_EXEC_TEST(I32AtomicExchange8U) { - RunU8BinOp(execution_tier, kExprI32AtomicExchange8U, Exchange); -} +#define TEST_OPERATION(Name) \ + WASM_EXEC_TEST(I32Atomic##Name##8U) { \ + RunU8BinOp(execution_tier, kExprI32Atomic##Name##8U, Name); \ + } +OPERATION_LIST(TEST_OPERATION) +#undef TEST_OPERATION WASM_EXEC_TEST(I32AtomicCompareExchange) { EXPERIMENTAL_FLAG_SCOPE(threads); 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 21b943595a..570c48d240 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-atomics64.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-atomics64.cc @@ -32,24 +32,12 @@ void RunU64BinOp(ExecutionTier execution_tier, WasmOpcode wasm_op, } } -WASM_EXEC_TEST(I64AtomicAdd) { - RunU64BinOp(execution_tier, kExprI64AtomicAdd, Add); -} -WASM_EXEC_TEST(I64AtomicSub) { - RunU64BinOp(execution_tier, kExprI64AtomicSub, Sub); -} -WASM_EXEC_TEST(I64AtomicAnd) { - RunU64BinOp(execution_tier, kExprI64AtomicAnd, And); -} -WASM_EXEC_TEST(I64AtomicOr) { - RunU64BinOp(execution_tier, kExprI64AtomicOr, Or); -} -WASM_EXEC_TEST(I64AtomicXor) { - RunU64BinOp(execution_tier, kExprI64AtomicXor, Xor); -} -WASM_EXEC_TEST(I64AtomicExchange) { - RunU64BinOp(execution_tier, kExprI64AtomicExchange, Exchange); -} +#define TEST_OPERATION(Name) \ + WASM_EXEC_TEST(I64Atomic##Name) { \ + RunU64BinOp(execution_tier, kExprI64Atomic##Name, Name); \ + } +OPERATION_LIST(TEST_OPERATION) +#undef TEST_OPERATION void RunU32BinOp(ExecutionTier execution_tier, WasmOpcode wasm_op, Uint32BinOp expected_op) { @@ -73,24 +61,12 @@ void RunU32BinOp(ExecutionTier execution_tier, WasmOpcode wasm_op, } } -WASM_EXEC_TEST(I64AtomicAdd32U) { - RunU32BinOp(execution_tier, kExprI64AtomicAdd32U, Add); -} -WASM_EXEC_TEST(I64AtomicSub32U) { - RunU32BinOp(execution_tier, kExprI64AtomicSub32U, Sub); -} -WASM_EXEC_TEST(I64AtomicAnd32U) { - RunU32BinOp(execution_tier, kExprI64AtomicAnd32U, And); -} -WASM_EXEC_TEST(I64AtomicOr32U) { - RunU32BinOp(execution_tier, kExprI64AtomicOr32U, Or); -} -WASM_EXEC_TEST(I64AtomicXor32U) { - RunU32BinOp(execution_tier, kExprI64AtomicXor32U, Xor); -} -WASM_EXEC_TEST(I64AtomicExchange32U) { - RunU32BinOp(execution_tier, kExprI64AtomicExchange32U, Exchange); -} +#define TEST_OPERATION(Name) \ + WASM_EXEC_TEST(I64Atomic##Name##32U) { \ + RunU32BinOp(execution_tier, kExprI64Atomic##Name##32U, Name); \ + } +OPERATION_LIST(TEST_OPERATION) +#undef TEST_OPERATION void RunU16BinOp(ExecutionTier tier, WasmOpcode wasm_op, Uint16BinOp expected_op) { @@ -114,24 +90,12 @@ void RunU16BinOp(ExecutionTier tier, WasmOpcode wasm_op, } } -WASM_EXEC_TEST(I64AtomicAdd16U) { - RunU16BinOp(execution_tier, kExprI64AtomicAdd16U, Add); -} -WASM_EXEC_TEST(I64AtomicSub16U) { - RunU16BinOp(execution_tier, kExprI64AtomicSub16U, Sub); -} -WASM_EXEC_TEST(I64AtomicAnd16U) { - RunU16BinOp(execution_tier, kExprI64AtomicAnd16U, And); -} -WASM_EXEC_TEST(I64AtomicOr16U) { - RunU16BinOp(execution_tier, kExprI64AtomicOr16U, Or); -} -WASM_EXEC_TEST(I64AtomicXor16U) { - RunU16BinOp(execution_tier, kExprI64AtomicXor16U, Xor); -} -WASM_EXEC_TEST(I64AtomicExchange16U) { - RunU16BinOp(execution_tier, kExprI64AtomicExchange16U, Exchange); -} +#define TEST_OPERATION(Name) \ + WASM_EXEC_TEST(I64Atomic##Name##16U) { \ + RunU16BinOp(execution_tier, kExprI64Atomic##Name##16U, Name); \ + } +OPERATION_LIST(TEST_OPERATION) +#undef TEST_OPERATION void RunU8BinOp(ExecutionTier execution_tier, WasmOpcode wasm_op, Uint8BinOp expected_op) { @@ -154,24 +118,12 @@ void RunU8BinOp(ExecutionTier execution_tier, WasmOpcode wasm_op, } } -WASM_EXEC_TEST(I64AtomicAdd8U) { - RunU8BinOp(execution_tier, kExprI64AtomicAdd8U, Add); -} -WASM_EXEC_TEST(I64AtomicSub8U) { - RunU8BinOp(execution_tier, kExprI64AtomicSub8U, Sub); -} -WASM_EXEC_TEST(I64AtomicAnd8U) { - RunU8BinOp(execution_tier, kExprI64AtomicAnd8U, And); -} -WASM_EXEC_TEST(I64AtomicOr8U) { - RunU8BinOp(execution_tier, kExprI64AtomicOr8U, Or); -} -WASM_EXEC_TEST(I64AtomicXor8U) { - RunU8BinOp(execution_tier, kExprI64AtomicXor8U, Xor); -} -WASM_EXEC_TEST(I64AtomicExchange8U) { - RunU8BinOp(execution_tier, kExprI64AtomicExchange8U, Exchange); -} +#define TEST_OPERATION(Name) \ + WASM_EXEC_TEST(I64Atomic##Name##8U) { \ + RunU8BinOp(execution_tier, kExprI64Atomic##Name##8U, Name); \ + } +OPERATION_LIST(TEST_OPERATION) +#undef TEST_OPERATION WASM_EXEC_TEST(I64AtomicCompareExchange) { EXPERIMENTAL_FLAG_SCOPE(threads); @@ -402,6 +354,172 @@ WASM_EXEC_TEST(I64AtomicStoreLoad8U) { } } +// Drop tests verify atomic operations are run correctly when the +// entire 64-bit output is optimized out +void RunDropTest(ExecutionTier execution_tier, WasmOpcode wasm_op, + Uint64BinOp op) { + EXPERIMENTAL_FLAG_SCOPE(threads); + WasmRunner<uint64_t, uint64_t> r(execution_tier); + uint64_t* memory = + r.builder().AddMemoryElems<uint64_t>(kWasmPageSize / sizeof(uint64_t)); + r.builder().SetHasSharedMemory(); + + BUILD(r, + WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_1(0), WASM_GET_LOCAL(0), + MachineRepresentation::kWord64), + WASM_DROP, WASM_GET_LOCAL(0)); + + uint64_t initial = 0x1111222233334444, local = 0x1111111111111111; + r.builder().WriteMemory(&memory[0], initial); + CHECK_EQ(local, r.Call(local)); + uint64_t expected = op(initial, local); + CHECK_EQ(expected, r.builder().ReadMemory(&memory[0])); +} + +#define TEST_OPERATION(Name) \ + WASM_EXEC_TEST(I64Atomic##Name##Drop) { \ + RunDropTest(execution_tier, kExprI64Atomic##Name, Name); \ + } +OPERATION_LIST(TEST_OPERATION) +#undef TEST_OPERATION + +WASM_EXEC_TEST(I64AtomicSub16UDrop) { + EXPERIMENTAL_FLAG_SCOPE(threads); + WasmRunner<uint64_t, uint64_t> r(execution_tier); + uint16_t* memory = + r.builder().AddMemoryElems<uint16_t>(kWasmPageSize / sizeof(uint16_t)); + r.builder().SetHasSharedMemory(); + + BUILD(r, + WASM_ATOMICS_BINOP(kExprI64AtomicSub16U, WASM_I32V_1(0), + WASM_GET_LOCAL(0), MachineRepresentation::kWord16), + WASM_DROP, WASM_GET_LOCAL(0)); + + uint16_t initial = 0x7, local = 0xffe0; + r.builder().WriteMemory(&memory[0], initial); + CHECK_EQ(local, r.Call(local)); + uint16_t expected = Sub(initial, local); + CHECK_EQ(expected, r.builder().ReadMemory(&memory[0])); +} + +WASM_EXEC_TEST(I64AtomicCompareExchangeDrop) { + EXPERIMENTAL_FLAG_SCOPE(threads); + WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_tier); + r.builder().SetHasSharedMemory(); + uint64_t* memory = + r.builder().AddMemoryElems<uint64_t>(kWasmPageSize / sizeof(uint64_t)); + BUILD(r, + WASM_ATOMICS_TERNARY_OP(kExprI64AtomicCompareExchange, WASM_I32V_1(0), + WASM_GET_LOCAL(0), WASM_GET_LOCAL(1), + MachineRepresentation::kWord64), + WASM_DROP, WASM_GET_LOCAL(1)); + + uint64_t initial = 0x1111222233334444, local = 0x1111111111111111; + r.builder().WriteMemory(&memory[0], initial); + CHECK_EQ(local, r.Call(initial, local)); + uint64_t expected = CompareExchange(initial, initial, local); + CHECK_EQ(expected, r.builder().ReadMemory(&memory[0])); +} + +WASM_EXEC_TEST(I64AtomicStoreLoadDrop) { + EXPERIMENTAL_FLAG_SCOPE(threads); + WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_tier); + r.builder().SetHasSharedMemory(); + uint64_t* memory = + r.builder().AddMemoryElems<uint64_t>(kWasmPageSize / sizeof(uint64_t)); + + BUILD(r, + WASM_ATOMICS_STORE_OP(kExprI64AtomicStore, WASM_ZERO, WASM_GET_LOCAL(0), + MachineRepresentation::kWord64), + WASM_ATOMICS_LOAD_OP(kExprI64AtomicLoad, WASM_ZERO, + MachineRepresentation::kWord64), + WASM_DROP, WASM_GET_LOCAL(1)); + + uint64_t store_value = 0x1111111111111111, expected = 0xC0DE; + CHECK_EQ(expected, r.Call(store_value, expected)); + CHECK_EQ(store_value, r.builder().ReadMemory(&memory[0])); +} + +WASM_EXEC_TEST(I64AtomicAddConvertDrop) { + EXPERIMENTAL_FLAG_SCOPE(threads); + WasmRunner<uint64_t, uint64_t> r(execution_tier); + uint64_t* memory = + r.builder().AddMemoryElems<uint64_t>(kWasmPageSize / sizeof(uint64_t)); + r.builder().SetHasSharedMemory(); + + BUILD(r, + WASM_ATOMICS_BINOP(kExprI64AtomicAdd, WASM_I32V_1(0), WASM_GET_LOCAL(0), + MachineRepresentation::kWord64), + kExprI32ConvertI64, WASM_DROP, WASM_GET_LOCAL(0)); + + uint64_t initial = 0x1111222233334444, local = 0x1111111111111111; + r.builder().WriteMemory(&memory[0], initial); + CHECK_EQ(local, r.Call(local)); + uint64_t expected = Add(initial, local); + CHECK_EQ(expected, r.builder().ReadMemory(&memory[0])); +} + +WASM_EXEC_TEST(I64AtomicLoadConvertDrop) { + EXPERIMENTAL_FLAG_SCOPE(threads); + WasmRunner<uint32_t, uint64_t> r(execution_tier); + uint64_t* memory = + r.builder().AddMemoryElems<uint64_t>(kWasmPageSize / sizeof(uint64_t)); + r.builder().SetHasSharedMemory(); + + BUILD(r, WASM_I32_CONVERT_I64(WASM_ATOMICS_LOAD_OP( + kExprI64AtomicLoad, WASM_ZERO, MachineRepresentation::kWord64))); + + uint64_t initial = 0x1111222233334444; + r.builder().WriteMemory(&memory[0], initial); + CHECK_EQ(static_cast<uint32_t>(initial), r.Call(initial)); +} + +// Convert tests verify atomic operations are run correctly when the +// upper half of the 64-bit output is optimized out +void RunConvertTest(ExecutionTier execution_tier, WasmOpcode wasm_op, + Uint64BinOp op) { + EXPERIMENTAL_FLAG_SCOPE(threads); + WasmRunner<uint32_t, uint64_t> r(execution_tier); + uint64_t* memory = + r.builder().AddMemoryElems<uint64_t>(kWasmPageSize / sizeof(uint64_t)); + r.builder().SetHasSharedMemory(); + + BUILD(r, WASM_I32_CONVERT_I64(WASM_ATOMICS_BINOP( + kExprI64AtomicAdd, WASM_ZERO, WASM_GET_LOCAL(0), + MachineRepresentation::kWord64))); + + uint64_t initial = 0x1111222233334444, local = 0x1111111111111111; + r.builder().WriteMemory(&memory[0], initial); + CHECK_EQ(static_cast<uint32_t>(initial), r.Call(local)); + uint64_t expected = Add(initial, local); + CHECK_EQ(expected, r.builder().ReadMemory(&memory[0])); +} + +#define TEST_OPERATION(Name) \ + WASM_EXEC_TEST(I64AtomicConvert##Name) { \ + RunConvertTest(execution_tier, kExprI64Atomic##Name, Name); \ + } +OPERATION_LIST(TEST_OPERATION) +#undef TEST_OPERATION + +WASM_EXEC_TEST(I64AtomicConvertCompareExchange) { + EXPERIMENTAL_FLAG_SCOPE(threads); + WasmRunner<uint32_t, uint64_t, uint64_t> r(execution_tier); + uint64_t* memory = + r.builder().AddMemoryElems<uint64_t>(kWasmPageSize / sizeof(uint64_t)); + r.builder().SetHasSharedMemory(); + + BUILD(r, WASM_I32_CONVERT_I64(WASM_ATOMICS_TERNARY_OP( + kExprI64AtomicCompareExchange, WASM_I32V_1(0), WASM_GET_LOCAL(0), + WASM_GET_LOCAL(1), MachineRepresentation::kWord64))); + + uint64_t initial = 0x1111222233334444, local = 0x1111111111111111; + r.builder().WriteMemory(&memory[0], initial); + CHECK_EQ(static_cast<uint32_t>(initial), r.Call(initial, local)); + uint64_t expected = CompareExchange(initial, initial, local); + CHECK_EQ(expected, r.builder().ReadMemory(&memory[0])); +} + } // 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 d25aeafa33..21d92cbada 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-module.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-module.cc @@ -198,8 +198,8 @@ TEST(Run_WasmModule_Global) { TestSignatures sigs; WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone); - uint32_t global1 = builder->AddGlobal(kWasmI32, 0); - uint32_t global2 = builder->AddGlobal(kWasmI32, 0); + uint32_t global1 = builder->AddGlobal(kWasmI32, false); + uint32_t global2 = builder->AddGlobal(kWasmI32, false); WasmFunctionBuilder* f1 = builder->AddFunction(sigs.i_v()); byte code1[] = { WASM_I32_ADD(WASM_GET_GLOBAL(global1), WASM_GET_GLOBAL(global2))}; @@ -284,7 +284,7 @@ class InterruptThread : public v8::base::Thread { WriteLittleEndianValue<int32_t>(ptr, interrupt_value_); } - virtual void Run() { + void Run() override { // Wait for the main thread to write the signal value. int32_t val = 0; do { @@ -771,7 +771,7 @@ TEST(Run_WasmModule_Buffer_Externalized_GrowMem) { uint32_t result = WasmMemoryObject::Grow(isolate, memory_object, 4); CHECK_EQ(16, result); CHECK(buffer1.buffer_->was_neutered()); // growing always neuters - CHECK_EQ(0, buffer1.buffer_->byte_length()->Number()); + CHECK_EQ(0, buffer1.buffer_->byte_length()); CHECK_NE(*buffer1.buffer_, memory_object->array_buffer()); @@ -782,7 +782,7 @@ TEST(Run_WasmModule_Buffer_Externalized_GrowMem) { result = testing::RunWasmModuleForTesting(isolate, instance, 0, nullptr); CHECK_EQ(26, result); CHECK(buffer2.buffer_->was_neutered()); // growing always neuters - CHECK_EQ(0, buffer2.buffer_->byte_length()->Number()); + CHECK_EQ(0, buffer2.buffer_->byte_length()); CHECK_NE(*buffer2.buffer_, memory_object->array_buffer()); } Cleanup(); 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 f60c65b727..b0f3dcf8ce 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-simd.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-simd.cc @@ -1080,8 +1080,6 @@ WASM_SIMD_TEST(I32x4ShrU) { LogicalShiftRight); } -#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || \ - V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_IA32 // Tests both signed and unsigned conversion from I8x16 (unpacking). WASM_SIMD_TEST(I16x8ConvertI8x16) { WasmRunner<int32_t, int32_t, int32_t, int32_t, int32_t> r(execution_tier, @@ -1124,8 +1122,6 @@ WASM_SIMD_TEST(I16x8ConvertI8x16) { CHECK_EQ(1, r.Call(*i, unpacked_signed, unpacked_unsigned, 0)); } } -#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || - // V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_IA32 void RunI16x8UnOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, WasmOpcode simd_op, Int16UnOp expected_op) { @@ -1144,8 +1140,6 @@ WASM_SIMD_TEST(I16x8Neg) { RunI16x8UnOpTest(execution_tier, lower_simd, kExprI16x8Neg, Negate); } -#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || \ - V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_IA32 // Tests both signed and unsigned conversion from I32x4 (packing). WASM_SIMD_TEST(I16x8ConvertI32x4) { WasmRunner<int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t> r( @@ -1190,8 +1184,6 @@ WASM_SIMD_TEST(I16x8ConvertI32x4) { } } } -#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || - // V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_IA32 void RunI16x8BinOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, WasmOpcode simd_op, Int16BinOp expected_op) { @@ -1374,8 +1366,6 @@ WASM_SIMD_TEST(I8x16Neg) { RunI8x16UnOpTest(execution_tier, lower_simd, kExprI8x16Neg, Negate); } -#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || \ - V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_IA32 // Tests both signed and unsigned conversion from I16x8 (packing). WASM_SIMD_TEST(I8x16ConvertI16x8) { WasmRunner<int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t> r( @@ -1422,8 +1412,6 @@ WASM_SIMD_TEST(I8x16ConvertI16x8) { } } } -#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || - // V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_IA32 void RunI8x16BinOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, WasmOpcode simd_op, Int8BinOp expected_op) { @@ -2012,6 +2000,8 @@ WASM_SIMD_COMPILED_TEST(S8x16MultiShuffleFuzz) { } } } +#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || + // V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_IA32 // Boolean unary operations are 'AllTrue' and 'AnyTrue', which return an integer // result. Use relational ops on numeric vectors to create the boolean vector @@ -2099,8 +2089,6 @@ WASM_SIMD_TEST(SimdI32x4ExtractWithF32x4) { WASM_I32V(1), WASM_I32V(0))); CHECK_EQ(1, r.Call()); } -#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || - // V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_IA32 WASM_SIMD_TEST(SimdF32x4ExtractWithI32x4) { WasmRunner<int32_t> r(execution_tier, lower_simd); diff --git a/deps/v8/test/cctest/wasm/test-wasm-breakpoints.cc b/deps/v8/test/cctest/wasm/test-wasm-breakpoints.cc index ec93639e17..26e98a1ba4 100644 --- a/deps/v8/test/cctest/wasm/test-wasm-breakpoints.cc +++ b/deps/v8/test/cctest/wasm/test-wasm-breakpoints.cc @@ -72,7 +72,7 @@ class BreakHandler : public debug::DebugDelegate { : isolate_(isolate), expected_breaks_(expected_breaks) { v8::debug::SetDebugDelegate(reinterpret_cast<v8::Isolate*>(isolate_), this); } - ~BreakHandler() { + ~BreakHandler() override { // Check that all expected breakpoints have been hit. CHECK_EQ(count_, expected_breaks_.size()); v8::debug::SetDebugDelegate(reinterpret_cast<v8::Isolate*>(isolate_), @@ -181,7 +181,7 @@ class CollectValuesBreakHandler : public debug::DebugDelegate { : isolate_(isolate), expected_values_(expected_values) { v8::debug::SetDebugDelegate(reinterpret_cast<v8::Isolate*>(isolate_), this); } - ~CollectValuesBreakHandler() { + ~CollectValuesBreakHandler() override { v8::debug::SetDebugDelegate(reinterpret_cast<v8::Isolate*>(isolate_), nullptr); } 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 5e70edf830..5d383bb9c5 100644 --- a/deps/v8/test/cctest/wasm/test-wasm-shared-engine.cc +++ b/deps/v8/test/cctest/wasm/test-wasm-shared-engine.cc @@ -56,7 +56,7 @@ class SharedEngineIsolate { public: explicit SharedEngineIsolate(SharedEngine* engine) : isolate_(v8::Isolate::Allocate()) { - isolate()->set_wasm_engine(engine->ExportEngineForSharing()); + isolate()->SetWasmEngine(engine->ExportEngineForSharing()); v8::Isolate::CreateParams create_params; create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); v8::Isolate::Initialize(isolate_, create_params); @@ -116,7 +116,7 @@ class SharedEngineThread : public v8::base::Thread { engine_(engine), callback_(callback) {} - virtual void Run() { + void Run() override { SharedEngineIsolate isolate(engine_); callback_(isolate); } @@ -145,10 +145,10 @@ class MockInstantiationResolver : public InstantiationResultResolver { public: explicit MockInstantiationResolver(Handle<Object>* out_instance) : out_instance_(out_instance) {} - virtual void OnInstantiationSucceeded(Handle<WasmInstanceObject> result) { + void OnInstantiationSucceeded(Handle<WasmInstanceObject> result) override { *out_instance_->location() = *result; } - virtual void OnInstantiationFailed(Handle<Object> error_reason) { + void OnInstantiationFailed(Handle<Object> error_reason) override { UNREACHABLE(); } @@ -161,13 +161,13 @@ class MockCompilationResolver : public CompilationResultResolver { MockCompilationResolver(SharedEngineIsolate& isolate, Handle<Object>* out_instance) : isolate_(isolate), out_instance_(out_instance) {} - virtual void OnCompilationSucceeded(Handle<WasmModuleObject> result) { + void OnCompilationSucceeded(Handle<WasmModuleObject> result) override { isolate_.isolate()->wasm_engine()->AsyncInstantiate( isolate_.isolate(), base::make_unique<MockInstantiationResolver>(out_instance_), result, {}); } - virtual void OnCompilationFailed(Handle<Object> error_reason) { + void OnCompilationFailed(Handle<Object> error_reason) override { UNREACHABLE(); } diff --git a/deps/v8/test/cctest/wasm/test-wasm-stack.cc b/deps/v8/test/cctest/wasm/test-wasm-stack.cc index 2bed7e64db..303fb75878 100644 --- a/deps/v8/test/cctest/wasm/test-wasm-stack.cc +++ b/deps/v8/test/cctest/wasm/test-wasm-stack.cc @@ -30,7 +30,7 @@ namespace { "Check failed: (%s) != (%s) ('%s' vs '%s').", #exp, #found, \ exp_, found_ ? found_ : "<null>"); \ } \ - } while (0) + } while (false) void PrintStackTrace(v8::Isolate* isolate, v8::Local<v8::StackTrace> stack) { printf("Stack Trace (length %d):\n", stack->GetFrameCount()); @@ -157,7 +157,8 @@ WASM_EXEC_TEST(CollectDetailedWasmStack_WasmError) { int unreachable_pos = 1 << (8 * pos_shift); TestSignatures sigs; // Create a WasmRunner with stack checks and traps enabled. - WasmRunner<int> r(execution_tier, 0, "main", kRuntimeExceptionSupport); + WasmRunner<int> r(execution_tier, nullptr, "main", + kRuntimeExceptionSupport); std::vector<byte> code(unreachable_pos + 1, kExprNop); code[unreachable_pos] = kExprUnreachable; diff --git a/deps/v8/test/cctest/wasm/test-wasm-trap-position.cc b/deps/v8/test/cctest/wasm/test-wasm-trap-position.cc index ad9b6d3b56..7b34ed824b 100644 --- a/deps/v8/test/cctest/wasm/test-wasm-trap-position.cc +++ b/deps/v8/test/cctest/wasm/test-wasm-trap-position.cc @@ -31,7 +31,7 @@ namespace { "Check failed: (%s) != (%s) ('%s' vs '%s').", #exp, #found, \ exp_, found_ ? found_ : "<null>"); \ } \ - } while (0) + } while (false) struct ExceptionInfo { const char* func_name; @@ -69,7 +69,7 @@ void CheckExceptionInfos(v8::internal::Isolate* i_isolate, Handle<Object> exc, // Trigger a trap for executing unreachable. WASM_EXEC_TEST(Unreachable) { // Create a WasmRunner with stack checks and traps enabled. - WasmRunner<void> r(execution_tier, 0, "main", kRuntimeExceptionSupport); + WasmRunner<void> r(execution_tier, nullptr, "main", kRuntimeExceptionSupport); TestSignatures sigs; BUILD(r, WASM_UNREACHABLE); @@ -103,7 +103,7 @@ WASM_EXEC_TEST(Unreachable) { // Trigger a trap for loading from out-of-bounds. WASM_EXEC_TEST(IllegalLoad) { - WasmRunner<void> r(execution_tier, 0, "main", kRuntimeExceptionSupport); + WasmRunner<void> r(execution_tier, nullptr, "main", kRuntimeExceptionSupport); TestSignatures sigs; r.builder().AddMemory(0L); diff --git a/deps/v8/test/cctest/wasm/wasm-atomics-utils.h b/deps/v8/test/cctest/wasm/wasm-atomics-utils.h index 1a0dd345b7..615deab208 100644 --- a/deps/v8/test/cctest/wasm/wasm-atomics-utils.h +++ b/deps/v8/test/cctest/wasm/wasm-atomics-utils.h @@ -13,6 +13,14 @@ namespace v8 { namespace internal { namespace wasm { +#define OPERATION_LIST(V) \ + V(Add) \ + V(Sub) \ + V(And) \ + V(Or) \ + V(Xor) \ + V(Exchange) + typedef uint64_t (*Uint64BinOp)(uint64_t, uint64_t); typedef uint32_t (*Uint32BinOp)(uint32_t, uint32_t); typedef uint16_t (*Uint16BinOp)(uint16_t, uint16_t); diff --git a/deps/v8/test/cctest/wasm/wasm-run-utils.cc b/deps/v8/test/cctest/wasm/wasm-run-utils.cc index 5f623a46cc..4ce07089e2 100644 --- a/deps/v8/test/cctest/wasm/wasm-run-utils.cc +++ b/deps/v8/test/cctest/wasm/wasm-run-utils.cc @@ -41,13 +41,15 @@ TestingModuleBuilder::TestingModuleBuilder( if (maybe_import) { // Manually compile a wasm to JS wrapper and insert it into the instance. CodeSpaceMemoryModificationScope modification_scope(isolate_->heap()); - MaybeHandle<Code> code = compiler::CompileWasmToJSWrapper( - isolate_, maybe_import->js_function, maybe_import->sig, - maybe_import_index, test_module_->origin, + auto kind = compiler::GetWasmImportCallKind(maybe_import->js_function, + maybe_import->sig); + MaybeHandle<Code> code = compiler::CompileWasmImportCallWrapper( + isolate_, kind, maybe_import->sig, maybe_import_index, + test_module_->origin, trap_handler::IsTrapHandlerEnabled() ? kUseTrapHandler : kNoTrapHandler); - auto wasm_to_js_wrapper = native_module_->AddCodeCopy( - code.ToHandleChecked(), WasmCode::kWasmToJsWrapper, maybe_import_index); + auto wasm_to_js_wrapper = native_module_->AddImportWrapper( + code.ToHandleChecked(), maybe_import_index); ImportedFunctionEntry(instance_object_, maybe_import_index) .set_wasm_to_js(*maybe_import->js_function, wasm_to_js_wrapper); @@ -123,9 +125,8 @@ Handle<JSFunction> TestingModuleBuilder::WrapCode(uint32_t index) { // Wrap the code so it can be called as a JS function. Link(); FunctionSig* sig = test_module_->functions[index].sig; - MaybeHandle<Code> maybe_ret_code = compiler::CompileJSToWasmWrapper( - isolate_, native_module_, sig, false, - trap_handler::IsTrapHandlerEnabled() ? kUseTrapHandler : kNoTrapHandler); + MaybeHandle<Code> maybe_ret_code = + compiler::CompileJSToWasmWrapper(isolate_, sig, false); Handle<Code> ret_code = maybe_ret_code.ToHandleChecked(); Handle<JSFunction> ret = WasmExportedFunction::New( isolate_, instance_object(), MaybeHandle<String>(), @@ -363,7 +364,7 @@ Handle<Code> WasmFunctionWrapper::GetWrapperCode() { Code::C_WASM_ENTRY); code_ = compiler::Pipeline::GenerateCodeForTesting( &info, isolate, call_descriptor, graph(), - AssemblerOptions::Default(isolate), nullptr); + AssemblerOptions::Default(isolate)); code = code_.ToHandleChecked(); #ifdef ENABLE_DISASSEMBLER if (FLAG_print_opt_code) { @@ -419,18 +420,13 @@ void WasmFunctionCompiler::Build(const byte* start, const byte* end) { ScopedVector<uint8_t> func_wire_bytes(function_->code.length()); memcpy(func_wire_bytes.start(), wire_bytes.start() + function_->code.offset(), func_wire_bytes.length()); - WireBytesRef func_name_ref = - module_env.module->LookupFunctionName(wire_bytes, function_->func_index); - ScopedVector<char> func_name(func_name_ref.length()); - memcpy(func_name.start(), wire_bytes.start() + func_name_ref.offset(), - func_name_ref.length()); FunctionBody func_body{function_->sig, function_->code.offset(), func_wire_bytes.start(), func_wire_bytes.end()}; NativeModule* native_module = builder_->instance_object()->module_object()->native_module(); WasmCompilationUnit unit(isolate()->wasm_engine(), &module_env, native_module, - func_body, func_name, function_->func_index, + func_body, function_->func_index, isolate()->counters(), tier); WasmFeatures unused_detected_features; unit.ExecuteCompilation(&unused_detected_features); @@ -458,7 +454,7 @@ WasmFunctionCompiler::WasmFunctionCompiler(Zone* zone, FunctionSig* sig, function_ = builder_->GetFunctionAt(index); } -WasmFunctionCompiler::~WasmFunctionCompiler() {} +WasmFunctionCompiler::~WasmFunctionCompiler() = default; FunctionSig* WasmRunnerBase::CreateSig(MachineType return_type, Vector<MachineType> param_types) { diff --git a/deps/v8/test/cctest/wasm/wasm-run-utils.h b/deps/v8/test/cctest/wasm/wasm-run-utils.h index 899dc06268..aba43f3a08 100644 --- a/deps/v8/test/cctest/wasm/wasm-run-utils.h +++ b/deps/v8/test/cctest/wasm/wasm-run-utils.h @@ -461,10 +461,12 @@ class WasmRunner : public WasmRunnerBase { wrapper_code, wrapper_.signature()); int32_t result; { - trap_handler::ThreadInWasmScope scope; + trap_handler::SetThreadInWasm(); result = runner.Call(static_cast<void*>(&p)..., static_cast<void*>(&return_value)); + + trap_handler::ClearThreadInWasm(); } CHECK_EQ(WASM_WRAPPER_RETURN_VALUE, result); return WasmRunnerBase::trap_happened |