Commit 4bbfc4b7 authored by Jakob Gruber's avatar Jakob Gruber Committed by V8 LUCI CQ

[regexp] Remove the `stack` parameter from regexp matchers

The argument is no longer in use.

Bug: v8:11382
Change-Id: I7febc7fe7ef17ae462c700f0dba3ca1beade3021
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3173681
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarPatrick Thier <pthier@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77017}
parent a705e655
......@@ -436,8 +436,6 @@ TNode<HeapObject> RegExpBuiltinsAssembler::RegExpExecInternal(
// External constants.
TNode<ExternalReference> isolate_address =
ExternalConstant(ExternalReference::isolate_address(isolate()));
TNode<ExternalReference> regexp_stack_memory_top_address = ExternalConstant(
ExternalReference::address_of_regexp_stack_memory_top_address(isolate()));
TNode<ExternalReference> static_offsets_vector_address = ExternalConstant(
ExternalReference::address_of_static_offsets_vector(isolate()));
......@@ -606,26 +604,18 @@ TNode<HeapObject> RegExpBuiltinsAssembler::RegExpExecInternal(
MachineType arg5_type = type_int32;
TNode<Int32T> arg5 = SmiToInt32(register_count);
// Argument 6: Start (high end) of backtracking stack memory area. This
// argument is ignored in the interpreter.
TNode<RawPtrT> stack_top = UncheckedCast<RawPtrT>(
Load(MachineType::Pointer(), regexp_stack_memory_top_address));
// Argument 6: Indicate that this is a direct call from JavaScript.
MachineType arg6_type = type_int32;
TNode<Int32T> arg6 = Int32Constant(RegExp::CallOrigin::kFromJs);
MachineType arg6_type = type_ptr;
TNode<RawPtrT> arg6 = stack_top;
// Argument 7: Pass current isolate address.
MachineType arg7_type = type_ptr;
TNode<ExternalReference> arg7 = isolate_address;
// Argument 7: Indicate that this is a direct call from JavaScript.
MachineType arg7_type = type_int32;
TNode<Int32T> arg7 = Int32Constant(RegExp::CallOrigin::kFromJs);
// Argument 8: Pass current isolate address.
MachineType arg8_type = type_ptr;
TNode<ExternalReference> arg8 = isolate_address;
// Argument 9: Regular expression object. This argument is ignored in native
// Argument 8: Regular expression object. This argument is ignored in native
// irregexp code.
MachineType arg9_type = type_tagged;
TNode<JSRegExp> arg9 = regexp;
MachineType arg8_type = type_tagged;
TNode<JSRegExp> arg8 = regexp;
// TODO(v8:11880): avoid roundtrips between cdc and code.
TNode<RawPtrT> code_entry = LoadCodeObjectEntry(code);
......@@ -640,8 +630,7 @@ TNode<HeapObject> RegExpBuiltinsAssembler::RegExpExecInternal(
std::make_pair(arg1_type, arg1), std::make_pair(arg2_type, arg2),
std::make_pair(arg3_type, arg3), std::make_pair(arg4_type, arg4),
std::make_pair(arg5_type, arg5), std::make_pair(arg6_type, arg6),
std::make_pair(arg7_type, arg7), std::make_pair(arg8_type, arg8),
std::make_pair(arg9_type, arg9)));
std::make_pair(arg7_type, arg7), std::make_pair(arg8_type, arg8)));
// Check the result.
// We expect exactly one result since we force the called regexp to behave
......
......@@ -38,14 +38,12 @@ namespace internal {
* Each call to a public method should retain this convention.
*
* The stack will have the following structure:
* - fp[56] Address regexp (address of the JSRegExp object; unused in
* - fp[52] Address regexp (address of the JSRegExp object; unused in
* native code, passed to match signature of
* the interpreter)
* - fp[52] Isolate* isolate (address of the current isolate)
* - fp[48] direct_call (if 1, direct call from JavaScript code,
* - fp[48] Isolate* isolate (address of the current isolate)
* - fp[44] direct_call (if 1, direct call from JavaScript code,
* if 0, call through the runtime system).
* - fp[44] stack_area_base (high end of the memory area to use as
* backtracking stack).
* - fp[40] capture array size (may fit multiple sets of matches)
* - fp[36] int* capture_array (int[num_saved_registers_], for output).
* --- sp when called ---
......@@ -82,7 +80,6 @@ namespace internal {
* Address end,
* int* capture_output_array,
* int num_capture_registers,
* byte* stack_area_base,
* bool direct_call = false,
* Isolate* isolate,
* Address regexp);
......
......@@ -91,15 +91,13 @@ class V8_EXPORT_PRIVATE RegExpMacroAssemblerARM
static const int kFramePointer = 0;
// Above the frame pointer - Stored registers and stack passed parameters.
// Register 4..11.
static const int kStoredRegisters = kFramePointer;
// Return address (stored from link register, read into pc on return).
static const int kReturnAddress = kStoredRegisters + 8 * kPointerSize;
// Stack parameters placed by caller.
static const int kRegisterOutput = kReturnAddress + kPointerSize;
static const int kNumOutputRegisters = kRegisterOutput + kPointerSize;
static const int kStackHighEnd = kNumOutputRegisters + kPointerSize;
static const int kDirectCall = kStackHighEnd + kPointerSize;
static const int kDirectCall = kNumOutputRegisters + kPointerSize;
static const int kIsolate = kDirectCall + kPointerSize;
// Below the frame pointer.
......
......@@ -66,14 +66,12 @@ namespace internal {
* ^^^^^^^^^ fp ^^^^^^^^^
* - fp[-8] direct_call 1 => Direct call from JavaScript code.
* 0 => Call through the runtime system.
* - fp[-16] stack_base High end of the memory area to use as
* the backtracking stack.
* - fp[-24] output_size Output may fit multiple sets of matches.
* - fp[-32] input Handle containing the input string.
* - fp[-40] success_counter
* - fp[-16] output_size Output may fit multiple sets of matches.
* - fp[-24] input Handle containing the input string.
* - fp[-32] success_counter
* ^^^^^^^^^^^^^ From here and downwards we store 32 bit values ^^^^^^^^^^^^^
* - fp[-44] register N Capture registers initialized with
* - fp[-48] register N + 1 non_position_value.
* - fp[-40] register N Capture registers initialized with
* - fp[-44] register N + 1 non_position_value.
* ... The first kNumCachedRegisters (N) registers
* ... are cached in x0 to x7.
* ... Only positions must be stored in the first
......@@ -95,7 +93,6 @@ namespace internal {
* Address end,
* int* capture_output_array,
* int num_capture_registers,
* byte* stack_area_base,
* bool direct_call = false,
* Isolate* isolate,
* Address regexp);
......@@ -750,11 +747,10 @@ Handle<HeapObject> RegExpMacroAssemblerARM64::GetCode(Handle<String> source) {
// x3: byte* input_end
// x4: int* output array
// x5: int output array size
// x6: Address stack_base
// x7: int direct_call
// sp[8]: address of the current isolate
// sp[0]: secondary link/return address used by native call
// x6: int direct_call
// x7: Isolate* isolate
//
// sp[0]: secondary link/return address used by native call
// Tell the system that we have a stack frame. Because the type is MANUAL, no
// code is generated.
......
......@@ -102,16 +102,12 @@ class V8_EXPORT_PRIVATE RegExpMacroAssemblerARM64
// Callee-saved registers (x19-x28).
static const int kNumCalleeSavedRegisters = 10;
static const int kCalleeSavedRegisters = kReturnAddress + kSystemPointerSize;
// Stack parameter placed by caller.
// It is placed above the FP, LR and the callee-saved registers.
static const int kIsolate =
kCalleeSavedRegisters + kNumCalleeSavedRegisters * kSystemPointerSize;
// Below the frame pointer.
// Register parameters stored by setup code.
static const int kDirectCall = -kSystemPointerSize;
static const int kStackHighEnd = kDirectCall - kSystemPointerSize;
static const int kOutputSize = kStackHighEnd - kSystemPointerSize;
static const int kIsolate = -kSystemPointerSize;
static const int kDirectCall = kIsolate - kSystemPointerSize;
static const int kOutputSize = kDirectCall - kSystemPointerSize;
static const int kInput = kOutputSize - kSystemPointerSize;
// When adding local variables remember to push space for them in
// the frame in GetCode.
......
......@@ -192,8 +192,7 @@ int32_t ExperimentalRegExp::ExecRaw(Isolate* isolate,
int32_t ExperimentalRegExp::MatchForCallFromJs(
Address subject, int32_t start_position, Address input_start,
Address input_end, int* output_registers, int32_t output_register_count,
Address backtrack_stack, RegExp::CallOrigin call_origin, Isolate* isolate,
Address regexp) {
RegExp::CallOrigin call_origin, Isolate* isolate, Address regexp) {
DCHECK(FLAG_enable_experimental_regexp_engine);
DCHECK_NOT_NULL(isolate);
DCHECK_NOT_NULL(output_registers);
......
......@@ -34,7 +34,6 @@ class ExperimentalRegExp final : public AllStatic {
Address input_start, Address input_end,
int* output_registers,
int32_t output_register_count,
Address backtrack_stack,
RegExp::CallOrigin call_origin,
Isolate* isolate, Address regexp);
static MaybeHandle<Object> Exec(
......
......@@ -40,8 +40,6 @@ namespace internal {
* - Isolate* isolate (address of the current isolate)
* - direct_call (if 1, direct call from JavaScript code, if 0
* call through the runtime system)
* - stack_area_base (high end of the memory area to use as
* backtracking stack)
* - capture array size (may fit multiple sets of matches)
* - int* capture_array (int[num_saved_registers_], for output).
* - end of input (address of end of string)
......@@ -74,7 +72,6 @@ namespace internal {
* Address end,
* int* capture_output_array,
* int num_capture_registers,
* byte* stack_area_base,
* bool direct_call = false,
* Isolate* isolate
* Address regexp);
......
......@@ -105,8 +105,7 @@ class V8_EXPORT_PRIVATE RegExpMacroAssemblerIA32
// one set of capture results. For the case of non-global regexp, we ignore
// this value.
static const int kNumOutputRegisters = kRegisterOutput + kSystemPointerSize;
static const int kStackHighEnd = kNumOutputRegisters + kSystemPointerSize;
static const int kDirectCall = kStackHighEnd + kSystemPointerSize;
static const int kDirectCall = kNumOutputRegisters + kSystemPointerSize;
static const int kIsolate = kDirectCall + kSystemPointerSize;
// Below the frame pointer - local stack variables.
// When adding local variables remember to push space for them in
......
......@@ -1111,7 +1111,7 @@ IrregexpInterpreter::Result IrregexpInterpreter::MatchInternal(
// builtin.
IrregexpInterpreter::Result IrregexpInterpreter::MatchForCallFromJs(
Address subject, int32_t start_position, Address, Address,
int* output_registers, int32_t output_register_count, Address,
int* output_registers, int32_t output_register_count,
RegExp::CallOrigin call_origin, Isolate* isolate, Address regexp) {
DCHECK_NOT_NULL(isolate);
DCHECK_NOT_NULL(output_registers);
......
......@@ -36,9 +36,8 @@ class V8_EXPORT_PRIVATE IrregexpInterpreter : public AllStatic {
// RETRY is returned if a retry through the runtime is needed (e.g. when
// interrupts have been scheduled or the regexp is marked for tier-up).
//
// Arguments input_start, input_end and backtrack_stack are
// unused. They are only passed to match the signature of the native irregex
// code.
// Arguments input_start and input_end are unused. They are only passed to
// match the signature of the native irregex code.
//
// Arguments output_registers and output_register_count describe the results
// array, which will contain register values of all captures if SUCCESS is
......@@ -47,7 +46,6 @@ class V8_EXPORT_PRIVATE IrregexpInterpreter : public AllStatic {
Address input_start, Address input_end,
int* output_registers,
int32_t output_register_count,
Address backtrack_stack,
RegExp::CallOrigin call_origin,
Isolate* isolate, Address regexp);
......
......@@ -306,23 +306,21 @@ int NativeRegExpMacroAssembler::Execute(
String input, // This needs to be the unpacked (sliced, cons) string.
int start_offset, const byte* input_start, const byte* input_end,
int* output, int output_size, Isolate* isolate, JSRegExp regexp) {
// Ensure that the minimum stack has been allocated.
RegExpStackScope stack_scope(isolate);
Address stack_base = stack_scope.stack()->memory_top();
bool is_one_byte = String::IsOneByteRepresentationUnderneath(input);
Code code = FromCodeT(CodeT::cast(regexp.Code(is_one_byte)));
RegExp::CallOrigin call_origin = RegExp::CallOrigin::kFromRuntime;
using RegexpMatcherSig = int(
Address input_string, int start_offset, const byte* input_start,
const byte* input_end, int* output, int output_size, Address stack_base,
int call_origin, Isolate* isolate, Address regexp);
using RegexpMatcherSig =
// NOLINTNEXTLINE(readability/casting)
int(Address input_string, int start_offset, const byte* input_start,
const byte* input_end, int* output, int output_size, int call_origin,
Isolate* isolate, Address regexp);
auto fn = GeneratedCode<RegexpMatcherSig>::FromCode(code);
int result =
fn.Call(input.ptr(), start_offset, input_start, input_end, output,
output_size, stack_base, call_origin, isolate, regexp.ptr());
int result = fn.Call(input.ptr(), start_offset, input_start, input_end,
output, output_size, call_origin, isolate, regexp.ptr());
DCHECK_GE(result, SMALLEST_REGEXP_RESULT);
if (result == EXCEPTION && !isolate->has_pending_exception()) {
......
......@@ -47,14 +47,12 @@ namespace internal {
* Each call to a C++ method should retain these registers.
*
* The stack will have the following content, in some order, indexable from the
* frame pointer (see, e.g., kStackHighEnd):
* frame pointer (see, e.g., kDirectCall):
* - Address regexp (address of the JSRegExp object; unused in native
* code, passed to match signature of interpreter)
* - Isolate* isolate (address of the current isolate)
* - direct_call (if 1, direct call from JavaScript code, if 0 call
* through the runtime system)
* - stack_area_base (high end of the memory area to use as
* backtracking stack)
* - capture array size (may fit multiple sets of matches)
* - int* capture_array (int[num_saved_registers_], for output).
* - end of input (address of end of string)
......@@ -85,7 +83,6 @@ namespace internal {
* Address end,
* int* capture_output_array,
* int num_capture_registers,
* byte* stack_area_base,
* bool direct_call = false,
* Isolate* isolate,
* Address regexp);
......@@ -849,8 +846,6 @@ Handle<HeapObject> RegExpMacroAssemblerX64::GetCode(Handle<String> source) {
}
// Initialize backtrack stack pointer.
// TODO(jgruber): Remove the kStackHighEnd parameter (and others like
// kIsolate).
LoadRegExpStackPointerFromMemory(backtrack_stackpointer());
__ jmp(&start_label_);
......
......@@ -108,9 +108,8 @@ class V8_EXPORT_PRIVATE RegExpMacroAssemblerX64
// this value. NumOutputRegisters is passed as 32-bit value. The upper
// 32 bit of this 64-bit stack slot may contain garbage.
static const int kNumOutputRegisters = kRegisterOutput + kSystemPointerSize;
static const int kStackHighEnd = kNumOutputRegisters + kSystemPointerSize;
// DirectCall is passed as 32 bit int (values 0 or 1).
static const int kDirectCall = kStackHighEnd + kSystemPointerSize;
static const int kDirectCall = kNumOutputRegisters + kSystemPointerSize;
static const int kIsolate = kDirectCall + kSystemPointerSize;
#else
// In AMD64 ABI Calling Convention, the first six integer parameters
......@@ -121,13 +120,12 @@ class V8_EXPORT_PRIVATE RegExpMacroAssemblerX64
static const int kInputStart = kStartIndex - kSystemPointerSize;
static const int kInputEnd = kInputStart - kSystemPointerSize;
static const int kRegisterOutput = kInputEnd - kSystemPointerSize;
// For the case of global regular expression, we have room to store at least
// one set of capture results. For the case of non-global regexp, we ignore
// this value.
static const int kNumOutputRegisters = kRegisterOutput - kSystemPointerSize;
static const int kStackHighEnd = kFrameAlign;
static const int kDirectCall = kStackHighEnd + kSystemPointerSize;
static const int kDirectCall = kFrameAlign;
static const int kIsolate = kDirectCall + kSystemPointerSize;
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment