19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package jdk.nashorn.internal.objects;
27
28 import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED;
29
30 import java.io.PrintWriter;
31 import java.util.LinkedList;
32 import java.util.Objects;
33 import jdk.nashorn.internal.objects.annotations.Attribute;
34 import jdk.nashorn.internal.objects.annotations.Function;
35 import jdk.nashorn.internal.objects.annotations.ScriptClass;
36 import jdk.nashorn.internal.objects.annotations.Where;
37 import jdk.nashorn.internal.runtime.Context;
38 import jdk.nashorn.internal.runtime.JSType;
39 import jdk.nashorn.internal.runtime.PropertyListeners;
40 import jdk.nashorn.internal.runtime.PropertyMap;
41 import jdk.nashorn.internal.runtime.Scope;
42 import jdk.nashorn.internal.runtime.ScriptFunction;
43 import jdk.nashorn.internal.runtime.ScriptObject;
44 import jdk.nashorn.internal.runtime.ScriptRuntime;
45 import jdk.nashorn.internal.runtime.events.RuntimeEvent;
46 import jdk.nashorn.internal.runtime.linker.LinkerCallSite;
47 import jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor;
48
49 /**
50 * Nashorn specific debug utils. This is meant for Nashorn developers.
51 * The interface is subject to change without notice!!
52 *
53 */
54 @ScriptClass("Debug")
55 public final class NativeDebug extends ScriptObject {
56
57 // initialized by nasgen
58 @SuppressWarnings("unused")
59 private static PropertyMap $nasgenmap$;
227 * Returns {@code true} if passed object is a function that is fully debuggable (has all vars in scope).
228 *
229 * @param self self reference
230 * @param obj object
231 * @return true {@code obj} is a debuggable function
232 */
233 @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
234 public static Object isDebuggableFunction(final Object self, final Object obj) {
235 return (obj instanceof ScriptFunction && ((ScriptFunction) obj).hasAllVarsInScope());
236 }
237
238 /**
239 * Returns the property listener count for a script object
240 *
241 * @param self self reference
242 * @param obj script object whose listener count is returned
243 * @return listener count
244 */
245 @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
246 public static int getListenerCount(final Object self, final Object obj) {
247 return (obj instanceof ScriptObject) ? PropertyListeners.getListenerCount((ScriptObject) obj) : 0;
248 }
249
250 /**
251 * Dump all Nashorn debug mode counters. Calling this may be better if
252 * you want to print all counters. This way you can avoid too many callsites
253 * due to counter access itself!!
254 * @param self self reference
255 * @return undefined
256 */
257 @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
258 public static Object dumpCounters(final Object self) {
259 final PrintWriter out = Context.getCurrentErr();
260
261 out.println("ScriptObject count " + ScriptObject.getCount());
262 out.println("Scope count " + Scope.getScopeCount());
263 out.println("ScriptObject listeners added " + PropertyListeners.getListenersAdded());
264 out.println("ScriptObject listeners removed " + PropertyListeners.getListenersRemoved());
265 out.println("ScriptFunction constructor calls " + ScriptFunction.getConstructorCount());
266 out.println("ScriptFunction invokes " + ScriptFunction.getInvokes());
267 out.println("ScriptFunction allocations " + ScriptFunction.getAllocations());
268 out.println("PropertyMap count " + PropertyMap.getCount());
269 out.println("PropertyMap cloned " + PropertyMap.getClonedCount());
270 out.println("PropertyMap history hit " + PropertyMap.getHistoryHit());
271 out.println("PropertyMap proto invalidations " + PropertyMap.getProtoInvalidations());
272 out.println("PropertyMap proto history hit " + PropertyMap.getProtoHistoryHit());
273 out.println("PropertyMap setProtoNewMapCount " + PropertyMap.getSetProtoNewMapCount());
274 out.println("Callsite count " + LinkerCallSite.getCount());
275 out.println("Callsite misses " + LinkerCallSite.getMissCount());
276 out.println("Callsite misses by site at " + LinkerCallSite.getMissSamplingPercentage() + "%");
277
278 LinkerCallSite.getMissCounts(out);
279
280 return UNDEFINED;
281 }
282
283 /*
284 * Framework for logging runtime events
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package jdk.nashorn.internal.objects;
27
28 import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED;
29
30 import java.io.PrintWriter;
31 import java.util.LinkedList;
32 import java.util.Objects;
33 import jdk.nashorn.internal.objects.annotations.Attribute;
34 import jdk.nashorn.internal.objects.annotations.Function;
35 import jdk.nashorn.internal.objects.annotations.ScriptClass;
36 import jdk.nashorn.internal.objects.annotations.Where;
37 import jdk.nashorn.internal.runtime.Context;
38 import jdk.nashorn.internal.runtime.JSType;
39 import jdk.nashorn.internal.runtime.PropertySwitchPoints;
40 import jdk.nashorn.internal.runtime.PropertyMap;
41 import jdk.nashorn.internal.runtime.Scope;
42 import jdk.nashorn.internal.runtime.ScriptFunction;
43 import jdk.nashorn.internal.runtime.ScriptObject;
44 import jdk.nashorn.internal.runtime.ScriptRuntime;
45 import jdk.nashorn.internal.runtime.events.RuntimeEvent;
46 import jdk.nashorn.internal.runtime.linker.LinkerCallSite;
47 import jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor;
48
49 /**
50 * Nashorn specific debug utils. This is meant for Nashorn developers.
51 * The interface is subject to change without notice!!
52 *
53 */
54 @ScriptClass("Debug")
55 public final class NativeDebug extends ScriptObject {
56
57 // initialized by nasgen
58 @SuppressWarnings("unused")
59 private static PropertyMap $nasgenmap$;
227 * Returns {@code true} if passed object is a function that is fully debuggable (has all vars in scope).
228 *
229 * @param self self reference
230 * @param obj object
231 * @return true {@code obj} is a debuggable function
232 */
233 @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
234 public static Object isDebuggableFunction(final Object self, final Object obj) {
235 return (obj instanceof ScriptFunction && ((ScriptFunction) obj).hasAllVarsInScope());
236 }
237
238 /**
239 * Returns the property listener count for a script object
240 *
241 * @param self self reference
242 * @param obj script object whose listener count is returned
243 * @return listener count
244 */
245 @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
246 public static int getListenerCount(final Object self, final Object obj) {
247 return (obj instanceof ScriptObject) ? PropertySwitchPoints.getSwitchPointCount((ScriptObject) obj) : 0;
248 }
249
250 /**
251 * Dump all Nashorn debug mode counters. Calling this may be better if
252 * you want to print all counters. This way you can avoid too many callsites
253 * due to counter access itself!!
254 * @param self self reference
255 * @return undefined
256 */
257 @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
258 public static Object dumpCounters(final Object self) {
259 final PrintWriter out = Context.getCurrentErr();
260
261 out.println("ScriptObject count " + ScriptObject.getCount());
262 out.println("Scope count " + Scope.getScopeCount());
263 out.println("Property SwitchPoints added " + PropertySwitchPoints.getSwitchPointsAdded());
264 out.println("Property SwitchPoints invalidated " + PropertySwitchPoints.getSwitchPointsInvalidated());
265 out.println("ScriptFunction constructor calls " + ScriptFunction.getConstructorCount());
266 out.println("ScriptFunction invokes " + ScriptFunction.getInvokes());
267 out.println("ScriptFunction allocations " + ScriptFunction.getAllocations());
268 out.println("PropertyMap count " + PropertyMap.getCount());
269 out.println("PropertyMap cloned " + PropertyMap.getClonedCount());
270 out.println("PropertyMap history hit " + PropertyMap.getHistoryHit());
271 out.println("PropertyMap proto invalidations " + PropertyMap.getProtoInvalidations());
272 out.println("PropertyMap proto history hit " + PropertyMap.getProtoHistoryHit());
273 out.println("PropertyMap setProtoNewMapCount " + PropertyMap.getSetProtoNewMapCount());
274 out.println("Callsite count " + LinkerCallSite.getCount());
275 out.println("Callsite misses " + LinkerCallSite.getMissCount());
276 out.println("Callsite misses by site at " + LinkerCallSite.getMissSamplingPercentage() + "%");
277
278 LinkerCallSite.getMissCounts(out);
279
280 return UNDEFINED;
281 }
282
283 /*
284 * Framework for logging runtime events
|