On Wed, Feb 26, 2014 at 2:46 PM, Nicholas Nethercote
<[email protected]> wrote:
> On Wed, Feb 26, 2014 at 2:29 PM, Nicholas Nethercote <[email protected]>
>>
>> Suggestions on how to do this properly would be appreciated. The
>> object metadata stuff is probably a better way to proceed here...
>
> billm pointed me to
> http://mxr.mozilla.org/mozilla-central/source/js/src/builtin/TestingFunctions.cpp#1066
> and
> http://mxr.mozilla.org/mozilla-central/source/js/src/builtin/TestingFunctions.cpp#1024,
> which is probably the right way to proceed here...
I have this working now. In the output I see quite a few lines of the
"??? (1)" form, i.e. the NonBuiltinScriptFrameIter has zero elements.
I'm not sure what this means... allocations triggered from within C++
code rather than JS code?
Nick
diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -5094,16 +5094,40 @@ AutoFinishGC::AutoFinishGC(JSRuntime *rt
AutoPrepareForTracing::AutoPrepareForTracing(JSRuntime *rt,
ZoneSelector selector)
: finish(rt),
session(rt),
copy(rt, selector)
{
RecordNativeStackTopForGC(rt);
}
+static bool
+MyObjectMetadataCallback(JSContext *cx, JSObject **pmetadata)
+{
+ *pmetadata = nullptr;
+
+ NonBuiltinScriptFrameIter i(cx);
+ if (i.done()) {
+ fprintf(stderr, "o: ??? (1)\n");
+ return true;
+ }
+
+ // If the caller is hidden, the embedding wants us to return null here so
+ // that it can check its own stack.
+ if (i.activation()->scriptedCallerIsHidden()) {
+ fprintf(stderr, "o: ??? (2)\n");
+ return true;
+ }
+
+ fprintf(stderr, "o: %s, %d\n",
+ JS_GetScriptFilename(cx, i.script()),
+ js::PCToLineNumber(i.script(), i.pc()));
+ return true;
+}
+
JSCompartment *
js::NewCompartment(JSContext *cx, Zone *zone, JSPrincipals *principals,
const JS::CompartmentOptions &options)
{
JSRuntime *rt = cx->runtime();
JS_AbortIfWrongThread(rt);
ScopedJSDeletePtr<Zone> zoneHolder;
@@ -5138,16 +5162,19 @@ js::NewCompartment(JSContext *cx, Zone *
}
if (zoneHolder && !rt->zones.append(zone)) {
js_ReportOutOfMemory(cx);
return nullptr;
}
zoneHolder.forget();
+
+ compartment->setObjectMetadataCallback(MyObjectMetadataCallback);
+
return compartment.forget();
}
void
gc::MergeCompartments(JSCompartment *source, JSCompartment *target)
{
// The source compartment must be specifically flagged as mergable. This
// also implies that the compartment is not visible to the debugger.
_______________________________________________
dev-tech-js-engine-internals mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-internals