[cleanup] Eliminate non-const references in src/builtins
- Makes accessor and iteration methods on Arguments and derived classes const. Bug: v8:9429,v8:9396 Change-Id: I47b3d95ab72e689327a0d7b6a36a08b4e63f6d95 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1803336 Reviewed-by: Yang Guo <yangguo@chromium.org> Reviewed-by: Clemens Hammacher <clemensh@chromium.org> Commit-Queue: Bill Budge <bbudge@chromium.org> Cr-Commit-Position: refs/heads/master@{#63841}
This commit is contained in:
parent
e27b7b6069
commit
35e102f1b8
@ -9562,7 +9562,7 @@ debug::ConsoleCallArguments::ConsoleCallArguments(
|
||||
}
|
||||
|
||||
debug::ConsoleCallArguments::ConsoleCallArguments(
|
||||
internal::BuiltinArguments& args)
|
||||
const internal::BuiltinArguments& args)
|
||||
: v8::FunctionCallbackInfo<v8::Value>(
|
||||
nullptr,
|
||||
// Drop the first argument (receiver, i.e. the "console" object).
|
||||
|
@ -39,8 +39,7 @@ namespace internal {
|
||||
|
||||
namespace {
|
||||
void ConsoleCall(
|
||||
Isolate* isolate,
|
||||
internal::BuiltinArguments& args, // NOLINT(runtime/references)
|
||||
Isolate* isolate, const internal::BuiltinArguments& args,
|
||||
void (debug::ConsoleDelegate::*func)(const v8::debug::ConsoleCallArguments&,
|
||||
const v8::debug::ConsoleContext&)) {
|
||||
CHECK(!isolate->has_pending_exception());
|
||||
|
@ -59,7 +59,8 @@ TNode<JSProxy> ProxiesCodeStubAssembler::AllocateProxy(
|
||||
}
|
||||
|
||||
Node* ProxiesCodeStubAssembler::AllocateJSArrayForCodeStubArguments(
|
||||
Node* context, CodeStubArguments& args, Node* argc, ParameterMode mode) {
|
||||
Node* context, const CodeStubArguments& args, Node* argc,
|
||||
ParameterMode mode) {
|
||||
Comment("AllocateJSArrayForCodeStubArguments");
|
||||
|
||||
Label if_empty_array(this), allocate_js_array(this);
|
||||
|
@ -39,10 +39,9 @@ class ProxiesCodeStubAssembler : public CodeStubAssembler {
|
||||
kProxyContextLength,
|
||||
};
|
||||
|
||||
Node* AllocateJSArrayForCodeStubArguments(
|
||||
Node* context,
|
||||
CodeStubArguments& args, // NOLINT(runtime/references)
|
||||
Node* argc, ParameterMode mode);
|
||||
Node* AllocateJSArrayForCodeStubArguments(Node* context,
|
||||
const CodeStubArguments& args,
|
||||
Node* argc, ParameterMode mode);
|
||||
|
||||
private:
|
||||
Node* CreateProxyRevokeFunctionContext(Node* proxy, Node* native_context);
|
||||
|
@ -12,20 +12,21 @@
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
Handle<Object> BuiltinArguments::atOrUndefined(Isolate* isolate, int index) {
|
||||
Handle<Object> BuiltinArguments::atOrUndefined(Isolate* isolate,
|
||||
int index) const {
|
||||
if (index >= length()) {
|
||||
return isolate->factory()->undefined_value();
|
||||
}
|
||||
return at<Object>(index);
|
||||
}
|
||||
|
||||
Handle<Object> BuiltinArguments::receiver() { return at<Object>(0); }
|
||||
Handle<Object> BuiltinArguments::receiver() const { return at<Object>(0); }
|
||||
|
||||
Handle<JSFunction> BuiltinArguments::target() {
|
||||
Handle<JSFunction> BuiltinArguments::target() const {
|
||||
return Arguments::at<JSFunction>(Arguments::length() - 1 - kTargetOffset);
|
||||
}
|
||||
|
||||
Handle<HeapObject> BuiltinArguments::new_target() {
|
||||
Handle<HeapObject> BuiltinArguments::new_target() const {
|
||||
return Arguments::at<HeapObject>(Arguments::length() - 1 - kNewTargetOffset);
|
||||
}
|
||||
|
||||
|
@ -23,13 +23,13 @@ class BuiltinArguments : public Arguments {
|
||||
DCHECK_LE(1, this->length());
|
||||
}
|
||||
|
||||
Object operator[](int index) {
|
||||
Object operator[](int index) const {
|
||||
DCHECK_LT(index, length());
|
||||
return Arguments::operator[](index);
|
||||
}
|
||||
|
||||
template <class S = Object>
|
||||
Handle<S> at(int index) {
|
||||
Handle<S> at(int index) const {
|
||||
DCHECK_LT(index, length());
|
||||
return Arguments::at<S>(index);
|
||||
}
|
||||
@ -42,10 +42,10 @@ class BuiltinArguments : public Arguments {
|
||||
static constexpr int kNumExtraArgs = 4;
|
||||
static constexpr int kNumExtraArgsWithReceiver = 5;
|
||||
|
||||
inline Handle<Object> atOrUndefined(Isolate* isolate, int index);
|
||||
inline Handle<Object> receiver();
|
||||
inline Handle<JSFunction> target();
|
||||
inline Handle<HeapObject> new_target();
|
||||
inline Handle<Object> atOrUndefined(Isolate* isolate, int index) const;
|
||||
inline Handle<Object> receiver() const;
|
||||
inline Handle<JSFunction> target() const;
|
||||
inline Handle<HeapObject> new_target() const;
|
||||
|
||||
// Gets the total number of arguments including the receiver (but
|
||||
// excluding extra arguments).
|
||||
|
@ -13621,7 +13621,7 @@ TNode<Object> CodeStubArguments::GetOptionalArgumentValue(
|
||||
void CodeStubArguments::ForEach(
|
||||
const CodeStubAssembler::VariableList& vars,
|
||||
const CodeStubArguments::ForEachBodyFunction& body, TNode<IntPtrT> first,
|
||||
TNode<IntPtrT> last) {
|
||||
TNode<IntPtrT> last) const {
|
||||
assembler_->Comment("CodeStubArguments::ForEach");
|
||||
if (first == nullptr) {
|
||||
first = assembler_->IntPtrConstant(0);
|
||||
|
@ -3923,7 +3923,7 @@ class V8_EXPORT_PRIVATE CodeStubArguments {
|
||||
// Iteration doesn't include the receiver. |first| and |last| are zero-based.
|
||||
template <typename TIndex>
|
||||
void ForEach(const ForEachBodyFunction& body, TNode<TIndex> first = {},
|
||||
TNode<TIndex> last = {}) {
|
||||
TNode<TIndex> last = {}) const {
|
||||
CodeStubAssembler::VariableList list(0, assembler_->zone());
|
||||
ForEach(list, body, first, last);
|
||||
}
|
||||
@ -3931,11 +3931,11 @@ class V8_EXPORT_PRIVATE CodeStubArguments {
|
||||
// Iteration doesn't include the receiver. |first| and |last| are zero-based.
|
||||
void ForEach(const CodeStubAssembler::VariableList& vars,
|
||||
const ForEachBodyFunction& body, TNode<IntPtrT> first = {},
|
||||
TNode<IntPtrT> last = {});
|
||||
TNode<IntPtrT> last = {}) const;
|
||||
|
||||
void ForEach(const CodeStubAssembler::VariableList& vars,
|
||||
const ForEachBodyFunction& body, TNode<Smi> first,
|
||||
TNode<Smi> last = {}) {
|
||||
TNode<Smi> last = {}) const {
|
||||
TNode<IntPtrT> first_intptr = assembler_->ParameterToIntPtr(first);
|
||||
TNode<IntPtrT> last_intptr;
|
||||
if (last != nullptr) {
|
||||
|
@ -129,7 +129,7 @@ class ConsoleCallArguments : private v8::FunctionCallbackInfo<v8::Value> {
|
||||
}
|
||||
|
||||
explicit ConsoleCallArguments(const v8::FunctionCallbackInfo<v8::Value>&);
|
||||
explicit ConsoleCallArguments(internal::BuiltinArguments&);
|
||||
explicit ConsoleCallArguments(const internal::BuiltinArguments&);
|
||||
};
|
||||
|
||||
class ConsoleContext {
|
||||
|
@ -14,15 +14,15 @@ namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
template <class S>
|
||||
Handle<S> Arguments::at(int index) {
|
||||
Handle<S> Arguments::at(int index) const {
|
||||
return Handle<S>::cast(at<Object>(index));
|
||||
}
|
||||
|
||||
int Arguments::smi_at(int index) {
|
||||
int Arguments::smi_at(int index) const {
|
||||
return Smi::ToInt(Object(*address_of_arg_at(index)));
|
||||
}
|
||||
|
||||
double Arguments::number_at(int index) { return (*this)[index].Number(); }
|
||||
double Arguments::number_at(int index) const { return (*this)[index].Number(); }
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
@ -37,24 +37,26 @@ class Arguments {
|
||||
DCHECK_GE(length_, 0);
|
||||
}
|
||||
|
||||
Object operator[](int index) { return Object(*address_of_arg_at(index)); }
|
||||
Object operator[](int index) const {
|
||||
return Object(*address_of_arg_at(index));
|
||||
}
|
||||
|
||||
template <class S = Object>
|
||||
inline Handle<S> at(int index);
|
||||
inline Handle<S> at(int index) const;
|
||||
|
||||
inline int smi_at(int index);
|
||||
inline int smi_at(int index) const;
|
||||
|
||||
inline double number_at(int index);
|
||||
inline double number_at(int index) const;
|
||||
|
||||
inline void set_at(int index, Object value) {
|
||||
*address_of_arg_at(index) = value.ptr();
|
||||
}
|
||||
|
||||
inline FullObjectSlot slot_at(int index) {
|
||||
inline FullObjectSlot slot_at(int index) const {
|
||||
return FullObjectSlot(address_of_arg_at(index));
|
||||
}
|
||||
|
||||
inline Address* address_of_arg_at(int index) {
|
||||
inline Address* address_of_arg_at(int index) const {
|
||||
DCHECK_LT(static_cast<uint32_t>(index), static_cast<uint32_t>(length_));
|
||||
return reinterpret_cast<Address*>(reinterpret_cast<Address>(arguments_) -
|
||||
index * kSystemPointerSize);
|
||||
@ -64,8 +66,8 @@ class Arguments {
|
||||
int length() const { return static_cast<int>(length_); }
|
||||
|
||||
// Arguments on the stack are in reverse order (compared to an array).
|
||||
FullObjectSlot first_slot() { return slot_at(length() - 1); }
|
||||
FullObjectSlot last_slot() { return slot_at(0); }
|
||||
FullObjectSlot first_slot() const { return slot_at(length() - 1); }
|
||||
FullObjectSlot last_slot() const { return slot_at(0); }
|
||||
|
||||
private:
|
||||
intptr_t length_;
|
||||
@ -73,7 +75,7 @@ class Arguments {
|
||||
};
|
||||
|
||||
template <>
|
||||
inline Handle<Object> Arguments::at(int index) {
|
||||
inline Handle<Object> Arguments::at(int index) const {
|
||||
return Handle<Object>(address_of_arg_at(index));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user