Commit 4717c9a2 authored by Victor Gomes's avatar Victor Gomes Committed by Commit Bot

[runtime] Change kDontAdaptArgumentsSentinel to be a global constant.

Context: This is part of a bigger CL:
https://chromium-review.googlesource.com/c/v8/v8/+/2043840

In order to get rid of the arguments adaptor frame, we will reverse
the JS arguments in the stack. Some macros will need to reverse its
arguments as well, we will do that using helper macros in another CL
(see src/builtins/builtins-descriptors.h in 2043840).
For that we need to stringify the name kDontAdaptArgumentsSentinel,
which cannot be done if '::' is in its name.

This CL should not have any impact performace/memory on V8.

Bug: v8:10201
Change-Id: If76b7f457c179fbddddfe1a0ae038d2f1210ad2b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2066969Reviewed-by: 's avatarVictor Gomes <victorgomes@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Auto-Submit: Victor Gomes <victorgomes@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66432}
parent 7a318130
......@@ -2293,7 +2293,7 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
// -----------------------------------
Label dont_adapt_arguments, stack_overflow, skip_adapt_arguments;
__ cmp(r2, Operand(SharedFunctionInfo::kDontAdaptArgumentsSentinel));
__ cmp(r2, Operand(kDontAdaptArgumentsSentinel));
__ b(eq, &dont_adapt_arguments);
__ ldr(r4, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset));
__ ldr(r4, FieldMemOperand(r4, SharedFunctionInfo::kFlagsOffset));
......
......@@ -2778,7 +2778,7 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
Label create_adaptor_frame, dont_adapt_arguments, stack_overflow,
adapt_arguments_in_place;
__ Cmp(argc_expected, SharedFunctionInfo::kDontAdaptArgumentsSentinel);
__ Cmp(argc_expected, kDontAdaptArgumentsSentinel);
__ B(eq, &dont_adapt_arguments);
// When the difference between argc_actual and argc_expected is odd, we
......
This diff is collapsed.
......@@ -2471,8 +2471,7 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
const Register kExpectedNumberOfArgumentsRegister = ecx;
Label invoke, dont_adapt_arguments, stack_overflow, enough, too_few;
__ cmp(kExpectedNumberOfArgumentsRegister,
SharedFunctionInfo::kDontAdaptArgumentsSentinel);
__ cmp(kExpectedNumberOfArgumentsRegister, kDontAdaptArgumentsSentinel);
__ j(equal, &dont_adapt_arguments);
__ cmp(eax, kExpectedNumberOfArgumentsRegister);
__ j(less, &too_few);
......
......@@ -2326,7 +2326,7 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
Label enough, too_few;
__ Branch(&dont_adapt_arguments, eq, a2,
Operand(SharedFunctionInfo::kDontAdaptArgumentsSentinel));
Operand(kDontAdaptArgumentsSentinel));
// We use Uless as the number of argument should always be greater than 0.
__ Branch(&too_few, Uless, a0, Operand(a2));
......
......@@ -2362,7 +2362,7 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
Label enough, too_few;
__ Branch(&dont_adapt_arguments, eq, a2,
Operand(SharedFunctionInfo::kDontAdaptArgumentsSentinel));
Operand(kDontAdaptArgumentsSentinel));
// We use Uless as the number of argument should always be greater than 0.
__ Branch(&too_few, Uless, a0, Operand(a2));
......
......@@ -2391,7 +2391,7 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
// -----------------------------------
Label dont_adapt_arguments, stack_overflow, skip_adapt_arguments;
__ cmpli(r5, Operand(SharedFunctionInfo::kDontAdaptArgumentsSentinel));
__ cmpli(r5, Operand(kDontAdaptArgumentsSentinel));
__ beq(&dont_adapt_arguments);
__ LoadP(r7, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset));
__ lwz(r7, FieldMemOperand(r7, SharedFunctionInfo::kFlagsOffset));
......
......@@ -2449,7 +2449,7 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
// -----------------------------------
Label dont_adapt_arguments, stack_overflow, skip_adapt_arguments;
__ tmll(r4, Operand(SharedFunctionInfo::kDontAdaptArgumentsSentinel));
__ tmll(r4, Operand(kDontAdaptArgumentsSentinel));
__ b(Condition(1), &dont_adapt_arguments);
__ LoadP(r6, FieldMemOperand(r3, JSFunction::kSharedFunctionInfoOffset));
__ LoadlW(r6, FieldMemOperand(r6, SharedFunctionInfo::kFlagsOffset));
......
......@@ -158,7 +158,7 @@ Code BuildWithCodeStubAssemblerJS(Isolate* isolate, int32_t builtin_index,
Zone zone(isolate->allocator(), ZONE_NAME);
const int argc_with_recv =
(argc == SharedFunctionInfo::kDontAdaptArgumentsSentinel) ? 0 : argc + 1;
(argc == kDontAdaptArgumentsSentinel) ? 0 : argc + 1;
compiler::CodeAssemblerState state(
isolate, &zone, argc_with_recv, Code::BUILTIN, name,
PoisoningMitigationLevel::kDontPoison, builtin_index);
......
......@@ -1872,7 +1872,7 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
// -----------------------------------
Label dont_adapt_arguments, stack_overflow, skip_adapt_arguments;
__ cmpq(rbx, Immediate(SharedFunctionInfo::kDontAdaptArgumentsSentinel));
__ cmpq(rbx, Immediate(kDontAdaptArgumentsSentinel));
__ j(equal, &dont_adapt_arguments);
__ LoadTaggedPointerField(
rcx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset));
......
......@@ -2166,7 +2166,7 @@ void MacroAssembler::InvokeFunctionWithNewTarget(
LoadTaggedPointerField(cp,
FieldMemOperand(function, JSFunction::kContextOffset));
// The number of arguments is stored as an int32_t, and -1 is a marker
// (SharedFunctionInfo::kDontAdaptArgumentsSentinel), so we need sign
// (kDontAdaptArgumentsSentinel), so we need sign
// extension to correctly handle it.
LoadTaggedPointerField(
expected_parameter_count,
......
......@@ -1633,6 +1633,8 @@ constexpr int kFunctionLiteralIdTopLevel = 0;
constexpr int kSmallOrderedHashSetMinCapacity = 4;
constexpr int kSmallOrderedHashMapMinCapacity = 4;
static const uint16_t kDontAdaptArgumentsSentinel = static_cast<uint16_t>(-1);
// Opaque data type for identifying stack frames. Used extensively
// by the debugger.
// ID_MIN_VALUE and ID_MAX_VALUE are specified to ensure that enumeration type
......
......@@ -1530,7 +1530,7 @@ void ReduceBuiltin(JSGraph* jsgraph, Node* node, int builtin_index, int arity,
}
bool NeedsArgumentAdaptorFrame(SharedFunctionInfoRef shared, int arity) {
static const int sentinel = SharedFunctionInfo::kDontAdaptArgumentsSentinel;
static const int sentinel = kDontAdaptArgumentsSentinel;
const int num_decl_parms = shared.internal_formal_parameter_count();
return (num_decl_parms != arity && num_decl_parms != sentinel);
}
......
......@@ -3880,7 +3880,7 @@ TranslatedFrame* TranslatedState::GetArgumentsInfoFromJSFrameIndex(
if (frames_[i].kind() ==
TranslatedFrame::kJavaScriptBuiltinContinuation &&
frames_[i].shared_info()->internal_formal_parameter_count() ==
SharedFunctionInfo::kDontAdaptArgumentsSentinel) {
kDontAdaptArgumentsSentinel) {
DCHECK(frames_[i].shared_info()->IsApiFunction());
// The argument count for this special case is always the second
......
......@@ -192,8 +192,7 @@ inline JavaScriptFrame::JavaScriptFrame(StackFrameIteratorBase* iterator)
Address JavaScriptFrame::GetParameterSlot(int index) const {
int param_count = ComputeParametersCount();
DCHECK(-1 <= index &&
(index < param_count ||
param_count == SharedFunctionInfo::kDontAdaptArgumentsSentinel));
(index < param_count || param_count == kDontAdaptArgumentsSentinel));
int parameter_offset = (param_count - index - 1) * kSystemPointerSize;
return caller_sp() + parameter_offset;
}
......
......@@ -614,8 +614,6 @@ class SharedFunctionInfo : public HeapObject {
DECL_CAST(SharedFunctionInfo)
// Constants.
static const uint16_t kDontAdaptArgumentsSentinel = static_cast<uint16_t>(-1);
static const int kMaximumFunctionTokenOffset = kMaxUInt16 - 1;
static const uint16_t kFunctionTokenOutOfRange = static_cast<uint16_t>(-1);
STATIC_ASSERT(kMaximumFunctionTokenOffset + 1 == kFunctionTokenOutOfRange);
......
......@@ -2970,8 +2970,7 @@ void ImplementationVisitor::GenerateBuiltinDefinitionsAndInterfaceDescriptors(
} else {
builtin_definitions << "TFJ(" << builtin->ExternalName();
if (builtin->IsVarArgsJavaScript()) {
builtin_definitions
<< ", SharedFunctionInfo::kDontAdaptArgumentsSentinel";
builtin_definitions << ", kDontAdaptArgumentsSentinel";
} else {
DCHECK(builtin->IsFixedArgsJavaScript());
// FixedArg javascript builtins need to offer the parameter
......
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