93
edits
(→Memory Profiling Globals: added more documentation.) |
(added more docs) |
||
| Line 37: | Line 37: | ||
<code>nsJetpack.</code>'''wrap'''(''wrappee'', ''membrane'') | <code>nsJetpack.</code>'''wrap'''(''wrappee'', ''membrane'') | ||
This function wraps ''wrappee'' with ''membrane'' (meaning that ''membrane'' mediates all access to and from ''wrappee''). The wrapped object is returned. | This function wraps ''wrappee'' with the [[Labs/Jetpack/Binary_Components#Membrane_Objects|Membrane]] ''membrane'' (meaning that ''membrane'' mediates all access to and from ''wrappee''). The wrapped object is returned. | ||
<code>nsJetpack.</code>'''unwrap'''(''wrappedObject'') | <code>nsJetpack.</code>'''unwrap'''(''wrappedObject'') | ||
| Line 91: | Line 91: | ||
== Memory Profiling == | == Memory Profiling == | ||
<code>nsJetpack</code> contains functionality allowing chrome code to examine the JavaScript heap. The semantics of this are described at a high level in Atul's blog post entitled [http://www.toolness.com/wp/?p=604 Fun with SpiderMonkey]. | <code>nsJetpack</code> contains functionality allowing chrome code to examine the JavaScript heap. The semantics of this are described at a high level in Atul's blog post entitled [http://www.toolness.com/wp/?p=604 Fun with SpiderMonkey]; please read this blog post before reading the rest of this section. | ||
The source code for this functionality is in [http://hg.mozilla.org/labs/jetpack/file/tip/components/src/memory_profiler.cpp memory_profiler.cpp]. | The source code for this functionality is in [http://hg.mozilla.org/labs/jetpack/file/tip/components/src/memory_profiler.cpp memory_profiler.cpp]. | ||
| Line 102: | Line 102: | ||
''namedObjects'' is an optional object whose properties, called "names", point to objects in the target JS runtime; these objects can be referred to by their names by certain functions in the memory profiling JS runtime. | ''namedObjects'' is an optional object whose properties, called "names", point to objects in the target JS runtime; these objects can be referred to by their names by certain functions in the memory profiling JS runtime. | ||
If the final statement of ''code'' results in a string value, this value is copied and passed back as the result of this function. This allows ''code'' to perform some memory profiling activity and return the results back to the target JS runtime. | |||
=== Memory Profiling Globals === | === Memory Profiling Globals === | ||
| Line 107: | Line 109: | ||
Code running in the memory profiling JS runtime has access to the following global objects and functions. | Code running in the memory profiling JS runtime has access to the following global objects and functions. | ||
'''ServerSocket | '''ServerSocket'''() | ||
This constructor creates a new blocking TCP/IP socket, or [[Labs/Jetpack/Binary_Components#ServerSocket_Objects|ServerSocket]]. | |||
'''getGCRoots'''() | '''getGCRoots'''() | ||
| Line 178: | Line 156: | ||
'''TODO:''' Document TCB functions. | '''TODO:''' Document TCB functions. | ||
=== ServerSocket Objects === | |||
<code>ServerSocket.</code>'''bind'''(''ip'', ''port'') | |||
Binds the socket to the given ''ip'' and ''port''. | |||
<code>ServerSocket.</code>'''listen'''() | |||
Configures the socket for listening. | |||
<code>ServerSocket.</code>'''accept'''() | |||
Blocks until a connection is made on the socket and returns a new <code>ServerSocket</code> object representing the new connection. | |||
<code>ServerSocket.</code>'''recv'''(''size'') | |||
Receives up to ''size'' bytes of text from the connected client and returns it as a string. If the connection has been closed, <code>null</code> is returned instead. | |||
<code>ServerSocket.</code>'''send'''(''text'') | |||
Sends the given text to the connected client. | |||
<code>ServerSocket.</code>'''close'''() | |||
Closes the connection. | |||
== Miscellaneous Functions == | == Miscellaneous Functions == | ||
edits