Commit 58cb79e5 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

Reland "Make NoSideEffectsToString gracefully handle huge msgs on error objects"

This reverts commit e04fbec1.

Reason for revert: Innocent.

Original change's description:
> Revert "Make NoSideEffectsToString gracefully handle huge msgs on error objects"
> 
> This reverts commit b0ebfabc.
> 
> Reason for revert: Speculative revert for nvidia bot failure: https://ci.chromium.org/p/v8/builders/ci/Linux%20V8%20FYI%20Release%20(NVIDIA)/7953
> 
> Original change's description:
> > Make NoSideEffectsToString gracefully handle huge msgs on error objects
> > 
> > Bug: chromium:1032512
> > Change-Id: I323981a08e316ebc10c729f2f04b7832373937b0
> > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1962865
> > Reviewed-by: Jakob Gruber <jgruber@chromium.org>
> > Commit-Queue: Georg Neis <neis@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#65782}
> 
> TBR=neis@chromium.org,jgruber@chromium.org
> 
> Change-Id: Ibdc1efccab3edcd05dd1df99ad0263ea4bce9989
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: chromium:1032512
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2002532
> Reviewed-by: Clemens Backes <clemensb@chromium.org>
> Commit-Queue: Clemens Backes <clemensb@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#65793}

TBR=neis@chromium.org,jgruber@chromium.org,clemensb@chromium.org

Change-Id: I9b2f745b15495e21c21c3198f2362437dc4376c1
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:1032512
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2002539Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65801}
parent 6fad6b7e
...@@ -406,15 +406,13 @@ Handle<String> AsStringOrEmpty(Isolate* isolate, Handle<Object> object) { ...@@ -406,15 +406,13 @@ Handle<String> AsStringOrEmpty(Isolate* isolate, Handle<Object> object) {
} }
Handle<String> NoSideEffectsErrorToString(Isolate* isolate, Handle<String> NoSideEffectsErrorToString(Isolate* isolate,
Handle<Object> input) { Handle<JSReceiver> error) {
Handle<JSReceiver> receiver = Handle<JSReceiver>::cast(input);
Handle<Name> name_key = isolate->factory()->name_string(); Handle<Name> name_key = isolate->factory()->name_string();
Handle<Object> name = JSReceiver::GetDataProperty(receiver, name_key); Handle<Object> name = JSReceiver::GetDataProperty(error, name_key);
Handle<String> name_str = AsStringOrEmpty(isolate, name); Handle<String> name_str = AsStringOrEmpty(isolate, name);
Handle<Name> msg_key = isolate->factory()->message_string(); Handle<Name> msg_key = isolate->factory()->message_string();
Handle<Object> msg = JSReceiver::GetDataProperty(receiver, msg_key); Handle<Object> msg = JSReceiver::GetDataProperty(error, msg_key);
Handle<String> msg_str = AsStringOrEmpty(isolate, msg); Handle<String> msg_str = AsStringOrEmpty(isolate, msg);
if (name_str->length() == 0) return msg_str; if (name_str->length() == 0) return msg_str;
...@@ -423,7 +421,12 @@ Handle<String> NoSideEffectsErrorToString(Isolate* isolate, ...@@ -423,7 +421,12 @@ Handle<String> NoSideEffectsErrorToString(Isolate* isolate,
IncrementalStringBuilder builder(isolate); IncrementalStringBuilder builder(isolate);
builder.AppendString(name_str); builder.AppendString(name_str);
builder.AppendCString(": "); builder.AppendCString(": ");
builder.AppendString(msg_str);
if (builder.Length() + msg_str->length() <= String::kMaxLength) {
builder.AppendString(msg_str);
} else {
builder.AppendCString("<a very large string>");
}
return builder.Finish().ToHandleChecked(); return builder.Finish().ToHandleChecked();
} }
...@@ -494,7 +497,8 @@ Handle<String> Object::NoSideEffectsToString(Isolate* isolate, ...@@ -494,7 +497,8 @@ Handle<String> Object::NoSideEffectsToString(Isolate* isolate,
// When internally formatting error objects, use a side-effects-free // When internally formatting error objects, use a side-effects-free
// version of Error.prototype.toString independent of the actually // version of Error.prototype.toString independent of the actually
// installed toString method. // installed toString method.
return NoSideEffectsErrorToString(isolate, input); return NoSideEffectsErrorToString(isolate,
Handle<JSReceiver>::cast(input));
} else if (*to_string == *isolate->object_to_string()) { } else if (*to_string == *isolate->object_to_string()) {
Handle<Object> ctor = JSReceiver::GetDataProperty( Handle<Object> ctor = JSReceiver::GetDataProperty(
receiver, isolate->factory()->constructor_string()); receiver, isolate->factory()->constructor_string());
......
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