diff --git a/deps/v8/include/v8-version.h b/deps/v8/include/v8-version.h index 415d17dbbbce8e..500576281862bb 100644 --- a/deps/v8/include/v8-version.h +++ b/deps/v8/include/v8-version.h @@ -11,7 +11,7 @@ #define V8_MAJOR_VERSION 7 #define V8_MINOR_VERSION 0 #define V8_BUILD_NUMBER 276 -#define V8_PATCH_LEVEL 25 +#define V8_PATCH_LEVEL 28 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) diff --git a/deps/v8/src/compiler/bytecode-graph-builder.cc b/deps/v8/src/compiler/bytecode-graph-builder.cc index bd8b551f4f3269..5fad7bc92056df 100644 --- a/deps/v8/src/compiler/bytecode-graph-builder.cc +++ b/deps/v8/src/compiler/bytecode-graph-builder.cc @@ -516,7 +516,7 @@ Node* BytecodeGraphBuilder::Environment::Checkpoint( BytecodeGraphBuilder::BytecodeGraphBuilder( Zone* local_zone, Handle shared_info, Handle feedback_vector, BailoutId osr_offset, - JSGraph* jsgraph, CallFrequency invocation_frequency, + JSGraph* jsgraph, CallFrequency& invocation_frequency, SourcePositionTable* source_positions, Handle native_context, int inlining_id, JSTypeHintLowering::Flags flags, bool stack_check, bool analyze_environment_liveness) diff --git a/deps/v8/src/compiler/bytecode-graph-builder.h b/deps/v8/src/compiler/bytecode-graph-builder.h index 57127142def497..016134ddbb488b 100644 --- a/deps/v8/src/compiler/bytecode-graph-builder.h +++ b/deps/v8/src/compiler/bytecode-graph-builder.h @@ -31,7 +31,7 @@ class BytecodeGraphBuilder { BytecodeGraphBuilder( Zone* local_zone, Handle shared, Handle feedback_vector, BailoutId osr_offset, - JSGraph* jsgraph, CallFrequency invocation_frequency, + JSGraph* jsgraph, CallFrequency& invocation_frequency, SourcePositionTable* source_positions, Handle native_context, int inlining_id = SourcePosition::kNotInlined, JSTypeHintLowering::Flags flags = JSTypeHintLowering::kNoFlags, diff --git a/deps/v8/src/compiler/js-inlining.cc b/deps/v8/src/compiler/js-inlining.cc index 247e36d5b39790..2f317728831725 100644 --- a/deps/v8/src/compiler/js-inlining.cc +++ b/deps/v8/src/compiler/js-inlining.cc @@ -485,9 +485,10 @@ Reduction JSInliner::ReduceJSCall(Node* node) { if (info_->is_bailout_on_uninitialized()) { flags |= JSTypeHintLowering::kBailoutOnUninitialized; } + CallFrequency frequency = call.frequency(); BytecodeGraphBuilder graph_builder( zone(), shared_info, feedback_vector, BailoutId::None(), jsgraph(), - call.frequency(), source_positions_, native_context(), inlining_id, + frequency, source_positions_, native_context(), inlining_id, flags, false, info_->is_analyze_environment_liveness()); graph_builder.CreateGraph(); diff --git a/deps/v8/src/compiler/js-operator.cc b/deps/v8/src/compiler/js-operator.cc index 797814314f7d3b..acfc0d3a19c59f 100644 --- a/deps/v8/src/compiler/js-operator.cc +++ b/deps/v8/src/compiler/js-operator.cc @@ -820,7 +820,8 @@ const Operator* JSOperatorBuilder::CallForwardVarargs(size_t arity, parameters); // parameter } -const Operator* JSOperatorBuilder::Call(size_t arity, CallFrequency frequency, +const Operator* JSOperatorBuilder::Call(size_t arity, + CallFrequency const& frequency, VectorSlotPair const& feedback, ConvertReceiverMode convert_mode, SpeculationMode speculation_mode) { @@ -844,8 +845,8 @@ const Operator* JSOperatorBuilder::CallWithArrayLike(CallFrequency frequency) { } const Operator* JSOperatorBuilder::CallWithSpread( - uint32_t arity, CallFrequency frequency, VectorSlotPair const& feedback, - SpeculationMode speculation_mode) { + uint32_t arity, CallFrequency const& frequency, + VectorSlotPair const& feedback, SpeculationMode speculation_mode) { DCHECK_IMPLIES(speculation_mode == SpeculationMode::kAllowSpeculation, feedback.IsValid()); CallParameters parameters(arity, frequency, feedback, diff --git a/deps/v8/src/compiler/js-operator.h b/deps/v8/src/compiler/js-operator.h index b10d89cdb9099f..a81b187c7b2771 100644 --- a/deps/v8/src/compiler/js-operator.h +++ b/deps/v8/src/compiler/js-operator.h @@ -160,7 +160,7 @@ CallForwardVarargsParameters const& CallForwardVarargsParametersOf( // used as a parameter by JSCall and JSCallWithSpread operators. class CallParameters final { public: - CallParameters(size_t arity, CallFrequency frequency, + CallParameters(size_t arity, CallFrequency const& frequency, VectorSlotPair const& feedback, ConvertReceiverMode convert_mode, SpeculationMode speculation_mode) @@ -171,7 +171,7 @@ class CallParameters final { feedback_(feedback) {} size_t arity() const { return ArityField::decode(bit_field_); } - CallFrequency frequency() const { return frequency_; } + CallFrequency const& frequency() const { return frequency_; } ConvertReceiverMode convert_mode() const { return ConvertReceiverModeField::decode(bit_field_); } @@ -747,13 +747,13 @@ class V8_EXPORT_PRIVATE JSOperatorBuilder final const Operator* CallForwardVarargs(size_t arity, uint32_t start_index); const Operator* Call( - size_t arity, CallFrequency frequency = CallFrequency(), + size_t arity, CallFrequency const& frequency = CallFrequency(), VectorSlotPair const& feedback = VectorSlotPair(), ConvertReceiverMode convert_mode = ConvertReceiverMode::kAny, SpeculationMode speculation_mode = SpeculationMode::kDisallowSpeculation); const Operator* CallWithArrayLike(CallFrequency frequency); const Operator* CallWithSpread( - uint32_t arity, CallFrequency frequency = CallFrequency(), + uint32_t arity, CallFrequency const& frequency = CallFrequency(), VectorSlotPair const& feedback = VectorSlotPair(), SpeculationMode speculation_mode = SpeculationMode::kDisallowSpeculation); const Operator* CallRuntime(Runtime::FunctionId id); diff --git a/deps/v8/src/compiler/pipeline.cc b/deps/v8/src/compiler/pipeline.cc index 5717c70348e407..0cc37235949b53 100644 --- a/deps/v8/src/compiler/pipeline.cc +++ b/deps/v8/src/compiler/pipeline.cc @@ -1142,10 +1142,11 @@ struct GraphBuilderPhase { if (data->info()->is_bailout_on_uninitialized()) { flags |= JSTypeHintLowering::kBailoutOnUninitialized; } + CallFrequency frequency = CallFrequency(1.0f); BytecodeGraphBuilder graph_builder( temp_zone, data->info()->shared_info(), handle(data->info()->closure()->feedback_vector(), data->isolate()), - data->info()->osr_offset(), data->jsgraph(), CallFrequency(1.0f), + data->info()->osr_offset(), data->jsgraph(), frequency, data->source_positions(), data->native_context(), SourcePosition::kNotInlined, flags, true, data->info()->is_analyze_environment_liveness()); diff --git a/deps/v8/src/compiler/ppc/instruction-selector-ppc.cc b/deps/v8/src/compiler/ppc/instruction-selector-ppc.cc index 6cb98c4f958b70..e29ae8c7a51565 100644 --- a/deps/v8/src/compiler/ppc/instruction-selector-ppc.cc +++ b/deps/v8/src/compiler/ppc/instruction-selector-ppc.cc @@ -941,7 +941,7 @@ void InstructionSelector::VisitWord64ReverseBytes(Node* node) { PPCOperandGenerator g(this); InstructionOperand temp[] = {g.TempRegister()}; Emit(kPPC_ByteRev64, g.DefineAsRegister(node), - g.UseRegister(node->InputAt(0)), 1, temp); + g.UseUniqueRegister(node->InputAt(0)), 1, temp); } void InstructionSelector::VisitWord32ReverseBytes(Node* node) { diff --git a/deps/v8/src/objects/string-inl.h b/deps/v8/src/objects/string-inl.h index 1e8eef754f0638..39f642063ec118 100644 --- a/deps/v8/src/objects/string-inl.h +++ b/deps/v8/src/objects/string-inl.h @@ -149,8 +149,8 @@ bool String::IsOneByteRepresentationUnderneath() { return true; case kTwoByteStringTag: return false; - default: // Cons or sliced string. Need to go deeper. - return GetUnderlying()->IsOneByteRepresentation(); + default: // Cons, sliced, thin, strings need to go deeper. + return GetUnderlying()->IsOneByteRepresentationUnderneath(); } } @@ -164,8 +164,8 @@ bool String::IsTwoByteRepresentationUnderneath() { return false; case kTwoByteStringTag: return true; - default: // Cons or sliced string. Need to go deeper. - return GetUnderlying()->IsTwoByteRepresentation(); + default: // Cons, sliced, thin, strings need to go deeper. + return GetUnderlying()->IsTwoByteRepresentationUnderneath(); } } diff --git a/deps/v8/src/ppc/macro-assembler-ppc.cc b/deps/v8/src/ppc/macro-assembler-ppc.cc index 5605907d6fa2df..9ae1e7139a6974 100644 --- a/deps/v8/src/ppc/macro-assembler-ppc.cc +++ b/deps/v8/src/ppc/macro-assembler-ppc.cc @@ -1768,11 +1768,8 @@ void TurboAssembler::Abort(AbortReason reason) { // We don't care if we constructed a frame. Just pretend we did. FrameScope assume_frame(this, StackFrame::NONE); mov(r3, Operand(static_cast(reason))); - PrepareCallCFunction(1, 0, r4); - Move(ip, ExternalReference::abort_with_reason()); - // Use Call directly to avoid any unneeded overhead. The function won't - // return anyway. - Call(ip); + PrepareCallCFunction(1, r4); + CallCFunction(ExternalReference::abort_with_reason(), 1); return; } diff --git a/deps/v8/src/profiler/cpu-profiler.cc b/deps/v8/src/profiler/cpu-profiler.cc index 555c47f2f4e418..21d7c9072e0403 100644 --- a/deps/v8/src/profiler/cpu-profiler.cc +++ b/deps/v8/src/profiler/cpu-profiler.cc @@ -368,8 +368,11 @@ void CpuProfiler::StartProcessorIfNotStarted() { // Disable logging when using the new implementation. saved_is_logging_ = logger->is_logging_; logger->is_logging_ = false; + + bool codemap_needs_initialization = false; if (!generator_) { generator_.reset(new ProfileGenerator(profiles_.get())); + codemap_needs_initialization = true; CreateEntriesForRuntimeCallStats(); } processor_.reset(new ProfilerEventsProcessor(isolate_, generator_.get(), @@ -382,12 +385,14 @@ void CpuProfiler::StartProcessorIfNotStarted() { isolate_->set_is_profiling(true); // Enumerate stuff we already have in the heap. DCHECK(isolate_->heap()->HasBeenSetUp()); - if (!FLAG_prof_browser_mode) { - logger->LogCodeObjects(); + if (codemap_needs_initialization) { + if (!FLAG_prof_browser_mode) { + logger->LogCodeObjects(); + } + logger->LogCompiledFunctions(); + logger->LogAccessorCallbacks(); + LogBuiltins(); } - logger->LogCompiledFunctions(); - logger->LogAccessorCallbacks(); - LogBuiltins(); // Enable stack sampling. processor_->AddCurrentStack(isolate_); processor_->StartSynchronously(); diff --git a/deps/v8/test/cctest/test-strings.cc b/deps/v8/test/cctest/test-strings.cc index 8aa621b1c177a8..2c66421831e3b0 100644 --- a/deps/v8/test/cctest/test-strings.cc +++ b/deps/v8/test/cctest/test-strings.cc @@ -1693,6 +1693,64 @@ TEST(StringEquals) { CHECK(!bar_str->StringEquals(foo_str2)); } +class OneByteStringResource : public v8::String::ExternalOneByteStringResource { + public: + // Takes ownership of |data|. + OneByteStringResource(char* data, size_t length) + : data_(data), length_(length) {} + ~OneByteStringResource() override { delete[] data_; } + const char* data() const override { return data_; } + size_t length() const override { return length_; } + + private: + char* data_; + size_t length_; +}; + +TEST(Regress876759) { + v8::V8::Initialize(); + Isolate* isolate = CcTest::i_isolate(); + Factory* factory = isolate->factory(); + + HandleScope handle_scope(isolate); + + const int kLength = 30; + uc16 two_byte_buf[kLength]; + char* external_one_byte_buf = new char[kLength]; + for (int j = 0; j < kLength; j++) { + char c = '0' + (j % 10); + two_byte_buf[j] = c; + external_one_byte_buf[j] = c; + } + + Handle parent; + { + Handle raw = + factory->NewRawTwoByteString(kLength).ToHandleChecked(); + CopyChars(raw->GetChars(), two_byte_buf, kLength); + parent = raw; + } + CHECK(parent->IsTwoByteRepresentation()); + Handle sliced = factory->NewSubString(parent, 1, 20); + CHECK(sliced->IsSlicedString()); + factory->InternalizeString(parent); + CHECK(parent->IsThinString()); + Handle grandparent = + handle(ThinString::cast(*parent)->actual(), isolate); + CHECK_EQ(*parent, SlicedString::cast(*sliced)->parent()); + OneByteStringResource* resource = + new OneByteStringResource(external_one_byte_buf, kLength); + grandparent->MakeExternal(resource); + // The grandparent string becomes one-byte, but the child strings are still + // two-byte. + CHECK(grandparent->IsOneByteRepresentation()); + CHECK(parent->IsTwoByteRepresentation()); + CHECK(sliced->IsTwoByteRepresentation()); + // The *Underneath versions return the correct representation. + CHECK(sliced->IsOneByteRepresentationUnderneath()); + CHECK(!sliced->IsTwoByteRepresentationUnderneath()); +} + } // namespace test_strings } // namespace internal } // namespace v8 diff --git a/deps/v8/test/unittests/assembler/turbo-assembler-ppc-unittest.cc b/deps/v8/test/unittests/assembler/turbo-assembler-ppc-unittest.cc index 8054eb1da5bfa9..dcc138fce125d1 100644 --- a/deps/v8/test/unittests/assembler/turbo-assembler-ppc-unittest.cc +++ b/deps/v8/test/unittests/assembler/turbo-assembler-ppc-unittest.cc @@ -25,6 +25,9 @@ TEST_F(TurboAssemblerTest, TestHardAbort) { byte* buffer = AllocateAssemblerBuffer(&allocated); TurboAssembler tasm(nullptr, AssemblerOptions{}, buffer, static_cast(allocated), CodeObjectRequired::kNo); + // Called from C + __ function_descriptor(); + __ set_abort_hard(true); __ Abort(AbortReason::kNoReason); @@ -43,6 +46,9 @@ TEST_F(TurboAssemblerTest, TestCheck) { byte* buffer = AllocateAssemblerBuffer(&allocated); TurboAssembler tasm(nullptr, AssemblerOptions{}, buffer, static_cast(allocated), CodeObjectRequired::kNo); + // Called from C + __ function_descriptor(); + __ set_abort_hard(true); // Fail if the first parameter is 17.