зеркало из https://github.com/mozilla/gecko-dev.git
Merge.
This commit is contained in:
Коммит
014b1f2ed1
|
@ -2860,6 +2860,14 @@ js_TraceContext(JSTracer *trc, JSContext *acx)
|
|||
js_TraceSharpMap(trc, &acx->sharpObjectMap);
|
||||
}
|
||||
|
||||
void
|
||||
js_TraceTraceMonitor(JSTracer *trc, JSTraceMonitor *tm)
|
||||
{
|
||||
TRACE_JSVALS(trc, tm->loopTableSize, tm->loopTable, "loop table");
|
||||
if (tm->recorder)
|
||||
JS_CALL_OBJECT_TRACER(trc, tm->recorder, "recorder object");
|
||||
}
|
||||
|
||||
void
|
||||
js_TraceRuntime(JSTracer *trc, JSBool allAtoms)
|
||||
{
|
||||
|
@ -2885,14 +2893,10 @@ js_TraceRuntime(JSTracer *trc, JSBool allAtoms)
|
|||
while ((acx = js_ContextIterator(rt, JS_FALSE, &iter)) != NULL) {
|
||||
if (!acx->thread)
|
||||
continue;
|
||||
JSTraceMonitor* tm = &acx->thread->traceMonitor;
|
||||
TRACE_JSVALS(trc, tm->loopTableSize, tm->loopTable,
|
||||
"thread->traceMonitor.loopTable");
|
||||
js_TraceTraceMonitor(trc, &acx->thread->traceMonitor);
|
||||
}
|
||||
#else
|
||||
JSTraceMonitor* tm = &rt->traceMonitor;
|
||||
TRACE_JSVALS(trc, tm->loopTableSize, tm->loopTable,
|
||||
"rt->traceMonitor.loopTable");
|
||||
js_TraceTraceMonitor(trc, &rt->traceMonitor);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -2760,7 +2760,7 @@ JS_INTERPRET(JSContext *cx)
|
|||
JS_END_MACRO
|
||||
|
||||
# define BEGIN_CASE(OP) L_##OP: \
|
||||
trace_stop(#OP);
|
||||
trace_stop(cx, #OP);
|
||||
# define TRACE_CASE(OP) L_##OP:
|
||||
# define END_CASE(OP) DO_NEXT_OP(OP##_LENGTH);
|
||||
# define END_VARLEN_CASE DO_NEXT_OP(len);
|
||||
|
@ -2780,7 +2780,7 @@ JS_INTERPRET(JSContext *cx)
|
|||
JS_END_MACRO
|
||||
|
||||
# define BEGIN_CASE(OP) case OP: \
|
||||
trace_stop(#OP);
|
||||
trace_stop(cx, #OP);
|
||||
# define TRACE_CASE(OP) case OP:
|
||||
# define END_CASE(OP) END_CASE_LEN(OP##_LENGTH)
|
||||
# define END_CASE_LEN(n) END_CASE_LENX(n)
|
||||
|
@ -6961,7 +6961,7 @@ JS_INTERPRET(JSContext *cx)
|
|||
|
||||
#define DEFINE_HANDLER(handler) \
|
||||
handler: \
|
||||
trace_stop(#handler);
|
||||
trace_stop(cx, #handler);
|
||||
|
||||
DEFINE_HANDLER(error)
|
||||
JS_ASSERT((size_t)(regs.pc - script->code) < script->length);
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
* Andreas Gal <gal@uci.edu>
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brendan Eich <brendan@mozilla.org
|
||||
* Brendan Eich <brendan@mozilla.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
|
@ -454,12 +454,19 @@ PRIMITIVE(guard_both_jsvals_are_string)(jsval& a, jsval& b)
|
|||
return JSVAL_IS_STRING(a) && JSVAL_IS_STRING(b);
|
||||
}
|
||||
|
||||
static inline void
|
||||
PRIMITIVE(trace_start)(JSContext* cx, jsbytecode* pc)
|
||||
{
|
||||
jsval args[] = { native_pointer_to_jsval(pc) };
|
||||
js_CallRecorder(cx, "start", 1, args);
|
||||
}
|
||||
|
||||
/*
|
||||
* Unsupported opcodes trigger a trace stop condition and cause the trace
|
||||
* recorder to abandon the current trace.
|
||||
*/
|
||||
static inline void
|
||||
PRIMITIVE(trace_stop)(const char* op)
|
||||
PRIMITIVE(trace_stop)(JSContext* cx, const char* op)
|
||||
{
|
||||
/* If we are not tracing, this is a no-op. */
|
||||
}
|
||||
|
|
|
@ -1579,8 +1579,8 @@ js_DestroyScript(JSContext *cx, JSScript *script)
|
|||
/*
|
||||
* Free the loop table slots for all JSOP_HEADER opcodes. We do this
|
||||
* only if not called from the GC via script_finalize, because the GC
|
||||
* will re-base all based, traceable scripts having loop table space,
|
||||
* to compress live slots toward the start of the table.
|
||||
* will re-base all of the scripts that it marks that have loop table
|
||||
* space, to compress live slots toward the start of the table.
|
||||
*/
|
||||
if (script->loopHeaders)
|
||||
js_FreeLoopTableSlots(cx, script->loopBase, script->loopHeaders);
|
||||
|
|
|
@ -109,3 +109,27 @@ js_GrowLoopTable(JSContext* cx, uint32 slot)
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
JSObject*
|
||||
js_GetRecorder(JSContext* cx)
|
||||
{
|
||||
JSTraceMonitor* tm = &JS_TRACE_MONITOR(cx);
|
||||
if (tm->recorder)
|
||||
return tm->recorder;
|
||||
JSScript* script = JS_CompileFile(cx, JS_GetGlobalObject(cx), "recorder.js");
|
||||
JS_ASSERT(script != NULL);
|
||||
jsval result;
|
||||
JSBool ok = JS_ExecuteScript(cx, JS_GetGlobalObject(cx), script, &result);
|
||||
JS_ASSERT(ok && JSVAL_IS_OBJECT(result));
|
||||
return tm->recorder = JSVAL_TO_OBJECT(result);
|
||||
}
|
||||
|
||||
jsval
|
||||
js_CallRecorder(JSContext* cx, const char* fn, uintN argc, jsval* argv)
|
||||
{
|
||||
jsval rval;
|
||||
JSBool ok;
|
||||
ok = JS_CallFunctionName(cx, js_GetRecorder(cx), fn, argc, argv, &rval);
|
||||
JS_ASSERT(ok);
|
||||
return rval;
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
struct JSTraceMonitor {
|
||||
jsval* loopTable;
|
||||
uint32 loopTableSize;
|
||||
JSObject* recorder;
|
||||
};
|
||||
|
||||
#define TRACE_THRESHOLD 10
|
||||
|
@ -62,5 +63,18 @@ struct JSTraceMonitor {
|
|||
uint32 js_AllocateLoopTableSlots(JSContext* cx, uint32 nloops);
|
||||
void js_FreeLoopTableSlots(JSContext* cx, uint32 base, uint32 nloops);
|
||||
bool js_GrowLoopTable(JSContext* cx, uint32 slot);
|
||||
jsval js_CallRecorder(JSContext* cx, const char* fn, uintN argc, jsval* argv);
|
||||
|
||||
/*
|
||||
* The recorder needs to keep track of native machine addresses. We speculate
|
||||
* that these addresses can be wrapped into a 31-bit integer, which is true for
|
||||
* most 32-bit machines.
|
||||
*/
|
||||
static inline jsval
|
||||
native_pointer_to_jsval(void* p)
|
||||
{
|
||||
JS_ASSERT(INT_FITS_IN_JSVAL((int)p));
|
||||
return INT_TO_JSVAL((int)p);
|
||||
}
|
||||
|
||||
#endif /* jstracer_h___ */
|
||||
|
|
|
@ -414,14 +414,14 @@ guard_both_jsvals_are_string(jsval& a, jsval& b)
|
|||
return interp_guard_both_jsvals_are_string(a, b);
|
||||
}
|
||||
|
||||
/*
|
||||
* Unsupported opcodes trigger a trace stop condition and cause the trace
|
||||
* recorder to abandon the current trace.
|
||||
*/
|
||||
static inline void
|
||||
trace_stop(const char* op)
|
||||
trace_start(JSContext* cx, jsbytecode* pc)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void
|
||||
trace_stop(JSContext* cx, const char* op)
|
||||
{
|
||||
/* If we are not tracing, this is a no-op. */
|
||||
}
|
||||
|
||||
#endif /* jstracerinlines_h___ */
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* vim: set ts=8 sw=4 et tw=78:
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla SpiderMonkey JavaScript 1.9 code, released
|
||||
* May 28, 2008.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Andreas Gal <gal@uci.edu>
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brendan Eich <brendan@mozilla.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
eval({
|
||||
start: function(pc) {
|
||||
print("Recording at @" + pc);
|
||||
}
|
||||
})
|
||||
|
Загрузка…
Ссылка в новой задаче