Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index 9ea131fa7b77e46ab1d19d86d6af3f46a30b3ebb..583af7c58a2f645b3fea67ee43f66f72d9888b62 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -1186,7 +1186,9 @@ void HeapNumber::HeapNumberPrint(StringStream* accumulator) { |
String* JSObject::class_name() { |
- if (IsJSFunction()) return Heap::function_class_symbol(); |
+ if (IsJSFunction()) { |
+ return Heap::function_class_symbol(); |
+ } |
if (map()->constructor()->IsJSFunction()) { |
JSFunction* constructor = JSFunction::cast(map()->constructor()); |
return String::cast(constructor->shared()->instance_class_name()); |
@@ -1196,6 +1198,20 @@ String* JSObject::class_name() { |
} |
+String* JSObject::constructor_name() { |
+ if (IsJSFunction()) { |
+ return Heap::function_class_symbol(); |
+ } |
+ if (map()->constructor()->IsJSFunction()) { |
+ JSFunction* constructor = JSFunction::cast(map()->constructor()); |
+ String* name = String::cast(constructor->shared()->name()); |
+ return name->length() > 0 ? name : constructor->shared()->inferred_name(); |
+ } |
+ // If the constructor is not present, return "Object". |
+ return Heap::Object_symbol(); |
+} |
+ |
+ |
void JSObject::JSObjectIterateBody(int object_size, ObjectVisitor* v) { |
// Iterate over all fields in the body. Assumes all are Object*. |
IteratePointers(v, kPropertiesOffset, object_size); |