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