Merge the last PGO-green changeset from mozilla-inbound into mozilla-central

This commit is contained in:
Ehsan Akhgari 2012-04-10 11:11:37 -04:00
commit 0e0d82c20e
4 changed files with 68 additions and 39 deletions

View File

@ -115,7 +115,7 @@ include $(topsrcdir)/config/rules.mk
# NB: the IPDL compiler manages .ipdl-->.h/.cpp dependencies itself,
# which is why we don't have explicit .h/.cpp targets here
export:: $(ALL_IPDLSRCS)
$(PYTHON_PATH) \
$(PYTHON) $(topsrcdir)/config/pythonpath.py \
$(PLY_INCLUDE) \
$(srcdir)/ipdl.py \
--outheaders-dir=_ipdlheaders \

View File

@ -150,7 +150,7 @@ dom_quickstubs.cpp: $(srcdir)/dom_quickstubs.qsconf \
$(topsrcdir)/xpcom/idl-parser/header.py \
$(topsrcdir)/xpcom/idl-parser/xpidl.py \
$(DEPTH)/js/src/js-confdefs.h
$(PYTHON_PATH) \
$(PYTHON) $(topsrcdir)/config/pythonpath.py \
$(PLY_INCLUDE) \
-I$(topsrcdir)/xpcom/idl-parser \
$(srcdir)/qsgen.py \
@ -171,7 +171,7 @@ dombindings_gen.h: $(srcdir)/dombindings.conf \
$(topsrcdir)/xpcom/idl-parser/header.py \
$(topsrcdir)/xpcom/idl-parser/xpidl.py \
$(DEPTH)/js/src/js-confdefs.h
$(PYTHON_PATH) \
$(PYTHON) $(topsrcdir)/config/pythonpath.py \
$(PLY_INCLUDE) \
-I$(topsrcdir)/xpcom/idl-parser \
$(srcdir)/dombindingsgen.py \
@ -188,7 +188,7 @@ dombindings_gen.cpp: $(srcdir)/dombindings.conf \
$(topsrcdir)/xpcom/idl-parser/header.py \
$(topsrcdir)/xpcom/idl-parser/xpidl.py \
$(DEPTH)/js/src/js-confdefs.h
$(PYTHON_PATH) \
$(PYTHON) $(topsrcdir)/config/pythonpath.py \
$(PLY_INCLUDE) \
-I$(topsrcdir)/xpcom/idl-parser \
$(srcdir)/dombindingsgen.py \
@ -207,7 +207,7 @@ DictionaryHelpers.h: $(srcdir)/dictionary_helper_gen.conf \
$(topsrcdir)/xpcom/idl-parser/header.py \
$(topsrcdir)/xpcom/idl-parser/xpidl.py \
$(DEPTH)/js/src/js-confdefs.h
$(PYTHON_PATH) \
$(PYTHON) $(topsrcdir)/config/pythonpath.py \
$(PLY_INCLUDE) \
-I$(topsrcdir)/xpcom/idl-parser \
$(srcdir)/dictionary_helper_gen.py \
@ -222,7 +222,7 @@ DictionaryHelpers.cpp: $(srcdir)/dictionary_helper_gen.conf \
$(topsrcdir)/xpcom/idl-parser/header.py \
$(topsrcdir)/xpcom/idl-parser/xpidl.py \
$(DEPTH)/js/src/js-confdefs.h
$(PYTHON_PATH) \
$(PYTHON) $(topsrcdir)/config/pythonpath.py \
$(PLY_INCLUDE) \
-I$(topsrcdir)/xpcom/idl-parser \
$(srcdir)/dictionary_helper_gen.py \

View File

@ -1,31 +1,61 @@
const Cc = Components.classes;
const Ci = Components.interfaces;
var timer;
const start_time = (new Date()).getTime();
const expected_time = 1;
var observer = {
observe: function observeTC(subject, topic, data) {
if (topic == "timer-callback") {
timer.cancel();
timer = null;
// expected time may not be exact so convert to seconds and round down.
var result = Math.floor(((new Date()).getTime() - start_time) / 1000);
do_check_eq(result, expected_time);
do_test_finished();
}
}
};
function run_test() {
do_test_pending();
timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
// Start a 5 second timer, than cancel it and start a 1 second timer.
timer.init(observer, 5000, timer.TYPE_REPEATING_PRECISE);
timer.cancel();
timer.init(observer, 1000, timer.TYPE_REPEATING_PRECISE);
}
const Cc = Components.classes;
const Ci = Components.interfaces;
// 5 seconds.
const kExpectedDelay1 = 5;
// 1 second.
const kExpectedDelay2 = 1;
var gStartTime1;
var gStartTime2;
var timer;
var observer1 = {
observe: function observeTC1(subject, topic, data) {
if (topic == "timer-callback") {
// Stop timer, so it doesn't repeat (if test runs slowly).
timer.cancel();
// Actual delay may not be exact, so convert to seconds and round down.
do_check_eq(Math.floor((Date.now() - gStartTime1) / 1000),
kExpectedDelay1);
timer = null;
do_print("1st timer triggered (before being cancelled). Should not have happened!");
do_check_true(false);
}
}
};
var observer2 = {
observe: function observeTC2(subject, topic, data) {
if (topic == "timer-callback") {
// Stop timer, so it doesn't repeat (if test runs slowly).
timer.cancel();
// Actual delay may not be exact, so convert to seconds and round down.
do_check_eq(Math.floor((Date.now() - gStartTime2) / 1000),
kExpectedDelay2);
timer = null;
do_test_finished();
}
}
};
function run_test() {
do_test_pending();
timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
// Initialize the timer (with some delay), then cancel it.
gStartTime1 = Date.now();
timer.init(observer1, kExpectedDelay1 * 1000, timer.TYPE_REPEATING_PRECISE);
timer.cancel();
// Re-initialize the timer (with a different delay).
gStartTime2 = Date.now();
timer.init(observer2, kExpectedDelay2 * 1000, timer.TYPE_REPEATING_PRECISE);
}

View File

@ -177,8 +177,7 @@ interface nsITimer : nsISupports
/**
* Initialize a timer to fire after the given millisecond interval.
* This version takes a function to call and a closure to pass to
* that function.
* This version takes a function to call.
*
* @param aFunc nsITimerCallback interface to call when timer expires
* @param aDelay The millisecond interval