Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(640)

Unified Diff: src/objects.cc

Issue 2206313002: Handle stack overflows in NoSideEffectToString (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Disallow recursion in NoSideEffectToString Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-633998.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 94b57afb85ac00d7ccbd90dc8b82eea9fbbdf311..b0c4723d4080c432f7fcecd55e6e670beaee96ce 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -228,21 +228,22 @@ bool IsErrorObject(Isolate* isolate, Handle<Object> object) {
.FromMaybe(false);
}
+Handle<String> AsStringOrEmpty(Isolate* isolate, Handle<Object> object) {
+ return object->IsString() ? Handle<String>::cast(object)
+ : isolate->factory()->empty_string();
+}
+
Handle<String> NoSideEffectsErrorToString(Isolate* isolate,
Handle<Object> input) {
Handle<JSReceiver> receiver = Handle<JSReceiver>::cast(input);
Handle<Name> name_key = isolate->factory()->name_string();
Handle<Object> name = JSReceiver::GetDataProperty(receiver, name_key);
- Handle<String> name_str = (name->IsUndefined(isolate))
- ? isolate->factory()->Error_string()
- : Object::NoSideEffectsToString(isolate, name);
+ Handle<String> name_str = AsStringOrEmpty(isolate, name);
Handle<Name> msg_key = isolate->factory()->message_string();
Handle<Object> msg = JSReceiver::GetDataProperty(receiver, msg_key);
- Handle<String> msg_str = (msg->IsUndefined(isolate))
- ? isolate->factory()->empty_string()
- : Object::NoSideEffectsToString(isolate, msg);
+ Handle<String> msg_str = AsStringOrEmpty(isolate, msg);
if (name_str->length() == 0) return msg_str;
if (msg_str->length() == 0) return name_str;
@@ -321,7 +322,7 @@ Handle<String> Object::NoSideEffectsToString(Isolate* isolate,
} else if (ctor->IsJSFunction()) {
Handle<Object> ctor_name_obj =
JSFunction::GetName(isolate, Handle<JSFunction>::cast(ctor));
- ctor_name = NoSideEffectsToString(isolate, ctor_name_obj);
+ ctor_name = AsStringOrEmpty(isolate, ctor_name_obj);
}
if (ctor_name->length() != 0) {
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-633998.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698