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 import java.io.PrintWriter;
30 import java.util.LinkedList;
31 import java.util.Objects;
32 import jdk.nashorn.internal.objects.annotations.Attribute;
33 import jdk.nashorn.internal.objects.annotations.Function;
34 import jdk.nashorn.internal.objects.annotations.ScriptClass;
35 import jdk.nashorn.internal.objects.annotations.Where;
36 import jdk.nashorn.internal.runtime.Context;
37 import jdk.nashorn.internal.runtime.JSType;
38 import jdk.nashorn.internal.runtime.PropertyListeners;
39 import jdk.nashorn.internal.runtime.PropertyMap;
40 import jdk.nashorn.internal.runtime.ScriptFunction;
41 import jdk.nashorn.internal.runtime.ScriptObject;
42 import jdk.nashorn.internal.runtime.ScriptRuntime;
43 import jdk.nashorn.internal.runtime.events.RuntimeEvent;
44 import jdk.nashorn.internal.runtime.linker.LinkerCallSite;
45 import jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor;
46
47 /**
48 * Nashorn specific debug utils. This is meant for Nashorn developers.
49 * The interface is subject to change without notice!!
50 *
51 */
52 @ScriptClass("Debug")
53 public final class NativeDebug extends ScriptObject {
54
55 // initialized by nasgen
56 @SuppressWarnings("unused")
57 private static PropertyMap $nasgenmap$;
58
59 private NativeDebug() {
228 * @param obj script object whose listener count is returned
229 * @return listener count
230 */
231 @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
232 public static int getListenerCount(final Object self, final Object obj) {
233 return (obj instanceof ScriptObject) ? PropertyListeners.getListenerCount((ScriptObject) obj) : 0;
234 }
235
236 /**
237 * Dump all Nashorn debug mode counters. Calling this may be better if
238 * you want to print all counters. This way you can avoid too many callsites
239 * due to counter access itself!!
240 * @param self self reference
241 * @return undefined
242 */
243 @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
244 public static Object dumpCounters(final Object self) {
245 final PrintWriter out = Context.getCurrentErr();
246
247 out.println("ScriptObject count " + ScriptObject.getCount());
248 out.println("Scope count " + ScriptObject.getScopeCount());
249 out.println("ScriptObject listeners added " + PropertyListeners.getListenersAdded());
250 out.println("ScriptObject listeners removed " + PropertyListeners.getListenersRemoved());
251 out.println("ScriptFunction constructor calls " + ScriptFunction.getConstructorCount());
252 out.println("ScriptFunction invokes " + ScriptFunction.getInvokes());
253 out.println("ScriptFunction allocations " + ScriptFunction.getAllocations());
254 out.println("PropertyMap count " + PropertyMap.getCount());
255 out.println("PropertyMap cloned " + PropertyMap.getClonedCount());
256 out.println("PropertyMap history hit " + PropertyMap.getHistoryHit());
257 out.println("PropertyMap proto invalidations " + PropertyMap.getProtoInvalidations());
258 out.println("PropertyMap proto history hit " + PropertyMap.getProtoHistoryHit());
259 out.println("PropertyMap setProtoNewMapCount " + PropertyMap.getSetProtoNewMapCount());
260 out.println("Callsite count " + LinkerCallSite.getCount());
261 out.println("Callsite misses " + LinkerCallSite.getMissCount());
262 out.println("Callsite misses by site at " + LinkerCallSite.getMissSamplingPercentage() + "%");
263
264 LinkerCallSite.getMissCounts(out);
265
266 return UNDEFINED;
267 }
268
|
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 import java.io.PrintWriter;
30 import java.util.LinkedList;
31 import java.util.Objects;
32 import jdk.nashorn.internal.objects.annotations.Attribute;
33 import jdk.nashorn.internal.objects.annotations.Function;
34 import jdk.nashorn.internal.objects.annotations.ScriptClass;
35 import jdk.nashorn.internal.objects.annotations.Where;
36 import jdk.nashorn.internal.runtime.Context;
37 import jdk.nashorn.internal.runtime.JSType;
38 import jdk.nashorn.internal.runtime.PropertyListeners;
39 import jdk.nashorn.internal.runtime.PropertyMap;
40 import jdk.nashorn.internal.runtime.Scope;
41 import jdk.nashorn.internal.runtime.ScriptFunction;
42 import jdk.nashorn.internal.runtime.ScriptObject;
43 import jdk.nashorn.internal.runtime.ScriptRuntime;
44 import jdk.nashorn.internal.runtime.events.RuntimeEvent;
45 import jdk.nashorn.internal.runtime.linker.LinkerCallSite;
46 import jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor;
47
48 /**
49 * Nashorn specific debug utils. This is meant for Nashorn developers.
50 * The interface is subject to change without notice!!
51 *
52 */
53 @ScriptClass("Debug")
54 public final class NativeDebug extends ScriptObject {
55
56 // initialized by nasgen
57 @SuppressWarnings("unused")
58 private static PropertyMap $nasgenmap$;
59
60 private NativeDebug() {
229 * @param obj script object whose listener count is returned
230 * @return listener count
231 */
232 @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
233 public static int getListenerCount(final Object self, final Object obj) {
234 return (obj instanceof ScriptObject) ? PropertyListeners.getListenerCount((ScriptObject) obj) : 0;
235 }
236
237 /**
238 * Dump all Nashorn debug mode counters. Calling this may be better if
239 * you want to print all counters. This way you can avoid too many callsites
240 * due to counter access itself!!
241 * @param self self reference
242 * @return undefined
243 */
244 @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
245 public static Object dumpCounters(final Object self) {
246 final PrintWriter out = Context.getCurrentErr();
247
248 out.println("ScriptObject count " + ScriptObject.getCount());
249 out.println("Scope count " + Scope.getCount());
250 out.println("ScriptObject listeners added " + PropertyListeners.getListenersAdded());
251 out.println("ScriptObject listeners removed " + PropertyListeners.getListenersRemoved());
252 out.println("ScriptFunction constructor calls " + ScriptFunction.getConstructorCount());
253 out.println("ScriptFunction invokes " + ScriptFunction.getInvokes());
254 out.println("ScriptFunction allocations " + ScriptFunction.getAllocations());
255 out.println("PropertyMap count " + PropertyMap.getCount());
256 out.println("PropertyMap cloned " + PropertyMap.getClonedCount());
257 out.println("PropertyMap history hit " + PropertyMap.getHistoryHit());
258 out.println("PropertyMap proto invalidations " + PropertyMap.getProtoInvalidations());
259 out.println("PropertyMap proto history hit " + PropertyMap.getProtoHistoryHit());
260 out.println("PropertyMap setProtoNewMapCount " + PropertyMap.getSetProtoNewMapCount());
261 out.println("Callsite count " + LinkerCallSite.getCount());
262 out.println("Callsite misses " + LinkerCallSite.getMissCount());
263 out.println("Callsite misses by site at " + LinkerCallSite.getMissSamplingPercentage() + "%");
264
265 LinkerCallSite.getMissCounts(out);
266
267 return UNDEFINED;
268 }
269
|