Mercurial > spidermonkey-playground
annotate memory_profiler.cpp @ 77:8cf72992387d default tip
add JSONP
author | Dion Almaer <dion@mozilla.com> |
---|---|
date | Fri, 26 Jun 2009 10:13:32 -0700 |
parents | b87b6ebb6e86 |
children |
rev | line source |
---|---|
50
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
1 #include "jsdhash.h" |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
2 |
72
eca8642eed4a
Made memory_profiler.cpp use TCB.cpp for the construction of its global object.
Atul Varma <varmaa@toolness.com>
parents:
65
diff
changeset
|
3 #include "tcb.h" |
50
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
4 #include "memory_profiler.h" |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
5 #include "server_socket.h" |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
6 |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
7 #define SERVER_FILENAME "memory_profiler_server.js" |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
8 |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
9 // Private structure to track the state of tracing the JS heap. |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
10 |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
11 typedef struct TracingState { |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
12 // Keeps track of what objects we've visited so far. |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
13 JSDHashTable visited; |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
14 |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
15 // Whether the tracing operation is successful or failed. |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
16 JSBool result; |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
17 |
51
8750e9ecf3af
Added a getGCRoots() function.
Atul Varma <varmaa@toolness.com>
parents:
50
diff
changeset
|
18 // Runtime that we're tracing. |
8750e9ecf3af
Added a getGCRoots() function.
Atul Varma <varmaa@toolness.com>
parents:
50
diff
changeset
|
19 JSRuntime *runtime; |
8750e9ecf3af
Added a getGCRoots() function.
Atul Varma <varmaa@toolness.com>
parents:
50
diff
changeset
|
20 |
8750e9ecf3af
Added a getGCRoots() function.
Atul Varma <varmaa@toolness.com>
parents:
50
diff
changeset
|
21 // Structure required to use JS tracing functions. |
8750e9ecf3af
Added a getGCRoots() function.
Atul Varma <varmaa@toolness.com>
parents:
50
diff
changeset
|
22 JSTracer tracer; |
50
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
23 }; |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
24 |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
25 // Static singleton for tracking the state of tracing the JS heap. |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
26 static TracingState tracingState; |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
27 |
57
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
28 typedef struct ChildTracingState { |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
29 int num; |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
30 void **things; |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
31 uint32 *kinds; |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
32 JSTracer tracer; |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
33 }; |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
34 |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
35 static ChildTracingState childTracingState; |
50
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
36 |
57
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
37 // JSTraceCallback to build a hashtable of children. |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
38 static void childCountBuilder(JSTracer *trc, void *thing, uint32 kind) |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
39 { |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
40 childTracingState.num++; |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
41 } |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
42 |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
43 // JSTraceCallback to build a hashtable of children. |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
44 static void childBuilder(JSTracer *trc, void *thing, uint32 kind) |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
45 { |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
46 *childTracingState.kinds = kind; |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
47 childTracingState.kinds++; |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
48 *childTracingState.things = thing; |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
49 childTracingState.things++; |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
50 } |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
51 |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
52 // JSTraceCallback to build a hashtable of existing object references. |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
53 static void visitedBuilder(JSTracer *trc, void *thing, uint32 kind) |
50
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
54 { |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
55 switch (kind) { |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
56 case JSTRACE_OBJECT: |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
57 JSDHashEntryStub *entry = (JSDHashEntryStub *) |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
58 JS_DHashTableOperate(&tracingState.visited, |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
59 thing, |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
60 JS_DHASH_LOOKUP); |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
61 if (JS_DHASH_ENTRY_IS_FREE((JSDHashEntryHdr *)entry)) { |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
62 entry = (JSDHashEntryStub *) JS_DHashTableOperate(&tracingState.visited, |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
63 thing, |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
64 JS_DHASH_ADD); |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
65 if (entry == NULL) { |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
66 JS_ReportOutOfMemory(trc->context); |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
67 tracingState.result = JS_FALSE; |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
68 return; |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
69 } |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
70 entry->key = thing; |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
71 JS_TraceChildren(trc, thing, kind); |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
72 } |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
73 break; |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
74 case JSTRACE_DOUBLE: |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
75 break; |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
76 case JSTRACE_STRING: |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
77 break; |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
78 } |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
79 } |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
80 |
57
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
81 static JSBool getChildrenInfo(JSContext *cx, JSObject *info, |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
82 JSObject *target, JSContext *targetCx) |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
83 { |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
84 childTracingState.tracer.context = targetCx; |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
85 childTracingState.tracer.callback = childCountBuilder; |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
86 childTracingState.num = 0; |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
87 JS_TraceChildren(&childTracingState.tracer, target, JSTRACE_OBJECT); |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
88 |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
89 void *things[childTracingState.num]; |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
90 uint32 kinds[childTracingState.num]; |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
91 |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
92 childTracingState.things = things; |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
93 childTracingState.kinds = kinds; |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
94 |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
95 childTracingState.tracer.callback = childBuilder; |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
96 JS_TraceChildren(&childTracingState.tracer, target, JSTRACE_OBJECT); |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
97 |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
98 int numObjectChildren = 0; |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
99 for (int i = 0; i < childTracingState.num; i++) { |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
100 if (kinds[i] == JSTRACE_OBJECT) |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
101 numObjectChildren++; |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
102 } |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
103 |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
104 jsval childrenVals[numObjectChildren]; |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
105 |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
106 int currChild = 0; |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
107 for (int i = 0; i < childTracingState.num; i++) { |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
108 if (kinds[i] == JSTRACE_OBJECT) { |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
109 childrenVals[currChild] = INT_TO_JSVAL((unsigned int) things[i]); |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
110 currChild += 1; |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
111 } |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
112 } |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
113 |
63
4910bc49a182
set GC Zeal to 2 and fixed some bugs exposed by it.
Atul Varma <varmaa@toolness.com>
parents:
62
diff
changeset
|
114 if (numObjectChildren != currChild) { |
4910bc49a182
set GC Zeal to 2 and fixed some bugs exposed by it.
Atul Varma <varmaa@toolness.com>
parents:
62
diff
changeset
|
115 JS_ReportError(cx, "Assertion failure, numObjectChildren != currChild"); |
4910bc49a182
set GC Zeal to 2 and fixed some bugs exposed by it.
Atul Varma <varmaa@toolness.com>
parents:
62
diff
changeset
|
116 return JS_FALSE; |
4910bc49a182
set GC Zeal to 2 and fixed some bugs exposed by it.
Atul Varma <varmaa@toolness.com>
parents:
62
diff
changeset
|
117 } |
4910bc49a182
set GC Zeal to 2 and fixed some bugs exposed by it.
Atul Varma <varmaa@toolness.com>
parents:
62
diff
changeset
|
118 |
57
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
119 JSObject *children = JS_NewArrayObject(cx, numObjectChildren, childrenVals); |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
120 if (children == NULL) { |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
121 JS_ReportOutOfMemory(cx); |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
122 return JS_FALSE; |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
123 } |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
124 |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
125 return JS_DefineProperty(cx, info, "children", OBJECT_TO_JSVAL(children), |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
126 NULL, NULL, JSPROP_ENUMERATE); |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
127 } |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
128 |
62
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
129 static JSBool getPropertiesInfo(JSContext *cx, JSObject *info, |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
130 JSObject *target, JSContext *targetCx) |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
131 { |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
132 JSObject *propInfo = JS_NewObject(cx, NULL, NULL, NULL); |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
133 if (propInfo == NULL) { |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
134 JS_ReportOutOfMemory(cx); |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
135 return JS_FALSE; |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
136 } |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
137 |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
138 if (!JS_DefineProperty(cx, info, "properties", OBJECT_TO_JSVAL(propInfo), |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
139 NULL, NULL, JSPROP_ENUMERATE)) |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
140 return JS_FALSE; |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
141 |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
142 JSPropertyDescArray properties; |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
143 if (!JS_GetPropertyDescArray(targetCx, target, &properties)) { |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
144 JS_ReportError(cx, "Couldn't get property desc array."); |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
145 return JS_FALSE; |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
146 } |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
147 |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
148 for (int i = 0; i < properties.length; i++) { |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
149 jsval id = properties.array[i].id; |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
150 // TODO: What if the property is a number? |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
151 if (JSVAL_IS_STRING(id)) { |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
152 jsval value = properties.array[i].value; |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
153 if (JSVAL_IS_OBJECT(value)) { |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
154 JSObject *valueObj = JSVAL_TO_OBJECT(value); |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
155 value = INT_TO_JSVAL((unsigned int) valueObj); |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
156 } else if (JSVAL_IS_STRING(value)) { |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
157 JSString *valueStr = JS_NewUCStringCopyZ( |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
158 cx, |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
159 JS_GetStringChars(JSVAL_TO_STRING(value)) |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
160 ); |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
161 if (valueStr == NULL) { |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
162 JS_ReportOutOfMemory(cx); |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
163 return JS_FALSE; |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
164 } |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
165 value = STRING_TO_JSVAL(valueStr); |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
166 } else |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
167 value = JSVAL_NULL; |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
168 |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
169 if (!JS_DefineProperty(cx, propInfo, |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
170 JS_GetStringBytes(JSVAL_TO_STRING(id)), |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
171 value, |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
172 NULL, |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
173 NULL, |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
174 JSPROP_ENUMERATE)) |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
175 return JS_FALSE; |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
176 } |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
177 } |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
178 |
65
109d9927c805
Fixed the leaking root bug.
Atul Varma <varmaa@toolness.com>
parents:
63
diff
changeset
|
179 // Unroot roots set by JS_GetPropertyDescArray(). |
109d9927c805
Fixed the leaking root bug.
Atul Varma <varmaa@toolness.com>
parents:
63
diff
changeset
|
180 JS_PutPropertyDescArray(targetCx, &properties); |
109d9927c805
Fixed the leaking root bug.
Atul Varma <varmaa@toolness.com>
parents:
63
diff
changeset
|
181 |
62
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
182 return JS_TRUE; |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
183 } |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
184 |
54
c451579bf83c
Built out more of the /objects/ method.
Atul Varma <varmaa@toolness.com>
parents:
51
diff
changeset
|
185 static JSBool getObjInfo(JSContext *cx, JSObject *obj, uintN argc, |
c451579bf83c
Built out more of the /objects/ method.
Atul Varma <varmaa@toolness.com>
parents:
51
diff
changeset
|
186 jsval *argv, jsval *rval) |
c451579bf83c
Built out more of the /objects/ method.
Atul Varma <varmaa@toolness.com>
parents:
51
diff
changeset
|
187 { |
c451579bf83c
Built out more of the /objects/ method.
Atul Varma <varmaa@toolness.com>
parents:
51
diff
changeset
|
188 uint32 id; |
c451579bf83c
Built out more of the /objects/ method.
Atul Varma <varmaa@toolness.com>
parents:
51
diff
changeset
|
189 |
c451579bf83c
Built out more of the /objects/ method.
Atul Varma <varmaa@toolness.com>
parents:
51
diff
changeset
|
190 if (!JS_ConvertArguments(cx, argc, argv, "u", &id)) |
c451579bf83c
Built out more of the /objects/ method.
Atul Varma <varmaa@toolness.com>
parents:
51
diff
changeset
|
191 return JS_FALSE; |
c451579bf83c
Built out more of the /objects/ method.
Atul Varma <varmaa@toolness.com>
parents:
51
diff
changeset
|
192 |
c451579bf83c
Built out more of the /objects/ method.
Atul Varma <varmaa@toolness.com>
parents:
51
diff
changeset
|
193 JSDHashEntryStub *entry = (JSDHashEntryStub *) |
c451579bf83c
Built out more of the /objects/ method.
Atul Varma <varmaa@toolness.com>
parents:
51
diff
changeset
|
194 JS_DHashTableOperate(&tracingState.visited, |
c451579bf83c
Built out more of the /objects/ method.
Atul Varma <varmaa@toolness.com>
parents:
51
diff
changeset
|
195 (void *) id, |
c451579bf83c
Built out more of the /objects/ method.
Atul Varma <varmaa@toolness.com>
parents:
51
diff
changeset
|
196 JS_DHASH_LOOKUP); |
c451579bf83c
Built out more of the /objects/ method.
Atul Varma <varmaa@toolness.com>
parents:
51
diff
changeset
|
197 if (entry == NULL) { |
c451579bf83c
Built out more of the /objects/ method.
Atul Varma <varmaa@toolness.com>
parents:
51
diff
changeset
|
198 JS_ReportOutOfMemory(cx); |
c451579bf83c
Built out more of the /objects/ method.
Atul Varma <varmaa@toolness.com>
parents:
51
diff
changeset
|
199 return JS_FALSE; |
c451579bf83c
Built out more of the /objects/ method.
Atul Varma <varmaa@toolness.com>
parents:
51
diff
changeset
|
200 } |
c451579bf83c
Built out more of the /objects/ method.
Atul Varma <varmaa@toolness.com>
parents:
51
diff
changeset
|
201 |
c451579bf83c
Built out more of the /objects/ method.
Atul Varma <varmaa@toolness.com>
parents:
51
diff
changeset
|
202 if (JS_DHASH_ENTRY_IS_BUSY((JSDHashEntryHdr *)entry)) { |
c451579bf83c
Built out more of the /objects/ method.
Atul Varma <varmaa@toolness.com>
parents:
51
diff
changeset
|
203 JSObject *info = JS_NewObject(cx, NULL, NULL, NULL); |
63
4910bc49a182
set GC Zeal to 2 and fixed some bugs exposed by it.
Atul Varma <varmaa@toolness.com>
parents:
62
diff
changeset
|
204 *rval = OBJECT_TO_JSVAL(info); |
55
1aba1b7a0a2c
Added a 'nativeClass' property to object info method.
Atul Varma <varmaa@toolness.com>
parents:
54
diff
changeset
|
205 |
1aba1b7a0a2c
Added a 'nativeClass' property to object info method.
Atul Varma <varmaa@toolness.com>
parents:
54
diff
changeset
|
206 JSObject *target = (JSObject *) id; |
56
b36c15de56f6
added a size property to info
Atul Varma <varmaa@toolness.com>
parents:
55
diff
changeset
|
207 JSContext *targetCx = tracingState.tracer.context; |
b36c15de56f6
added a size property to info
Atul Varma <varmaa@toolness.com>
parents:
55
diff
changeset
|
208 JSClass *classp = JS_GET_CLASS(targetCx, target); |
55
1aba1b7a0a2c
Added a 'nativeClass' property to object info method.
Atul Varma <varmaa@toolness.com>
parents:
54
diff
changeset
|
209 if (classp != NULL) { |
1aba1b7a0a2c
Added a 'nativeClass' property to object info method.
Atul Varma <varmaa@toolness.com>
parents:
54
diff
changeset
|
210 // TODO: Should really be using an interned string here or something. |
1aba1b7a0a2c
Added a 'nativeClass' property to object info method.
Atul Varma <varmaa@toolness.com>
parents:
54
diff
changeset
|
211 JSString *name = JS_NewStringCopyZ(cx, classp->name); |
1aba1b7a0a2c
Added a 'nativeClass' property to object info method.
Atul Varma <varmaa@toolness.com>
parents:
54
diff
changeset
|
212 if (name == NULL) { |
1aba1b7a0a2c
Added a 'nativeClass' property to object info method.
Atul Varma <varmaa@toolness.com>
parents:
54
diff
changeset
|
213 JS_ReportOutOfMemory(cx); |
1aba1b7a0a2c
Added a 'nativeClass' property to object info method.
Atul Varma <varmaa@toolness.com>
parents:
54
diff
changeset
|
214 return JS_FALSE; |
1aba1b7a0a2c
Added a 'nativeClass' property to object info method.
Atul Varma <varmaa@toolness.com>
parents:
54
diff
changeset
|
215 } |
1aba1b7a0a2c
Added a 'nativeClass' property to object info method.
Atul Varma <varmaa@toolness.com>
parents:
54
diff
changeset
|
216 if (!JS_DefineProperty(cx, info, "nativeClass", STRING_TO_JSVAL(name), |
1aba1b7a0a2c
Added a 'nativeClass' property to object info method.
Atul Varma <varmaa@toolness.com>
parents:
54
diff
changeset
|
217 NULL, NULL, JSPROP_ENUMERATE)) { |
1aba1b7a0a2c
Added a 'nativeClass' property to object info method.
Atul Varma <varmaa@toolness.com>
parents:
54
diff
changeset
|
218 JS_ReportOutOfMemory(cx); |
1aba1b7a0a2c
Added a 'nativeClass' property to object info method.
Atul Varma <varmaa@toolness.com>
parents:
54
diff
changeset
|
219 return JS_FALSE; |
1aba1b7a0a2c
Added a 'nativeClass' property to object info method.
Atul Varma <varmaa@toolness.com>
parents:
54
diff
changeset
|
220 } |
1aba1b7a0a2c
Added a 'nativeClass' property to object info method.
Atul Varma <varmaa@toolness.com>
parents:
54
diff
changeset
|
221 } |
1aba1b7a0a2c
Added a 'nativeClass' property to object info method.
Atul Varma <varmaa@toolness.com>
parents:
54
diff
changeset
|
222 |
56
b36c15de56f6
added a size property to info
Atul Varma <varmaa@toolness.com>
parents:
55
diff
changeset
|
223 if (!JS_DefineProperty( |
b36c15de56f6
added a size property to info
Atul Varma <varmaa@toolness.com>
parents:
55
diff
changeset
|
224 cx, info, "size", |
b36c15de56f6
added a size property to info
Atul Varma <varmaa@toolness.com>
parents:
55
diff
changeset
|
225 INT_TO_JSVAL(JS_GetObjectTotalSize(targetCx, target)), |
b36c15de56f6
added a size property to info
Atul Varma <varmaa@toolness.com>
parents:
55
diff
changeset
|
226 NULL, NULL, JSPROP_ENUMERATE)) { |
b36c15de56f6
added a size property to info
Atul Varma <varmaa@toolness.com>
parents:
55
diff
changeset
|
227 JS_ReportOutOfMemory(cx); |
b36c15de56f6
added a size property to info
Atul Varma <varmaa@toolness.com>
parents:
55
diff
changeset
|
228 return JS_FALSE; |
b36c15de56f6
added a size property to info
Atul Varma <varmaa@toolness.com>
parents:
55
diff
changeset
|
229 } |
b36c15de56f6
added a size property to info
Atul Varma <varmaa@toolness.com>
parents:
55
diff
changeset
|
230 |
57
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
231 if (!getChildrenInfo(cx, info, target, targetCx)) |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
232 return JS_FALSE; |
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
233 |
62
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
234 if (!getPropertiesInfo(cx, info, target, targetCx)) |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
235 return JS_FALSE; |
03078138a4cd
object info now includes information about properties.
Atul Varma <varmaa@toolness.com>
parents:
61
diff
changeset
|
236 |
54
c451579bf83c
Built out more of the /objects/ method.
Atul Varma <varmaa@toolness.com>
parents:
51
diff
changeset
|
237 *rval = OBJECT_TO_JSVAL(info); |
c451579bf83c
Built out more of the /objects/ method.
Atul Varma <varmaa@toolness.com>
parents:
51
diff
changeset
|
238 } else |
c451579bf83c
Built out more of the /objects/ method.
Atul Varma <varmaa@toolness.com>
parents:
51
diff
changeset
|
239 *rval = JSVAL_NULL; |
c451579bf83c
Built out more of the /objects/ method.
Atul Varma <varmaa@toolness.com>
parents:
51
diff
changeset
|
240 |
c451579bf83c
Built out more of the /objects/ method.
Atul Varma <varmaa@toolness.com>
parents:
51
diff
changeset
|
241 return JS_TRUE; |
c451579bf83c
Built out more of the /objects/ method.
Atul Varma <varmaa@toolness.com>
parents:
51
diff
changeset
|
242 } |
c451579bf83c
Built out more of the /objects/ method.
Atul Varma <varmaa@toolness.com>
parents:
51
diff
changeset
|
243 |
60
4bafda49e56e
Modified get GC roots to work w/ things other than just objects.
Atul Varma <varmaa@toolness.com>
parents:
59
diff
changeset
|
244 typedef struct RootMapStruct { |
4bafda49e56e
Modified get GC roots to work w/ things other than just objects.
Atul Varma <varmaa@toolness.com>
parents:
59
diff
changeset
|
245 JSBool rval; |
4bafda49e56e
Modified get GC roots to work w/ things other than just objects.
Atul Varma <varmaa@toolness.com>
parents:
59
diff
changeset
|
246 int length; |
4bafda49e56e
Modified get GC roots to work w/ things other than just objects.
Atul Varma <varmaa@toolness.com>
parents:
59
diff
changeset
|
247 JSContext *cx; |
4bafda49e56e
Modified get GC roots to work w/ things other than just objects.
Atul Varma <varmaa@toolness.com>
parents:
59
diff
changeset
|
248 JSObject *array; |
4bafda49e56e
Modified get GC roots to work w/ things other than just objects.
Atul Varma <varmaa@toolness.com>
parents:
59
diff
changeset
|
249 }; |
4bafda49e56e
Modified get GC roots to work w/ things other than just objects.
Atul Varma <varmaa@toolness.com>
parents:
59
diff
changeset
|
250 |
4bafda49e56e
Modified get GC roots to work w/ things other than just objects.
Atul Varma <varmaa@toolness.com>
parents:
59
diff
changeset
|
251 static intN rootMapFun(void *rp, const char *name, void *data) |
4bafda49e56e
Modified get GC roots to work w/ things other than just objects.
Atul Varma <varmaa@toolness.com>
parents:
59
diff
changeset
|
252 { |
61
44849dbd9017
changed the root mapping function and added docs.
Atul Varma <varmaa@toolness.com>
parents:
60
diff
changeset
|
253 // rp is a JS GC root. From the documentation for JS_AddRoot() in jsapi.h: |
44849dbd9017
changed the root mapping function and added docs.
Atul Varma <varmaa@toolness.com>
parents:
60
diff
changeset
|
254 // |
44849dbd9017
changed the root mapping function and added docs.
Atul Varma <varmaa@toolness.com>
parents:
60
diff
changeset
|
255 // A JS GC root is a pointer to a JSObject *, JSString *, or |
44849dbd9017
changed the root mapping function and added docs.
Atul Varma <varmaa@toolness.com>
parents:
60
diff
changeset
|
256 // jsdouble * that itself points into the GC heap (more recently, |
44849dbd9017
changed the root mapping function and added docs.
Atul Varma <varmaa@toolness.com>
parents:
60
diff
changeset
|
257 // we support this extension: a root may be a pointer to a jsval v |
44849dbd9017
changed the root mapping function and added docs.
Atul Varma <varmaa@toolness.com>
parents:
60
diff
changeset
|
258 // for which JSVAL_IS_GCTHING(v) is true). |
44849dbd9017
changed the root mapping function and added docs.
Atul Varma <varmaa@toolness.com>
parents:
60
diff
changeset
|
259 // |
44849dbd9017
changed the root mapping function and added docs.
Atul Varma <varmaa@toolness.com>
parents:
60
diff
changeset
|
260 // The public JSAPI appears to provide no way of actually determining |
44849dbd9017
changed the root mapping function and added docs.
Atul Varma <varmaa@toolness.com>
parents:
60
diff
changeset
|
261 // which it is, though, so we're just going to have to list them all, |
44849dbd9017
changed the root mapping function and added docs.
Atul Varma <varmaa@toolness.com>
parents:
60
diff
changeset
|
262 // and hope that a later tracing will give us more information about |
44849dbd9017
changed the root mapping function and added docs.
Atul Varma <varmaa@toolness.com>
parents:
60
diff
changeset
|
263 // them. |
44849dbd9017
changed the root mapping function and added docs.
Atul Varma <varmaa@toolness.com>
parents:
60
diff
changeset
|
264 |
44849dbd9017
changed the root mapping function and added docs.
Atul Varma <varmaa@toolness.com>
parents:
60
diff
changeset
|
265 RootMapStruct *roots = (RootMapStruct *) data; |
44849dbd9017
changed the root mapping function and added docs.
Atul Varma <varmaa@toolness.com>
parents:
60
diff
changeset
|
266 jsval id = INT_TO_JSVAL(*((unsigned int *)rp)); |
44849dbd9017
changed the root mapping function and added docs.
Atul Varma <varmaa@toolness.com>
parents:
60
diff
changeset
|
267 if (!JS_SetElement(roots->cx, roots->array, roots->length, &id)) { |
44849dbd9017
changed the root mapping function and added docs.
Atul Varma <varmaa@toolness.com>
parents:
60
diff
changeset
|
268 roots->rval = JS_FALSE; |
44849dbd9017
changed the root mapping function and added docs.
Atul Varma <varmaa@toolness.com>
parents:
60
diff
changeset
|
269 return JS_MAP_GCROOT_STOP; |
60
4bafda49e56e
Modified get GC roots to work w/ things other than just objects.
Atul Varma <varmaa@toolness.com>
parents:
59
diff
changeset
|
270 } |
61
44849dbd9017
changed the root mapping function and added docs.
Atul Varma <varmaa@toolness.com>
parents:
60
diff
changeset
|
271 roots->length++; |
60
4bafda49e56e
Modified get GC roots to work w/ things other than just objects.
Atul Varma <varmaa@toolness.com>
parents:
59
diff
changeset
|
272 return JS_MAP_GCROOT_NEXT; |
4bafda49e56e
Modified get GC roots to work w/ things other than just objects.
Atul Varma <varmaa@toolness.com>
parents:
59
diff
changeset
|
273 } |
4bafda49e56e
Modified get GC roots to work w/ things other than just objects.
Atul Varma <varmaa@toolness.com>
parents:
59
diff
changeset
|
274 |
51
8750e9ecf3af
Added a getGCRoots() function.
Atul Varma <varmaa@toolness.com>
parents:
50
diff
changeset
|
275 static JSBool getGCRoots(JSContext *cx, JSObject *obj, uintN argc, |
8750e9ecf3af
Added a getGCRoots() function.
Atul Varma <varmaa@toolness.com>
parents:
50
diff
changeset
|
276 jsval *argv, jsval *rval) |
8750e9ecf3af
Added a getGCRoots() function.
Atul Varma <varmaa@toolness.com>
parents:
50
diff
changeset
|
277 { |
60
4bafda49e56e
Modified get GC roots to work w/ things other than just objects.
Atul Varma <varmaa@toolness.com>
parents:
59
diff
changeset
|
278 RootMapStruct roots; |
4bafda49e56e
Modified get GC roots to work w/ things other than just objects.
Atul Varma <varmaa@toolness.com>
parents:
59
diff
changeset
|
279 roots.array = JS_NewArrayObject(cx, 0, NULL); |
4bafda49e56e
Modified get GC roots to work w/ things other than just objects.
Atul Varma <varmaa@toolness.com>
parents:
59
diff
changeset
|
280 roots.length = 0; |
4bafda49e56e
Modified get GC roots to work w/ things other than just objects.
Atul Varma <varmaa@toolness.com>
parents:
59
diff
changeset
|
281 roots.rval = JS_TRUE; |
4bafda49e56e
Modified get GC roots to work w/ things other than just objects.
Atul Varma <varmaa@toolness.com>
parents:
59
diff
changeset
|
282 roots.cx = cx; |
51
8750e9ecf3af
Added a getGCRoots() function.
Atul Varma <varmaa@toolness.com>
parents:
50
diff
changeset
|
283 |
60
4bafda49e56e
Modified get GC roots to work w/ things other than just objects.
Atul Varma <varmaa@toolness.com>
parents:
59
diff
changeset
|
284 if (roots.array == NULL) { |
51
8750e9ecf3af
Added a getGCRoots() function.
Atul Varma <varmaa@toolness.com>
parents:
50
diff
changeset
|
285 JS_ReportError(cx, "Creating array failed."); |
8750e9ecf3af
Added a getGCRoots() function.
Atul Varma <varmaa@toolness.com>
parents:
50
diff
changeset
|
286 return JS_FALSE; |
8750e9ecf3af
Added a getGCRoots() function.
Atul Varma <varmaa@toolness.com>
parents:
50
diff
changeset
|
287 } |
8750e9ecf3af
Added a getGCRoots() function.
Atul Varma <varmaa@toolness.com>
parents:
50
diff
changeset
|
288 |
60
4bafda49e56e
Modified get GC roots to work w/ things other than just objects.
Atul Varma <varmaa@toolness.com>
parents:
59
diff
changeset
|
289 JS_MapGCRoots(tracingState.runtime, rootMapFun, &roots); |
4bafda49e56e
Modified get GC roots to work w/ things other than just objects.
Atul Varma <varmaa@toolness.com>
parents:
59
diff
changeset
|
290 |
4bafda49e56e
Modified get GC roots to work w/ things other than just objects.
Atul Varma <varmaa@toolness.com>
parents:
59
diff
changeset
|
291 if (roots.rval == JS_FALSE) |
4bafda49e56e
Modified get GC roots to work w/ things other than just objects.
Atul Varma <varmaa@toolness.com>
parents:
59
diff
changeset
|
292 return JS_FALSE; |
4bafda49e56e
Modified get GC roots to work w/ things other than just objects.
Atul Varma <varmaa@toolness.com>
parents:
59
diff
changeset
|
293 |
4bafda49e56e
Modified get GC roots to work w/ things other than just objects.
Atul Varma <varmaa@toolness.com>
parents:
59
diff
changeset
|
294 *rval = OBJECT_TO_JSVAL(roots.array); |
51
8750e9ecf3af
Added a getGCRoots() function.
Atul Varma <varmaa@toolness.com>
parents:
50
diff
changeset
|
295 return JS_TRUE; |
8750e9ecf3af
Added a getGCRoots() function.
Atul Varma <varmaa@toolness.com>
parents:
50
diff
changeset
|
296 } |
8750e9ecf3af
Added a getGCRoots() function.
Atul Varma <varmaa@toolness.com>
parents:
50
diff
changeset
|
297 |
50
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
298 static JSFunctionSpec server_global_functions[] = { |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
299 JS_FS("ServerSocket", createServerSocket, 0, 0, 0), |
51
8750e9ecf3af
Added a getGCRoots() function.
Atul Varma <varmaa@toolness.com>
parents:
50
diff
changeset
|
300 JS_FS("getGCRoots", getGCRoots, 0, 0, 0), |
54
c451579bf83c
Built out more of the /objects/ method.
Atul Varma <varmaa@toolness.com>
parents:
51
diff
changeset
|
301 JS_FS("getObjectInfo", getObjInfo, 1, 0, 0), |
50
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
302 JS_FS_END |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
303 }; |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
304 |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
305 JSBool profileMemory(JSContext *cx, JSObject *obj, uintN argc, |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
306 jsval *argv, jsval *rval) |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
307 { |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
308 if (!JS_DHashTableInit(&tracingState.visited, JS_DHashGetStubOps(), |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
309 NULL, sizeof(JSDHashEntryStub), |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
310 JS_DHASH_DEFAULT_CAPACITY(100))) { |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
311 JS_ReportOutOfMemory(cx); |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
312 return JS_FALSE; |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
313 } |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
314 |
51
8750e9ecf3af
Added a getGCRoots() function.
Atul Varma <varmaa@toolness.com>
parents:
50
diff
changeset
|
315 tracingState.runtime = JS_GetRuntime(cx); |
50
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
316 tracingState.result = JS_TRUE; |
51
8750e9ecf3af
Added a getGCRoots() function.
Atul Varma <varmaa@toolness.com>
parents:
50
diff
changeset
|
317 tracingState.tracer.context = cx; |
57
1fd63ee398dc
Added some really terrible code that adds a 'children' array property to object info.
Atul Varma <varmaa@toolness.com>
parents:
56
diff
changeset
|
318 tracingState.tracer.callback = visitedBuilder; |
51
8750e9ecf3af
Added a getGCRoots() function.
Atul Varma <varmaa@toolness.com>
parents:
50
diff
changeset
|
319 JS_TraceRuntime(&tracingState.tracer); |
50
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
320 |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
321 if (!tracingState.result) |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
322 return JS_FALSE; |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
323 |
51
8750e9ecf3af
Added a getGCRoots() function.
Atul Varma <varmaa@toolness.com>
parents:
50
diff
changeset
|
324 JSRuntime *serverRuntime = JS_NewRuntime(8L * 1024L * 1024L); |
50
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
325 if (serverRuntime == NULL) { |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
326 JS_ReportError(cx, "Couldn't create server JS runtime."); |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
327 return JS_FALSE; |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
328 } |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
329 |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
330 JSContext *serverCx = JS_NewContext(serverRuntime, 8192); |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
331 if (serverCx == NULL) { |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
332 JS_ReportError(cx, "Couldn't create server JS context."); |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
333 return JS_FALSE; |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
334 } |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
335 JS_SetOptions(serverCx, JSOPTION_VAROBJFIX); |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
336 JS_SetVersion(serverCx, JSVERSION_LATEST); |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
337 |
58
0b66a265df13
Fixed some bugs that raised assertions in debug builds of SpiderMonkey.
Atul Varma <varmaa@toolness.com>
parents:
57
diff
changeset
|
338 JS_BeginRequest(serverCx); |
0b66a265df13
Fixed some bugs that raised assertions in debug builds of SpiderMonkey.
Atul Varma <varmaa@toolness.com>
parents:
57
diff
changeset
|
339 |
72
eca8642eed4a
Made memory_profiler.cpp use TCB.cpp for the construction of its global object.
Atul Varma <varmaa@toolness.com>
parents:
65
diff
changeset
|
340 jsval serverRval; |
eca8642eed4a
Made memory_profiler.cpp use TCB.cpp for the construction of its global object.
Atul Varma <varmaa@toolness.com>
parents:
65
diff
changeset
|
341 if (!TCB_init(serverCx, &serverRval)) |
50
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
342 return JS_FALSE; |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
343 |
72
eca8642eed4a
Made memory_profiler.cpp use TCB.cpp for the construction of its global object.
Atul Varma <varmaa@toolness.com>
parents:
65
diff
changeset
|
344 JSObject *serverGlobal = JSVAL_TO_OBJECT(serverRval); |
eca8642eed4a
Made memory_profiler.cpp use TCB.cpp for the construction of its global object.
Atul Varma <varmaa@toolness.com>
parents:
65
diff
changeset
|
345 |
eca8642eed4a
Made memory_profiler.cpp use TCB.cpp for the construction of its global object.
Atul Varma <varmaa@toolness.com>
parents:
65
diff
changeset
|
346 if (!JS_DefineFunctions(serverCx, serverGlobal, server_global_functions)) |
50
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
347 return JS_FALSE; |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
348 |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
349 FILE *f = fopen(SERVER_FILENAME, "r"); |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
350 if (!f) { |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
351 JS_ReportError(cx, "Couldn't open " SERVER_FILENAME); |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
352 return JS_FALSE; |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
353 } |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
354 |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
355 fseek(f, 0, SEEK_END); |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
356 long fileSize = ftell(f); |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
357 fseek(f, 0, SEEK_SET); |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
358 |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
359 char source[fileSize]; |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
360 fread(source, fileSize, 1, f); |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
361 fclose(f); |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
362 |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
363 if (!JS_EvaluateScript(serverCx, serverGlobal, source, |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
364 fileSize, SERVER_FILENAME, 1, |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
365 &serverRval)) { |
73
b87b6ebb6e86
Memory profiler server is now much better at reporting errors.
Atul Varma <varmaa@toolness.com>
parents:
72
diff
changeset
|
366 TCB_handleError(serverCx, serverGlobal); |
b87b6ebb6e86
Memory profiler server is now much better at reporting errors.
Atul Varma <varmaa@toolness.com>
parents:
72
diff
changeset
|
367 JS_ReportError(cx, "Running server script failed."); |
50
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
368 return JS_FALSE; |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
369 } |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
370 |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
371 /* Cleanup. */ |
54
c451579bf83c
Built out more of the /objects/ method.
Atul Varma <varmaa@toolness.com>
parents:
51
diff
changeset
|
372 JS_DHashTableFinish(&tracingState.visited); |
58
0b66a265df13
Fixed some bugs that raised assertions in debug builds of SpiderMonkey.
Atul Varma <varmaa@toolness.com>
parents:
57
diff
changeset
|
373 JS_EndRequest(serverCx); |
50
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
374 JS_DestroyContext(serverCx); |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
375 JS_DestroyRuntime(serverRuntime); |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
376 |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
377 *rval = JSVAL_VOID; |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
378 return JS_TRUE; |
853f80bd3b4b
Added tentative profileMemory() server, which suspends the current JS runtime, creates a new one and runs a web server in it.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
379 } |