Index: js/src/irregexp/imported/regexp-bytecode-generator.cc =================================================================== --- js/src/irregexp/imported/regexp-bytecode-generator.cc +++ js/src/irregexp/imported/regexp-bytecode-generator.cc @@ -223,11 +223,11 @@ } template void BytecodeGenerator::Emit(Args... args) { // Converts nullptr labels into our internal backtrack_ label. - auto fix_label = [this](auto arg) { + [[maybe_unused]] auto fix_label = [this](auto arg) { if constexpr (std::is_convertible_v) { Label* l = static_cast(arg); return l ? l : &backtrack_; } else { return arg; Index: js/src/irregexp/imported/regexp-bytecode-peephole.cc =================================================================== --- js/src/irregexp/imported/regexp-bytecode-peephole.cc +++ js/src/irregexp/imported/regexp-bytecode-peephole.cc @@ -1074,10 +1074,11 @@ DirectHandle array = isolate->factory()->NewTrustedByteArray(optimized_length); MemCopy(array->begin(), optimized_bytecode, optimized_length); +#ifndef COMPILING_IRREGEXP_FOR_EXTERNAL_EMBEDDER if (did_optimize && v8_flags.trace_regexp_peephole_optimization) { std::unique_ptr pattern_cstring = re_data->escaped_source()->ToCString(); PrintF("Original Bytecode:\n"); RegExpBytecodeDisassemble(original_bytecode->data(), @@ -1085,10 +1086,11 @@ pattern_cstring.get()); PrintF("Optimized Bytecode:\n"); RegExpBytecodeDisassemble(array->begin(), optimized_length, pattern_cstring.get()); } +#endif // !COMPILING_IRREGEXP_FOR_EXTERNAL_EMBEDDER return array; } } // namespace regexp Index: js/src/irregexp/imported/regexp-bytecodes-inl.h =================================================================== --- js/src/irregexp/imported/regexp-bytecodes-inl.h +++ js/src/irregexp/imported/regexp-bytecodes-inl.h @@ -73,11 +73,11 @@ constexpr int CountOf() { return sizeof...(Args); } template -consteval std::array SplitNames(const char* raw_names) { +constexpr std::array SplitNames(const char* raw_names) { std::array result; std::string_view names(raw_names); // Remove '(' and ')'. DCHECK_EQ(names.front(), '('); @@ -102,11 +102,11 @@ } // Calculates packed offsets for each Bytecode operand. // All operands are aligned to their own size. template -consteval auto CalculateAlignedOffsets() { +constexpr auto CalculateAlignedOffsets() { constexpr int N = sizeof...(operand_types); constexpr std::array kOperandSizes = { OperandTypeTraits::kSize...}; constexpr std::array kOperandAlignments = { OperandTypeTraits::kAlignment...}; @@ -154,46 +154,45 @@ struct BytecodeOperandNames; #define DECLARE_OPERAND_NAMES(CamelName, OpNames, OpTypes, ...) \ template <> \ struct BytecodeOperandNames { \ - enum class Operand { UNPAREN(OpNames) }; \ - using enum Operand; \ + enum Operand { UNPAREN(OpNames) }; \ static constexpr size_t kCount = detail::CountOf(); \ static constexpr auto kNames = detail::SplitNames(#OpNames); \ static constexpr std::string_view Name(Operand op) { \ return kNames[static_cast(op)]; \ } \ }; REGEXP_BYTECODE_LIST(DECLARE_OPERAND_NAMES) #undef DECLARE_OPERAND_NAMES template -class BytecodeOperandsBase { +class BytecodeOperandsBase : public BytecodeOperandNames { public: static constexpr Bytecode kBytecode = bc; using Operand = BytecodeOperandNames::Operand; using Traits = BytecodeOperandsTraits; static constexpr int kCount = Traits::kOperandCount; static constexpr int kTotalSize = Traits::kSize; - static consteval int Index(Operand op) { return static_cast(op); } - static consteval int Size(Operand op) { + static constexpr int Index(Operand op) { return static_cast(op); } + static constexpr int Size(Operand op) { return Traits::kOperandSizes[Index(op)]; } - static consteval int Offset(Operand op) { + static constexpr int Offset(Operand op) { return Traits::kOperandOffsets[Index(op)]; } - static consteval BytecodeOperandType Type(Operand op) { + static constexpr BytecodeOperandType Type(Operand op) { return Traits::kOperandTypes[Index(op)]; } static constexpr std::string_view Name(Operand op) { return BytecodeOperandNames::Name(op); } // Returns a tuple of all operands. - static consteval auto GetOperandsTuple() { + static constexpr auto GetOperandsTuple() { return [](std::index_sequence) { return std::tuple_cat([]() { constexpr auto id = static_cast(I); return std::tuple(std::integral_constant{}); }.template operator()()...); @@ -292,12 +291,10 @@ template <> \ class BytecodeOperands final \ : public detail::BytecodeOperandsBase, \ public AllStatic { \ - public: \ - using enum Operand; \ }; REGEXP_BYTECODE_LIST(DECLARE_OPERANDS) #undef DECLARE_OPERANDS Index: js/src/irregexp/imported/regexp-code-generator.cc =================================================================== --- js/src/irregexp/imported/regexp-code-generator.cc +++ js/src/irregexp/imported/regexp-code-generator.cc @@ -3,10 +3,11 @@ // found in the LICENSE file. #include "irregexp/imported/regexp-code-generator.h" #include +#include #include #include #include #include "irregexp/imported/regexp-bytecode-analysis.h" @@ -34,10 +35,11 @@ CodeGenerator::Result CodeGenerator::Assemble(DirectHandle re_data, Flags flags) { USE(isolate_); USE(masm_); +#ifndef COMPILING_IRREGEXP_FOR_EXTERNAL_EMBEDDER // Bytecode analysis is currently unused. In future work it could form the // basis for compiler optimizations. if (V8_UNLIKELY(v8_flags.regexp_bytecode_analysis)) { BytecodeAnalysis analysis(isolate_, &zone_, bytecode_); analysis.Analyze(); @@ -47,10 +49,11 @@ RegExpBytecodeDisassemble(bytecode_->begin(), bytecode_->ulength().value(), pattern_cstring.get(), &analysis); } } +#endif // !COMPILING_IRREGEXP_FOR_EXTERNAL_EMBEDDER PreVisitBytecodes(); iter_.reset(); VisitBytecodes(); if (has_unsupported_bytecode_) return Result::UnsupportedBytecode(); Index: js/src/irregexp/imported/regexp-graph-printer.cc =================================================================== --- js/src/irregexp/imported/regexp-graph-printer.cc +++ js/src/irregexp/imported/regexp-graph-printer.cc @@ -5,10 +5,12 @@ #ifdef V8_ENABLE_REGEXP_DIAGNOSTICS #include "irregexp/imported/regexp-graph-printer.h" #include +#include +#include #include "irregexp/imported/regexp-ast-printer.h" #include "irregexp/imported/regexp-compiler.h" #include "irregexp/imported/regexp-node-printer.h" Index: js/src/irregexp/imported/regexp-interpreter.cc =================================================================== --- js/src/irregexp/imported/regexp-interpreter.cc +++ js/src/irregexp/imported/regexp-interpreter.cc @@ -203,11 +203,11 @@ IrregexpInterpreter::Result ThrowStackOverflow(Isolate* isolate, RegExp::CallOrigin call_origin) { CHECK(call_origin == RegExp::CallOrigin::kFromRuntime); // We abort interpreter execution after the stack overflow is thrown, and thus // allow allocation here despite the outer DisallowGarbageCollectionScope. - AllowGarbageCollection yes_gc; + [[maybe_unused]] AllowGarbageCollection yes_gc; isolate->StackOverflow(); return IrregexpInterpreter::EXCEPTION; } // Only throws if called from the runtime, otherwise just returns the EXCEPTION @@ -280,11 +280,11 @@ } else if (check.InterruptRequested()) { const bool was_one_byte = String::IsOneByteRepresentationUnderneath(*subject_string_out); Tagged result; { - AllowGarbageCollection yes_gc; + [[maybe_unused]] AllowGarbageCollection yes_gc; result = isolate->stack_guard()->HandleInterrupts(); } if (IsExceptionHole(result)) { return IrregexpInterpreter::EXCEPTION; } Index: js/src/irregexp/imported/regexp-macro-assembler-tracer.h =================================================================== --- js/src/irregexp/imported/regexp-macro-assembler-tracer.h +++ js/src/irregexp/imported/regexp-macro-assembler-tracer.h @@ -14,11 +14,11 @@ // Decorator on a RegExpMacroAssembler that write all calls. class RegExpMacroAssemblerTracer : public RegExpMacroAssembler { public: explicit RegExpMacroAssemblerTracer( - std::unique_ptr&& assembler); + js::UniquePtr&& assembler); ~RegExpMacroAssemblerTracer() override; void AbortedCodeGeneration() override; void AdvanceCurrentPosition(int by) override; // Signed cp change. void AdvanceRegister(int reg, int by) override; // r[reg] += by. void Backtrack() override; @@ -122,11 +122,11 @@ void set_global_mode(GlobalMode mode) override; void set_backtrack_limit(uint32_t backtrack_limit) override; void set_can_fallback(bool val) override; private: - std::unique_ptr assembler_; + js::UniquePtr assembler_; }; } // namespace regexp } // namespace internal } // namespace v8 Index: js/src/irregexp/imported/regexp-macro-assembler-tracer.cc =================================================================== --- js/src/irregexp/imported/regexp-macro-assembler-tracer.cc +++ js/src/irregexp/imported/regexp-macro-assembler-tracer.cc @@ -10,11 +10,11 @@ namespace v8 { namespace internal { namespace regexp { RegExpMacroAssemblerTracer::RegExpMacroAssemblerTracer( - std::unique_ptr&& assembler) + js::UniquePtr&& assembler) : RegExpMacroAssembler(*assembler), assembler_(std::move(assembler)) { PrintF("RegExpMacroAssembler%s();\n", ImplementationToString(assembler_->Implementation())); } Index: js/src/irregexp/imported/regexp-macro-assembler.cc =================================================================== --- js/src/irregexp/imported/regexp-macro-assembler.cc +++ js/src/irregexp/imported/regexp-macro-assembler.cc @@ -536,15 +536,15 @@ int return_value = 0; { DisableGCMole no_gc_mole; if (js_has_overflowed) { - AllowGarbageCollection yes_gc; + [[maybe_unused]] AllowGarbageCollection yes_gc; isolate->StackOverflow(); return_value = EXCEPTION; } else if (check.InterruptRequested()) { - AllowGarbageCollection yes_gc; + [[maybe_unused]] AllowGarbageCollection yes_gc; Tagged result = isolate->stack_guard()->HandleInterrupts(); if (IsExceptionHole(result)) return_value = EXCEPTION; } // We are not using operator == here because it does a slow DCHECK Index: js/src/irregexp/imported/regexp-parser.cc =================================================================== --- js/src/irregexp/imported/regexp-parser.cc +++ js/src/irregexp/imported/regexp-parser.cc @@ -8,10 +8,11 @@ #include "irregexp/imported/regexp-ast.h" #include "irregexp/imported/regexp-macro-assembler.h" #include "irregexp/imported/regexp.h" #ifdef V8_INTL_SUPPORT +#include "js/properties_glue.h" #include "unicode/uniset.h" #include "unicode/unistr.h" #include "unicode/usetiter.h" #include "unicode/utf16.h" // For U16_NEXT #endif // V8_INTL_SUPPORT @@ -2106,11 +2107,13 @@ zone); } else if (NameEquals(name, "Assigned")) { return LookupPropertyValueName(UCHAR_GENERAL_CATEGORY, "Unassigned", !negate, result, nullptr, flags, zone); } else { - return false; + return mozilla_properties_glue_add_property_ranges( + static_cast(result), static_cast(zone), name, negate, + IsUnicodeSets(flags) && IsIgnoreCase(flags)); } return true; } // Explicitly allowlist supported binary properties. The spec forbids supporting Index: js/src/irregexp/imported/regexp-stack.h =================================================================== --- js/src/irregexp/imported/regexp-stack.h +++ js/src/irregexp/imported/regexp-stack.h @@ -91,16 +91,14 @@ void FreeThreadResources() { thread_local_.ResetToStaticStack(this); } // Maximal size of allocated stack area. static constexpr size_t kMaximumStackSize = 64 * MB; - private: - // Currently private as we need to use New/Delete instead. - // TODO(426514762): revert this change once its no longer needed. Stack(); ~Stack(); + private: // Artificial limit used when the thread-local state has been destroyed. static const Address kMemoryTop = static_cast
(static_cast(-1)); // In addition to dynamically-allocated, variable-sized stacks, we also have Index: js/src/irregexp/imported/regexp-stack.cc =================================================================== --- js/src/irregexp/imported/regexp-stack.cc +++ js/src/irregexp/imported/regexp-stack.cc @@ -22,10 +22,12 @@ Stack::Stack() : thread_local_(this) {} Stack::~Stack() { thread_local_.FreeAndInvalidate(); } +#ifndef COMPILING_IRREGEXP_FOR_EXTERNAL_EMBEDDER + // static Stack* Stack::New() { #ifdef V8_ENABLE_SANDBOX_HARDWARE_SUPPORT // TODO(426514762): Stack objects must currently be accessible to // sandboxed code (which is unsafe). As such we need to register them as @@ -55,10 +57,12 @@ #else delete instance; #endif } +#endif // !COMPILING_IRREGEXP_FOR_EXTERNAL_EMBEDDER + char* Stack::ArchiveStack(char* to) { if (!thread_local_.owns_memory_) { // Force dynamic stacks prior to archiving. Any growth will do. A dynamic // stack is needed because stack archival & restoration rely on `memory_` // pointing at a fixed-location backing store, whereas the static stack is