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

Side by Side Diff: src/objects.cc

Issue 5256004: Expose an API method for getting JSObject constructor name (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/heap-profiler.cc ('k') | src/profile-generator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 if (map()->constructor()->IsJSFunction()) { 1159 if (map()->constructor()->IsJSFunction()) {
1160 JSFunction* constructor = JSFunction::cast(map()->constructor()); 1160 JSFunction* constructor = JSFunction::cast(map()->constructor());
1161 return String::cast(constructor->shared()->instance_class_name()); 1161 return String::cast(constructor->shared()->instance_class_name());
1162 } 1162 }
1163 // If the constructor is not present, return "Object". 1163 // If the constructor is not present, return "Object".
1164 return Heap::Object_symbol(); 1164 return Heap::Object_symbol();
1165 } 1165 }
1166 1166
1167 1167
1168 String* JSObject::constructor_name() { 1168 String* JSObject::constructor_name() {
1169 if (IsJSFunction()) {
1170 return Heap::closure_symbol();
1171 }
1172 if (map()->constructor()->IsJSFunction()) { 1169 if (map()->constructor()->IsJSFunction()) {
1173 JSFunction* constructor = JSFunction::cast(map()->constructor()); 1170 JSFunction* constructor = JSFunction::cast(map()->constructor());
1174 String* name = String::cast(constructor->shared()->name()); 1171 String* name = String::cast(constructor->shared()->name());
1175 if (name->length() > 0) return name; 1172 if (name->length() > 0) return name;
1176 String* inferred_name = constructor->shared()->inferred_name(); 1173 String* inferred_name = constructor->shared()->inferred_name();
1177 if (inferred_name->length() > 0) return inferred_name; 1174 if (inferred_name->length() > 0) return inferred_name;
1178 Object* proto = GetPrototype(); 1175 Object* proto = GetPrototype();
1179 if (proto->IsJSObject()) return JSObject::cast(proto)->constructor_name(); 1176 if (proto->IsJSObject()) return JSObject::cast(proto)->constructor_name();
1180 } 1177 }
1181 // If the constructor is not present, return "Object". 1178 // If the constructor is not present, return "Object".
(...skipping 8165 matching lines...) Expand 10 before | Expand all | Expand 10 after
9347 if (break_point_objects()->IsUndefined()) return 0; 9344 if (break_point_objects()->IsUndefined()) return 0;
9348 // Single beak point. 9345 // Single beak point.
9349 if (!break_point_objects()->IsFixedArray()) return 1; 9346 if (!break_point_objects()->IsFixedArray()) return 1;
9350 // Multiple break points. 9347 // Multiple break points.
9351 return FixedArray::cast(break_point_objects())->length(); 9348 return FixedArray::cast(break_point_objects())->length();
9352 } 9349 }
9353 #endif 9350 #endif
9354 9351
9355 9352
9356 } } // namespace v8::internal 9353 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap-profiler.cc ('k') | src/profile-generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698