Commit e362c487 authored by Bill Budge's avatar Bill Budge Committed by Commit Bot

[cleanup] Eliminate non-const reference parameters

- Eliminates non-const reference parameters in src/objects.

Bug: v8:9429
Change-Id: Ic39a59d54bda26c622db29f07143055c3cc6c7a0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1794683Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Bill Budge <bbudge@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63650}
parent 6a5c85ff
...@@ -2059,7 +2059,7 @@ void Isolate::PrintCurrentStackTrace(FILE* out) { ...@@ -2059,7 +2059,7 @@ void Isolate::PrintCurrentStackTrace(FILE* out) {
for (int i = 0; i < frames->length(); ++i) { for (int i = 0; i < frames->length(); ++i) {
Handle<StackTraceFrame> frame(StackTraceFrame::cast(frames->get(i)), this); Handle<StackTraceFrame> frame(StackTraceFrame::cast(frames->get(i)), this);
SerializeStackTraceFrame(this, frame, builder); SerializeStackTraceFrame(this, frame, &builder);
} }
Handle<String> stack_trace = builder.Finish().ToHandleChecked(); Handle<String> stack_trace = builder.Finish().ToHandleChecked();
......
...@@ -894,7 +894,7 @@ MaybeHandle<Object> ErrorUtils::FormatStackTrace(Isolate* isolate, ...@@ -894,7 +894,7 @@ MaybeHandle<Object> ErrorUtils::FormatStackTrace(Isolate* isolate,
Handle<StackTraceFrame> frame(StackTraceFrame::cast(elems->get(i)), Handle<StackTraceFrame> frame(StackTraceFrame::cast(elems->get(i)),
isolate); isolate);
SerializeStackTraceFrame(isolate, frame, builder); SerializeStackTraceFrame(isolate, frame, &builder);
if (isolate->has_pending_exception()) { if (isolate->has_pending_exception()) {
// CallSite.toString threw. Parts of the current frame might have been // CallSite.toString threw. Parts of the current frame might have been
......
...@@ -941,7 +941,7 @@ icu::Calendar* CreateCalendar(Isolate* isolate, const icu::Locale& icu_locale, ...@@ -941,7 +941,7 @@ icu::Calendar* CreateCalendar(Isolate* isolate, const icu::Locale& icu_locale,
std::unique_ptr<icu::SimpleDateFormat> CreateICUDateFormat( std::unique_ptr<icu::SimpleDateFormat> CreateICUDateFormat(
const icu::Locale& icu_locale, const icu::UnicodeString& skeleton, const icu::Locale& icu_locale, const icu::UnicodeString& skeleton,
icu::DateTimePatternGenerator& generator) { // NOLINT(runtime/references) icu::DateTimePatternGenerator* generator) {
// See https://github.com/tc39/ecma402/issues/225 . The best pattern // See https://github.com/tc39/ecma402/issues/225 . The best pattern
// generation needs to be done in the base locale according to the // generation needs to be done in the base locale according to the
// current spec however odd it may be. See also crbug.com/826549 . // current spec however odd it may be. See also crbug.com/826549 .
...@@ -954,8 +954,8 @@ std::unique_ptr<icu::SimpleDateFormat> CreateICUDateFormat( ...@@ -954,8 +954,8 @@ std::unique_ptr<icu::SimpleDateFormat> CreateICUDateFormat(
// has to be discussed. Revisit once the spec is clarified/revised. // has to be discussed. Revisit once the spec is clarified/revised.
icu::UnicodeString pattern; icu::UnicodeString pattern;
UErrorCode status = U_ZERO_ERROR; UErrorCode status = U_ZERO_ERROR;
pattern = generator.getBestPattern(skeleton, UDATPG_MATCH_HOUR_FIELD_LENGTH, pattern = generator->getBestPattern(skeleton, UDATPG_MATCH_HOUR_FIELD_LENGTH,
status); status);
CHECK(U_SUCCESS(status)); CHECK(U_SUCCESS(status));
// Make formatter from skeleton. Calendar and numbering system are added // Make formatter from skeleton. Calendar and numbering system are added
...@@ -971,9 +971,9 @@ std::unique_ptr<icu::SimpleDateFormat> CreateICUDateFormat( ...@@ -971,9 +971,9 @@ std::unique_ptr<icu::SimpleDateFormat> CreateICUDateFormat(
class DateFormatCache { class DateFormatCache {
public: public:
icu::SimpleDateFormat* Create( icu::SimpleDateFormat* Create(const icu::Locale& icu_locale,
const icu::Locale& icu_locale, const icu::UnicodeString& skeleton, const icu::UnicodeString& skeleton,
icu::DateTimePatternGenerator& generator) { // NOLINT(runtime/references) icu::DateTimePatternGenerator* generator) {
std::string key; std::string key;
skeleton.toUTF8String<std::string>(key); skeleton.toUTF8String<std::string>(key);
key += ":"; key += ":";
...@@ -1002,7 +1002,7 @@ class DateFormatCache { ...@@ -1002,7 +1002,7 @@ class DateFormatCache {
std::unique_ptr<icu::SimpleDateFormat> CreateICUDateFormatFromCache( std::unique_ptr<icu::SimpleDateFormat> CreateICUDateFormatFromCache(
const icu::Locale& icu_locale, const icu::UnicodeString& skeleton, const icu::Locale& icu_locale, const icu::UnicodeString& skeleton,
icu::DateTimePatternGenerator& generator) { // NOLINT(runtime/references) icu::DateTimePatternGenerator* generator) {
static base::LazyInstance<DateFormatCache>::type cache = static base::LazyInstance<DateFormatCache>::type cache =
LAZY_INSTANCE_INITIALIZER; LAZY_INSTANCE_INITIALIZER;
return std::unique_ptr<icu::SimpleDateFormat>( return std::unique_ptr<icu::SimpleDateFormat>(
...@@ -1138,8 +1138,7 @@ icu::UnicodeString ReplaceSkeleton(const icu::UnicodeString input, ...@@ -1138,8 +1138,7 @@ icu::UnicodeString ReplaceSkeleton(const icu::UnicodeString input,
std::unique_ptr<icu::SimpleDateFormat> DateTimeStylePattern( std::unique_ptr<icu::SimpleDateFormat> DateTimeStylePattern(
JSDateTimeFormat::DateTimeStyle date_style, JSDateTimeFormat::DateTimeStyle date_style,
JSDateTimeFormat::DateTimeStyle time_style, const icu::Locale& icu_locale, JSDateTimeFormat::DateTimeStyle time_style, const icu::Locale& icu_locale,
Intl::HourCycle hc, Intl::HourCycle hc, icu::DateTimePatternGenerator* generator) {
icu::DateTimePatternGenerator& generator) { // NOLINT(runtime/references)
std::unique_ptr<icu::SimpleDateFormat> result; std::unique_ptr<icu::SimpleDateFormat> result;
if (date_style != JSDateTimeFormat::DateTimeStyle::kUndefined) { if (date_style != JSDateTimeFormat::DateTimeStyle::kUndefined) {
if (time_style != JSDateTimeFormat::DateTimeStyle::kUndefined) { if (time_style != JSDateTimeFormat::DateTimeStyle::kUndefined) {
...@@ -1443,7 +1442,7 @@ MaybeHandle<JSDateTimeFormat> JSDateTimeFormat::New( ...@@ -1443,7 +1442,7 @@ MaybeHandle<JSDateTimeFormat> JSDateTimeFormat::New(
if (date_style != DateTimeStyle::kUndefined || if (date_style != DateTimeStyle::kUndefined ||
time_style != DateTimeStyle::kUndefined) { time_style != DateTimeStyle::kUndefined) {
icu_date_format = DateTimeStylePattern(date_style, time_style, icu_locale, icu_date_format = DateTimeStylePattern(date_style, time_style, icu_locale,
hc, *generator); hc, generator.get());
} }
} }
// 33. Else, // 33. Else,
...@@ -1496,13 +1495,13 @@ MaybeHandle<JSDateTimeFormat> JSDateTimeFormat::New( ...@@ -1496,13 +1495,13 @@ MaybeHandle<JSDateTimeFormat> JSDateTimeFormat::New(
// FormatMatcherOption format_matcher = maybe_format_matcher.FromJust(); // FormatMatcherOption format_matcher = maybe_format_matcher.FromJust();
icu::UnicodeString skeleton_ustr(skeleton.c_str()); icu::UnicodeString skeleton_ustr(skeleton.c_str());
icu_date_format = icu_date_format = CreateICUDateFormatFromCache(icu_locale, skeleton_ustr,
CreateICUDateFormatFromCache(icu_locale, skeleton_ustr, *generator); generator.get());
if (icu_date_format.get() == nullptr) { if (icu_date_format.get() == nullptr) {
// Remove extensions and try again. // Remove extensions and try again.
icu_locale = icu::Locale(icu_locale.getBaseName()); icu_locale = icu::Locale(icu_locale.getBaseName());
icu_date_format = icu_date_format = CreateICUDateFormatFromCache(icu_locale, skeleton_ustr,
CreateICUDateFormatFromCache(icu_locale, skeleton_ustr, *generator); generator.get());
if (icu_date_format.get() == nullptr) { if (icu_date_format.get() == nullptr) {
FATAL("Failed to create ICU date format, are ICU data files missing?"); FATAL("Failed to create ICU date format, are ICU data files missing?");
} }
......
...@@ -1094,8 +1094,7 @@ Maybe<bool> SetPropertyWithInterceptorInternal( ...@@ -1094,8 +1094,7 @@ Maybe<bool> SetPropertyWithInterceptorInternal(
Maybe<bool> DefinePropertyWithInterceptorInternal( Maybe<bool> DefinePropertyWithInterceptorInternal(
LookupIterator* it, Handle<InterceptorInfo> interceptor, LookupIterator* it, Handle<InterceptorInfo> interceptor,
Maybe<ShouldThrow> should_throw, Maybe<ShouldThrow> should_throw, PropertyDescriptor* desc) {
PropertyDescriptor& desc) { // NOLINT(runtime/references)
Isolate* isolate = it->isolate(); Isolate* isolate = it->isolate();
// Make sure that the top context does not change when doing callbacks or // Make sure that the top context does not change when doing callbacks or
// interceptor calls. // interceptor calls.
...@@ -1116,23 +1115,23 @@ Maybe<bool> DefinePropertyWithInterceptorInternal( ...@@ -1116,23 +1115,23 @@ Maybe<bool> DefinePropertyWithInterceptorInternal(
std::unique_ptr<v8::PropertyDescriptor> descriptor( std::unique_ptr<v8::PropertyDescriptor> descriptor(
new v8::PropertyDescriptor()); new v8::PropertyDescriptor());
if (PropertyDescriptor::IsAccessorDescriptor(&desc)) { if (PropertyDescriptor::IsAccessorDescriptor(desc)) {
descriptor.reset(new v8::PropertyDescriptor( descriptor.reset(new v8::PropertyDescriptor(
v8::Utils::ToLocal(desc.get()), v8::Utils::ToLocal(desc.set()))); v8::Utils::ToLocal(desc->get()), v8::Utils::ToLocal(desc->set())));
} else if (PropertyDescriptor::IsDataDescriptor(&desc)) { } else if (PropertyDescriptor::IsDataDescriptor(desc)) {
if (desc.has_writable()) { if (desc->has_writable()) {
descriptor.reset(new v8::PropertyDescriptor( descriptor.reset(new v8::PropertyDescriptor(
v8::Utils::ToLocal(desc.value()), desc.writable())); v8::Utils::ToLocal(desc->value()), desc->writable()));
} else { } else {
descriptor.reset( descriptor.reset(
new v8::PropertyDescriptor(v8::Utils::ToLocal(desc.value()))); new v8::PropertyDescriptor(v8::Utils::ToLocal(desc->value())));
} }
} }
if (desc.has_enumerable()) { if (desc->has_enumerable()) {
descriptor->set_enumerable(desc.enumerable()); descriptor->set_enumerable(desc->enumerable());
} }
if (desc.has_configurable()) { if (desc->has_configurable()) {
descriptor->set_configurable(desc.configurable()); descriptor->set_configurable(desc->configurable());
} }
if (it->IsElement()) { if (it->IsElement()) {
...@@ -1166,7 +1165,7 @@ Maybe<bool> JSReceiver::OrdinaryDefineOwnProperty( ...@@ -1166,7 +1165,7 @@ Maybe<bool> JSReceiver::OrdinaryDefineOwnProperty(
if (it->state() == LookupIterator::INTERCEPTOR) { if (it->state() == LookupIterator::INTERCEPTOR) {
if (it->HolderIsReceiverOrHiddenPrototype()) { if (it->HolderIsReceiverOrHiddenPrototype()) {
Maybe<bool> result = DefinePropertyWithInterceptorInternal( Maybe<bool> result = DefinePropertyWithInterceptorInternal(
it, it->GetInterceptor(), should_throw, *desc); it, it->GetInterceptor(), should_throw, desc);
if (result.IsNothing() || result.FromJust()) { if (result.IsNothing() || result.FromJust()) {
return result; return result;
} }
......
...@@ -299,10 +299,8 @@ void AppendMethodCall(Isolate* isolate, Handle<StackTraceFrame> frame, ...@@ -299,10 +299,8 @@ void AppendMethodCall(Isolate* isolate, Handle<StackTraceFrame> frame,
} }
} }
void SerializeJSStackFrame( void SerializeJSStackFrame(Isolate* isolate, Handle<StackTraceFrame> frame,
Isolate* isolate, Handle<StackTraceFrame> frame, IncrementalStringBuilder* builder) {
IncrementalStringBuilder& builder // NOLINT(runtime/references)
) {
Handle<Object> function_name = StackTraceFrame::GetFunctionName(frame); Handle<Object> function_name = StackTraceFrame::GetFunctionName(frame);
const bool is_toplevel = StackTraceFrame::IsToplevel(frame); const bool is_toplevel = StackTraceFrame::IsToplevel(frame);
...@@ -316,96 +314,91 @@ void SerializeJSStackFrame( ...@@ -316,96 +314,91 @@ void SerializeJSStackFrame(
const bool is_method_call = !(is_toplevel || is_constructor); const bool is_method_call = !(is_toplevel || is_constructor);
if (is_async) { if (is_async) {
builder.AppendCString("async "); builder->AppendCString("async ");
} }
if (is_promise_all) { if (is_promise_all) {
builder.AppendCString("Promise.all (index "); builder->AppendCString("Promise.all (index ");
builder.AppendInt(StackTraceFrame::GetPromiseAllIndex(frame)); builder->AppendInt(StackTraceFrame::GetPromiseAllIndex(frame));
builder.AppendCString(")"); builder->AppendCString(")");
return; return;
} }
if (is_method_call) { if (is_method_call) {
AppendMethodCall(isolate, frame, &builder); AppendMethodCall(isolate, frame, builder);
} else if (is_constructor) { } else if (is_constructor) {
builder.AppendCString("new "); builder->AppendCString("new ");
if (IsNonEmptyString(function_name)) { if (IsNonEmptyString(function_name)) {
builder.AppendString(Handle<String>::cast(function_name)); builder->AppendString(Handle<String>::cast(function_name));
} else { } else {
builder.AppendCString("<anonymous>"); builder->AppendCString("<anonymous>");
} }
} else if (IsNonEmptyString(function_name)) { } else if (IsNonEmptyString(function_name)) {
builder.AppendString(Handle<String>::cast(function_name)); builder->AppendString(Handle<String>::cast(function_name));
} else { } else {
AppendFileLocation(isolate, frame, &builder); AppendFileLocation(isolate, frame, builder);
return; return;
} }
builder.AppendCString(" ("); builder->AppendCString(" (");
AppendFileLocation(isolate, frame, &builder); AppendFileLocation(isolate, frame, builder);
builder.AppendCString(")"); builder->AppendCString(")");
} }
void SerializeAsmJsWasmStackFrame( void SerializeAsmJsWasmStackFrame(Isolate* isolate,
Isolate* isolate, Handle<StackTraceFrame> frame, Handle<StackTraceFrame> frame,
IncrementalStringBuilder& builder // NOLINT(runtime/references) IncrementalStringBuilder* builder) {
) {
// The string should look exactly as the respective javascript frame string. // The string should look exactly as the respective javascript frame string.
// Keep this method in line to // Keep this method in line to
// JSStackFrame::ToString(IncrementalStringBuilder&). // JSStackFrame::ToString(IncrementalStringBuilder&).
Handle<Object> function_name = StackTraceFrame::GetFunctionName(frame); Handle<Object> function_name = StackTraceFrame::GetFunctionName(frame);
if (IsNonEmptyString(function_name)) { if (IsNonEmptyString(function_name)) {
builder.AppendString(Handle<String>::cast(function_name)); builder->AppendString(Handle<String>::cast(function_name));
builder.AppendCString(" ("); builder->AppendCString(" (");
} }
AppendFileLocation(isolate, frame, &builder); AppendFileLocation(isolate, frame, builder);
if (IsNonEmptyString(function_name)) builder.AppendCString(")"); if (IsNonEmptyString(function_name)) builder->AppendCString(")");
return; return;
} }
void SerializeWasmStackFrame( void SerializeWasmStackFrame(Isolate* isolate, Handle<StackTraceFrame> frame,
Isolate* isolate, Handle<StackTraceFrame> frame, IncrementalStringBuilder* builder) {
IncrementalStringBuilder& builder // NOLINT(runtime/references)
) {
Handle<Object> module_name = StackTraceFrame::GetWasmModuleName(frame); Handle<Object> module_name = StackTraceFrame::GetWasmModuleName(frame);
Handle<Object> function_name = StackTraceFrame::GetFunctionName(frame); Handle<Object> function_name = StackTraceFrame::GetFunctionName(frame);
const bool has_name = !module_name->IsNull() || !function_name->IsNull(); const bool has_name = !module_name->IsNull() || !function_name->IsNull();
if (has_name) { if (has_name) {
if (module_name->IsNull()) { if (module_name->IsNull()) {
builder.AppendString(Handle<String>::cast(function_name)); builder->AppendString(Handle<String>::cast(function_name));
} else { } else {
builder.AppendString(Handle<String>::cast(module_name)); builder->AppendString(Handle<String>::cast(module_name));
if (!function_name->IsNull()) { if (!function_name->IsNull()) {
builder.AppendCString("."); builder->AppendCString(".");
builder.AppendString(Handle<String>::cast(function_name)); builder->AppendString(Handle<String>::cast(function_name));
} }
} }
builder.AppendCString(" ("); builder->AppendCString(" (");
} }
const int wasm_func_index = StackTraceFrame::GetLineNumber(frame); const int wasm_func_index = StackTraceFrame::GetLineNumber(frame);
builder.AppendCString("wasm-function["); builder->AppendCString("wasm-function[");
builder.AppendInt(wasm_func_index); builder->AppendInt(wasm_func_index);
builder.AppendCString("]:"); builder->AppendCString("]:");
char buffer[16]; char buffer[16];
SNPrintF(ArrayVector(buffer), "0x%x", SNPrintF(ArrayVector(buffer), "0x%x",
StackTraceFrame::GetColumnNumber(frame)); StackTraceFrame::GetColumnNumber(frame));
builder.AppendCString(buffer); builder->AppendCString(buffer);
if (has_name) builder.AppendCString(")"); if (has_name) builder->AppendCString(")");
} }
} // namespace } // namespace
void SerializeStackTraceFrame( void SerializeStackTraceFrame(Isolate* isolate, Handle<StackTraceFrame> frame,
Isolate* isolate, Handle<StackTraceFrame> frame, IncrementalStringBuilder* builder) {
IncrementalStringBuilder& builder // NOLINT(runtime/references)
) {
// Ordering here is important, as AsmJs frames are also marked as Wasm. // Ordering here is important, as AsmJs frames are also marked as Wasm.
if (StackTraceFrame::IsAsmJsWasm(frame)) { if (StackTraceFrame::IsAsmJsWasm(frame)) {
SerializeAsmJsWasmStackFrame(isolate, frame, builder); SerializeAsmJsWasmStackFrame(isolate, frame, builder);
...@@ -419,7 +412,7 @@ void SerializeStackTraceFrame( ...@@ -419,7 +412,7 @@ void SerializeStackTraceFrame(
MaybeHandle<String> SerializeStackTraceFrame(Isolate* isolate, MaybeHandle<String> SerializeStackTraceFrame(Isolate* isolate,
Handle<StackTraceFrame> frame) { Handle<StackTraceFrame> frame) {
IncrementalStringBuilder builder(isolate); IncrementalStringBuilder builder(isolate);
SerializeStackTraceFrame(isolate, frame, builder); SerializeStackTraceFrame(isolate, frame, &builder);
return builder.Finish(); return builder.Finish();
} }
......
...@@ -124,10 +124,8 @@ Handle<FrameArray> GetFrameArrayFromStackTrace(Isolate* isolate, ...@@ -124,10 +124,8 @@ Handle<FrameArray> GetFrameArrayFromStackTrace(Isolate* isolate,
Handle<FixedArray> stack_trace); Handle<FixedArray> stack_trace);
class IncrementalStringBuilder; class IncrementalStringBuilder;
void SerializeStackTraceFrame( void SerializeStackTraceFrame(Isolate* isolate, Handle<StackTraceFrame> frame,
Isolate* isolate, Handle<StackTraceFrame> frame, IncrementalStringBuilder* builder);
IncrementalStringBuilder& builder // NOLINT(runtime/references)
);
MaybeHandle<String> SerializeStackTraceFrame(Isolate* isolate, MaybeHandle<String> SerializeStackTraceFrame(Isolate* isolate,
Handle<StackTraceFrame> frame); Handle<StackTraceFrame> frame);
......
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