Merge m-c to fx-team

This commit is contained in:
Carsten "Tomcat" Book 2014-04-30 15:28:33 +02:00
commit 697641a848
290 changed files with 23520 additions and 12923 deletions

View File

@ -86,6 +86,11 @@ this.FxAccountsMgmtService = {
if (!data) {
return;
}
// Backwards compatibility: handle accountId coming from Gaia
if (data.accountId && typeof(data.email === "undefined")) {
data.email = data.accountId;
delete data.accountId;
}
switch(data.method) {
case "getAccounts":
@ -110,7 +115,7 @@ this.FxAccountsMgmtService = {
).then(null, Components.utils.reportError);
break;
case "queryAccount":
FxAccountsManager.queryAccount(data.accountId).then(
FxAccountsManager.queryAccount(data.email).then(
result => {
self._onFulfill(msg.id, result);
},
@ -122,7 +127,7 @@ this.FxAccountsMgmtService = {
case "signIn":
case "signUp":
case "refreshAuthentication":
FxAccountsManager[data.method](data.accountId, data.password).then(
FxAccountsManager[data.method](data.email, data.password).then(
user => {
self._onFulfill(msg.id, user);
},

View File

@ -64,9 +64,9 @@ FxAccountsUIGlue.prototype = {
return this._contentRequest("openFlow");
},
refreshAuthentication: function(aAccountId) {
refreshAuthentication: function(aEmail) {
return this._contentRequest("refreshAuthentication", {
accountId: aAccountId
email: aEmail
});
},

View File

@ -128,7 +128,7 @@ add_test(function test_invalidEmailCase_signIn() {
case "getAccounts":
Services.obs.removeObserver(onMessage, "mozFxAccountsChromeEvent");
do_check_eq(message.data.accountId, canonicalEmail);
do_check_eq(message.data.email, canonicalEmail);
do_test_finished();
server.stop(run_next_test);
@ -151,7 +151,7 @@ add_test(function test_invalidEmailCase_signIn() {
id: "signIn",
data: {
method: "signIn",
accountId: clientEmail,
email: clientEmail,
password: "123456",
},
},

View File

@ -19,7 +19,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="badc73ee7f108fa631150bded0cc57e92aad810e"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="a3437e7e204e32f0f93880a43bfc0cef909cb84d"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="f313e6d3aaaefe8c82eaed15912a09b120fb7260"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="0292e64ef8451df104dcf9ac3b2c6749b81684dd"/>
@ -102,7 +102,7 @@
<project name="platform/external/iproute2" path="external/iproute2" revision="c66c5716d5335e450f7a7b71ccc6a604fb2f41d2"/>
<project name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="d2685281e2e54ca14d1df304867aa82c37b27162"/>
<project name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="627f9b20fc518937b93747a7ff1ed4f5ed46e06f"/>
<project name="platform/prebuilts/tools" path="prebuilts/tools" revision="bdce08ae0f7c92e5f1d2bafd777213702d6445f0"/>
<project name="platform/prebuilts/tools" path="prebuilts/tools" revision="d7755abaf703f86228e3938a3e204121b254638d"/>
<project name="platform_prebuilts_qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="431afac2ebfdd9c1c8402b413ff5914ed448e961"/>
<project name="android-sdk" path="sdk" remote="b2g" revision="4f46930827957afbce500a4a920755a218bf3155"/>
</manifest>

View File

@ -17,7 +17,7 @@
</project>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="badc73ee7f108fa631150bded0cc57e92aad810e"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="a3437e7e204e32f0f93880a43bfc0cef909cb84d"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="f313e6d3aaaefe8c82eaed15912a09b120fb7260"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="ce95d372e6d285725b96490afdaaf489ad8f9ca9"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="8d6c36d74ba9aefbc8c3618fc93dd4907a0dbf5e"/>

View File

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="65fba428f8d76336b33ddd9e15900357953600ba">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="badc73ee7f108fa631150bded0cc57e92aad810e"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="a3437e7e204e32f0f93880a43bfc0cef909cb84d"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="f313e6d3aaaefe8c82eaed15912a09b120fb7260"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="ce95d372e6d285725b96490afdaaf489ad8f9ca9"/>

View File

@ -19,7 +19,11 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<<<<<<< local
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="badc73ee7f108fa631150bded0cc57e92aad810e"/>
=======
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="a3437e7e204e32f0f93880a43bfc0cef909cb84d"/>
>>>>>>> other
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="f313e6d3aaaefe8c82eaed15912a09b120fb7260"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="0292e64ef8451df104dcf9ac3b2c6749b81684dd"/>
@ -102,7 +106,7 @@
<project name="platform/external/iproute2" path="external/iproute2" revision="c66c5716d5335e450f7a7b71ccc6a604fb2f41d2"/>
<project name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="d2685281e2e54ca14d1df304867aa82c37b27162"/>
<project name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="627f9b20fc518937b93747a7ff1ed4f5ed46e06f"/>
<project name="platform/prebuilts/tools" path="prebuilts/tools" revision="bdce08ae0f7c92e5f1d2bafd777213702d6445f0"/>
<project name="platform/prebuilts/tools" path="prebuilts/tools" revision="d7755abaf703f86228e3938a3e204121b254638d"/>
<project name="platform_prebuilts_qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="431afac2ebfdd9c1c8402b413ff5914ed448e961"/>
<project name="android-sdk" path="sdk" remote="b2g" revision="4f46930827957afbce500a4a920755a218bf3155"/>
</manifest>

View File

@ -18,7 +18,7 @@
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1f6a1fe07f81c5bc5e1d079c9b60f7f78ca2bf4f"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="badc73ee7f108fa631150bded0cc57e92aad810e"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="a3437e7e204e32f0f93880a43bfc0cef909cb84d"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="f313e6d3aaaefe8c82eaed15912a09b120fb7260"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="ce95d372e6d285725b96490afdaaf489ad8f9ca9"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="8d6c36d74ba9aefbc8c3618fc93dd4907a0dbf5e"/>

View File

@ -4,6 +4,6 @@
"remote": "",
"branch": ""
},
"revision": "2ba34e93a4be9aa6c52fcd9303bd7d78cffb58b7",
"revision": "ecde92711ca63dd62dd6008686532c0cc52c75dd",
"repo_path": "/integration/gaia-central"
}

View File

@ -17,7 +17,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="badc73ee7f108fa631150bded0cc57e92aad810e"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="a3437e7e204e32f0f93880a43bfc0cef909cb84d"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="f313e6d3aaaefe8c82eaed15912a09b120fb7260"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1f6a1fe07f81c5bc5e1d079c9b60f7f78ca2bf4f"/>

View File

@ -15,7 +15,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="badc73ee7f108fa631150bded0cc57e92aad810e"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="a3437e7e204e32f0f93880a43bfc0cef909cb84d"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="f313e6d3aaaefe8c82eaed15912a09b120fb7260"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1f6a1fe07f81c5bc5e1d079c9b60f7f78ca2bf4f"/>

View File

@ -19,7 +19,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="badc73ee7f108fa631150bded0cc57e92aad810e"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="a3437e7e204e32f0f93880a43bfc0cef909cb84d"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="f313e6d3aaaefe8c82eaed15912a09b120fb7260"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1f6a1fe07f81c5bc5e1d079c9b60f7f78ca2bf4f"/>

View File

@ -17,7 +17,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="badc73ee7f108fa631150bded0cc57e92aad810e"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="a3437e7e204e32f0f93880a43bfc0cef909cb84d"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="f313e6d3aaaefe8c82eaed15912a09b120fb7260"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1f6a1fe07f81c5bc5e1d079c9b60f7f78ca2bf4f"/>

View File

@ -17,7 +17,7 @@
</project>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="badc73ee7f108fa631150bded0cc57e92aad810e"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="a3437e7e204e32f0f93880a43bfc0cef909cb84d"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="f313e6d3aaaefe8c82eaed15912a09b120fb7260"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="ce95d372e6d285725b96490afdaaf489ad8f9ca9"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="8d6c36d74ba9aefbc8c3618fc93dd4907a0dbf5e"/>

View File

@ -17,7 +17,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="badc73ee7f108fa631150bded0cc57e92aad810e"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="a3437e7e204e32f0f93880a43bfc0cef909cb84d"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="f313e6d3aaaefe8c82eaed15912a09b120fb7260"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1f6a1fe07f81c5bc5e1d079c9b60f7f78ca2bf4f"/>

View File

@ -1,10 +1,14 @@
function check(aElementName, aBarred) {
function check(aElementName, aBarred, aType) {
let doc = gBrowser.contentDocument;
let tooltip = document.getElementById("aHTMLTooltip");
let content = doc.getElementById('content');
let e = doc.createElement(aElementName);
content.appendChild(e);
if (aType) {
e.type = aType;
}
ok(!tooltip.fillInPageTooltip(e),
"No tooltip should be shown when the element is valid");
@ -59,17 +63,18 @@ function test () {
let testData = [
/* element name, barred */
[ 'input', false ],
[ 'textarea', false ],
[ 'button', true ],
[ 'select', false ],
[ 'output', true ],
[ 'fieldset', true ],
[ 'object', true ],
[ 'input', false, null],
[ 'textarea', false, null],
[ 'button', true, 'button'],
[ 'button', false, 'submit'],
[ 'select', false, null],
[ 'output', true, null],
[ 'fieldset', true, null],
[ 'object', true, null],
];
for each (let data in testData) {
check(data[0], data[1]);
check(data[0], data[1], data[2]);
}
let todo_testData = [

View File

@ -12155,7 +12155,7 @@ nsIDocument::WrapObject(JSContext *aCx)
NS_NAMED_LITERAL_STRING(doc_str, "document");
if (!JS_DefineUCProperty(aCx, JSVAL_TO_OBJECT(winVal), doc_str.get(),
if (!JS_DefineUCProperty(aCx, winVal.toObjectOrNull(), doc_str.get(),
doc_str.Length(), JS::ObjectValue(*obj),
JS_PropertyStub, JS_StrictPropertyStub,
JSPROP_READONLY | JSPROP_ENUMERATE)) {

View File

@ -2450,8 +2450,8 @@ GetRequestBody(nsIVariant* aBody, nsIInputStream** aResult, uint64_t* aContentLe
JS::Rooted<JS::Value> realVal(cx);
nsresult rv = aBody->GetAsJSVal(&realVal);
if (NS_SUCCEEDED(rv) && !JSVAL_IS_PRIMITIVE(realVal)) {
JS::Rooted<JSObject*> obj(cx, JSVAL_TO_OBJECT(realVal));
if (NS_SUCCEEDED(rv) && !realVal.isPrimitive()) {
JS::Rooted<JSObject*> obj(cx, realVal.toObjectOrNull());
if (JS_IsArrayBufferObject(obj)) {
ArrayBuffer buf(obj);
return GetRequestBody(buf.Data(), buf.Length(), aResult,

View File

@ -825,7 +825,7 @@ CanvasRenderingContext2D::RemoveDemotableContext(CanvasRenderingContext2D* conte
}
bool
CheckSizeForSkiaGL(IntSize size) {
CanvasRenderingContext2D::CheckSizeForSkiaGL(IntSize size) {
MOZ_ASSERT(NS_IsMainThread());
int minsize = Preferences::GetInt("gfx.canvas.min-size-for-skia-gl", 128);
@ -852,6 +852,11 @@ CheckSizeForSkiaGL(IntSize size) {
// Cache the number of pixels on the primary screen
static int32_t gScreenPixels = -1;
if (gScreenPixels < 0) {
// Default to historical mobile screen size of 980x480. In addition,
// allow skia use up to this size even if the screen is smaller. A lot
// content expects this size to work well.
gScreenPixels = 980 * 480;
nsCOMPtr<nsIScreenManager> screenManager =
do_GetService("@mozilla.org/gfx/screenmanager;1");
if (screenManager) {
@ -861,13 +866,33 @@ CheckSizeForSkiaGL(IntSize size) {
int32_t x, y, width, height;
primaryScreen->GetRect(&x, &y, &width, &height);
gScreenPixels = width * height;
gScreenPixels = std::max(gScreenPixels, width * height);
}
}
}
// On high DPI devices the screen pixels may be scaled up. Make
// sure to apply that scaling here as well if we are hooked up
// to a widget.
static double gDefaultScale = 0.0;
if (gDefaultScale < 1.0) {
nsIPresShell* ps = GetPresShell();
if (ps) {
nsIFrame* frame = ps->GetRootFrame();
if (frame) {
nsIWidget* widget = frame->GetNearestWidget();
if (widget) {
gDefaultScale = widget->GetDefaultScale().scale;
}
}
}
}
int32_t threshold = gDefaultScale > 0 ? ceil(gDefaultScale * gScreenPixels)
: gScreenPixels;
// screen size acts as max threshold
return gScreenPixels < 0 || (size.width * size.height) <= gScreenPixels;
return threshold < 0 || (size.width * size.height) <= threshold;
}
void
@ -1335,7 +1360,7 @@ CanvasRenderingContext2D::GetMozCurrentTransformInverse(JSContext* cx,
Matrix ctm = mTarget->GetTransform();
if (!ctm.Invert()) {
double NaN = JSVAL_TO_DOUBLE(JS_GetNaNValue(cx));
double NaN = JS_GetNaNValue(cx).toDouble();
ctm = Matrix(NaN, NaN, NaN, NaN, NaN, NaN);
}

View File

@ -852,6 +852,8 @@ protected:
TextDrawOperation op,
float* aWidth);
bool CheckSizeForSkiaGL(mozilla::gfx::IntSize size);
// state stack handling
class ContextState {
public:

View File

@ -67,11 +67,11 @@ DoDrawImageSecurityCheck(dom::HTMLCanvasElement *aCanvasElement,
bool
CoerceDouble(JS::Value v, double* d)
{
if (JSVAL_IS_DOUBLE(v)) {
*d = JSVAL_TO_DOUBLE(v);
} else if (JSVAL_IS_INT(v)) {
*d = double(JSVAL_TO_INT(v));
} else if (JSVAL_IS_VOID(v)) {
if (v.isDouble()) {
*d = v.toDouble();
} else if (v.isInt32()) {
*d = double(v.toInt32());
} else if (v.isUndefined()) {
*d = 0.0;
} else {
return false;

View File

@ -106,8 +106,8 @@ JSValToDashArray(JSContext* cx, const JS::Value& patternArray,
// anybody...
static const uint32_t MAX_NUM_DASHES = 1 << 14;
if (!JSVAL_IS_PRIMITIVE(patternArray)) {
JS::Rooted<JSObject*> obj(cx, JSVAL_TO_OBJECT(patternArray));
if (!patternArray.isPrimitive()) {
JS::Rooted<JSObject*> obj(cx, patternArray.toObjectOrNull());
uint32_t length;
if (!JS_GetArrayLength(cx, obj, &length)) {
// Not an array-like thing
@ -141,7 +141,7 @@ JSValToDashArray(JSContext* cx, const JS::Value& patternArray,
// An all-zero pattern makes no sense.
return NS_ERROR_ILLEGAL_VALUE;
}
} else if (!(JSVAL_IS_VOID(patternArray) || JSVAL_IS_NULL(patternArray))) {
} else if (!(patternArray.isUndefined() || patternArray.isNull())) {
// undefined and null mean "reset to no dash". Any other
// random garbage is a type error.
return NS_ERROR_INVALID_ARG;

View File

@ -63,9 +63,6 @@ HTMLButtonElement::HTMLButtonElement(already_AddRefed<nsINodeInfo>& aNodeInfo,
mInInternalActivate(false),
mInhibitStateRestoration(!!(aFromParser & FROM_PARSER_FRAGMENT))
{
// <button> is always barred from constraint validation.
SetBarredFromConstraintValidation(true);
// Set up our default state: enabled
AddStatesSilently(NS_EVENT_STATE_ENABLED);
}
@ -92,11 +89,36 @@ NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(HTMLButtonElement)
NS_INTERFACE_TABLE_TAIL_INHERITING(nsGenericHTMLFormElementWithState)
// nsIConstraintValidation
NS_IMPL_NSICONSTRAINTVALIDATION(HTMLButtonElement)
NS_IMPL_NSICONSTRAINTVALIDATION_EXCEPT_SETCUSTOMVALIDITY(HTMLButtonElement)
NS_IMETHODIMP
HTMLButtonElement::SetCustomValidity(const nsAString& aError)
{
nsIConstraintValidation::SetCustomValidity(aError);
UpdateState(true);
return NS_OK;
}
void
HTMLButtonElement::UpdateBarredFromConstraintValidation()
{
SetBarredFromConstraintValidation(mType == NS_FORM_BUTTON_BUTTON ||
mType == NS_FORM_BUTTON_RESET ||
IsDisabled());
}
void
HTMLButtonElement::FieldSetDisabledChanged(bool aNotify)
{
UpdateBarredFromConstraintValidation();
nsGenericHTMLFormElementWithState::FieldSetDisabledChanged(aNotify);
}
// nsIDOMHTMLButtonElement
NS_IMPL_ELEMENT_CLONE(HTMLButtonElement)
@ -491,8 +513,11 @@ HTMLButtonElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
if (!aValue) {
mType = kButtonDefaultType->value;
}
}
UpdateState(aNotify);
if (aName == nsGkAtoms::type || aName == nsGkAtoms::disabled) {
UpdateBarredFromConstraintValidation();
UpdateState(aNotify);
}
}
@ -531,6 +556,20 @@ EventStates
HTMLButtonElement::IntrinsicState() const
{
EventStates state = nsGenericHTMLFormElementWithState::IntrinsicState();
if (IsCandidateForConstraintValidation()) {
if (IsValid()) {
state |= NS_EVENT_STATE_VALID;
if (!mForm || !mForm->HasAttr(kNameSpaceID_None, nsGkAtoms::novalidate)) {
state |= NS_EVENT_STATE_MOZ_UI_VALID;
}
} else {
state |= NS_EVENT_STATE_INVALID;
if (!mForm || !mForm->HasAttr(kNameSpaceID_None, nsGkAtoms::novalidate)) {
state |= NS_EVENT_STATE_MOZ_UI_INVALID;
}
}
}
if (mForm && !mForm->GetValidity() && IsSubmitControl()) {
state |= NS_EVENT_STATE_MOZ_SUBMITINVALID;

View File

@ -48,6 +48,8 @@ public:
bool RestoreState(nsPresState* aState) MOZ_OVERRIDE;
virtual bool IsDisabledForEvents(uint32_t aMessage) MOZ_OVERRIDE;
virtual void FieldSetDisabledChanged(bool aNotify) MOZ_OVERRIDE;
// nsIDOMEventTarget
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PostHandleEvent(
@ -65,6 +67,7 @@ public:
bool aNullParent = true) MOZ_OVERRIDE;
virtual void DoneCreatingElement() MOZ_OVERRIDE;
void UpdateBarredFromConstraintValidation();
// Element
EventStates IntrinsicState() const MOZ_OVERRIDE;
/**

View File

@ -6685,8 +6685,6 @@ HTMLInputElement::UpdateBarredFromConstraintValidation()
SetBarredFromConstraintValidation(mType == NS_FORM_INPUT_HIDDEN ||
mType == NS_FORM_INPUT_BUTTON ||
mType == NS_FORM_INPUT_RESET ||
mType == NS_FORM_INPUT_SUBMIT ||
mType == NS_FORM_INPUT_IMAGE ||
HasAttr(kNameSpaceID_None, nsGkAtoms::readonly) ||
IsDisabled());
}

View File

@ -255,8 +255,8 @@ var input = document.getElementById('i');
// |validTypes| are the types which accept @pattern
// and |invalidTypes| are the ones which do not accept it.
var validTypes = Array('text', 'password', 'search', 'tel', 'email', 'url');
var barredTypes = Array('hidden', 'reset', 'button', 'submit', 'image');
var invalidTypes = Array('checkbox', 'radio', 'file', 'number', 'range', 'date', 'time', 'color');
var barredTypes = Array('hidden', 'reset', 'button');
var invalidTypes = Array('checkbox', 'radio', 'file', 'number', 'range', 'date', 'time', 'color', 'submit', 'image');
// TODO: 'datetime', 'month', 'week', and 'datetime-local'
// do not accept the @pattern too but are not implemented yet.

View File

@ -360,13 +360,13 @@ checkTextareaRequiredValidity();
// The require attribute behavior depend of the input type.
// First of all, checks for types that make the element barred from
// constraint validation.
var typeBarredFromConstraintValidation = ["hidden", "button", "reset", "submit", "image"];
var typeBarredFromConstraintValidation = ["hidden", "button", "reset"];
for (type of typeBarredFromConstraintValidation) {
checkInputRequiredNotApply(type, true);
}
// Then, checks for the types which do not use the required attribute.
var typeRequireNotApply = ['range', 'color'];
var typeRequireNotApply = ['range', 'color', 'submit', 'image'];
for (type of typeRequireNotApply) {
checkInputRequiredNotApply(type, false);
}

View File

@ -119,8 +119,8 @@ function checkDefaultPseudoClass()
":valid pseudo-class should apply");
is(window.getComputedStyle(document.getElementById('b'), null)
.getPropertyValue('background-color'), "rgb(0, 0, 0)",
":valid pseudo-class should not apply");
.getPropertyValue('background-color'), "rgb(0, 255, 0)",
":valid pseudo-class should apply");
}
function checkSpecificWillValidate()
@ -147,13 +147,13 @@ function checkSpecificWillValidate()
is(window.getComputedStyle(i, null).getPropertyValue('background-color'),
"rgb(0, 0, 0)", "Nor :valid and :invalid should apply");
i.type = "image";
ok(!i.willValidate, "Image state input should be barred from constraint validation");
ok(i.willValidate, "Image state input should not be barred from constraint validation");
is(window.getComputedStyle(i, null).getPropertyValue('background-color'),
"rgb(0, 0, 0)", "Nor :valid and :invalid should apply");
"rgb(0, 255, 0)", ":valid and :invalid should apply");
i.type = "submit";
ok(!i.willValidate, "Submit state input should be barred from constraint validation");
ok(i.willValidate, "Submit state input should not be barred from constraint validation");
is(window.getComputedStyle(i, null).getPropertyValue('background-color'),
"rgb(0, 0, 0)", "Nor :valid and :invalid should apply");
"rgb(0, 255, 0)", ":valid and :invalid should apply");
i.type = "number";
ok(i.willValidate, "Number state input should not be barred from constraint validation");
is(window.getComputedStyle(i, null).getPropertyValue('background-color'),
@ -179,13 +179,13 @@ function checkSpecificWillValidate()
is(window.getComputedStyle(b, null).getPropertyValue('background-color'),
"rgb(0, 0, 0)", "Nor :valid and :invalid should apply");
b.type = "submit";
ok(!b.willValidate, "Submit state button should be barred from constraint validation");
ok(b.willValidate, "Submit state button should not be barred from constraint validation");
is(window.getComputedStyle(b, null).getPropertyValue('background-color'),
"rgb(0, 0, 0)", "Nor :valid and :invalid should apply");
"rgb(0, 255, 0)", ":valid and :invalid should apply");
b.type = "";
ok(!b.willValidate, "Default button element should be barred from constraint validation");
ok(b.willValidate, "Default button element should not be barred from constraint validation");
is(window.getComputedStyle(b, null).getPropertyValue('background-color'),
"rgb(0, 0, 0)", ":valid pseudo-class should apply");
"rgb(0, 255, 0)", ":valid pseudo-class should apply");
// textarea element
t = document.getElementById('t');
@ -332,7 +332,7 @@ checkCustomError(document.getElementById('i'), false);
checkCustomError(document.getElementById('s'), false);
checkCustomError(document.getElementById('t'), false);
checkCustomError(document.getElementById('o'), false);
checkCustomError(document.getElementById('b'), true);
checkCustomError(document.getElementById('b'), false);
checkCustomError(document.getElementById('f'), true);
checkCustomError(document.getElementById('obj'), true);

View File

@ -319,6 +319,7 @@ skip-if = (buildapp == 'b2g' && (toolkit != 'gonk' || debug)) # b2g-debug(timed
[test_bug957847.html]
[test_chaining.html]
skip-if = buildapp == 'b2g' # b2g(timed out) b2g-debug(timed out) b2g-desktop(timed out)
[test_clone_media_element.html]
[test_contentDuration1.html]
[test_contentDuration2.html]
[test_contentDuration3.html]

View File

@ -0,0 +1,55 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test: cloned media element should continue to play to the end even after the source of the original element is cleared</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script type="text/javascript" src="manifest.js"></script>
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.requestLongerTimeout(2);
// tests must run in sequence otherwise concurrent running test will also
// update media cache which will hide the fact media cache not updated
// after changes in media cache streams.
PARALLEL_TESTS = 1;
function startTest(test, token) {
manager.started(token);
info("Trying to load " + token);
var v = document.createElement('video');
v.preload = "metadata";
v.token = token;
v.src = test.name;
v.onloadedmetadata = function(evt) {
info(evt.target.token + " metadata loaded.");
evt.target.onloadedmetadata = null;
var clone = evt.target.cloneNode(false);
clone.token = evt.target.token;
clone.play();
clone.onloadstart = function(evt) {
info("cloned " + evt.target.token + " start loading.");
evt.target.onloadstart = null;
removeNodeAndSource(v);
}
clone.onended = function(evt) {
ok(true, "cloned " + evt.target.token + " ended.");
evt.target.onended = null;
removeNodeAndSource(evt.target);
manager.finished(evt.target.token);
}
}
}
var manager = new MediaTestManager;
manager.runTests(gSmallTests.concat(gPlayedTests), startTest);
</script>
</pre>
</body>
</html>

View File

@ -88,7 +88,10 @@ void EbmlComposer::FinishCluster()
EbmlGlobal ebml;
EbmlLoc ebmlLoc;
ebmlLoc.offset = mClusterLengthLoc;
ebml.offset = mClusterBuffs[mClusterHeaderIndex].Length();
ebml.offset = 0;
for (uint32_t i = mClusterHeaderIndex; i < mClusterBuffs.Length(); i++) {
ebml.offset += mClusterBuffs[i].Length();
}
ebml.buf = mClusterBuffs[mClusterHeaderIndex].Elements();
Ebml_EndSubElement(&ebml, &ebmlLoc);
// Move the mClusterBuffs data from mClusterHeaderIndex that we can skip

View File

@ -1392,7 +1392,7 @@ nsXULTemplateBuilder::InitHTMLTemplateRoot()
rv = nsContentUtils::WrapNative(jscontext, mRoot, mRoot, &v);
NS_ENSURE_SUCCESS(rv, rv);
JS::Rooted<JSObject*> jselement(jscontext, JSVAL_TO_OBJECT(v));
JS::Rooted<JSObject*> jselement(jscontext, v.toObjectOrNull());
if (mDB) {
// database

View File

@ -101,7 +101,7 @@ DOMRequest::FireSuccess(JS::Handle<JS::Value> aResult)
NS_ASSERTION(mResult == JSVAL_VOID, "mResult shouldn't have been set!");
mDone = true;
if (JSVAL_IS_GCTHING(aResult)) {
if (aResult.isGCThing()) {
RootResultVal();
}
mResult = aResult;

View File

@ -109,7 +109,7 @@ PostMessageReadStructuredClone(JSContext* cx,
if (JS_ReadBytes(reader, &supports, sizeof(supports))) {
JS::Rooted<JS::Value> val(cx);
if (NS_SUCCEEDED(nsContentUtils::WrapNative(cx, supports, &val))) {
return JSVAL_TO_OBJECT(val);
return val.toObjectOrNull();
}
}
}

View File

@ -1428,7 +1428,7 @@ nsDOMClassInfo::ResolveConstructor(JSContext *cx, JSObject *aObj,
return NS_ERROR_UNEXPECTED;
}
if (!JSVAL_IS_PRIMITIVE(val)) {
if (!val.isPrimitive()) {
// If val is not an (non-null) object there either is no
// constructor for this class, or someone messed with
// window.classname, just fall through and let the JS engine
@ -2273,7 +2273,7 @@ nsDOMConstructor::HasInstance(nsIXPConnectWrappedNative *wrapper,
{
// No need to look these up in the hash.
*bp = false;
if (JSVAL_IS_PRIMITIVE(v)) {
if (v.isPrimitive()) {
return NS_OK;
}
@ -2305,7 +2305,7 @@ nsDOMConstructor::HasInstance(nsIXPConnectWrappedNative *wrapper,
return NS_ERROR_UNEXPECTED;
}
if (JSVAL_IS_PRIMITIVE(val)) {
if (val.isPrimitive()) {
return NS_OK;
}
@ -3034,7 +3034,7 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
NS_ENSURE_SUCCESS(rv, rv);
}
if (JSVAL_IS_PRIMITIVE(prop_val) && !JSVAL_IS_NULL(prop_val)) {
if (prop_val.isPrimitive() && !prop_val.isNull()) {
if (aWin->IsOuterWindow()) {
nsGlobalWindow *inner = aWin->GetCurrentInnerWindowInternal();
NS_ENSURE_TRUE(inner, NS_ERROR_UNEXPECTED);
@ -3547,13 +3547,13 @@ nsGenericArraySH::GetLength(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
return NS_ERROR_UNEXPECTED;
}
if (!JSVAL_IS_INT(lenval)) {
if (!lenval.isInt32()) {
// This can apparently happen with some sparse array impls falling back
// onto this code.
return NS_OK;
}
int32_t slen = JSVAL_TO_INT(lenval);
int32_t slen = lenval.toInt32();
if (slen < 0) {
return NS_OK;
}
@ -3584,8 +3584,8 @@ nsGenericArraySH::Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JS::Rooted<JS::Value> len_val(cx);
bool ok = ::JS_GetProperty(cx, obj, "length", &len_val);
if (ok && JSVAL_IS_INT(len_val)) {
int32_t length = JSVAL_TO_INT(len_val);
if (ok && len_val.isInt32()) {
int32_t length = len_val.toInt32();
for (int32_t i = 0; ok && i < length; ++i) {
ok = ::JS_DefineElement(cx, obj, i, JSVAL_VOID, nullptr, nullptr,
@ -3844,8 +3844,7 @@ nsStorage2SH::NewEnumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
return NS_OK;
}
nsTArray<nsString> *keys =
(nsTArray<nsString> *)JSVAL_TO_PRIVATE(*statep);
nsTArray<nsString> *keys = (nsTArray<nsString> *)statep->toPrivate();
if (enum_op == JSENUMERATE_NEXT && keys->Length() != 0) {
nsString& key = keys->ElementAt(0);

View File

@ -2386,11 +2386,11 @@ nsDOMWindowUtils::GetClassName(JS::Handle<JS::Value> aObject, JSContext* aCx,
}
// Our argument must be a non-null object.
if (JSVAL_IS_PRIMITIVE(aObject)) {
if (aObject.isPrimitive()) {
return NS_ERROR_XPC_BAD_CONVERT_JS;
}
*aName = NS_strdup(JS_GetClass(JSVAL_TO_OBJECT(aObject))->name);
*aName = NS_strdup(JS_GetClass(aObject.toObjectOrNull())->name);
NS_ABORT_IF_FALSE(*aName, "NS_strdup should be infallible.");
return NS_OK;
}
@ -3212,8 +3212,8 @@ nsDOMWindowUtils::GetFileId(JS::Handle<JS::Value> aFile, JSContext* aCx,
return NS_ERROR_DOM_SECURITY_ERR;
}
if (!JSVAL_IS_PRIMITIVE(aFile)) {
JSObject* obj = JSVAL_TO_OBJECT(aFile);
if (!aFile.isPrimitive()) {
JSObject* obj = aFile.toObjectOrNull();
file::FileHandle* fileHandle;
if (NS_SUCCEEDED(UNWRAP_OBJECT(FileHandle, obj, fileHandle))) {

View File

@ -185,7 +185,7 @@ public:
bool init(JSContext* aContext, const JS::Value &v)
{
return init(aContext, JSVAL_TO_STRING(v));
return init(aContext, v.toString());
}
void init(JSFlatString* fstr)

View File

@ -352,7 +352,7 @@ InterfaceObjectToString(JSContext* cx, unsigned argc, JS::Value *vp)
const JSClass* clasp = static_cast<const JSClass*>(v.toPrivate());
v = js::GetFunctionNativeReserved(callee, TOSTRING_NAME_RESERVED_SLOT);
JSString* jsname = static_cast<JSString*>(JSVAL_TO_STRING(v));
JSString* jsname = static_cast<JSString*>(v.toString());
size_t length;
const jschar* name = JS_GetInternedStringCharsAndLength(jsname, &length);

View File

@ -517,12 +517,12 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(IDBCursor)
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
NS_ASSERTION(tmp->mHaveCachedKey || JSVAL_IS_VOID(tmp->mCachedKey),
NS_ASSERTION(tmp->mHaveCachedKey || tmp->mCachedKey.isUndefined(),
"Should have a cached key");
NS_ASSERTION(tmp->mHaveCachedPrimaryKey ||
JSVAL_IS_VOID(tmp->mCachedPrimaryKey),
tmp->mCachedPrimaryKey.isUndefined(),
"Should have a cached primary key");
NS_ASSERTION(tmp->mHaveCachedValue || JSVAL_IS_VOID(tmp->mCachedValue),
NS_ASSERTION(tmp->mHaveCachedValue || tmp->mCachedValue.isUndefined(),
"Should have a cached value");
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mScriptOwner)
NS_IMPL_CYCLE_COLLECTION_TRACE_JSVAL_MEMBER_CALLBACK(mCachedKey)

View File

@ -831,14 +831,14 @@ IDBIndex::GetKeyPath(JSContext* aCx, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
if (!JSVAL_IS_VOID(mCachedKeyPath)) {
if (!mCachedKeyPath.isUndefined()) {
return mCachedKeyPath;
}
aRv = GetKeyPath().ToJSVal(aCx, mCachedKeyPath);
ENSURE_SUCCESS(aRv, JSVAL_VOID);
if (JSVAL_IS_GCTHING(mCachedKeyPath)) {
if (mCachedKeyPath.isGCThing()) {
mozilla::HoldJSObjects(this);
mRooted = true;
}

View File

@ -837,7 +837,7 @@ public:
return nullptr;
}
return JSVAL_TO_OBJECT(wrappedBlob);
return wrappedBlob.toObjectOrNull();
}
nsCOMPtr<nsIDOMFile> domFile;
@ -862,7 +862,7 @@ public:
return nullptr;
}
return JSVAL_TO_OBJECT(wrappedFile);
return wrappedFile.toObjectOrNull();
}
};
@ -1837,7 +1837,7 @@ IDBObjectStore::GetAddInfo(JSContext* aCx,
// Return DATA_ERR if a key was passed in and this objectStore uses inline
// keys.
if (!JSVAL_IS_VOID(aKeyVal) && HasValidKeyPath()) {
if (!aKeyVal.isUndefined() && HasValidKeyPath()) {
return NS_ERROR_DOM_INDEXEDDB_DATA_ERR;
}
@ -2615,14 +2615,14 @@ IDBObjectStore::GetKeyPath(JSContext* aCx, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
if (!JSVAL_IS_VOID(mCachedKeyPath)) {
if (!mCachedKeyPath.isUndefined()) {
return mCachedKeyPath;
}
aRv = GetKeyPath().ToJSVal(aCx, mCachedKeyPath);
ENSURE_SUCCESS(aRv, JSVAL_VOID);
if (JSVAL_IS_GCTHING(mCachedKeyPath)) {
if (mCachedKeyPath.isGCThing()) {
mozilla::HoldJSObjects(this);
mRooted = true;
}

View File

@ -169,7 +169,7 @@ IDBRequest::NotifyHelperCompleted(HelperBase* aHelper)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
NS_ASSERTION(!mHaveResultOrErrorCode, "Already called!");
NS_ASSERTION(JSVAL_IS_VOID(mResultVal), "Should be undefined!");
NS_ASSERTION(mResultVal.isUndefined(), "Should be undefined!");
mHaveResultOrErrorCode = true;
@ -225,7 +225,7 @@ IDBRequest::NotifyHelperSentResultsToChildProcess(nsresult aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
NS_ASSERTION(!mHaveResultOrErrorCode, "Already called!");
NS_ASSERTION(JSVAL_IS_VOID(mResultVal), "Should be undefined!");
NS_ASSERTION(mResultVal.isUndefined(), "Should be undefined!");
// See if our window is still valid. If not then we're going to pretend that
// we never completed.

View File

@ -655,7 +655,7 @@ IndexedDatabaseManager::InitWindowless(JS::Handle<JS::Value> aGlobal, JSContext*
{
NS_ENSURE_TRUE(nsContentUtils::IsCallerChrome(), NS_ERROR_NOT_AVAILABLE);
JS::Rooted<JSObject*> global(aCx, JSVAL_TO_OBJECT(aGlobal));
JS::Rooted<JSObject*> global(aCx, aGlobal.toObjectOrNull());
if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
NS_WARNING("Passed object is not a global object!");
return NS_ERROR_FAILURE;

View File

@ -96,7 +96,7 @@ GetJSValFromKeyPathString(JSContext* aCx,
nsString targetObjectPropName;
JS::Rooted<JSObject*> targetObject(aCx, nullptr);
JS::Rooted<JSObject*> obj(aCx,
JSVAL_IS_PRIMITIVE(aValue) ? nullptr : JSVAL_TO_OBJECT(aValue));
aValue.isPrimitive() ? nullptr : aValue.toObjectOrNull());
while (tokenizer.hasMoreTokens()) {
const nsDependentSubstring& token = tokenizer.nextToken();
@ -129,10 +129,10 @@ GetJSValFromKeyPathString(JSContext* aCx,
}
if (tokenizer.hasMoreTokens()) {
// ...and walk to it if there are more steps...
if (JSVAL_IS_PRIMITIVE(intermediate)) {
if (intermediate.isPrimitive()) {
return NS_ERROR_DOM_INDEXEDDB_DATA_ERR;
}
obj = JSVAL_TO_OBJECT(intermediate);
obj = intermediate.toObjectOrNull();
}
else {
// ...otherwise use it as key
@ -272,7 +272,7 @@ KeyPath::Parse(JSContext* aCx, const JS::Value& aValue_, KeyPath* aKeyPath)
// See if this is a JS array.
if (JS_IsArrayObject(aCx, aValue)) {
JS::Rooted<JSObject*> obj(aCx, JSVAL_TO_OBJECT(aValue));
JS::Rooted<JSObject*> obj(aCx, aValue.toObjectOrNull());
uint32_t length;
if (!JS_GetArrayLength(aCx, obj, &length)) {
@ -301,7 +301,7 @@ KeyPath::Parse(JSContext* aCx, const JS::Value& aValue_, KeyPath* aKeyPath)
}
}
// Otherwise convert it to a string.
else if (!JSVAL_IS_NULL(aValue) && !JSVAL_IS_VOID(aValue)) {
else if (!aValue.isNull() && !aValue.isUndefined()) {
JSString* jsstr;
nsDependentJSString str;
if (!(jsstr = JS::ToString(aCx, aValue)) ||
@ -435,7 +435,7 @@ KeyPath::ExtractOrCreateKey(JSContext* aCx, const JS::Value& aValue,
if (NS_FAILED(aKey.AppendItem(aCx, false, value))) {
NS_ASSERTION(aKey.IsUnset(), "Should be unset");
return JSVAL_IS_VOID(value) ? NS_OK : NS_ERROR_DOM_INDEXEDDB_DATA_ERR;
return value.isUndefined() ? NS_OK : NS_ERROR_DOM_INDEXEDDB_DATA_ERR;
}
aKey.FinishArray();

View File

@ -411,7 +411,7 @@ IndexedDBDatabaseParent::HandleRequestEvent(nsIDOMEvent* aEvent,
JS::Rooted<JS::Value> result(cx, mOpenRequest->GetResult(cx, error));
ENSURE_SUCCESS(error, error.ErrorCode());
MOZ_ASSERT(!JSVAL_IS_PRIMITIVE(result));
MOZ_ASSERT(!result.isPrimitive());
IDBDatabase *database;
rv = UNWRAP_OBJECT(IDBDatabase, &result.toObject(), database);

View File

@ -0,0 +1,55 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "DOMMMIError.h"
#include "mozilla/dom/DOMMMIErrorBinding.h"
using namespace mozilla::dom;
NS_IMPL_CYCLE_COLLECTION_CLASS(DOMMMIError)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(DOMMMIError, DOMError)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(DOMMMIError, DOMError)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(DOMMMIError)
NS_INTERFACE_MAP_END_INHERITING(DOMError)
NS_IMPL_ADDREF_INHERITED(DOMMMIError, DOMError)
NS_IMPL_RELEASE_INHERITED(DOMMMIError, DOMError)
DOMMMIError::DOMMMIError(nsPIDOMWindow* aWindow, const nsAString& aName,
const nsAString& aMessage, const nsAString& aServiceCode,
const Nullable<int16_t>& aInfo)
: DOMError(aWindow, aName, aMessage)
, mServiceCode(aServiceCode)
, mInfo(aInfo)
{
}
JSObject*
DOMMMIError::WrapObject(JSContext* aCx)
{
return DOMMMIErrorBinding::Wrap(aCx, this);
}
// WebIDL interface
/* static */ already_AddRefed<DOMMMIError>
DOMMMIError::Constructor(const GlobalObject& aGlobal,
const nsAString& aServiceCode,
const nsAString& aName,
const nsAString& aMessage,
const Nullable<int16_t>& aInfo,
ErrorResult& aRv) {
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
nsRefPtr<DOMMMIError> error = new DOMMMIError(window, aName, aMessage,
aServiceCode, aInfo);
return error.forget();
}

View File

@ -0,0 +1,54 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_MmiError_h
#define mozilla_dom_MmiError_h
#include "mozilla/dom/DOMError.h"
namespace mozilla {
namespace dom {
class DOMMMIError MOZ_FINAL : public DOMError
{
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DOMMMIError, DOMError)
DOMMMIError(nsPIDOMWindow* aWindow, const nsAString& aName,
const nsAString& aMessage, const nsAString& aServiceCode,
const Nullable<int16_t>& aInfo);
virtual JSObject*
WrapObject(JSContext* aCx) MOZ_OVERRIDE;
// WebIDL interface
static already_AddRefed<DOMMMIError>
Constructor(const GlobalObject& aGlobal, const nsAString& aServiceCode,
const nsAString& aName, const nsAString& aMessage,
const Nullable<int16_t>& aInfo, ErrorResult& aRv);
void
GetServiceCode(nsString& aServiceCode) const
{
aServiceCode = mServiceCode;
}
Nullable<int16_t>
GetAdditionalInformation() const
{
return mInfo;
}
private:
nsString mServiceCode;
Nullable<int16_t> mInfo;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_MmiError_h

View File

@ -5,11 +5,13 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
EXPORTS.mozilla.dom += [
'DOMMMIError.h',
'MobileConnection.h',
'MobileConnectionArray.h',
]
SOURCES += [
'DOMMMIError.cpp',
'MobileConnection.cpp',
'MobileConnectionArray.cpp',
]

View File

@ -387,6 +387,23 @@ function selectNetworkAutomaticallyAndWait() {
return Promise.all(promises);
}
/**
* Send a MMI message.
*
* Fulfill params: An object contains MMI result.
* Reject params: A DOMMMIError.
*
* @param aMmi
* A MMI string.
*
* @return A deferred promise.
*/
function sendMMI(aMmi) {
let request = mobileConnection.sendMMI(aMmi);
return wrapDomRequestAsPromise(request)
.then(() => request.result, () => { throw request.error });
}
/**
* Set data connection enabling state and wait for "datachange" event.
*

View File

@ -14,6 +14,7 @@ qemu = true
[test_mobile_data_location.js]
[test_mobile_data_state.js]
[test_mobile_mmi.js]
[test_mobile_mmi_change_pin.js]
[test_mobile_roaming_preference.js]
[test_call_barring_get_option.js]
[test_call_barring_set_error.js]

View File

@ -1,107 +1,46 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 20000;
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = "head.js";
SpecialPowers.addPermission("mobileconnection", true, document);
// Permission changes can't change existing Navigator.prototype
// objects, so grab our objects from a new Navigator
let ifr = document.createElement("iframe");
let mobileConnection;
ifr.onload = function() {
mobileConnection = ifr.contentWindow.navigator.mozMobileConnections[0];
tasks.run();
};
document.body.appendChild(ifr);
let tasks = {
// List of test functions. Each of them should call |tasks.next()| when
// completed or |tasks.abort()| to jump to the last one.
_tasks: [],
_nextTaskIndex: 0,
push: function(func) {
this._tasks.push(func);
},
next: function() {
let index = this._nextTaskIndex++;
let task = this._tasks[index];
try {
task();
} catch (ex) {
ok(false, "test task[" + index + "] throws: " + ex);
// Run last task as clean up if possible.
if (index != this._tasks.length - 1) {
this.abort();
}
}
},
abort: function() {
this._tasks[this._tasks.length - 1]();
},
run: function() {
this.next();
}
};
tasks.push(function verifyInitialState() {
log("Verifying initial state.");
ok(mobileConnection instanceof ifr.contentWindow.MozMobileConnection,
"mobileConnection is instanceof " + mobileConnection.constructor);
tasks.next();
});
tasks.push(function testGettingIMEI() {
function testGettingIMEI() {
log("Test *#06# ...");
let request = mobileConnection.sendMMI("*#06#");
ok(request instanceof DOMRequest,
"request is instanceof " + request.constructor);
let MMI_CODE = "*#06#";
return sendMMI(MMI_CODE)
.then(function resolve(aResult) {
ok(true, MMI_CODE + " success");
is(aResult.serviceCode, "scImei", "Service code IMEI");
// IMEI is hardcoded as "000000000000000".
// See it here {B2G_HOME}/external/qemu/telephony/android_modem.c
// (The result of +CGSN).
is(aResult.statusMessage, "000000000000000", "Emulator IMEI");
is(aResult.additionalInformation, undefined, "No additional information");
}, function reject() {
ok(false, MMI_CODE + " should not fail");
});
}
request.onsuccess = function onsuccess(event) {
ok(true, "request success");
is(typeof event.target.result, "object", "typeof result object");
ok(event.target.result instanceof Object, "result instanceof Object");
is(event.target.result.statusMessage, "000000000000000", "Emulator IMEI");
is(event.target.result.serviceCode, "scImei", "Service code IMEI");
is(event.target.result.additionalInformation, undefined,
"No additional information");
tasks.next();
}
request.onerror = function onerror() {
ok(false, "request should not error");
tasks.abort();
};
});
tasks.push(function testInvalidMMICode(){
function testInvalidMMICode() {
log("Test invalid MMI code ...");
let request = mobileConnection.sendMMI("InvalidMMICode");
ok(request instanceof DOMRequest,
"request is instanceof " + request.constructor);
let MMI_CODE = "InvalidMMICode";
return sendMMI(MMI_CODE)
.then(function resolve() {
ok(false, MMI_CODE + " should not success");
}, function reject(aError) {
ok(true, MMI_CODE + " fail");
is(aError.name, "emMmiError", "MMI error name");
is(aError.message, "", "No message");
is(aError.serviceCode, "", "No serviceCode");
is(aError.additionalInformation, null, "No additional information");
});
}
request.onsuccess = function onsuccess(event) {
ok(false, "request should not success");
tasks.abort();
};
request.onerror = function onerror() {
ok(true, "request error");
is(request.error.name, "emMmiError", "MMI error name");
tasks.next();
};
});
// WARNING: All tasks should be pushed before this!!!
tasks.push(function cleanUp() {
SpecialPowers.removePermission("mobileconnection", document);
finish();
// Start test
startTestCommon(function() {
return Promise.resolve()
.then(() => testGettingIMEI())
.then(() => testInvalidMMICode());
});

View File

@ -0,0 +1,111 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = "head.js";
// PIN is hardcoded as "0000" by default.
// See it here {B2G_HOME}/external/qemu/telephony/sim_card.c,
// in asimcard_create().
const TEST_DATA = [
// Test passing no pin.
{
pin: "",
newPin: "0000",
newPinAgain: "1111",
expectedError: {
name: "emMmiError",
additionalInformation: null
}
},
// Test passing no newPin.
{
pin: "0000",
newPin: "",
newPinAgain: "",
expectedError: {
name: "emMmiError",
additionalInformation: null
}
},
// Test passing mismatched newPin.
{
pin: "0000",
newPin: "0000",
newPinAgain: "1111",
expectedError: {
name: "emMmiErrorMismatchPin",
additionalInformation: null
}
},
// Test passing invalid pin (< 4 digit).
{
pin: "000",
newPin: "0000",
newPinAgain: "0000",
expectedError: {
name: "emMmiErrorInvalidPin",
additionalInformation: null
}
},
// Test passing invalid newPin (> 8 digit).
{
pin: "0000",
newPin: "000000000",
newPinAgain: "000000000",
expectedError: {
name: "emMmiErrorInvalidPin",
additionalInformation: null
}
},
// Test passing incorrect pin.
{
pin: "1234",
newPin: "0000",
newPinAgain: "0000",
expectedError: {
name: "emMmiErrorBadPin",
// The default pin retries is 3, failed once becomes to 2
additionalInformation: 2
}
},
// Test changing pin successfully (Reset the retries).
{
pin: "0000",
newPin: "0000",
newPinAgain: "0000"
}
];
function testChangePin(aPin, aNewPin, aNewPinAgain, aExpectedError) {
let MMI_CODE = "**04*" + aPin + "*" + aNewPin + "*" + aNewPinAgain + "#";
log("Test " + MMI_CODE);
return sendMMI(MMI_CODE)
.then(function resolve(aResult) {
ok(!aExpectedError, MMI_CODE + " success");
is(aResult.serviceCode, "scPin", "Check service code");
is(aResult.statusMessage, "smPinChanged", "Check status message");
is(aResult.additionalInformation, undefined, "Check additional information");
}, function reject(aError) {
ok(aExpectedError, MMI_CODE + " fail");
is(aError.name, aExpectedError.name, "Check name");
is(aError.message, "", "Check message");
is(aError.serviceCode, "scPin", "Check service code");
is(aError.additionalInformation, aExpectedError.additionalInformation,
"Chech additional information");
});
}
// Start test
startTestCommon(function() {
let promise = Promise.resolve();
for (let i = 0; i < TEST_DATA.length; i++) {
let data = TEST_DATA[i];
promise = promise.then(() => testChangePin(data.pin,
data.newPin,
data.newPinAgain,
data.expectedError));
}
return promise;
});

View File

@ -240,8 +240,8 @@ TCPSocketParent::SendEvent(const nsAString& aType, JS::Handle<JS::Value> aDataVa
JS::Rooted<JS::Value> val(aCx);
if (!JS_GetProperty(aCx, obj, "name", &val)) {
NS_ERROR("No name property on supposed error object");
} else if (JSVAL_IS_STRING(val)) {
if (!name.init(aCx, JSVAL_TO_STRING(val))) {
} else if (val.isString()) {
if (!name.init(aCx, val.toString())) {
NS_WARNING("couldn't initialize string");
}
}

View File

@ -381,25 +381,25 @@ JSValToNPVariant(NPP npp, JSContext *cx, JS::Value val, NPVariant *variant)
{
NS_ASSERTION(npp, "Must have an NPP to wrap a jsval!");
if (JSVAL_IS_PRIMITIVE(val)) {
if (val.isPrimitive()) {
if (val == JSVAL_VOID) {
VOID_TO_NPVARIANT(*variant);
} else if (JSVAL_IS_NULL(val)) {
} else if (val.isNull()) {
NULL_TO_NPVARIANT(*variant);
} else if (JSVAL_IS_BOOLEAN(val)) {
BOOLEAN_TO_NPVARIANT(JSVAL_TO_BOOLEAN(val), *variant);
} else if (JSVAL_IS_INT(val)) {
INT32_TO_NPVARIANT(JSVAL_TO_INT(val), *variant);
} else if (JSVAL_IS_DOUBLE(val)) {
double d = JSVAL_TO_DOUBLE(val);
} else if (val.isBoolean()) {
BOOLEAN_TO_NPVARIANT(val.toBoolean(), *variant);
} else if (val.isInt32()) {
INT32_TO_NPVARIANT(val.toInt32(), *variant);
} else if (val.isDouble()) {
double d = val.toDouble();
int i;
if (JS_DoubleIsInt32(d, &i)) {
INT32_TO_NPVARIANT(i, *variant);
} else {
DOUBLE_TO_NPVARIANT(d, *variant);
}
} else if (JSVAL_IS_STRING(val)) {
JSString *jsstr = JSVAL_TO_STRING(val);
} else if (val.isString()) {
JSString *jsstr = val.toString();
size_t length;
const jschar *chars = ::JS_GetStringCharsZAndLength(cx, jsstr, &length);
if (!chars) {
@ -435,7 +435,7 @@ JSValToNPVariant(NPP npp, JSContext *cx, JS::Value val, NPVariant *variant)
JS::Rooted<JSObject*> obj(cx, val.toObjectOrNull());
obj = js::CheckedUnwrap(obj);
if (!obj) {
obj = JSVAL_TO_OBJECT(val);
obj = val.toObjectOrNull();
}
NPObject *npobj = nsJSObjWrapper::GetNewOrUsed(npp, cx, obj);
@ -593,8 +593,8 @@ nsJSObjWrapper::NP_HasMethod(NPObject *npobj, NPIdentifier id)
JS::Rooted<JS::Value> v(cx);
bool ok = GetProperty(cx, npjsobj->mJSObj, id, &v);
return ok && !JSVAL_IS_PRIMITIVE(v) &&
::JS_ObjectIsFunction(cx, JSVAL_TO_OBJECT(v));
return ok && !v.isPrimitive() &&
::JS_ObjectIsFunction(cx, v.toObjectOrNull());
}
static bool
@ -901,9 +901,9 @@ nsJSObjWrapper::NP_Enumerate(NPObject *npobj, NPIdentifier **idarray,
}
id = StringToNPIdentifier(cx, str);
} else {
NS_ASSERTION(JSVAL_IS_INT(v),
NS_ASSERTION(v.isInt32(),
"The element in ida must be either string or int!\n");
id = IntToNPIdentifier(JSVAL_TO_INT(v));
id = IntToNPIdentifier(v.toInt32());
}
(*idarray)[i] = id;
@ -1352,7 +1352,7 @@ CallNPMethodInternal(JSContext *cx, JS::Handle<JSObject*> obj, unsigned argc,
NPVariant v;
VOID_TO_NPVARIANT(v);
JSObject *funobj = JSVAL_TO_OBJECT(argv[-2]);
JSObject *funobj = argv[-2].toObjectOrNull();
bool ok;
const char *msg = "Error calling method on NPObject!";
@ -1498,7 +1498,7 @@ NPObjWrapper_newEnumerate(JSContext *cx, JS::Handle<JSObject*> obj, JSIterateOp
break;
case JSENUMERATE_NEXT:
state = (NPObjectEnumerateState *)JSVAL_TO_PRIVATE(*statep);
state = (NPObjectEnumerateState *)statep->toPrivate();
enum_value = state->value;
length = state->length;
if (state->index != length) {
@ -1509,7 +1509,7 @@ NPObjWrapper_newEnumerate(JSContext *cx, JS::Handle<JSObject*> obj, JSIterateOp
// FALL THROUGH
case JSENUMERATE_DESTROY:
state = (NPObjectEnumerateState *)JSVAL_TO_PRIVATE(*statep);
state = (NPObjectEnumerateState *)statep->toPrivate();
if (state->value)
PR_Free(state->value);
delete state;
@ -1594,10 +1594,10 @@ NPObjWrapper_Convert(JSContext *cx, JS::Handle<JSObject*> obj, JSType hint, JS::
JS::Rooted<JS::Value> v(cx, JSVAL_VOID);
if (!JS_GetProperty(cx, obj, "toString", &v))
return false;
if (!JSVAL_IS_PRIMITIVE(v) && JS_ObjectIsCallable(cx, JSVAL_TO_OBJECT(v))) {
if (!v.isPrimitive() && JS_ObjectIsCallable(cx, v.toObjectOrNull())) {
if (!JS_CallFunctionValue(cx, obj, v, JS::HandleValueArray::empty(), vp))
return false;
if (JSVAL_IS_PRIMITIVE(vp))
if (vp.isPrimitive())
return true;
}
@ -2098,7 +2098,7 @@ NPObjectMember_Trace(JSTracer *trc, JSObject *obj)
// Our NPIdentifier is not always interned, so we must root it explicitly.
JS_CallHeapIdTracer(trc, &memberPrivate->methodName, "NPObjectMemberPrivate.methodName");
if (!JSVAL_IS_PRIMITIVE(memberPrivate->fieldValue)) {
if (!memberPrivate->fieldValue.isPrimitive()) {
JS_CallHeapValueTracer(trc, &memberPrivate->fieldValue,
"NPObject Member => fieldValue");
}

View File

@ -125,9 +125,9 @@ public:
{
nsCOMPtr<nsIAudioManager> audioManager =
do_GetService(NS_AUDIOMANAGER_CONTRACTID);
NS_ENSURE_TRUE(JSVAL_IS_INT(aResult), NS_OK);
NS_ENSURE_TRUE(aResult.isInt32(), NS_OK);
int32_t volIndex = JSVAL_TO_INT(aResult);
int32_t volIndex = aResult.toInt32();
if (aName.EqualsLiteral("audio.volume.content")) {
audioManager->SetAudioChannelVolume((int32_t)AudioChannel::Content,
volIndex);

View File

@ -43,8 +43,8 @@ public:
NS_IMETHOD Handle(const nsAString& aName, JS::Handle<JS::Value> aResult)
{
if (JSVAL_IS_INT(aResult)) {
int32_t mode = JSVAL_TO_INT(aResult);
if (aResult.isInt32()) {
int32_t mode = aResult.toInt32();
SetAutoMounterMode(mode);
}
return NS_OK;
@ -69,8 +69,8 @@ public:
NS_IMETHOD Handle(const nsAString& aName, JS::Handle<JS::Value> aResult)
{
if (JSVAL_IS_BOOLEAN(aResult)) {
bool isSharingEnabled = JSVAL_TO_BOOLEAN(aResult);
if (aResult.isBoolean()) {
bool isSharingEnabled = aResult.toBoolean();
SetAutoMounterSharingMode(mVolumeName, isSharingEnabled);
}
return NS_OK;

View File

@ -57,8 +57,6 @@ const CELLBROADCASTMESSAGE_CID =
Components.ID("{29474c96-3099-486f-bb4a-3c9a1da834e4}");
const CELLBROADCASTETWSINFO_CID =
Components.ID("{59f176ee-9dcd-4005-9d47-f6be0cd08e17}");
const DOMMMIERROR_CID =
Components.ID("{6b204c42-7928-4e71-89ad-f90cd82aff96}");
const ICCCARDLOCKERROR_CID =
Components.ID("{08a71987-408c-44ff-93fd-177c0a85c3dd}");
@ -422,20 +420,6 @@ DOMCLIRStatus.prototype = {
m: 'r'}
};
function DOMMMIError() {
}
DOMMMIError.prototype = {
classDescription: "DOMMMIError",
classID: DOMMMIERROR_CID,
contractID: "@mozilla.org/dom/mmi-error;1",
QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports]),
__init: function(serviceCode, name, message, additionalInformation) {
this.__DOM_IMPL__.init(name, message);
this.serviceCode = serviceCode;
this.additionalInformation = additionalInformation;
},
};
function IccCardLockError() {
}
IccCardLockError.prototype = {
@ -2128,7 +2112,7 @@ RILContentHelper.prototype = {
}
let result = {
serviceCode: message.mmiServiceCode,
serviceCode: message.mmiServiceCode || "",
additionalInformation: message.additionalInformation
};
@ -2139,7 +2123,7 @@ RILContentHelper.prototype = {
} else {
let mmiError = new requestWindow.DOMMMIError(result.serviceCode,
message.errorMsg,
null,
"",
result.additionalInformation);
Services.DOMRequest.fireDetailedError(request, mmiError);
}
@ -2239,5 +2223,4 @@ RILContentHelper.prototype = {
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([RILContentHelper,
DOMMMIError,
IccCardLockError]);

View File

@ -19,9 +19,7 @@ category profile-after-change RadioInterfaceLayer @mozilla.org/ril;1
# RILContentHelper.js
component {472816e1-1fd6-4405-996c-806f9ea68174} RILContentHelper.js
component {6b204c42-7928-4e71-89ad-f90cd82aff96} RILContentHelper.js
component {08a71987-408c-44ff-93fd-177c0a85c3dd} RILContentHelper.js
contract @mozilla.org/ril/content-helper;1 {472816e1-1fd6-4405-996c-806f9ea68174}
contract @mozilla.org/dom/mmi-error;1 {6b204c42-7928-4e71-89ad-f90cd82aff96}
contract @mozilla.org/dom/icccardlock-error;1 {08a71987-408c-44ff-93fd-177c0a85c3dd}
category profile-after-change RILContentHelper @mozilla.org/ril/content-helper;1

View File

@ -304,7 +304,7 @@ var interfaceNamesInGlobalScope =
// IMPORTANT: Do not change this list without review from a DOM peer!
"DOMImplementation",
// IMPORTANT: Do not change this list without review from a DOM peer!
"DOMMMIError",
{name: "DOMMMIError", b2g: true, pref: "dom.mobileconnection.enabled"},
// IMPORTANT: Do not change this list without review from a DOM peer!
"DOMParser",
// IMPORTANT: Do not change this list without review from a DOM peer!

View File

@ -4,13 +4,15 @@
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
[JSImplementation="@mozilla.org/dom/mmi-error;1",
[Pref="dom.mobileconnection.enabled",
Constructor(DOMString serviceCode,
DOMString name,
optional DOMString message = "",
optional DOMString additionalInformation = "")]
optional short? additionalInformation = null)]
interface DOMMMIError : DOMError {
[Constant]
readonly attribute DOMString serviceCode;
readonly attribute any additionalInformation;
[Constant]
readonly attribute short? additionalInformation;
};

View File

@ -84,7 +84,6 @@ WEBIDL_FILES = [
'DOMError.webidl',
'DOMException.webidl',
'DOMImplementation.webidl',
'DOMMMIError.webidl',
'DOMParser.webidl',
'DOMPoint.webidl',
'DOMQuad.webidl',
@ -544,6 +543,7 @@ if CONFIG['MOZ_B2G_BT']:
if CONFIG['MOZ_B2G_RIL']:
WEBIDL_FILES += [
'DOMMMIError.webidl',
'IccCardLockError.webidl',
'MozCellBroadcast.webidl',
'MozCellBroadcastEvent.webidl',

View File

@ -63,7 +63,7 @@ DefineChromeWorkerFunctions(JSContext* aCx, JS::Handle<JSObject*> aGlobal)
UnicodeToNative
};
JS_SetCTypesCallbacks(JSVAL_TO_OBJECT(ctypes), &callbacks);
JS_SetCTypesCallbacks(ctypes.toObjectOrNull(), &callbacks);
}
#endif // BUILD_CTYPES

View File

@ -1160,7 +1160,7 @@ EventRunnable::PreDispatch(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
JS::Rooted<JS::Value> response(aCx);
mResponseResult = xhr->GetResponse(aCx, &response);
if (NS_SUCCEEDED(mResponseResult)) {
if (JSVAL_IS_UNIVERSAL(response)) {
if (!response.isGCThing()) {
mResponse = response;
}
else {
@ -1256,7 +1256,7 @@ EventRunnable::WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
state->mResponseText = mResponseText;
if (NS_SUCCEEDED(mResponseTextResult)) {
MOZ_ASSERT(JSVAL_IS_VOID(mResponse) || JSVAL_IS_NULL(mResponse));
MOZ_ASSERT(mResponse.isUndefined() || mResponse.isNull());
state->mResponseResult = mResponseTextResult;
state->mResponse = mResponse;
}
@ -1265,7 +1265,7 @@ EventRunnable::WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
if (NS_SUCCEEDED(mResponseResult)) {
if (mResponseBuffer.data()) {
MOZ_ASSERT(JSVAL_IS_VOID(mResponse));
MOZ_ASSERT(mResponse.isUndefined());
JSAutoStructuredCloneBuffer responseBuffer(Move(mResponseBuffer));
@ -2258,7 +2258,7 @@ jsval
XMLHttpRequest::GetResponse(JSContext* /* unused */, ErrorResult& aRv)
{
if (NS_SUCCEEDED(mStateData.mResponseTextResult) &&
JSVAL_IS_VOID(mStateData.mResponse)) {
mStateData.mResponse.isUndefined()) {
MOZ_ASSERT(mStateData.mResponseText.Length());
MOZ_ASSERT(NS_SUCCEEDED(mStateData.mResponseResult));
@ -2289,7 +2289,7 @@ void
XMLHttpRequest::UpdateState(const StateData& aStateData)
{
mStateData = aStateData;
if (JSVAL_IS_GCTHING(mStateData.mResponse)) {
if (mStateData.mResponse.isGCThing()) {
mozilla::HoldJSObjects(this);
}
}

View File

@ -780,7 +780,7 @@ nsXBLBinding::ChangeDocument(nsIDocument* aOldDocument, nsIDocument* aNewDocumen
JS::Value protoBinding = ::JS_GetReservedSlot(proto, 0);
if (JSVAL_TO_PRIVATE(protoBinding) != mPrototypeBinding) {
if (protoBinding.toPrivate() != mPrototypeBinding) {
// Not the right binding
continue;
}

View File

@ -110,7 +110,7 @@ global_resolve(JSContext *cx, JSObject *obj, jsval id, uintN flags, JSObject **o
JSBool ok, found;
JSFunction *fun;
if (!JSVAL_IS_STRING(id))
if (!id.isString())
return JS_TRUE;
path = getenv("PATH");
if (!path)
@ -118,7 +118,7 @@ global_resolve(JSContext *cx, JSObject *obj, jsval id, uintN flags, JSObject **o
path = JS_strdup(cx, path);
if (!path)
return JS_FALSE;
name = JS_GetStringBytes(JSVAL_TO_STRING(id));
name = JS_GetStringBytes(id.toString());
ok = JS_TRUE;
for (comp = strtok(path, ":"); comp; comp = strtok(NULL, ":")) {
if (*comp != '\0') {

View File

@ -218,14 +218,14 @@ void SkJSDisplayable::Destructor(JSContext *cx, JSObject *obj) {
JSBool SkJSDisplayable::GetProperty(JSContext *cx, JSObject *obj, jsval id,
jsval *vp)
{
if (JSVAL_IS_INT(id) == 0)
if (id.isInt32() == 0)
return JS_TRUE;
SkJSDisplayable *p = (SkJSDisplayable *) JS_GetPrivate(cx, obj);
SkDisplayable* displayable = p->fDisplayable;
SkDisplayTypes displayableType = displayable->getType();
int members;
const SkMemberInfo* info = SkDisplayType::GetMembers(NULL /* fMaker */, displayableType, &members);
int idIndex = JSVAL_TO_INT(id);
int idIndex = id.toInt32();
SkASSERT(idIndex >= 0 && idIndex < members);
info = &info[idIndex];
SkDisplayTypes infoType = (SkDisplayTypes) info->fType;
@ -290,14 +290,14 @@ JSBool SkJSDisplayable::GetProperty(JSContext *cx, JSObject *obj, jsval id,
}
JSBool SkJSDisplayable::SetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) {
if (JSVAL_IS_INT(id) == 0)
if (id.isInt32() == 0)
return JS_TRUE;
SkJSDisplayable *p = (SkJSDisplayable *) JS_GetPrivate(cx, obj);
SkDisplayable* displayable = p->fDisplayable;
SkDisplayTypes displayableType = displayable->getType();
int members;
const SkMemberInfo* info = SkDisplayType::GetMembers(NULL /* fMaker */, displayableType, &members);
int idIndex = JSVAL_TO_INT(id);
int idIndex = id.toInt32();
SkASSERT(idIndex >= 0 && idIndex < members);
info = &info[idIndex];
SkDisplayTypes infoType = info->getType();
@ -308,18 +308,18 @@ JSBool SkJSDisplayable::SetProperty(JSContext *cx, JSObject *obj, jsval id, jsva
jsval value = *vp;
switch (infoType) {
case SkType_Boolean:
s32 = JSVAL_TO_BOOLEAN(value);
s32 = value.toBoolean();
break;
case SkType_Color:
case SkType_S32:
s32 = JSVAL_TO_INT(value);
s32 = value.toInt32();
break;
case SkType_Scalar:
if (JSVAL_IS_INT(value))
scalar = SkIntToScalar(JSVAL_TO_INT(value));
if (value.isInt32())
scalar = SkIntToScalar(value.toInt32());
else {
SkASSERT(JSVAL_IS_DOUBLE(value));
scalar = (float) *(double*) JSVAL_TO_DOUBLE(value);
SkASSERT(value.isDouble());
scalar = (float) *(double*) value.toDouble();
}
break;
case SkType_String:

View File

@ -90,7 +90,7 @@ PostToNFC(JSContext* aCx,
JSAutoByteString abs;
void* data;
size_t size;
if (JSVAL_IS_STRING(v)) {
if (v.isString()) {
JS::Rooted<JSString*> str(aCx, v.toString());
if (!abs.encodeUtf8(aCx, str)) {
return false;
@ -98,8 +98,8 @@ PostToNFC(JSContext* aCx,
data = abs.ptr();
size = abs.length();
} else if (!JSVAL_IS_PRIMITIVE(v)) {
JSObject* obj = JSVAL_TO_OBJECT(v);
} else if (!v.isPrimitive()) {
JSObject* obj = v.toObjectOrNull();
if (!JS_IsTypedArrayObject(obj)) {
JS_ReportError(aCx, "Object passed in wasn't a typed array");
return false;

View File

@ -95,7 +95,7 @@ PostToRIL(JSContext *aCx,
JSAutoByteString abs;
void *data;
size_t size;
if (JSVAL_IS_STRING(v)) {
if (v.isString()) {
JS::Rooted<JSString*> str(aCx, v.toString());
if (!abs.encodeUtf8(aCx, str)) {
return false;
@ -103,8 +103,8 @@ PostToRIL(JSContext *aCx,
data = abs.ptr();
size = abs.length();
} else if (!JSVAL_IS_PRIMITIVE(v)) {
JSObject *obj = JSVAL_TO_OBJECT(v);
} else if (!v.isPrimitive()) {
JSObject *obj = v.toObjectOrNull();
if (!JS_IsTypedArrayObject(obj)) {
JS_ReportError(aCx, "Object passed in wasn't a typed array");
return false;

View File

@ -210,7 +210,7 @@ JavaScriptShared::toVariant(JSContext *cx, JS::HandleValue from, JSVariant *to)
}
case JSTYPE_NUMBER:
if (JSVAL_IS_INT(from))
if (from.isInt32())
*to = double(from.toInt32());
else
*to = from.toDouble();

View File

@ -222,7 +222,7 @@ jsd_GetJSDObjectForJSObject(JSDContext* jsdc, JSObject* jsobj)
JSDObject*
jsd_GetObjectForValue(JSDContext* jsdc, JSDValue* jsdval)
{
return jsd_GetJSDObjectForJSObject(jsdc, JSVAL_TO_OBJECT(jsdval->val));
return jsd_GetJSDObjectForJSObject(jsdc, jsdval->val.toObjectOrNull());
}
JSDValue*

View File

@ -706,7 +706,7 @@ jsd_TrapHandler(JSContext *cx, JSScript *script_, jsbytecode *pc, jsval *rval,
jsval closure)
{
JS::RootedScript script(cx, script_);
JSDExecHook* jsdhook = (JSDExecHook*) JSVAL_TO_PRIVATE(closure);
JSDExecHook* jsdhook = (JSDExecHook*) closure.toPrivate();
JSD_ExecutionHookProc hook;
void* hookData;
JSDContext* jsdc;

View File

@ -99,7 +99,7 @@ _callHook(JSDContext *jsdc, JSContext *cx, JSAbstractFramePtr frame, bool isCons
JS::RootedValue newObj(cx);
if (!frame.getThisValue(cx, &newObj))
return false;
jsd_Constructing(jsdc, cx, JSVAL_TO_OBJECT(newObj), frame);
jsd_Constructing(jsdc, cx, newObj.toObjectOrNull(), frame);
}
jsscript = frame.script();

View File

@ -24,7 +24,7 @@ void JSD_ASSERT_VALID_VALUE(JSDValue* jsdval)
if(!JS_CLIST_IS_EMPTY(&jsdval->props))
{
MOZ_ASSERT(CHECK_BIT_FLAG(jsdval->flags, GOT_PROPS));
MOZ_ASSERT(!JSVAL_IS_PRIMITIVE(jsdval->val));
MOZ_ASSERT(!jsdval->val.isPrimitive());
}
if(jsdval->proto)
@ -60,63 +60,63 @@ void JSD_ASSERT_VALID_PROPERTY(JSDProperty* jsdprop)
bool
jsd_IsValueObject(JSDContext* jsdc, JSDValue* jsdval)
{
return !JSVAL_IS_PRIMITIVE(jsdval->val) || JSVAL_IS_NULL(jsdval->val);
return !jsdval->val.isPrimitive() || jsdval->val.isNull();
}
bool
jsd_IsValueNumber(JSDContext* jsdc, JSDValue* jsdval)
{
return JSVAL_IS_NUMBER(jsdval->val);
return jsdval->val.isNumber();
}
bool
jsd_IsValueInt(JSDContext* jsdc, JSDValue* jsdval)
{
return JSVAL_IS_INT(jsdval->val);
return jsdval->val.isInt32();
}
bool
jsd_IsValueDouble(JSDContext* jsdc, JSDValue* jsdval)
{
return JSVAL_IS_DOUBLE(jsdval->val);
return jsdval->val.isDouble();
}
bool
jsd_IsValueString(JSDContext* jsdc, JSDValue* jsdval)
{
return JSVAL_IS_STRING(jsdval->val);
return jsdval->val.isString();
}
bool
jsd_IsValueBoolean(JSDContext* jsdc, JSDValue* jsdval)
{
return JSVAL_IS_BOOLEAN(jsdval->val);
return jsdval->val.isBoolean();
}
bool
jsd_IsValueNull(JSDContext* jsdc, JSDValue* jsdval)
{
return JSVAL_IS_NULL(jsdval->val);
return jsdval->val.isNull();
}
bool
jsd_IsValueVoid(JSDContext* jsdc, JSDValue* jsdval)
{
return JSVAL_IS_VOID(jsdval->val);
return jsdval->val.isUndefined();
}
bool
jsd_IsValuePrimitive(JSDContext* jsdc, JSDValue* jsdval)
{
return JSVAL_IS_PRIMITIVE(jsdval->val);
return jsdval->val.isPrimitive();
}
bool
jsd_IsValueFunction(JSDContext* jsdc, JSDValue* jsdval)
{
AutoSafeJSContext cx; // NB: Actually unused.
return !JSVAL_IS_PRIMITIVE(jsdval->val) &&
JS_ObjectIsCallable(cx, JSVAL_TO_OBJECT(jsdval->val));
return !jsdval->val.isPrimitive() &&
JS_ObjectIsCallable(cx, jsdval->val.toObjectOrNull());
}
bool
@ -127,7 +127,7 @@ jsd_IsValueNative(JSDContext* jsdc, JSDValue* jsdval)
if(jsd_IsValueFunction(jsdc, jsdval))
{
JSAutoCompartment ac(cx, JSVAL_TO_OBJECT(jsdval->val));
JSAutoCompartment ac(cx, jsdval->val.toObjectOrNull());
AutoSaveExceptionState as(cx);
bool ok = false;
fun = JSD_GetValueFunction(jsdc, jsdval);
@ -136,7 +136,7 @@ jsd_IsValueNative(JSDContext* jsdc, JSDValue* jsdval)
MOZ_ASSERT(fun);
return ok;
}
return !JSVAL_IS_PRIMITIVE(jsdval->val);
return !jsdval->val.isPrimitive();
}
/***************************************************************************/
@ -145,26 +145,26 @@ bool
jsd_GetValueBoolean(JSDContext* jsdc, JSDValue* jsdval)
{
jsval val = jsdval->val;
if(!JSVAL_IS_BOOLEAN(val))
if(!val.isBoolean())
return false;
return JSVAL_TO_BOOLEAN(val);
return val.toBoolean();
}
int32_t
jsd_GetValueInt(JSDContext* jsdc, JSDValue* jsdval)
{
jsval val = jsdval->val;
if(!JSVAL_IS_INT(val))
if(!val.isInt32())
return 0;
return JSVAL_TO_INT(val);
return val.toInt32();
}
double
jsd_GetValueDouble(JSDContext* jsdc, JSDValue* jsdval)
{
if(!JSVAL_IS_DOUBLE(jsdval->val))
if(!jsdval->val.isDouble())
return 0;
return JSVAL_TO_DOUBLE(jsdval->val);
return jsdval->val.toDouble();
}
JSString*
@ -179,13 +179,13 @@ jsd_GetValueString(JSDContext* jsdc, JSDValue* jsdval)
return jsdval->string;
/* Reuse the string without copying or re-rooting it */
if(JSVAL_IS_STRING(jsdval->val)) {
jsdval->string = JSVAL_TO_STRING(jsdval->val);
if(jsdval->val.isString()) {
jsdval->string = jsdval->val.toString();
return jsdval->string;
}
/* Objects call JS_ValueToString in their own compartment. */
scopeObj = !JSVAL_IS_PRIMITIVE(jsdval->val) ? JSVAL_TO_OBJECT(jsdval->val) : jsdc->glob;
scopeObj = !jsdval->val.isPrimitive() ? jsdval->val.toObjectOrNull() : jsdc->glob;
{
JSAutoCompartment ac(cx, scopeObj);
AutoSaveExceptionState as(cx);
@ -201,7 +201,7 @@ jsd_GetValueString(JSDContext* jsdc, JSDValue* jsdval)
return nullptr;
}
jsdval->string = JSVAL_TO_STRING(stringval);
jsdval->string = stringval.toString();
if(!JS::AddNamedStringRoot(cx, &jsdval->string, "ValueString"))
jsdval->string = nullptr;
@ -216,7 +216,7 @@ jsd_GetValueFunctionId(JSDContext* jsdc, JSDValue* jsdval)
if(!jsdval->funName && jsd_IsValueFunction(jsdc, jsdval))
{
JSAutoCompartment ac(cx, JSVAL_TO_OBJECT(jsdval->val));
JSAutoCompartment ac(cx, jsdval->val.toObjectOrNull());
AutoSaveExceptionState as(cx);
fun = JSD_GetValueFunction(jsdc, jsdval);
if(!fun)
@ -247,13 +247,13 @@ jsd_NewValue(JSDContext* jsdc, jsval value)
if(!(jsdval = (JSDValue*) calloc(1, sizeof(JSDValue))))
return nullptr;
if(JSVAL_IS_GCTHING(val))
if(val.isGCThing())
{
bool ok;
JSAutoCompartment ac(cx, jsdc->glob);
ok = JS::AddNamedValueRoot(cx, &jsdval->val, "JSDValue");
if(ok && JSVAL_IS_STRING(val)) {
if(ok && val.isString()) {
if(!JS_WrapValue(cx, &val)) {
ok = false;
}
@ -279,7 +279,7 @@ jsd_DropValue(JSDContext* jsdc, JSDValue* jsdval)
if(0 == --jsdval->nref)
{
jsd_RefreshValue(jsdc, jsdval);
if(JSVAL_IS_GCTHING(jsdval->val))
if(jsdval->val.isGCThing())
{
AutoSafeJSContext cx;
JSAutoCompartment ac(cx, jsdc->glob);
@ -362,12 +362,12 @@ static bool _buildProps(JSDContext* jsdc, JSDValue* jsdval)
MOZ_ASSERT(JS_CLIST_IS_EMPTY(&jsdval->props));
MOZ_ASSERT(!(CHECK_BIT_FLAG(jsdval->flags, GOT_PROPS)));
MOZ_ASSERT(!JSVAL_IS_PRIMITIVE(jsdval->val));
MOZ_ASSERT(!jsdval->val.isPrimitive());
if(JSVAL_IS_PRIMITIVE(jsdval->val))
if(jsdval->val.isPrimitive())
return false;
obj = JSVAL_TO_OBJECT(jsdval->val);
obj = jsdval->val.toObjectOrNull();
JSAutoCompartment ac(cx, obj);
@ -409,7 +409,7 @@ jsd_RefreshValue(JSDContext* jsdc, JSDValue* jsdval)
if(jsdval->string)
{
/* if the jsval is a string, then we didn't need to root the string */
if(!JSVAL_IS_STRING(jsdval->val))
if(!jsdval->val.isString())
{
JSAutoCompartment ac(cx, jsdc->glob);
JS::RemoveStringRoot(cx, &jsdval->string);
@ -505,7 +505,7 @@ jsd_GetValueProperty(JSDContext* jsdc, JSDValue* jsdval, JSString* nameStr)
if(!JS_ValueToId(cx, nameval, &nameid))
return nullptr;
if(!(obj = JSVAL_TO_OBJECT(jsdval->val)))
if(!(obj = jsdval->val.toObjectOrNull()))
return nullptr;
JS::Rooted<JSPropertyDescriptor> desc(cx);
@ -567,10 +567,10 @@ jsd_GetValueFunction(JSDContext* jsdc, JSDValue* jsdval)
JS::RootedObject obj(cx);
JS::RootedFunction fun(cx);
if (JSVAL_IS_PRIMITIVE(jsdval->val))
if (jsdval->val.isPrimitive())
return nullptr;
obj = js::UncheckedUnwrap(JSVAL_TO_OBJECT(jsdval->val));
obj = js::UncheckedUnwrap(jsdval->val.toObjectOrNull());
JSAutoCompartment ac(cx, obj);
JS::RootedValue funval(cx, JS::ObjectValue(*obj));
fun = JS_ValueToFunction(cx, funval);
@ -588,9 +588,9 @@ jsd_GetValuePrototype(JSDContext* jsdc, JSDValue* jsdval)
JS::RootedObject proto(cx);
MOZ_ASSERT(!jsdval->proto);
SET_BIT_FLAG(jsdval->flags, GOT_PROTO);
if(JSVAL_IS_PRIMITIVE(jsdval->val))
if(jsdval->val.isPrimitive())
return nullptr;
obj = JSVAL_TO_OBJECT(jsdval->val);
obj = jsdval->val.toObjectOrNull();
if(!JS_GetPrototype(cx, obj, &proto))
return nullptr;
if(!proto)
@ -612,9 +612,9 @@ jsd_GetValueParent(JSDContext* jsdc, JSDValue* jsdval)
JS::RootedObject parent(cx);
MOZ_ASSERT(!jsdval->parent);
SET_BIT_FLAG(jsdval->flags, GOT_PARENT);
if(JSVAL_IS_PRIMITIVE(jsdval->val))
if(jsdval->val.isPrimitive())
return nullptr;
obj = JSVAL_TO_OBJECT(jsdval->val);
obj = jsdval->val.toObjectOrNull();
{
JSAutoCompartment ac(cx, obj);
parent = JS_GetParentOrScopeChain(cx, obj);
@ -639,9 +639,9 @@ jsd_GetValueConstructor(JSDContext* jsdc, JSDValue* jsdval)
JS::RootedObject ctor(cx);
MOZ_ASSERT(!jsdval->ctor);
SET_BIT_FLAG(jsdval->flags, GOT_CTOR);
if(JSVAL_IS_PRIMITIVE(jsdval->val))
if(jsdval->val.isPrimitive())
return nullptr;
obj = JSVAL_TO_OBJECT(jsdval->val);
obj = jsdval->val.toObjectOrNull();
if(!JS_GetPrototype(cx, obj, &proto))
return nullptr;
if(!proto)
@ -663,9 +663,9 @@ const char*
jsd_GetValueClassName(JSDContext* jsdc, JSDValue* jsdval)
{
jsval val = jsdval->val;
if(!jsdval->className && !JSVAL_IS_PRIMITIVE(val))
if(!jsdval->className && !val.isPrimitive())
{
JS::RootedObject obj(jsdc->jsrt, JSVAL_TO_OBJECT(val));
JS::RootedObject obj(jsdc->jsrt, val.toObjectOrNull());
AutoSafeJSContext cx;
JSAutoCompartment ac(cx, obj);
jsdval->className = JS_GetDebugClassName(obj);
@ -685,7 +685,7 @@ jsd_GetScriptForValue(JSDContext* jsdc, JSDValue* jsdval)
return nullptr;
{
JSAutoCompartment ac(cx, JSVAL_TO_OBJECT(val));
JSAutoCompartment ac(cx, val.toObjectOrNull());
AutoSaveExceptionState as(cx);
JS::RootedFunction fun(cx, JSD_GetValueFunction(jsdc, jsdval));
if (fun)

View File

@ -2158,21 +2158,21 @@ jsdValue::GetJsType (uint32_t *_rval)
ASSERT_VALID_EPHEMERAL;
JS::RootedValue val(JSD_GetJSRuntime(mCx), JSD_GetValueWrappedJSVal (mCx, mValue));
if (JSVAL_IS_NULL(val))
if (val.isNull())
*_rval = TYPE_NULL;
else if (JSVAL_IS_BOOLEAN(val))
else if (val.isBoolean())
*_rval = TYPE_BOOLEAN;
else if (JSVAL_IS_DOUBLE(val))
else if (val.isDouble())
*_rval = TYPE_DOUBLE;
else if (JSVAL_IS_INT(val))
else if (val.isInt32())
*_rval = TYPE_INT;
else if (JSVAL_IS_STRING(val))
else if (val.isString())
*_rval = TYPE_STRING;
else if (JSVAL_IS_VOID(val))
else if (val.isUndefined())
*_rval = TYPE_VOID;
else if (JSD_IsValueFunction (mCx, mValue))
*_rval = TYPE_FUNCTION;
else if (!JSVAL_IS_PRIMITIVE(val))
else if (!val.isPrimitive())
*_rval = TYPE_OBJECT;
else
NS_ASSERTION (0, "Value has no discernible type.");

View File

@ -388,7 +388,7 @@ CallArgsFromSp(unsigned argc, Value *sp)
* take a const JS::CallArgs&.
*/
#define JS_THIS_OBJECT(cx,vp) (JSVAL_TO_OBJECT(JS_THIS(cx,vp)))
#define JS_THIS_OBJECT(cx,vp) (JS_THIS(cx,vp).toObjectOrNull())
/*
* Note: if this method returns null, an error has occurred and must be
@ -397,7 +397,7 @@ CallArgsFromSp(unsigned argc, Value *sp)
MOZ_ALWAYS_INLINE JS::Value
JS_THIS(JSContext *cx, JS::Value *vp)
{
return JSVAL_IS_PRIMITIVE(vp[1]) ? JS_ComputeThis(cx, vp) : vp[1];
return vp[1].isPrimitive() ? JS_ComputeThis(cx, vp) : vp[1];
}
/*

View File

@ -585,7 +585,7 @@ JSVAL_IS_SPECIFIC_INT32_IMPL(jsval_layout l, int32_t i32)
}
static inline bool
JSVAL_IS_SPECIFIC_BOOLEAN(jsval_layout l, bool b)
JSVAL_IS_SPECIFIC_BOOLEAN_IMPL(jsval_layout l, bool b)
{
return (l.s.tag == JSVAL_TAG_BOOLEAN) && (l.s.payload.boo == uint32_t(b));
}
@ -821,7 +821,7 @@ JSVAL_IS_SPECIFIC_INT32_IMPL(jsval_layout l, int32_t i32)
}
static inline bool
JSVAL_IS_SPECIFIC_BOOLEAN(jsval_layout l, bool b)
JSVAL_IS_SPECIFIC_BOOLEAN_IMPL(jsval_layout l, bool b)
{
return l.asBits == (((uint64_t)(uint32_t)b) | JSVAL_SHIFTED_TAG_BOOLEAN);
}
@ -914,11 +914,7 @@ CanonicalizeNaN(double d)
* - The JS::Value operations are preferred. The JSVAL_* operations remain for
* compatibility; they may be removed at some point. These operations mostly
* provide similar functionality. But there are a few key differences. One
* is that JS::Value gives null a separate type. Thus
*
* JSVAL_IS_OBJECT(v) === v.isObjectOrNull()
* !JSVAL_IS_PRIMITIVE(v) === v.isObject()
*
* is that JS::Value gives null a separate type.
* Also, to help prevent mistakenly boxing a nullable JSObject* as an object,
* Value::setObject takes a JSObject&. (Conversely, Value::toObject returns a
* JSObject&.) A convenience member Value::setObjectOrNull is provided.
@ -1084,11 +1080,11 @@ class Value
}
bool isTrue() const {
return JSVAL_IS_SPECIFIC_BOOLEAN(data, true);
return JSVAL_IS_SPECIFIC_BOOLEAN_IMPL(data, true);
}
bool isFalse() const {
return JSVAL_IS_SPECIFIC_BOOLEAN(data, false);
return JSVAL_IS_SPECIFIC_BOOLEAN_IMPL(data, false);
}
bool isMagic() const {
@ -1821,52 +1817,12 @@ static_assert(sizeof(jsval_layout) == sizeof(JS::Value),
/************************************************************************/
static inline bool
JSVAL_IS_NULL(jsval v)
{
return JSVAL_IS_NULL_IMPL(JSVAL_TO_IMPL(v));
}
static inline bool
JSVAL_IS_VOID(jsval v)
{
return JSVAL_IS_UNDEFINED_IMPL(JSVAL_TO_IMPL(v));
}
static inline bool
JSVAL_IS_INT(jsval v)
{
return JSVAL_IS_INT32_IMPL(JSVAL_TO_IMPL(v));
}
static inline int32_t
JSVAL_TO_INT(jsval v)
{
MOZ_ASSERT(JSVAL_IS_INT(v));
return JSVAL_TO_INT32_IMPL(JSVAL_TO_IMPL(v));
}
static inline JS_VALUE_CONSTEXPR jsval
INT_TO_JSVAL(int32_t i)
{
return IMPL_TO_JSVAL(INT32_TO_JSVAL_IMPL(i));
}
static inline bool
JSVAL_IS_DOUBLE(jsval v)
{
return JSVAL_IS_DOUBLE_IMPL(JSVAL_TO_IMPL(v));
}
static inline double
JSVAL_TO_DOUBLE(jsval v)
{
jsval_layout l;
MOZ_ASSERT(JSVAL_IS_DOUBLE(v));
l = JSVAL_TO_IMPL(v);
return l.asDouble;
}
static inline JS_VALUE_CONSTEXPR jsval
DOUBLE_TO_JSVAL(double d)
{
@ -1898,38 +1854,12 @@ UINT_TO_JSVAL(uint32_t i)
: DOUBLE_TO_JSVAL((double)i));
}
static inline bool
JSVAL_IS_NUMBER(jsval v)
{
return JSVAL_IS_NUMBER_IMPL(JSVAL_TO_IMPL(v));
}
static inline bool
JSVAL_IS_STRING(jsval v)
{
return JSVAL_IS_STRING_IMPL(JSVAL_TO_IMPL(v));
}
static inline JSString *
JSVAL_TO_STRING(jsval v)
{
MOZ_ASSERT(JSVAL_IS_STRING(v));
return JSVAL_TO_STRING_IMPL(JSVAL_TO_IMPL(v));
}
static inline jsval
STRING_TO_JSVAL(JSString *str)
{
return IMPL_TO_JSVAL(STRING_TO_JSVAL_IMPL(str));
}
static inline JSObject *
JSVAL_TO_OBJECT(jsval v)
{
MOZ_ASSERT(JSVAL_IS_OBJECT_OR_NULL_IMPL(JSVAL_TO_IMPL(v)));
return JSVAL_TO_OBJECT_IMPL(JSVAL_TO_IMPL(v));
}
static inline jsval
OBJECT_TO_JSVAL(JSObject *obj)
{
@ -1938,44 +1868,12 @@ OBJECT_TO_JSVAL(JSObject *obj)
return IMPL_TO_JSVAL(BUILD_JSVAL(JSVAL_TAG_NULL, 0));
}
static inline bool
JSVAL_IS_BOOLEAN(jsval v)
{
return JSVAL_IS_BOOLEAN_IMPL(JSVAL_TO_IMPL(v));
}
static inline bool
JSVAL_TO_BOOLEAN(jsval v)
{
MOZ_ASSERT(JSVAL_IS_BOOLEAN(v));
return JSVAL_TO_BOOLEAN_IMPL(JSVAL_TO_IMPL(v));
}
static inline jsval
BOOLEAN_TO_JSVAL(bool b)
{
return IMPL_TO_JSVAL(BOOLEAN_TO_JSVAL_IMPL(b));
}
static inline bool
JSVAL_IS_PRIMITIVE(jsval v)
{
return JSVAL_IS_PRIMITIVE_IMPL(JSVAL_TO_IMPL(v));
}
static inline bool
JSVAL_IS_GCTHING(jsval v)
{
return JSVAL_IS_GCTHING_IMPL(JSVAL_TO_IMPL(v));
}
static inline void *
JSVAL_TO_GCTHING(jsval v)
{
MOZ_ASSERT(JSVAL_IS_GCTHING(v));
return JSVAL_TO_GCTHING_IMPL(JSVAL_TO_IMPL(v));
}
/* To be GC-safe, privates are tagged as doubles. */
static inline jsval
@ -1984,13 +1882,6 @@ PRIVATE_TO_JSVAL(void *ptr)
return IMPL_TO_JSVAL(PRIVATE_PTR_TO_JSVAL_IMPL(ptr));
}
static inline void *
JSVAL_TO_PRIVATE(jsval v)
{
MOZ_ASSERT(JSVAL_IS_DOUBLE(v));
return JSVAL_TO_PRIVATE_PTR_IMPL(JSVAL_TO_IMPL(v));
}
// JS constants. For efficiency, prefer predicates (e.g. v.isNull()) and
// constructing values from scratch (e.g. Int32Value(0)). These constants are
// stored in memory and initialized at startup, so testing against them and

View File

@ -191,30 +191,6 @@ TryEvalJSON(JSContext *cx, JSScript *callerScript,
return EvalJSON_NotJSON;
}
static void
MarkFunctionsWithinEvalScript(JSScript *script)
{
// Mark top level functions in an eval script as being within an eval and,
// if applicable, inside a with statement.
if (!script->hasObjects())
return;
ObjectArray *objects = script->objects();
size_t start = script->innerObjectsStart();
for (size_t i = start; i < objects->length; i++) {
JSObject *obj = objects->vector[i];
if (obj->is<JSFunction>()) {
JSFunction *fun = &obj->as<JSFunction>();
if (fun->hasScript())
fun->nonLazyScript()->setDirectlyInsideEval();
else if (fun->isInterpretedLazy())
fun->lazyScript()->setDirectlyInsideEval();
}
}
}
// Define subset of ExecuteType so that casting performs the injection.
enum EvalType { DIRECT_EVAL = EXECUTE_DIRECT_EVAL, INDIRECT_EVAL = EXECUTE_INDIRECT_EVAL };
@ -327,8 +303,6 @@ EvalKernel(JSContext *cx, const CallArgs &args, EvalType evalType, AbstractFrame
if (!compiled)
return false;
MarkFunctionsWithinEvalScript(compiled);
esg.setNewScript(compiled);
}
@ -396,8 +370,6 @@ js::DirectEvalStringFromIon(JSContext *cx,
if (!compiled)
return false;
MarkFunctionsWithinEvalScript(compiled);
esg.setNewScript(compiled);
}

View File

@ -821,7 +821,7 @@ GetABICode(JSObject* obj)
return INVALID_ABI;
jsval result = JS_GetReservedSlot(obj, SLOT_ABICODE);
return ABICode(JSVAL_TO_INT(result));
return ABICode(result.toInt32());
}
static const JSErrorFormatString ErrorFormatString[CTYPESERR_LIMIT] = {
@ -1286,10 +1286,10 @@ GetCallbacks(JSObject* obj)
JS_ASSERT(IsCTypesGlobal(obj));
jsval result = JS_GetReservedSlot(obj, SLOT_CALLBACKS);
if (JSVAL_IS_VOID(result))
if (result.isUndefined())
return nullptr;
return static_cast<JSCTypesCallbacks*>(JSVAL_TO_PRIVATE(result));
return static_cast<JSCTypesCallbacks*>(result.toPrivate());
}
// Utility function to access a property of an object as an object
@ -1303,12 +1303,12 @@ static bool GetObjectProperty(JSContext *cx, HandleObject obj,
return false;
}
if (JSVAL_IS_PRIMITIVE(val)) {
if (val.isPrimitive()) {
JS_ReportError(cx, "missing or non-object field");
return false;
}
result.set(JSVAL_TO_OBJECT(val));
result.set(val.toObjectOrNull());
return true;
}
@ -1384,11 +1384,11 @@ SizeOfDataIfCDataObject(mozilla::MallocSizeOf mallocSizeOf, JSObject *obj)
size_t n = 0;
jsval slot = JS_GetReservedSlot(obj, ctypes::SLOT_OWNS);
if (!JSVAL_IS_VOID(slot)) {
bool owns = JSVAL_TO_BOOLEAN(slot);
if (!slot.isUndefined()) {
bool owns = slot.toBoolean();
slot = JS_GetReservedSlot(obj, ctypes::SLOT_DATA);
if (!JSVAL_IS_VOID(slot)) {
char** buffer = static_cast<char**>(JSVAL_TO_PRIVATE(slot));
if (!slot.isUndefined()) {
char** buffer = static_cast<char**>(slot.toPrivate());
n += mallocSizeOf(buffer);
if (owns)
n += mallocSizeOf(*buffer);
@ -1575,17 +1575,17 @@ static MOZ_ALWAYS_INLINE bool IsNegative(Type i)
static bool
jsvalToBool(JSContext* cx, jsval val, bool* result)
{
if (JSVAL_IS_BOOLEAN(val)) {
*result = JSVAL_TO_BOOLEAN(val);
if (val.isBoolean()) {
*result = val.toBoolean();
return true;
}
if (JSVAL_IS_INT(val)) {
int32_t i = JSVAL_TO_INT(val);
if (val.isInt32()) {
int32_t i = val.toInt32();
*result = i != 0;
return i == 0 || i == 1;
}
if (JSVAL_IS_DOUBLE(val)) {
double d = JSVAL_TO_DOUBLE(val);
if (val.isDouble()) {
double d = val.toDouble();
*result = d != 0;
// Allow -0.
return d == 1 || d == 0;
@ -1603,20 +1603,20 @@ jsvalToInteger(JSContext* cx, jsval val, IntegerType* result)
{
JS_STATIC_ASSERT(NumericLimits<IntegerType>::is_exact);
if (JSVAL_IS_INT(val)) {
if (val.isInt32()) {
// Make sure the integer fits in the alotted precision, and has the right
// sign.
int32_t i = JSVAL_TO_INT(val);
int32_t i = val.toInt32();
return ConvertExact(i, result);
}
if (JSVAL_IS_DOUBLE(val)) {
if (val.isDouble()) {
// Don't silently lose bits here -- check that val really is an
// integer value, and has the right sign.
double d = JSVAL_TO_DOUBLE(val);
double d = val.toDouble();
return ConvertExact(d, result);
}
if (!JSVAL_IS_PRIMITIVE(val)) {
JSObject* obj = JSVAL_TO_OBJECT(val);
if (val.isObject()) {
JSObject* obj = &val.toObject();
if (CData::IsCData(obj)) {
JSObject* typeObj = CData::GetCType(obj);
void* data = CData::GetData(obj);
@ -1673,9 +1673,9 @@ jsvalToInteger(JSContext* cx, jsval val, IntegerType* result)
return false;
}
if (JSVAL_IS_BOOLEAN(val)) {
if (val.isBoolean()) {
// Implicitly promote boolean values to 0 or 1, like C.
*result = JSVAL_TO_BOOLEAN(val);
*result = val.toBoolean();
JS_ASSERT(*result == 0 || *result == 1);
return true;
}
@ -1696,16 +1696,16 @@ jsvalToFloat(JSContext *cx, jsval val, FloatType* result)
// no good way around it. Sternly requiring that the 64-bit double
// argument be exactly representable as a 32-bit float is
// unrealistic: it would allow 1/2 to pass but not 1/3.
if (JSVAL_IS_INT(val)) {
*result = FloatType(JSVAL_TO_INT(val));
if (val.isInt32()) {
*result = FloatType(val.toInt32());
return true;
}
if (JSVAL_IS_DOUBLE(val)) {
*result = FloatType(JSVAL_TO_DOUBLE(val));
if (val.isDouble()) {
*result = FloatType(val.toDouble());
return true;
}
if (!JSVAL_IS_PRIMITIVE(val)) {
JSObject* obj = JSVAL_TO_OBJECT(val);
if (val.isObject()) {
JSObject* obj = &val.toObject();
if (CData::IsCData(obj)) {
JSObject* typeObj = CData::GetCType(obj);
void* data = CData::GetData(obj);
@ -1808,28 +1808,28 @@ jsvalToBigInteger(JSContext* cx,
{
JS_STATIC_ASSERT(NumericLimits<IntegerType>::is_exact);
if (JSVAL_IS_INT(val)) {
if (val.isInt32()) {
// Make sure the integer fits in the alotted precision, and has the right
// sign.
int32_t i = JSVAL_TO_INT(val);
int32_t i = val.toInt32();
return ConvertExact(i, result);
}
if (JSVAL_IS_DOUBLE(val)) {
if (val.isDouble()) {
// Don't silently lose bits here -- check that val really is an
// integer value, and has the right sign.
double d = JSVAL_TO_DOUBLE(val);
double d = val.toDouble();
return ConvertExact(d, result);
}
if (allowString && JSVAL_IS_STRING(val)) {
if (allowString && val.isString()) {
// Allow conversion from base-10 or base-16 strings, provided the result
// fits in IntegerType. (This allows an Int64 or UInt64 object to be passed
// to the JS array element operator, which will automatically call
// toString() on the object for us.)
return StringToInteger(cx, JSVAL_TO_STRING(val), result);
return StringToInteger(cx, val.toString(), result);
}
if (!JSVAL_IS_PRIMITIVE(val)) {
if (val.isObject()) {
// Allow conversion from an Int64 or UInt64 object directly.
JSObject* obj = JSVAL_TO_OBJECT(val);
JSObject* obj = &val.toObject();
if (UInt64::IsUInt64(obj)) {
// Make sure the integer fits in IntegerType.
@ -1944,15 +1944,15 @@ jsvalToIntegerExplicit(jsval val, IntegerType* result)
{
JS_STATIC_ASSERT(NumericLimits<IntegerType>::is_exact);
if (JSVAL_IS_DOUBLE(val)) {
if (val.isDouble()) {
// Convert -Inf, Inf, and NaN to 0; otherwise, convert by C-style cast.
double d = JSVAL_TO_DOUBLE(val);
double d = val.toDouble();
*result = mozilla::IsFinite(d) ? IntegerType(d) : 0;
return true;
}
if (!JSVAL_IS_PRIMITIVE(val)) {
if (val.isObject()) {
// Convert Int64 and UInt64 values by C-style cast.
JSObject* obj = JSVAL_TO_OBJECT(val);
JSObject* obj = &val.toObject();
if (Int64::IsInt64(obj)) {
int64_t i = Int64Base::GetInt(obj);
*result = IntegerType(i);
@ -1971,15 +1971,15 @@ jsvalToIntegerExplicit(jsval val, IntegerType* result)
static bool
jsvalToPtrExplicit(JSContext* cx, jsval val, uintptr_t* result)
{
if (JSVAL_IS_INT(val)) {
if (val.isInt32()) {
// int32_t always fits in intptr_t. If the integer is negative, cast through
// an intptr_t intermediate to sign-extend.
int32_t i = JSVAL_TO_INT(val);
int32_t i = val.toInt32();
*result = i < 0 ? uintptr_t(intptr_t(i)) : uintptr_t(i);
return true;
}
if (JSVAL_IS_DOUBLE(val)) {
double d = JSVAL_TO_DOUBLE(val);
if (val.isDouble()) {
double d = val.toDouble();
if (d < 0) {
// Cast through an intptr_t intermediate to sign-extend.
intptr_t i = Convert<intptr_t>(d);
@ -1995,8 +1995,8 @@ jsvalToPtrExplicit(JSContext* cx, jsval val, uintptr_t* result)
*result = Convert<uintptr_t>(d);
return double(*result) == d;
}
if (!JSVAL_IS_PRIMITIVE(val)) {
JSObject* obj = JSVAL_TO_OBJECT(val);
if (val.isObject()) {
JSObject* obj = &val.toObject();
if (Int64::IsInt64(obj)) {
int64_t i = Int64Base::GetInt(obj);
intptr_t p = intptr_t(i);
@ -2242,8 +2242,8 @@ ImplicitConvert(JSContext* cx,
JSObject* sourceData = nullptr;
JSObject* sourceType = nullptr;
RootedObject valObj(cx, nullptr);
if (!JSVAL_IS_PRIMITIVE(val)) {
valObj = JSVAL_TO_OBJECT(val);
if (val.isObject()) {
valObj = &val.toObject();
if (CData::IsCData(valObj)) {
sourceData = valObj;
sourceType = CData::GetCType(sourceData);
@ -2312,8 +2312,8 @@ ImplicitConvert(JSContext* cx,
/* Convert from a 1-character string, regardless of encoding, */ \
/* or from an integer, provided the result fits in 'type'. */ \
type result; \
if (JSVAL_IS_STRING(val)) { \
JSString* str = JSVAL_TO_STRING(val); \
if (val.isString()) { \
JSString* str = val.toString(); \
if (str->length() != 1) \
return TypeError(cx, #name, val); \
const jschar *chars = str->getChars(cx); \
@ -2328,7 +2328,7 @@ ImplicitConvert(JSContext* cx,
}
#include "ctypes/typedefs.h"
case TYPE_pointer: {
if (JSVAL_IS_NULL(val)) {
if (val.isNull()) {
// Convert to a null pointer.
*static_cast<void**>(buffer) = nullptr;
break;
@ -2356,11 +2356,11 @@ ImplicitConvert(JSContext* cx,
}
}
} else if (isArgument && JSVAL_IS_STRING(val)) {
} else if (isArgument && val.isString()) {
// Convert the string for the ffi call. This requires allocating space
// which the caller assumes ownership of.
// TODO: Extend this so we can safely convert strings at other times also.
JSString* sourceString = JSVAL_TO_STRING(val);
JSString* sourceString = val.toString();
size_t sourceLength = sourceString->length();
const jschar* sourceChars = sourceString->getChars(cx);
if (!sourceChars)
@ -2409,7 +2409,7 @@ ImplicitConvert(JSContext* cx,
return TypeError(cx, "string pointer", val);
}
break;
} else if (!JSVAL_IS_PRIMITIVE(val) && JS_IsArrayBufferObject(valObj)) {
} else if (val.isObject() && JS_IsArrayBufferObject(valObj)) {
// Convert ArrayBuffer to pointer without any copy.
// Just as with C arrays, we make no effort to
// keep the ArrayBuffer alive.
@ -2418,7 +2418,7 @@ ImplicitConvert(JSContext* cx,
return false;
*static_cast<void**>(buffer) = p;
break;
} if (!JSVAL_IS_PRIMITIVE(val) && JS_IsTypedArrayObject(valObj)) {
} if (val.isObject() && JS_IsTypedArrayObject(valObj)) {
if(!CanConvertTypedArrayItemTo(baseType, valObj, cx)) {
return TypeError(cx, "typed array with the appropriate type", val);
}
@ -2435,8 +2435,8 @@ ImplicitConvert(JSContext* cx,
RootedObject baseType(cx, ArrayType::GetBaseType(targetType));
size_t targetLength = ArrayType::GetLength(targetType);
if (JSVAL_IS_STRING(val)) {
JSString* sourceString = JSVAL_TO_STRING(val);
if (val.isString()) {
JSString* sourceString = val.toString();
size_t sourceLength = sourceString->length();
const jschar* sourceChars = sourceString->getChars(cx);
if (!sourceChars)
@ -2484,7 +2484,7 @@ ImplicitConvert(JSContext* cx,
return TypeError(cx, "array", val);
}
} else if (!JSVAL_IS_PRIMITIVE(val) && JS_IsArrayObject(cx, valObj)) {
} else if (val.isObject() && JS_IsArrayObject(cx, valObj)) {
// Convert each element of the array by calling ImplicitConvert.
uint32_t sourceLength;
if (!JS_GetArrayLength(cx, valObj, &sourceLength) ||
@ -2514,8 +2514,7 @@ ImplicitConvert(JSContext* cx,
memcpy(buffer, intermediate.get(), arraySize);
} else if (!JSVAL_IS_PRIMITIVE(val) &&
JS_IsArrayBufferObject(valObj)) {
} else if (val.isObject() && JS_IsArrayBufferObject(valObj)) {
// Check that array is consistent with type, then
// copy the array.
uint32_t sourceLength = JS_GetArrayBufferByteLength(valObj);
@ -2527,8 +2526,7 @@ ImplicitConvert(JSContext* cx,
}
memcpy(buffer, JS_GetArrayBufferData(valObj), sourceLength);
break;
} else if (!JSVAL_IS_PRIMITIVE(val) &&
JS_IsTypedArrayObject(valObj)) {
} else if (val.isObject() && JS_IsTypedArrayObject(valObj)) {
// Check that array is consistent with type, then
// copy the array.
if(!CanConvertTypedArrayItemTo(baseType, valObj, cx)) {
@ -2552,7 +2550,7 @@ ImplicitConvert(JSContext* cx,
break;
}
case TYPE_struct: {
if (!JSVAL_IS_PRIMITIVE(val) && !sourceData) {
if (val.isObject() && !sourceData) {
// Enumerate the properties of the object; if they match the struct
// specification, convert the fields.
RootedObject iter(cx, JS_NewPropertyIterator(cx, valObj));
@ -2651,8 +2649,8 @@ ExplicitConvert(JSContext* cx, HandleValue val, HandleObject targetType, void* b
/* allow conversion from a base-10 or base-16 string. */ \
type result; \
if (!jsvalToIntegerExplicit(val, &result) && \
(!JSVAL_IS_STRING(val) || \
!StringToInteger(cx, JSVAL_TO_STRING(val), &result))) \
(!val.isString() || \
!StringToInteger(cx, val.toString(), &result))) \
return TypeError(cx, #name, val); \
*static_cast<type*>(buffer) = result; \
break; \
@ -3292,24 +3290,24 @@ CType::Finalize(JSFreeOp *fop, JSObject* obj)
{
// Make sure our TypeCode slot is legit. If it's not, bail.
jsval slot = JS_GetReservedSlot(obj, SLOT_TYPECODE);
if (JSVAL_IS_VOID(slot))
if (slot.isUndefined())
return;
// The contents of our slots depends on what kind of type we are.
switch (TypeCode(JSVAL_TO_INT(slot))) {
switch (TypeCode(slot.toInt32())) {
case TYPE_function: {
// Free the FunctionInfo.
slot = JS_GetReservedSlot(obj, SLOT_FNINFO);
if (!JSVAL_IS_VOID(slot))
FreeOp::get(fop)->delete_(static_cast<FunctionInfo*>(JSVAL_TO_PRIVATE(slot)));
if (!slot.isUndefined())
FreeOp::get(fop)->delete_(static_cast<FunctionInfo*>(slot.toPrivate()));
break;
}
case TYPE_struct: {
// Free the FieldInfoHash table.
slot = JS_GetReservedSlot(obj, SLOT_FIELDINFO);
if (!JSVAL_IS_VOID(slot)) {
void* info = JSVAL_TO_PRIVATE(slot);
if (!slot.isUndefined()) {
void* info = slot.toPrivate();
FreeOp::get(fop)->delete_(static_cast<FieldInfoHash*>(info));
}
}
@ -3318,8 +3316,8 @@ CType::Finalize(JSFreeOp *fop, JSObject* obj)
case TYPE_array: {
// Free the ffi_type info.
slot = JS_GetReservedSlot(obj, SLOT_FFITYPE);
if (!JSVAL_IS_VOID(slot)) {
ffi_type* ffiType = static_cast<ffi_type*>(JSVAL_TO_PRIVATE(slot));
if (!slot.isUndefined()) {
ffi_type* ffiType = static_cast<ffi_type*>(slot.toPrivate());
FreeOp::get(fop)->free_(ffiType->elements);
FreeOp::get(fop)->delete_(ffiType);
}
@ -3337,18 +3335,17 @@ CType::Trace(JSTracer* trc, JSObject* obj)
{
// Make sure our TypeCode slot is legit. If it's not, bail.
jsval slot = obj->getSlot(SLOT_TYPECODE);
if (JSVAL_IS_VOID(slot))
if (slot.isUndefined())
return;
// The contents of our slots depends on what kind of type we are.
switch (TypeCode(JSVAL_TO_INT(slot))) {
switch (TypeCode(slot.toInt32())) {
case TYPE_struct: {
slot = obj->getReservedSlot(SLOT_FIELDINFO);
if (JSVAL_IS_VOID(slot))
if (slot.isUndefined())
return;
FieldInfoHash* fields =
static_cast<FieldInfoHash*>(JSVAL_TO_PRIVATE(slot));
FieldInfoHash* fields = static_cast<FieldInfoHash*>(slot.toPrivate());
for (FieldInfoHash::Enum e(*fields); !e.empty(); e.popFront()) {
JSString *key = e.front().key();
JS_CallStringTracer(trc, &key, "fieldName");
@ -3362,10 +3359,10 @@ CType::Trace(JSTracer* trc, JSObject* obj)
case TYPE_function: {
// Check if we have a FunctionInfo.
slot = obj->getReservedSlot(SLOT_FNINFO);
if (JSVAL_IS_VOID(slot))
if (slot.isUndefined())
return;
FunctionInfo* fninfo = static_cast<FunctionInfo*>(JSVAL_TO_PRIVATE(slot));
FunctionInfo* fninfo = static_cast<FunctionInfo*>(slot.toPrivate());
JS_ASSERT(fninfo);
// Identify our objects to the tracer.
@ -3400,7 +3397,7 @@ CType::GetTypeCode(JSObject* typeObj)
JS_ASSERT(IsCType(typeObj));
jsval result = JS_GetReservedSlot(typeObj, SLOT_TYPECODE);
return TypeCode(JSVAL_TO_INT(result));
return TypeCode(result.toInt32());
}
bool
@ -3481,16 +3478,16 @@ CType::GetSafeSize(JSObject* obj, size_t* result)
// The "size" property can be an int, a double, or JSVAL_VOID
// (for arrays of undefined length), and must always fit in a size_t.
if (JSVAL_IS_INT(size)) {
*result = JSVAL_TO_INT(size);
if (size.isInt32()) {
*result = size.toInt32();
return true;
}
if (JSVAL_IS_DOUBLE(size)) {
*result = Convert<size_t>(JSVAL_TO_DOUBLE(size));
if (size.isDouble()) {
*result = Convert<size_t>(size.toDouble());
return true;
}
JS_ASSERT(JSVAL_IS_VOID(size));
JS_ASSERT(size.isUndefined());
return false;
}
@ -3501,14 +3498,14 @@ CType::GetSize(JSObject* obj)
jsval size = JS_GetReservedSlot(obj, SLOT_SIZE);
JS_ASSERT(!JSVAL_IS_VOID(size));
JS_ASSERT(!size.isUndefined());
// The "size" property can be an int, a double, or JSVAL_VOID
// (for arrays of undefined length), and must always fit in a size_t.
// For callers who know it can never be JSVAL_VOID, return a size_t directly.
if (JSVAL_IS_INT(size))
return JSVAL_TO_INT(size);
return Convert<size_t>(JSVAL_TO_DOUBLE(size));
if (size.isInt32())
return size.toInt32();
return Convert<size_t>(size.toDouble());
}
bool
@ -3520,8 +3517,8 @@ CType::IsSizeDefined(JSObject* obj)
// The "size" property can be an int, a double, or JSVAL_VOID
// (for arrays of undefined length), and must always fit in a size_t.
JS_ASSERT(JSVAL_IS_INT(size) || JSVAL_IS_DOUBLE(size) || JSVAL_IS_VOID(size));
return !JSVAL_IS_VOID(size);
JS_ASSERT(size.isInt32() || size.isDouble() || size.isUndefined());
return !size.isUndefined();
}
size_t
@ -3530,7 +3527,7 @@ CType::GetAlignment(JSObject* obj)
JS_ASSERT(CType::IsCType(obj));
jsval slot = JS_GetReservedSlot(obj, SLOT_ALIGN);
return static_cast<size_t>(JSVAL_TO_INT(slot));
return static_cast<size_t>(slot.toInt32());
}
ffi_type*
@ -3540,8 +3537,8 @@ CType::GetFFIType(JSContext* cx, JSObject* obj)
jsval slot = JS_GetReservedSlot(obj, SLOT_FFITYPE);
if (!JSVAL_IS_VOID(slot)) {
return static_cast<ffi_type*>(JSVAL_TO_PRIVATE(slot));
if (!slot.isUndefined()) {
return static_cast<ffi_type*>(slot.toPrivate());
}
AutoPtr<ffi_type> result;
@ -3570,8 +3567,8 @@ CType::GetName(JSContext* cx, HandleObject obj)
JS_ASSERT(CType::IsCType(obj));
jsval string = JS_GetReservedSlot(obj, SLOT_NAME);
if (!JSVAL_IS_VOID(string))
return JSVAL_TO_STRING(string);
if (!string.isUndefined())
return string.toString();
// Build the type name lazily.
JSString* name = BuildTypeName(cx, obj);
@ -3611,8 +3608,8 @@ CType::GetProtoFromType(JSContext* cx, JSObject* objArg, CTypeProtoSlot slot)
// Get the requested ctypes.{Pointer,Array,Struct,Function}Type.prototype.
jsval result = JS_GetReservedSlot(proto, slot);
JS_ASSERT(!JSVAL_IS_PRIMITIVE(result));
return JSVAL_TO_OBJECT(result);
JS_ASSERT(result.isObject());
return &result.toObject();
}
bool
@ -3779,7 +3776,7 @@ CType::HasInstance(JSContext* cx, HandleObject obj, MutableHandleValue v, bool*
JS_ASSERT(CData::IsCDataProto(prototype));
*bp = false;
if (JSVAL_IS_PRIMITIVE(v))
if (v.isPrimitive())
return true;
RootedObject proto(cx, &v.toObject());
@ -3809,9 +3806,7 @@ CType::GetGlobalCTypes(JSContext* cx, JSObject* objArg)
JS_ASSERT(CType::IsCTypeProto(objTypeProto));
jsval valCTypes = JS_GetReservedSlot(objTypeProto, SLOT_CTYPES);
JS_ASSERT(!JSVAL_IS_PRIMITIVE(valCTypes));
JS_ASSERT(!JSVAL_IS_PRIMITIVE(valCTypes));
JS_ASSERT(valCTypes.isObject());
return &valCTypes.toObject();
}
@ -3881,7 +3876,7 @@ PointerType::Create(JSContext* cx, unsigned argc, jsval* vp)
jsval arg = args[0];
RootedObject obj(cx);
if (JSVAL_IS_PRIMITIVE(arg) || !CType::IsCType(obj = &arg.toObject())) {
if (arg.isPrimitive() || !CType::IsCType(obj = &arg.toObject())) {
JS_ReportError(cx, "first argument must be a CType");
return false;
}
@ -3994,7 +3989,7 @@ PointerType::ConstructData(JSContext* cx,
if (args.length() >= 2) {
if (args[1].isNull()) {
thisObj = nullptr;
} else if (!JSVAL_IS_PRIMITIVE(args[1])) {
} else if (args[1].isObject()) {
thisObj = &args[1].toObject();
} else if (!JS_ValueToObject(cx, args[1], &thisObj)) {
return false;
@ -4181,7 +4176,7 @@ ArrayType::Create(JSContext* cx, unsigned argc, jsval* vp)
return false;
}
if (JSVAL_IS_PRIMITIVE(args[0]) ||
if (args[0].isPrimitive() ||
!CType::IsCType(&args[0].toObject())) {
JS_ReportError(cx, "first argument must be a CType");
return false;
@ -4295,7 +4290,7 @@ ArrayType::ConstructData(JSContext* cx,
// Have a length, rather than an object to initialize from.
convertObject = false;
} else if (!JSVAL_IS_PRIMITIVE(args[0])) {
} else if (args[0].isObject()) {
// We were given an object with a .length property.
// This could be a JS array, or a CData array.
RootedObject arg(cx, &args[0].toObject());
@ -4366,7 +4361,7 @@ ArrayType::GetBaseType(JSObject* obj)
JS_ASSERT(CType::GetTypeCode(obj) == TYPE_array);
jsval type = JS_GetReservedSlot(obj, SLOT_ELEMENT_T);
JS_ASSERT(!JSVAL_IS_NULL(type));
JS_ASSERT(!type.isNull());
return &type.toObject();
}
@ -4634,12 +4629,12 @@ ArrayType::AddressOfElement(JSContext* cx, unsigned argc, jsval* vp)
static JSFlatString*
ExtractStructField(JSContext* cx, jsval val, JSObject** typeObj)
{
if (JSVAL_IS_PRIMITIVE(val)) {
if (val.isPrimitive()) {
JS_ReportError(cx, "struct field descriptors require a valid name and type");
return nullptr;
}
RootedObject obj(cx, JSVAL_TO_OBJECT(val));
RootedObject obj(cx, val.toObjectOrNull());
RootedObject iter(cx, JS_NewPropertyIterator(cx, obj));
if (!iter)
return nullptr;
@ -4737,12 +4732,12 @@ StructType::Create(JSContext* cx, unsigned argc, jsval* vp)
// non-instantiable as CData, will have no 'prototype' property, and will
// have undefined size and alignment and no ffi_type.
RootedObject result(cx, CType::Create(cx, typeProto, NullPtr(), TYPE_struct,
JSVAL_TO_STRING(name), JSVAL_VOID, JSVAL_VOID, nullptr));
name.toString(), JSVAL_VOID, JSVAL_VOID, nullptr));
if (!result)
return false;
if (args.length() == 2) {
RootedObject arr(cx, JSVAL_IS_PRIMITIVE(args[1]) ? nullptr : &args[1].toObject());
RootedObject arr(cx, args[1].isPrimitive() ? nullptr : &args[1].toObject());
if (!arr || !JS_IsArrayObject(cx, arr)) {
JS_ReportError(cx, "second argument must be an array");
return false;
@ -4999,11 +4994,11 @@ StructType::Define(JSContext* cx, unsigned argc, jsval* vp)
}
jsval arg = args[0];
if (JSVAL_IS_PRIMITIVE(arg)) {
if (arg.isPrimitive()) {
JS_ReportError(cx, "argument must be an array");
return false;
}
RootedObject arr(cx, JSVAL_TO_OBJECT(arg));
RootedObject arr(cx, arg.toObjectOrNull());
if (!JS_IsArrayObject(cx, arr)) {
JS_ReportError(cx, "argument must be an array");
return false;
@ -5094,9 +5089,9 @@ StructType::GetFieldInfo(JSObject* obj)
JS_ASSERT(CType::GetTypeCode(obj) == TYPE_struct);
jsval slot = JS_GetReservedSlot(obj, SLOT_FIELDINFO);
JS_ASSERT(!JSVAL_IS_VOID(slot) && JSVAL_TO_PRIVATE(slot));
JS_ASSERT(!slot.isUndefined() && slot.toPrivate());
return static_cast<const FieldInfoHash*>(JSVAL_TO_PRIVATE(slot));
return static_cast<const FieldInfoHash*>(slot.toPrivate());
}
const FieldInfo*
@ -5311,10 +5306,10 @@ struct AutoValue
static bool
GetABI(JSContext* cx, jsval abiType, ffi_abi* result)
{
if (JSVAL_IS_PRIMITIVE(abiType))
if (abiType.isPrimitive())
return false;
ABICode abi = GetABICode(JSVAL_TO_OBJECT(abiType));
ABICode abi = GetABICode(abiType.toObjectOrNull());
// determine the ABI from the subset of those available on the
// given platform. ABI_DEFAULT specifies the default
@ -5343,13 +5338,12 @@ GetABI(JSContext* cx, jsval abiType, ffi_abi* result)
static JSObject*
PrepareType(JSContext* cx, jsval type)
{
if (JSVAL_IS_PRIMITIVE(type) ||
!CType::IsCType(JSVAL_TO_OBJECT(type))) {
if (type.isPrimitive() || !CType::IsCType(type.toObjectOrNull())) {
JS_ReportError(cx, "not a ctypes type");
return nullptr;
}
JSObject* result = JSVAL_TO_OBJECT(type);
JSObject* result = type.toObjectOrNull();
TypeCode typeCode = CType::GetTypeCode(result);
if (typeCode == TYPE_array) {
@ -5380,13 +5374,12 @@ PrepareType(JSContext* cx, jsval type)
static JSObject*
PrepareReturnType(JSContext* cx, jsval type)
{
if (JSVAL_IS_PRIMITIVE(type) ||
!CType::IsCType(JSVAL_TO_OBJECT(type))) {
if (type.isPrimitive() || !CType::IsCType(type.toObjectOrNull())) {
JS_ReportError(cx, "not a ctypes type");
return nullptr;
}
JSObject* result = JSVAL_TO_OBJECT(type);
JSObject* result = type.toObjectOrNull();
TypeCode typeCode = CType::GetTypeCode(result);
// Arrays and functions can never be return types.
@ -5410,9 +5403,9 @@ static MOZ_ALWAYS_INLINE bool
IsEllipsis(JSContext* cx, jsval v, bool* isEllipsis)
{
*isEllipsis = false;
if (!JSVAL_IS_STRING(v))
if (!v.isString())
return true;
JSString* str = JSVAL_TO_STRING(v);
JSString* str = v.toString();
if (str->length() != 3)
return true;
const jschar* chars = str->getChars(cx);
@ -5524,7 +5517,7 @@ NewFunctionInfo(JSContext* cx,
JS_ReportError(cx, "Invalid ABI specification");
return nullptr;
}
fninfo->mABI = JSVAL_TO_OBJECT(abiType);
fninfo->mABI = abiType.toObjectOrNull();
// prepare the result type
fninfo->mReturnType = PrepareReturnType(cx, returnType);
@ -5601,7 +5594,7 @@ FunctionType::Create(JSContext* cx, unsigned argc, jsval* vp)
if (args.length() == 3) {
// Prepare an array of jsvals for the arguments.
if (!JSVAL_IS_PRIMITIVE(args[2]))
if (args[2].isObject())
arrayObj = &args[2].toObject();
if (!arrayObj || !JS_IsArrayObject(cx, arrayObj)) {
JS_ReportError(cx, "third argument must be an array");
@ -5807,7 +5800,7 @@ FunctionType::Call(JSContext* cx,
RootedObject type(cx); // RootedObject, but readability would suffer.
for (uint32_t i = argcFixed; i < args.length(); ++i) {
if (JSVAL_IS_PRIMITIVE(args[i]) ||
if (args[i].isPrimitive() ||
!CData::IsCData(obj = &args[i].toObject())) {
// Since we know nothing about the CTypes of the ... arguments,
// they absolutely must be CData objects already.
@ -5912,9 +5905,9 @@ FunctionType::GetFunctionInfo(JSObject* obj)
JS_ASSERT(CType::GetTypeCode(obj) == TYPE_function);
jsval slot = JS_GetReservedSlot(obj, SLOT_FNINFO);
JS_ASSERT(!JSVAL_IS_VOID(slot) && JSVAL_TO_PRIVATE(slot));
JS_ASSERT(!slot.isUndefined() && slot.toPrivate());
return static_cast<FunctionInfo*>(JSVAL_TO_PRIVATE(slot));
return static_cast<FunctionInfo*>(slot.toPrivate());
}
bool
@ -6030,7 +6023,7 @@ CClosure::Create(JSContext* cx,
// we might be unable to convert the value to the proper type. If so, we want
// the caller to know about it _now_, rather than some uncertain time in the
// future when the error sentinel is actually needed.
if (!JSVAL_IS_VOID(errVal)) {
if (!errVal.isUndefined()) {
// Make sure the callback returns something.
if (CType::GetTypeCode(fninfo->mReturnType) == TYPE_void_t) {
@ -6092,10 +6085,10 @@ CClosure::Trace(JSTracer* trc, JSObject* obj)
{
// Make sure our ClosureInfo slot is legit. If it's not, bail.
jsval slot = JS_GetReservedSlot(obj, SLOT_CLOSUREINFO);
if (JSVAL_IS_VOID(slot))
if (slot.isUndefined())
return;
ClosureInfo* cinfo = static_cast<ClosureInfo*>(JSVAL_TO_PRIVATE(slot));
ClosureInfo* cinfo = static_cast<ClosureInfo*>(slot.toPrivate());
// Identify our objects to the tracer. (There's no need to identify
// 'closureObj', since that's us.)
@ -6110,10 +6103,10 @@ CClosure::Finalize(JSFreeOp *fop, JSObject* obj)
{
// Make sure our ClosureInfo slot is legit. If it's not, bail.
jsval slot = JS_GetReservedSlot(obj, SLOT_CLOSUREINFO);
if (JSVAL_IS_VOID(slot))
if (slot.isUndefined())
return;
ClosureInfo* cinfo = static_cast<ClosureInfo*>(JSVAL_TO_PRIVATE(slot));
ClosureInfo* cinfo = static_cast<ClosureInfo*>(slot.toPrivate());
FreeOp::get(fop)->delete_(cinfo);
}
@ -6295,9 +6288,9 @@ CData::Create(JSContext* cx,
// Get the 'prototype' property from the type.
jsval slot = JS_GetReservedSlot(typeObj, SLOT_PROTO);
JS_ASSERT(!JSVAL_IS_PRIMITIVE(slot));
JS_ASSERT(slot.isObject());
RootedObject proto(cx, JSVAL_TO_OBJECT(slot));
RootedObject proto(cx, &slot.toObject());
RootedObject parent(cx, JS_GetParent(typeObj));
JS_ASSERT(parent);
@ -6354,15 +6347,15 @@ CData::Finalize(JSFreeOp *fop, JSObject* obj)
{
// Delete our buffer, and the data it contains if we own it.
jsval slot = JS_GetReservedSlot(obj, SLOT_OWNS);
if (JSVAL_IS_VOID(slot))
if (slot.isUndefined())
return;
bool owns = JSVAL_TO_BOOLEAN(slot);
bool owns = slot.toBoolean();
slot = JS_GetReservedSlot(obj, SLOT_DATA);
if (JSVAL_IS_VOID(slot))
if (slot.isUndefined())
return;
char** buffer = static_cast<char**>(JSVAL_TO_PRIVATE(slot));
char** buffer = static_cast<char**>(slot.toPrivate());
if (owns)
FreeOp::get(fop)->free_(*buffer);
@ -6375,7 +6368,7 @@ CData::GetCType(JSObject* dataObj)
JS_ASSERT(CData::IsCData(dataObj));
jsval slot = JS_GetReservedSlot(dataObj, SLOT_CTYPE);
JSObject* typeObj = JSVAL_TO_OBJECT(slot);
JSObject* typeObj = slot.toObjectOrNull();
JS_ASSERT(CType::IsCType(typeObj));
return typeObj;
}
@ -6387,7 +6380,7 @@ CData::GetData(JSObject* dataObj)
jsval slot = JS_GetReservedSlot(dataObj, SLOT_DATA);
void** buffer = static_cast<void**>(JSVAL_TO_PRIVATE(slot));
void** buffer = static_cast<void**>(slot.toPrivate());
JS_ASSERT(buffer);
JS_ASSERT(*buffer);
return *buffer;
@ -6473,16 +6466,14 @@ CData::Cast(JSContext* cx, unsigned argc, jsval* vp)
return false;
}
if (JSVAL_IS_PRIMITIVE(args[0]) ||
!CData::IsCData(&args[0].toObject())) {
if (args[0].isPrimitive() || !CData::IsCData(&args[0].toObject())) {
JS_ReportError(cx, "first argument must be a CData");
return false;
}
RootedObject sourceData(cx, &args[0].toObject());
JSObject* sourceType = CData::GetCType(sourceData);
if (JSVAL_IS_PRIMITIVE(args[1]) ||
!CType::IsCType(&args[1].toObject())) {
if (args[1].isPrimitive() || !CType::IsCType(&args[1].toObject())) {
JS_ReportError(cx, "second argument must be a CType");
return false;
}
@ -6516,8 +6507,7 @@ CData::GetRuntime(JSContext* cx, unsigned argc, jsval* vp)
return false;
}
if (JSVAL_IS_PRIMITIVE(args[0]) ||
!CType::IsCType(&args[0].toObject())) {
if (args[0].isPrimitive() || !CType::IsCType(&args[0].toObject())) {
JS_ReportError(cx, "first argument must be a CType");
return false;
}
@ -6742,11 +6732,11 @@ CDataFinalizer::Methods::ToSource(JSContext *cx, unsigned argc, jsval *vp)
AppendString(source, ", ");
jsval valCodePtrType = JS_GetReservedSlot(objThis,
SLOT_DATAFINALIZER_CODETYPE);
if (JSVAL_IS_PRIMITIVE(valCodePtrType)) {
if (valCodePtrType.isPrimitive()) {
return false;
}
RootedObject typeObj(cx, JSVAL_TO_OBJECT(valCodePtrType));
RootedObject typeObj(cx, valCodePtrType.toObjectOrNull());
JSString *srcDispose = CData::GetSourceString(cx, typeObj, &(p->code));
if (!srcDispose) {
return false;
@ -6813,11 +6803,11 @@ CDataFinalizer::GetCType(JSContext *cx, JSObject *obj)
jsval valData = JS_GetReservedSlot(obj,
SLOT_DATAFINALIZER_VALTYPE);
if (JSVAL_IS_VOID(valData)) {
if (valData.isUndefined()) {
return nullptr;
}
return JSVAL_TO_OBJECT(valData);
return valData.toObjectOrNull();
}
JSObject*
@ -6835,11 +6825,11 @@ CDataFinalizer::GetCData(JSContext *cx, JSObject *obj)
return nullptr;
}
RootedValue val(cx);
if (!CDataFinalizer::GetValue(cx, obj, val.address()) || JSVAL_IS_PRIMITIVE(val)) {
if (!CDataFinalizer::GetValue(cx, obj, val.address()) || val.isPrimitive()) {
JS_ReportError(cx, "Empty CDataFinalizer");
return nullptr;
}
return JSVAL_TO_OBJECT(val);
return val.toObjectOrNull();
}
bool
@ -6993,7 +6983,7 @@ CDataFinalizer::Construct(JSContext* cx, unsigned argc, jsval *vp)
// This is the type that we should capture, not that
// of the function, which may be less precise.
JSObject *objBestArgType = objArgType;
if (!JSVAL_IS_PRIMITIVE(valData)) {
if (valData.isObject()) {
JSObject *objData = &valData.toObject();
if (CData::IsCData(objData)) {
objBestArgType = CData::GetCType(objData);
@ -7173,14 +7163,14 @@ CDataFinalizer::Methods::Dispose(JSContext* cx, unsigned argc, jsval *vp)
}
jsval valType = JS_GetReservedSlot(obj, SLOT_DATAFINALIZER_VALTYPE);
JS_ASSERT(!JSVAL_IS_PRIMITIVE(valType));
JS_ASSERT(valType.isObject());
JSObject *objCTypes = CType::GetGlobalCTypes(cx, &valType.toObject());
if (!objCTypes)
return false;
jsval valCodePtrType = JS_GetReservedSlot(obj, SLOT_DATAFINALIZER_CODETYPE);
JS_ASSERT(!JSVAL_IS_PRIMITIVE(valCodePtrType));
JS_ASSERT(valCodePtrType.isObject());
JSObject *objCodePtrType = &valCodePtrType.toObject();
JSObject *objCodeType = PointerType::GetBaseType(objCodePtrType);
@ -7306,10 +7296,10 @@ void
Int64Base::Finalize(JSFreeOp *fop, JSObject* obj)
{
jsval slot = JS_GetReservedSlot(obj, SLOT_INT64);
if (JSVAL_IS_VOID(slot))
if (slot.isUndefined())
return;
FreeOp::get(fop)->delete_(static_cast<uint64_t*>(JSVAL_TO_PRIVATE(slot)));
FreeOp::get(fop)->delete_(static_cast<uint64_t*>(slot.toPrivate()));
}
uint64_t
@ -7317,7 +7307,7 @@ Int64Base::GetInt(JSObject* obj) {
JS_ASSERT(Int64::IsInt64(obj) || UInt64::IsUInt64(obj));
jsval slot = JS_GetReservedSlot(obj, SLOT_INT64);
return *static_cast<uint64_t*>(JSVAL_TO_PRIVATE(slot));
return *static_cast<uint64_t*>(slot.toPrivate());
}
bool
@ -7408,7 +7398,7 @@ Int64::Construct(JSContext* cx,
RootedValue slot(cx);
RootedObject callee(cx, &args.callee());
ASSERT_OK(JS_GetProperty(cx, callee, "prototype", &slot));
RootedObject proto(cx, JSVAL_TO_OBJECT(slot));
RootedObject proto(cx, slot.toObjectOrNull());
JS_ASSERT(JS_GetClass(proto) == &sInt64ProtoClass);
JSObject* result = Int64Base::Construct(cx, proto, i, false);
@ -7460,8 +7450,8 @@ Int64::Compare(JSContext* cx, unsigned argc, jsval* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
if (args.length() != 2 ||
JSVAL_IS_PRIMITIVE(args[0]) ||
JSVAL_IS_PRIMITIVE(args[1]) ||
args[0].isPrimitive() ||
args[1].isPrimitive() ||
!Int64::IsInt64(&args[0].toObject()) ||
!Int64::IsInt64(&args[1].toObject())) {
JS_ReportError(cx, "compare takes two Int64 arguments");
@ -7492,7 +7482,7 @@ bool
Int64::Lo(JSContext* cx, unsigned argc, jsval* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
if (args.length() != 1 || JSVAL_IS_PRIMITIVE(args[0]) ||
if (args.length() != 1 || args[0].isPrimitive() ||
!Int64::IsInt64(&args[0].toObject())) {
JS_ReportError(cx, "lo takes one Int64 argument");
return false;
@ -7510,7 +7500,7 @@ bool
Int64::Hi(JSContext* cx, unsigned argc, jsval* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
if (args.length() != 1 || JSVAL_IS_PRIMITIVE(args[0]) ||
if (args.length() != 1 || args[0].isPrimitive() ||
!Int64::IsInt64(&args[0].toObject())) {
JS_ReportError(cx, "hi takes one Int64 argument");
return false;
@ -7630,8 +7620,8 @@ UInt64::Compare(JSContext* cx, unsigned argc, jsval* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
if (args.length() != 2 ||
JSVAL_IS_PRIMITIVE(args[0]) ||
JSVAL_IS_PRIMITIVE(args[1]) ||
args[0].isPrimitive() ||
args[1].isPrimitive() ||
!UInt64::IsUInt64(&args[0].toObject()) ||
!UInt64::IsUInt64(&args[1].toObject())) {
JS_ReportError(cx, "compare takes two UInt64 arguments");
@ -7658,7 +7648,7 @@ bool
UInt64::Lo(JSContext* cx, unsigned argc, jsval* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
if (args.length() != 1 || JSVAL_IS_PRIMITIVE(args[0]) ||
if (args.length() != 1 || args[0].isPrimitive() ||
!UInt64::IsUInt64(&args[0].toObject())) {
JS_ReportError(cx, "lo takes one UInt64 argument");
return false;
@ -7676,7 +7666,7 @@ bool
UInt64::Hi(JSContext* cx, unsigned argc, jsval* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
if (args.length() != 1 || JSVAL_IS_PRIMITIVE(args[0]) ||
if (args.length() != 1 || args[0].isPrimitive() ||
!UInt64::IsUInt64(&args[0].toObject())) {
JS_ReportError(cx, "hi takes one UInt64 argument");
return false;

View File

@ -58,10 +58,9 @@ Library::Name(JSContext* cx, unsigned argc, jsval *vp)
Value arg = args[0];
JSString* str = nullptr;
if (JSVAL_IS_STRING(arg)) {
str = JSVAL_TO_STRING(arg);
}
else {
if (arg.isString()) {
str = arg.toString();
} else {
JS_ReportError(cx, "name argument must be a string");
return false;
}
@ -96,13 +95,13 @@ Library::Create(JSContext* cx, jsval path_, JSCTypesCallbacks* callbacks)
if (!JS_DefineFunctions(cx, libraryObj, sLibraryFunctions))
return nullptr;
if (!JSVAL_IS_STRING(path)) {
if (!path.isString()) {
JS_ReportError(cx, "open takes a string argument");
return nullptr;
}
PRLibSpec libSpec;
RootedFlatString pathStr(cx, JS_FlattenString(cx, JSVAL_TO_STRING(path)));
RootedFlatString pathStr(cx, JS_FlattenString(cx, path.toString()));
if (!pathStr)
return nullptr;
#ifdef XP_WIN
@ -179,7 +178,7 @@ Library::GetLibrary(JSObject* obj)
JS_ASSERT(IsLibrary(obj));
jsval slot = JS_GetReservedSlot(obj, SLOT_LIBRARY);
return static_cast<PRLibrary*>(JSVAL_TO_PRIVATE(slot));
return static_cast<PRLibrary*>(slot.toPrivate());
}
static void

View File

@ -152,6 +152,30 @@ CanLazilyParse(ExclusiveContext *cx, const ReadOnlyCompileOptions &options)
cx->compartment()->runtimeFromAnyThread()->debugHooks.newScriptHook);
}
static void
MarkFunctionsWithinEvalScript(JSScript *script)
{
// Mark top level functions in an eval script as being within an eval and,
// if applicable, inside a with statement.
if (!script->hasObjects())
return;
ObjectArray *objects = script->objects();
size_t start = script->innerObjectsStart();
for (size_t i = start; i < objects->length; i++) {
JSObject *obj = objects->vector[i];
if (obj->is<JSFunction>()) {
JSFunction *fun = &obj->as<JSFunction>();
if (fun->hasScript())
fun->nonLazyScript()->setDirectlyInsideEval();
else if (fun->isInterpretedLazy())
fun->lazyScript()->setDirectlyInsideEval();
}
}
}
void
frontend::MaybeCallSourceHandler(JSContext *cx, const ReadOnlyCompileOptions &options,
SourceBufferHolder &srcBuf)
@ -420,6 +444,12 @@ frontend::CompileScript(ExclusiveContext *cx, LifoAlloc *alloc, HandleObject sco
if (!JSScript::fullyInitFromEmitter(cx, script, &bce))
return nullptr;
// Note that this marking must happen before we tell Debugger
// about the new script, in case Debugger delazifies the script's
// inner functions.
if (options.forEval)
MarkFunctionsWithinEvalScript(script);
bce.tellDebuggerAboutCompiledScript(cx);
if (sct && !extraSct && !sct->complete())

View File

@ -0,0 +1,32 @@
// Tests that exception handling works with block scopes.
var g = newGlobal();
var dbg = new Debugger(g);
var correct;
dbg.onEnterFrame = function (f) {
if (f.callee && f.callee.name == "f") {
f.onPop = function() {
// The scope at the point of onPop is the outermost.
correct = (f.environment.getVariable("e") === undefined &&
f.environment.getVariable("outer") === 43);
};
}
};
g.eval("" + function f() {
var outer = 43;
try {
eval("");
throw 42;
} catch (e) {
noSuchFn(e);
}
});
try {
g.eval("f();");
} catch (e) {
// The above is expected to throw.
}
assertEq(correct, true);

View File

@ -0,0 +1,35 @@
// Tests that exception handling works with block scopes.
var g = newGlobal();
var dbg = new Debugger(g);
var correct;
dbg.onEnterFrame = function (f) {
if (f.callee && f.callee.name == "f") {
f.onPop = function() {
// The scope at the point of onPop is the outermost.
correct = (f.environment.getVariable("e") === undefined &&
f.environment.getVariable("outer") === 43);
};
}
};
g.eval("" + function f() {
var outer = 43;
// Surround with a loop to insert a loop trynote.
for (;;) {
try {
eval("");
throw 42;
} catch (e) {
noSuchFn(e);
}
}
});
try {
g.eval("f();");
} catch (e) {
// The above is expected to throw.
}
assertEq(correct, true);

View File

@ -0,0 +1,16 @@
// Test that lazy inner functions inside eval are tagged properly so we don't
// incorrectly do NAME -> GNAME optimization.
var g = newGlobal();
var dbg = new Debugger(g);
dbg.onNewScript = function delazify(script, global) {
// Force delazification of inner functions.
script.getChildScripts();
};
g.eval("" + function f() {
var $;
eval('var obj={foo:1}; $=function() { assertEq(obj.foo, 1); }');
return $;
});
g.eval("f()();");

View File

@ -0,0 +1,21 @@
var lfcode = new Array();
lfcode.push = loadFile;
lfcode.push("");
lfcode.push("");
lfcode.push("3");
lfcode.push("");
lfcode.push("");
lfcode.push("");
lfcode.push("");
lfcode.push("4");
lfcode.push("");
lfcode.push("0");
lfcode.push("gczeal(2);");
lfcode.push("\
var g = newGlobal();\
g.parent = this;\
g.eval('new Debugger(parent).onExceptionUnwind = function() {};');\
");
function loadFile(lfVarx) {
evaluate(lfVarx);
}

View File

@ -0,0 +1,15 @@
var lfcode = new Array();
lfcode.push("");
lfcode.push("0");
lfcode.push("newGlobal(\"1\").eval(\"(new Debugger).addAllGlobalsAsDebuggees();\");\n");
while (true) {
var file = lfcode.shift(); if (file == undefined) { break; }
loadFile(file)
}
function loadFile(lfVarx) {
try {
if (lfVarx.substr(-3) != ".js" && lfVarx.length != 1) {
evaluate(lfVarx);
} else if (!isNaN(lfVarx)) {}
} catch (lfVare) { }
}

View File

@ -387,12 +387,12 @@ static inline void*
GetStubReturnAddress(JSContext *cx, jsbytecode *pc)
{
if (IsGetPropPC(pc))
return cx->compartment()->jitCompartment()->baselineGetPropReturnFromIonAddr();
return cx->compartment()->jitCompartment()->baselineGetPropReturnAddr();
if (IsSetPropPC(pc))
return cx->compartment()->jitCompartment()->baselineSetPropReturnFromIonAddr();
return cx->compartment()->jitCompartment()->baselineSetPropReturnAddr();
// This should be a call op of some kind, now.
JS_ASSERT(IsCallPC(pc));
return cx->compartment()->jitCompartment()->baselineCallReturnFromIonAddr();
return cx->compartment()->jitCompartment()->baselineCallReturnAddr();
}
static inline jsbytecode *

View File

@ -21,29 +21,30 @@ struct DebugModeOSREntry
{
JSScript *script;
BaselineScript *oldBaselineScript;
ICStub *oldStub;
ICStub *newStub;
BaselineDebugModeOSRInfo *recompInfo;
uint32_t pcOffset;
ICEntry::Kind frameKind;
// Used for sanity asserts in debug builds.
DebugOnly<ICStub *> stub;
DebugModeOSREntry(JSScript *script)
: script(script),
oldBaselineScript(script->baselineScript()),
oldStub(nullptr),
newStub(nullptr),
recompInfo(nullptr),
pcOffset(uint32_t(-1)),
frameKind(ICEntry::Kind_NonOp),
stub(nullptr)
frameKind(ICEntry::Kind_NonOp)
{ }
DebugModeOSREntry(JSScript *script, const ICEntry &icEntry)
: script(script),
oldBaselineScript(script->baselineScript()),
oldStub(nullptr),
newStub(nullptr),
recompInfo(nullptr),
pcOffset(icEntry.pcOffset()),
frameKind(icEntry.kind()),
stub(nullptr)
frameKind(icEntry.kind())
{
#ifdef DEBUG
MOZ_ASSERT(pcOffset == icEntry.pcOffset());
@ -71,10 +72,11 @@ struct DebugModeOSREntry
DebugModeOSREntry(DebugModeOSREntry &&other)
: script(other.script),
oldBaselineScript(other.oldBaselineScript),
oldStub(other.oldStub),
newStub(other.newStub),
recompInfo(other.recompInfo ? other.takeRecompInfo() : nullptr),
pcOffset(other.pcOffset),
frameKind(other.frameKind),
stub(other.stub)
frameKind(other.frameKind)
{ }
~DebugModeOSREntry() {
@ -112,6 +114,11 @@ struct DebugModeOSREntry
recompInfo = cx->new_<BaselineDebugModeOSRInfo>(pc, kind);
return !!recompInfo;
}
ICFallbackStub *fallbackStub() const {
MOZ_ASSERT(oldStub);
return script->baselineScript()->icEntryFromPCOffset(pcOffset).fallbackStub();
}
};
typedef js::Vector<DebugModeOSREntry> DebugModeOSREntryVector;
@ -120,7 +127,7 @@ static bool
CollectOnStackScripts(JSContext *cx, const JitActivationIterator &activation,
DebugModeOSREntryVector &entries)
{
DebugOnly<ICStub *> prevFrameStubPtr = nullptr;
ICStub *prevFrameStubPtr = nullptr;
bool needsRecompileHandler = false;
for (JitFrameIterator iter(activation); !iter.done(); ++iter) {
switch (iter.type()) {
@ -139,7 +146,7 @@ CollectOnStackScripts(JSContext *cx, const JitActivationIterator &activation,
needsRecompileHandler |= true;
}
entries.back().stub = prevFrameStubPtr;
entries.back().oldStub = prevFrameStubPtr;
prevFrameStubPtr = nullptr;
break;
}
@ -175,22 +182,6 @@ CollectOnStackScripts(JSContext *cx, const JitActivationIterator &activation,
return true;
}
static inline uint8_t *
GetStubReturnFromStubAddress(JSContext *cx, jsbytecode *pc)
{
JitCompartment *comp = cx->compartment()->jitCompartment();
void *addr;
if (IsGetPropPC(pc)) {
addr = comp->baselineGetPropReturnFromStubAddr();
} else if (IsSetPropPC(pc)) {
addr = comp->baselineSetPropReturnFromStubAddr();
} else {
JS_ASSERT(IsCallPC(pc));
addr = comp->baselineCallReturnFromStubAddr();
}
return reinterpret_cast<uint8_t *>(addr);
}
static const char *
ICEntryKindToString(ICEntry::Kind kind)
{
@ -224,15 +215,11 @@ SpewPatchBaselineFrame(uint8_t *oldReturnAddress, uint8_t *newReturnAddress,
}
static void
SpewPatchStubFrame(uint8_t *oldReturnAddress, uint8_t *newReturnAddress,
ICStub *oldStub, ICStub *newStub)
SpewPatchStubFrame(ICStub *oldStub, ICStub *newStub)
{
IonSpew(IonSpew_BaselineDebugModeOSR,
"Patch return %#016llx -> %#016llx",
uintptr_t(oldReturnAddress), uintptr_t(newReturnAddress));
IonSpew(IonSpew_BaselineDebugModeOSR,
"Patch stub %#016llx -> %#016llx to BaselineStub",
uintptr_t(oldStub), uintptr_t(newStub));
"Patch stub %#016llx -> %#016llx to BaselineStub (%s)",
uintptr_t(oldStub), uintptr_t(newStub), ICStub::KindString(newStub->kind()));
}
static void
@ -266,10 +253,11 @@ PatchBaselineFramesForDebugMode(JSContext *cx, const JitActivationIterator &acti
DebugOnly<bool> expectedDebugMode = cx->compartment()->debugMode();
for (JitFrameIterator iter(activation); !iter.done(); ++iter) {
DebugModeOSREntry &entry = entries[entryIndex];
switch (iter.type()) {
case JitFrame_BaselineJS: {
JSScript *script = entries[entryIndex].script;
uint32_t pcOffset = entries[entryIndex].pcOffset;
JSScript *script = entry.script;
uint32_t pcOffset = entry.pcOffset;
jsbytecode *pc = script->offsetToPC(pcOffset);
MOZ_ASSERT(script == iter.script());
@ -277,7 +265,7 @@ PatchBaselineFramesForDebugMode(JSContext *cx, const JitActivationIterator &acti
MOZ_ASSERT(script->baselineScript()->debugMode() == expectedDebugMode);
BaselineScript *bl = script->baselineScript();
ICEntry::Kind kind = entries[entryIndex].frameKind;
ICEntry::Kind kind = entry.frameKind;
if (kind == ICEntry::Kind_Op) {
// Case A above.
@ -287,7 +275,7 @@ PatchBaselineFramesForDebugMode(JSContext *cx, const JitActivationIterator &acti
// the baseline frame here, we resume right after the IC
// returns.
//
// Since we're using the IC-specific k-fixer, we can resume
// Since we're using the same IC stub code, we can resume
// directly to the IC resume address.
uint8_t *retAddr = bl->returnAddressForIC(bl->icEntryFromPCOffset(pcOffset));
SpewPatchBaselineFrame(prev->returnAddress(), retAddr, script, kind, pc);
@ -300,7 +288,7 @@ PatchBaselineFramesForDebugMode(JSContext *cx, const JitActivationIterator &acti
// The RecompileInfo must already be allocated so that this
// function may be infallible.
BaselineDebugModeOSRInfo *recompInfo = entries[entryIndex].takeRecompInfo();
BaselineDebugModeOSRInfo *recompInfo = entry.takeRecompInfo();
switch (kind) {
case ICEntry::Kind_CallVM:
@ -363,19 +351,19 @@ PatchBaselineFramesForDebugMode(JSContext *cx, const JitActivationIterator &acti
}
case JitFrame_BaselineStub: {
JSScript *script = entries[entryIndex].script;
JSScript *script = entry.script;
IonBaselineStubFrameLayout *layout =
reinterpret_cast<IonBaselineStubFrameLayout *>(iter.fp());
MOZ_ASSERT(script->baselineScript()->debugMode() == expectedDebugMode);
MOZ_ASSERT(layout->maybeStubPtr() == entries[entryIndex].stub);
MOZ_ASSERT(layout->maybeStubPtr() == entry.oldStub);
// Patch baseline stub frames for case A above.
//
// We need to patch the stub frame return address to go to the
// k-fixer that is at the end of fallback stubs of all such
// can-call ICs. These k-fixers share code with bailout-from-Ion
// fixers, but in this case we are returning from VM and not
// Ion. See e.g., JitCompartment::baselineCallReturnFromStubAddr()
// We need to patch the stub frame to point to an ICStub belonging
// to the recompiled baseline script. These stubs are allocated up
// front in CloneOldBaselineStub. They share the same JitCode as
// the old baseline script's stubs, so we don't need to patch the
// exit frame's return address.
//
// Subtlety here: the debug trap handler of case C above pushes a
// stub frame with a null stub pointer. This handler will exist
@ -387,17 +375,9 @@ PatchBaselineFramesForDebugMode(JSContext *cx, const JitActivationIterator &acti
// (i.e. fallback calls), we need to check for recompilation using
// DebugModeOSRVolatileStub.
if (layout->maybeStubPtr()) {
MOZ_ASSERT(layout->maybeStubPtr() == entries[entryIndex].stub);
uint32_t pcOffset = entries[entryIndex].pcOffset;
uint8_t *retAddr = GetStubReturnFromStubAddress(cx, script->offsetToPC(pcOffset));
// Get the fallback stub for the IC in the recompiled
// script. The fallback stub is guaranteed to exist.
ICEntry &entry = script->baselineScript()->icEntryFromPCOffset(pcOffset);
ICStub *newStub = entry.fallbackStub();
SpewPatchStubFrame(prev->returnAddress(), retAddr, layout->maybeStubPtr(), newStub);
prev->setReturnAddress(retAddr);
layout->setStubPtr(newStub);
MOZ_ASSERT(entry.newStub);
SpewPatchStubFrame(entry.oldStub, entry.newStub);
layout->setStubPtr(entry.newStub);
}
break;
@ -433,6 +413,8 @@ RecompileBaselineScriptForDebugMode(JSContext *cx, JSScript *script)
IonSpew(IonSpew_BaselineDebugModeOSR, "Recompiling (%s:%d) for debug mode %s",
script->filename(), script->lineno(), expectedDebugMode ? "ON" : "OFF");
CancelOffThreadIonCompile(cx->compartment(), script);
if (script->hasIonScript())
Invalidate(cx, script, /* resetUses = */ false);
@ -454,6 +436,101 @@ RecompileBaselineScriptForDebugMode(JSContext *cx, JSScript *script)
return true;
}
#define PATCHABLE_ICSTUB_KIND_LIST(_) \
_(Call_Scripted) \
_(Call_AnyScripted) \
_(Call_Native) \
_(Call_ScriptedApplyArray) \
_(Call_ScriptedApplyArguments) \
_(Call_ScriptedFunCall) \
_(GetElem_NativePrototypeCallNative) \
_(GetElem_NativePrototypeCallScripted) \
_(GetProp_CallScripted) \
_(GetProp_CallNative) \
_(GetProp_CallNativePrototype) \
_(GetProp_CallDOMProxyNative) \
_(GetProp_CallDOMProxyWithGenerationNative) \
_(GetProp_DOMProxyShadowed) \
_(SetProp_CallScripted) \
_(SetProp_CallNative)
#if JS_HAS_NO_SUCH_METHOD
#define PATCHABLE_NSM_ICSTUB_KIND_LIST(_) \
_(GetElem_Dense) \
_(GetElem_Arguments) \
_(GetProp_NativePrototype) \
_(GetProp_Native)
#endif
static bool
CloneOldBaselineStub(JSContext *cx, DebugModeOSREntryVector &entries, size_t entryIndex)
{
DebugModeOSREntry &entry = entries[entryIndex];
if (!entry.oldStub)
return true;
ICStub *oldStub = entry.oldStub;
MOZ_ASSERT(ICStub::CanMakeCalls(oldStub->kind()));
// Get the new fallback stub from the recompiled baseline script.
ICFallbackStub *fallbackStub = entry.fallbackStub();
// We don't need to clone fallback stubs, as they are guaranteed to
// exist. Furthermore, their JitCode is cached and should be the same even
// across the recompile.
if (oldStub->isFallback()) {
MOZ_ASSERT(oldStub->jitCode() == fallbackStub->jitCode());
entry.newStub = fallbackStub;
return true;
}
// Check if we have already cloned the stub on a younger frame.
for (size_t i = 0; i < entryIndex; i++) {
if (oldStub == entries[i].oldStub) {
MOZ_ASSERT(entries[i].newStub);
entry.newStub = entries[i].newStub;
return true;
}
}
// Some stubs are monitored, get the first stub in the monitor chain from
// the new fallback stub if so.
ICStub *firstMonitorStub;
if (fallbackStub->isMonitoredFallback()) {
ICMonitoredFallbackStub *monitored = fallbackStub->toMonitoredFallbackStub();
firstMonitorStub = monitored->fallbackMonitorStub()->firstMonitorStub();
} else {
firstMonitorStub = nullptr;
}
ICStubSpace *stubSpace = ICStubCompiler::StubSpaceForKind(oldStub->kind(), entry.script);
// Clone the existing stub into the recompiled IC.
//
// Note that since JitCode is a GC thing, cloning an ICStub with the same
// JitCode ensures it won't be collected.
switch (oldStub->kind()) {
#define CASE_KIND(kindName) \
case ICStub::kindName: \
entry.newStub = IC##kindName::Clone(cx, stubSpace, firstMonitorStub, \
*oldStub->to##kindName()); \
break;
PATCHABLE_ICSTUB_KIND_LIST(CASE_KIND)
#if JS_HAS_NO_SUCH_METHOD
PATCHABLE_NSM_ICSTUB_KIND_LIST(CASE_KIND)
#endif
#undef CASE_KIND
default:
MOZ_ASSUME_UNREACHABLE("Bad stub kind");
}
if (!entry.newStub)
return false;
fallbackStub->addNewStub(entry.newStub);
return true;
}
static void
UndoRecompileBaselineScriptsForDebugMode(JSContext *cx,
const DebugModeOSREntryVector &entries)
@ -497,7 +574,10 @@ jit::RecompileOnStackBaselineScriptsForDebugMode(JSContext *cx, JSCompartment *c
// crash.
for (size_t i = 0; i < entries.length(); i++) {
JSScript *script = entries[i].script;
if (!RecompileBaselineScriptForDebugMode(cx, script)) {
if (!RecompileBaselineScriptForDebugMode(cx, script) ||
!CloneOldBaselineStub(cx, entries, i))
{
UndoRecompileBaselineScriptsForDebugMode(cx, entries);
return false;
}

View File

@ -63,7 +63,16 @@ class BaselineFrame
// Frame has a BaselineRecompileInfo stashed in the scratch value
// slot. See PatchBaselineFramesForDebugMOde.
HAS_DEBUG_MODE_OSR_INFO = 1 << 10
HAS_DEBUG_MODE_OSR_INFO = 1 << 10,
// Frame has had its scope chain unwound to a pc during exception
// handling that is different from its current pc.
//
// This flag is intended for use in the DebugEpilogue. Once it is set,
// the only way to clear it is to pop the frame. Do *not* set this if
// we will resume execution on the frame, such as in a catch or
// finally block.
HAS_UNWOUND_SCOPE_OVERRIDE_PC = 1 << 11
};
protected: // Silence Clang warning about unused private fields.
@ -71,17 +80,15 @@ class BaselineFrame
// compiler may add some padding between the fields.
uint32_t loScratchValue_;
uint32_t hiScratchValue_;
uint32_t loReturnValue_; // If HAS_RVAL, the frame's return value.
uint32_t loReturnValue_; // If HAS_RVAL, the frame's return value.
uint32_t hiReturnValue_;
uint32_t frameSize_;
JSObject *scopeChain_; // Scope chain (always initialized).
JSScript *evalScript_; // If isEvalFrame(), the current eval script.
ArgumentsObject *argsObj_; // If HAS_ARGS_OBJ, the arguments object.
void *hookData_; // If HAS_HOOK_DATA, debugger call hook data.
JSObject *scopeChain_; // Scope chain (always initialized).
JSScript *evalScript_; // If isEvalFrame(), the current eval script.
ArgumentsObject *argsObj_; // If HAS_ARGS_OBJ, the arguments object.
void *hookData_; // If HAS_HOOK_DATA, debugger call hook data.
uint32_t unwoundScopeOverrideOffset_; // If HAS_UNWOUND_SCOPE_OVERRIDE_PC.
uint32_t flags_;
#if JS_BITS_PER_WORD == 32
uint32_t padding_; // Pad to 8-byte alignment.
#endif
public:
// Distance between the frame pointer and the frame header (return address).
@ -320,6 +327,22 @@ class BaselineFrame
void deleteDebugModeOSRInfo();
jsbytecode *unwoundScopeOverridePc() {
MOZ_ASSERT(flags_ & HAS_UNWOUND_SCOPE_OVERRIDE_PC);
return script()->offsetToPC(unwoundScopeOverrideOffset_);
}
jsbytecode *getUnwoundScopeOverridePc() {
if (flags_ & HAS_UNWOUND_SCOPE_OVERRIDE_PC)
return unwoundScopeOverridePc();
return nullptr;
}
void setUnwoundScopeOverridePc(jsbytecode *pc) {
flags_ |= HAS_UNWOUND_SCOPE_OVERRIDE_PC;
unwoundScopeOverrideOffset_ = script()->pcToOffset(pc);
}
void trace(JSTracer *trc, JitFrameIterator &frame);
bool isFunctionFrame() const {

View File

@ -670,20 +670,6 @@ ICStubCompiler::leaveStubFrame(MacroAssembler &masm, bool calledIntoIon)
EmitLeaveStubFrame(masm, calledIntoIon);
}
void
ICStubCompiler::leaveStubFrameHead(MacroAssembler &masm, bool calledIntoIon)
{
JS_ASSERT(entersStubFrame_);
EmitLeaveStubFrameHead(masm, calledIntoIon);
}
void
ICStubCompiler::leaveStubFrameCommonTail(MacroAssembler &masm)
{
JS_ASSERT(entersStubFrame_);
EmitLeaveStubFrameCommonTail(masm);
}
void
ICStubCompiler::guardProfilingEnabled(MacroAssembler &masm, Register scratch, Label *skip)
{
@ -6499,27 +6485,17 @@ ICGetProp_Fallback::Compiler::generateStubCode(MacroAssembler &masm)
if (!tailCallVM(DoGetPropFallbackInfo, masm))
return false;
// What follows is bailout for inlined scripted getters or for on-stack
// debug mode recompile. The return address pointed to by the baseline
// stack points here.
//
// What follows is bailout for inlined scripted getters.
// The return address pointed to by the baseline stack points here.
returnOffset_ = masm.currentOffset();
// Even though the fallback frame doesn't enter a stub frame, the CallScripted
// frame that we are emulating does. Again, we lie.
#ifdef DEBUG
entersStubFrame_ = true;
#endif
Label leaveStubCommon;
returnFromStubOffset_ = masm.currentOffset();
leaveStubFrameHead(masm, false);
masm.jump(&leaveStubCommon);
returnFromIonOffset_ = masm.currentOffset();
leaveStubFrameHead(masm, true);
masm.bind(&leaveStubCommon);
leaveStubFrameCommonTail(masm);
leaveStubFrame(masm, true);
// When we get here, BaselineStubReg contains the ICGetProp_Fallback stub,
// which we can't use to enter the TypeMonitor IC, because it's a MonitoredFallbackStub
@ -6534,16 +6510,9 @@ ICGetProp_Fallback::Compiler::generateStubCode(MacroAssembler &masm)
bool
ICGetProp_Fallback::Compiler::postGenerateStubCode(MacroAssembler &masm, Handle<JitCode *> code)
{
JitCompartment *comp = cx->compartment()->jitCompartment();
CodeOffsetLabel fromIon(returnFromIonOffset_);
fromIon.fixup(&masm);
comp->initBaselineGetPropReturnFromIonAddr(code->raw() + fromIon.offset());
CodeOffsetLabel fromVM(returnFromStubOffset_);
fromVM.fixup(&masm);
comp->initBaselineGetPropReturnFromStubAddr(code->raw() + fromVM.offset());
CodeOffsetLabel offset(returnOffset_);
offset.fixup(&masm);
cx->compartment()->jitCompartment()->initBaselineGetPropReturnAddr(code->raw() + offset.offset());
return true;
}
@ -7444,27 +7413,17 @@ ICSetProp_Fallback::Compiler::generateStubCode(MacroAssembler &masm)
if (!tailCallVM(DoSetPropFallbackInfo, masm))
return false;
// What follows is bailout debug mode recompile code for inlined scripted
// getters The return address pointed to by the baseline stack points
// here.
//
// What follows is bailout-only code for inlined script getters.
// The return address pointed to by the baseline stack points here.
returnOffset_ = masm.currentOffset();
// Even though the fallback frame doesn't enter a stub frame, the CallScripted
// frame that we are emulating does. Again, we lie.
#ifdef DEBUG
entersStubFrame_ = true;
#endif
Label leaveStubCommon;
returnFromStubOffset_ = masm.currentOffset();
leaveStubFrameHead(masm, false);
masm.jump(&leaveStubCommon);
returnFromIonOffset_ = masm.currentOffset();
leaveStubFrameHead(masm, true);
masm.bind(&leaveStubCommon);
leaveStubFrameCommonTail(masm);
leaveStubFrame(masm, true);
// Retrieve the stashed initial argument from the caller's frame before returning
EmitUnstowICValues(masm, 1);
@ -7476,16 +7435,9 @@ ICSetProp_Fallback::Compiler::generateStubCode(MacroAssembler &masm)
bool
ICSetProp_Fallback::Compiler::postGenerateStubCode(MacroAssembler &masm, Handle<JitCode *> code)
{
JitCompartment *comp = cx->compartment()->jitCompartment();
CodeOffsetLabel fromIon(returnFromIonOffset_);
fromIon.fixup(&masm);
comp->initBaselineSetPropReturnFromIonAddr(code->raw() + fromIon.offset());
CodeOffsetLabel fromVM(returnFromStubOffset_);
fromVM.fixup(&masm);
comp->initBaselineSetPropReturnFromStubAddr(code->raw() + fromVM.offset());
CodeOffsetLabel offset(returnOffset_);
offset.fixup(&masm);
cx->compartment()->jitCompartment()->initBaselineSetPropReturnAddr(code->raw() + offset.offset());
return true;
}
@ -8506,35 +8458,17 @@ ICCall_Fallback::Compiler::generateStubCode(MacroAssembler &masm)
leaveStubFrame(masm);
EmitReturnFromIC(masm);
// The following asmcode is only used either when an Ion inlined frame
// bails out into baseline jitcode or we need to do on-stack script
// replacement for debug mode recompile.
Label leaveStubCommon;
returnFromStubOffset_ = masm.currentOffset();
// The following asmcode is only used when an Ion inlined frame bails out
// into into baseline jitcode. The return address pushed onto the
// reconstructed baseline stack points here.
returnOffset_ = masm.currentOffset();
// Load passed-in ThisV into R1 just in case it's needed. Need to do this before
// we leave the stub frame since that info will be lost.
// Current stack: [...., ThisV, ActualArgc, CalleeToken, Descriptor ]
masm.loadValue(Address(BaselineStackReg, 3 * sizeof(size_t)), R1);
// Emit the coming-from-VM specific part of the stub-leaving code.
leaveStubFrameHead(masm, /* calledIntoIon = */ false);
// Jump to the common leave stub tail.
masm.jump(&leaveStubCommon);
// For Ion bailouts, the return address pushed onto the reconstructed
// baseline stack points here.
returnFromIonOffset_ = masm.currentOffset();
masm.loadValue(Address(BaselineStackReg, 3 * sizeof(size_t)), R1);
// Emit the coming-from-Ion specific part of the stub-leaving code.
leaveStubFrameHead(masm, /* calledIntoIon = */ true);
// Emit the common stub-leaving tail.
masm.bind(&leaveStubCommon);
leaveStubFrameCommonTail(masm);
leaveStubFrame(masm, true);
// R1 and R0 are taken.
regs = availableGeneralRegs(2);
@ -8569,16 +8503,9 @@ ICCall_Fallback::Compiler::generateStubCode(MacroAssembler &masm)
bool
ICCall_Fallback::Compiler::postGenerateStubCode(MacroAssembler &masm, Handle<JitCode *> code)
{
JitCompartment *comp = cx->compartment()->jitCompartment();
CodeOffsetLabel fromIon(returnFromIonOffset_);
fromIon.fixup(&masm);
comp->initBaselineCallReturnFromIonAddr(code->raw() + fromIon.offset());
CodeOffsetLabel fromVM(returnFromStubOffset_);
fromVM.fixup(&masm);
comp->initBaselineCallReturnFromStubAddr(code->raw() + fromVM.offset());
CodeOffsetLabel offset(returnOffset_);
offset.fixup(&masm);
cx->compartment()->jitCompartment()->initBaselineCallReturnAddr(code->raw() + offset.offset());
return true;
}
@ -9920,11 +9847,47 @@ ICGetElemNativePrototypeCallStub::ICGetElemNativePrototypeCallStub(
holderShape_(holderShape)
{}
/* static */ ICGetElem_NativePrototypeCallNative *
ICGetElem_NativePrototypeCallNative::Clone(JSContext *cx, ICStubSpace *space,
ICStub *firstMonitorStub,
ICGetElem_NativePrototypeCallNative &other)
{
RootedShape shape(cx, other.shape());
RootedPropertyName name(cx, other.name());
RootedFunction getter(cx, other.getter());
RootedObject holder(cx, other.holder());
RootedShape holderShape(cx, other.holderShape());
return New(space, other.jitCode(), firstMonitorStub, shape, name, other.accessType(),
other.needsAtomize(), getter, other.pcOffset_, holder, holderShape);
}
/* static */ ICGetElem_NativePrototypeCallScripted *
ICGetElem_NativePrototypeCallScripted::Clone(JSContext *cx, ICStubSpace *space,
ICStub *firstMonitorStub,
ICGetElem_NativePrototypeCallScripted &other)
{
RootedShape shape(cx, other.shape());
RootedPropertyName name(cx, other.name());
RootedFunction getter(cx, other.getter());
RootedObject holder(cx, other.holder());
RootedShape holderShape(cx, other.holderShape());
return New(space, other.jitCode(), firstMonitorStub, shape, name, other.accessType(),
other.needsAtomize(), getter, other.pcOffset_, holder, holderShape);
}
ICGetElem_Dense::ICGetElem_Dense(JitCode *stubCode, ICStub *firstMonitorStub, HandleShape shape)
: ICMonitoredStub(GetElem_Dense, stubCode, firstMonitorStub),
shape_(shape)
{ }
/* static */ ICGetElem_Dense *
ICGetElem_Dense::Clone(JSContext *cx, ICStubSpace *space, ICStub *firstMonitorStub,
ICGetElem_Dense &other)
{
RootedShape shape(cx, other.shape_);
return New(space, other.jitCode(), firstMonitorStub, shape);
}
ICGetElem_TypedArray::ICGetElem_TypedArray(JitCode *stubCode, HandleShape shape, uint32_t type)
: ICStub(GetElem_TypedArray, stubCode),
shape_(shape)
@ -9933,6 +9896,13 @@ ICGetElem_TypedArray::ICGetElem_TypedArray(JitCode *stubCode, HandleShape shape,
JS_ASSERT(extra_ == type);
}
/* static */ ICGetElem_Arguments *
ICGetElem_Arguments::Clone(JSContext *, ICStubSpace *space, ICStub *firstMonitorStub,
ICGetElem_Arguments &other)
{
return New(space, other.jitCode(), firstMonitorStub, other.which());
}
ICSetElem_Dense::ICSetElem_Dense(JitCode *stubCode, HandleShape shape, HandleTypeObject type)
: ICUpdatedStub(SetElem_Dense, stubCode),
shape_(shape),
@ -10011,6 +9981,14 @@ ICGetPropNativeStub::ICGetPropNativeStub(ICStub::Kind kind, JitCode *stubCode,
offset_(offset)
{ }
/* static */ ICGetProp_Native *
ICGetProp_Native::Clone(JSContext *cx, ICStubSpace *space, ICStub *firstMonitorStub,
ICGetProp_Native &other)
{
RootedShape shape(cx, other.shape());
return New(space, other.jitCode(), firstMonitorStub, shape, other.offset());
}
ICGetProp_NativePrototype::ICGetProp_NativePrototype(JitCode *stubCode, ICStub *firstMonitorStub,
HandleShape shape, uint32_t offset,
HandleObject holder, HandleShape holderShape)
@ -10019,6 +9997,17 @@ ICGetProp_NativePrototype::ICGetProp_NativePrototype(JitCode *stubCode, ICStub *
holderShape_(holderShape)
{ }
/* static */ ICGetProp_NativePrototype *
ICGetProp_NativePrototype::Clone(JSContext *cx, ICStubSpace *space, ICStub *firstMonitorStub,
ICGetProp_NativePrototype &other)
{
RootedShape shape(cx, other.shape());
RootedObject holder(cx, other.holder_);
RootedShape holderShape(cx, other.holderShape_);
return New(space, other.jitCode(), firstMonitorStub, shape, other.offset(),
holder, holderShape);
}
ICGetPropCallGetter::ICGetPropCallGetter(Kind kind, JitCode *stubCode, ICStub *firstMonitorStub,
HandleObject holder, HandleShape holderShape, HandleFunction getter,
uint32_t pcOffset)
@ -10044,6 +10033,41 @@ ICGetPropCallPrototypeGetter::ICGetPropCallPrototypeGetter(Kind kind, JitCode *s
JS_ASSERT(kind == ICStub::GetProp_CallScripted || kind == ICStub::GetProp_CallNativePrototype);
}
/* static */ ICGetProp_CallScripted *
ICGetProp_CallScripted::Clone(JSContext *cx, ICStubSpace *space, ICStub *firstMonitorStub,
ICGetProp_CallScripted &other)
{
RootedShape receiverShape(cx, other.receiverShape_);
RootedObject holder(cx, other.holder_);
RootedShape holderShape(cx, other.holderShape_);
RootedFunction getter(cx, other.getter_);
return New(space, other.jitCode(), firstMonitorStub, receiverShape, holder,
holderShape, getter, other.pcOffset_);
}
/* static */ ICGetProp_CallNative *
ICGetProp_CallNative::Clone(JSContext *cx, ICStubSpace *space, ICStub *firstMonitorStub,
ICGetProp_CallNative &other)
{
RootedObject holder(cx, other.holder_);
RootedShape holderShape(cx, other.holderShape_);
RootedFunction getter(cx, other.getter_);
return New(space, other.jitCode(), firstMonitorStub, holder, holderShape, getter,
other.pcOffset_);
}
/* static */ ICGetProp_CallNativePrototype *
ICGetProp_CallNativePrototype::Clone(JSContext *cx, ICStubSpace *space, ICStub *firstMonitorStub,
ICGetProp_CallNativePrototype &other)
{
RootedShape receiverShape(cx, other.receiverShape_);
RootedObject holder(cx, other.holder_);
RootedShape holderShape(cx, other.holderShape_);
RootedFunction getter(cx, other.getter_);
return New(space, other.jitCode(), firstMonitorStub, receiverShape, holder,
holderShape, getter, other.pcOffset_);
}
ICSetProp_Native::ICSetProp_Native(JitCode *stubCode, HandleTypeObject type, HandleShape shape,
uint32_t offset)
: ICUpdatedStub(SetProp_Native, stubCode),
@ -10120,6 +10144,28 @@ ICSetPropCallSetter::ICSetPropCallSetter(Kind kind, JitCode *stubCode, HandleSha
JS_ASSERT(kind == ICStub::SetProp_CallScripted || kind == ICStub::SetProp_CallNative);
}
/* static */ ICSetProp_CallScripted *
ICSetProp_CallScripted::Clone(JSContext *cx, ICStubSpace *space, ICStub *,
ICSetProp_CallScripted &other)
{
RootedShape shape(cx, other.shape_);
RootedObject holder(cx, other.holder_);
RootedShape holderShape(cx, other.holderShape_);
RootedFunction setter(cx, other.setter_);
return New(space, other.jitCode(), shape, holder, holderShape, setter, other.pcOffset_);
}
/* static */ ICSetProp_CallNative *
ICSetProp_CallNative::Clone(JSContext *cx, ICStubSpace *space, ICStub *,
ICSetProp_CallNative &other)
{
RootedShape shape(cx, other.shape_);
RootedObject holder(cx, other.holder_);
RootedShape holderShape(cx, other.holderShape_);
RootedFunction setter(cx, other.setter_);
return New(space, other.jitCode(), shape, holder, holderShape, setter, other.pcOffset_);
}
ICCall_Scripted::ICCall_Scripted(JitCode *stubCode, ICStub *firstMonitorStub,
HandleScript calleeScript, HandleObject templateObject,
uint32_t pcOffset)
@ -10129,6 +10175,23 @@ ICCall_Scripted::ICCall_Scripted(JitCode *stubCode, ICStub *firstMonitorStub,
pcOffset_(pcOffset)
{ }
/* static */ ICCall_Scripted *
ICCall_Scripted::Clone(JSContext *cx, ICStubSpace *space, ICStub *firstMonitorStub,
ICCall_Scripted &other)
{
RootedScript calleeScript(cx, other.calleeScript_);
RootedObject templateObject(cx, other.templateObject_);
return New(space, other.jitCode(), firstMonitorStub, calleeScript, templateObject,
other.pcOffset_);
}
/* static */ ICCall_AnyScripted *
ICCall_AnyScripted::Clone(JSContext *, ICStubSpace *space, ICStub *firstMonitorStub,
ICCall_AnyScripted &other)
{
return New(space, other.jitCode(), firstMonitorStub, other.pcOffset_);
}
ICCall_Native::ICCall_Native(JitCode *stubCode, ICStub *firstMonitorStub,
HandleFunction callee, HandleObject templateObject,
uint32_t pcOffset)
@ -10146,6 +10209,38 @@ ICCall_Native::ICCall_Native(JitCode *stubCode, ICStub *firstMonitorStub,
#endif
}
/* static */ ICCall_Native *
ICCall_Native::Clone(JSContext *cx, ICStubSpace *space, ICStub *firstMonitorStub,
ICCall_Native &other)
{
RootedFunction callee(cx, other.callee_);
RootedObject templateObject(cx, other.templateObject_);
return New(space, other.jitCode(), firstMonitorStub, callee, templateObject,
other.pcOffset_);
}
/* static */ ICCall_ScriptedApplyArray *
ICCall_ScriptedApplyArray::Clone(JSContext *, ICStubSpace *space, ICStub *firstMonitorStub,
ICCall_ScriptedApplyArray &other)
{
return New(space, other.jitCode(), firstMonitorStub, other.pcOffset_);
}
/* static */ ICCall_ScriptedApplyArguments *
ICCall_ScriptedApplyArguments::Clone(JSContext *, ICStubSpace *space,
ICStub *firstMonitorStub,
ICCall_ScriptedApplyArguments &other)
{
return New(space, other.jitCode(), firstMonitorStub, other.pcOffset_);
}
/* static */ ICCall_ScriptedFunCall *
ICCall_ScriptedFunCall::Clone(JSContext *, ICStubSpace *space, ICStub *firstMonitorStub,
ICCall_ScriptedFunCall &other)
{
return New(space, other.jitCode(), firstMonitorStub, other.pcOffset_);
}
ICGetPropCallDOMProxyNativeStub::ICGetPropCallDOMProxyNativeStub(Kind kind, JitCode *stubCode,
ICStub *firstMonitorStub,
HandleShape shape,
@ -10184,6 +10279,34 @@ ICGetPropCallDOMProxyNativeCompiler::ICGetPropCallDOMProxyNativeCompiler(JSConte
JS_ASSERT(proxy_->handler()->family() == GetDOMProxyHandlerFamily());
}
/* static */ ICGetProp_CallDOMProxyNative *
ICGetProp_CallDOMProxyNative::Clone(JSContext *cx, ICStubSpace *space, ICStub *firstMonitorStub,
ICGetProp_CallDOMProxyNative &other)
{
RootedShape shape(cx, other.shape_);
RootedShape expandoShape(cx, other.expandoShape_);
RootedObject holder(cx, other.holder_);
RootedShape holderShape(cx, other.holderShape_);
RootedFunction getter(cx, other.getter_);
return New(space, other.jitCode(), firstMonitorStub, shape, other.proxyHandler_,
expandoShape, holder, holderShape, getter, other.pcOffset_);
}
/* static */ ICGetProp_CallDOMProxyWithGenerationNative *
ICGetProp_CallDOMProxyWithGenerationNative::Clone(JSContext *cx, ICStubSpace *space,
ICStub *firstMonitorStub,
ICGetProp_CallDOMProxyWithGenerationNative &other)
{
RootedShape shape(cx, other.shape_);
RootedShape expandoShape(cx, other.expandoShape_);
RootedObject holder(cx, other.holder_);
RootedShape holderShape(cx, other.holderShape_);
RootedFunction getter(cx, other.getter_);
return New(space, other.jitCode(), firstMonitorStub, shape, other.proxyHandler_,
other.expandoAndGeneration_, other.generation_,
expandoShape, holder, holderShape, getter, other.pcOffset_);
}
ICGetProp_DOMProxyShadowed::ICGetProp_DOMProxyShadowed(JitCode *stubCode,
ICStub *firstMonitorStub,
HandleShape shape,
@ -10197,6 +10320,16 @@ ICGetProp_DOMProxyShadowed::ICGetProp_DOMProxyShadowed(JitCode *stubCode,
pcOffset_(pcOffset)
{ }
/* static */ ICGetProp_DOMProxyShadowed *
ICGetProp_DOMProxyShadowed::Clone(JSContext *cx, ICStubSpace *space, ICStub *firstMonitorStub,
ICGetProp_DOMProxyShadowed &other)
{
RootedShape shape(cx, other.shape_);
RootedPropertyName name(cx, other.name_);
return New(space, other.jitCode(), firstMonitorStub, shape, other.proxyHandler_,
name, other.pcOffset_);
}
//
// Rest_Fallback
//

View File

@ -1092,8 +1092,6 @@ class ICStubCompiler
// to pc mapping to work.
void enterStubFrame(MacroAssembler &masm, Register scratch);
void leaveStubFrame(MacroAssembler &masm, bool calledIntoIon = false);
void leaveStubFrameHead(MacroAssembler &masm, bool calledIntoIon = false);
void leaveStubFrameCommonTail(MacroAssembler &masm);
// Some stubs need to emit SPS profiler updates. This emits the guarding
// jitcode for those stubs. If profiling is not enabled, jumps to the
@ -1147,11 +1145,15 @@ class ICStubCompiler
public:
virtual ICStub *getStub(ICStubSpace *space) = 0;
ICStubSpace *getStubSpace(JSScript *script) {
static ICStubSpace *StubSpaceForKind(ICStub::Kind kind, JSScript *script) {
if (ICStub::CanMakeCalls(kind))
return script->baselineScript()->fallbackStubSpace();
return script->zone()->jitZone()->optimizedStubSpace();
}
ICStubSpace *getStubSpace(JSScript *script) {
return StubSpaceForKind(kind, script);
}
};
// Base class for stub compilers that can generate multiple stubcodes.
@ -3160,6 +3162,10 @@ class ICGetElem_NativePrototypeCallNative : public ICGetElemNativePrototypeCallS
code, firstMonitorStub, shape, name, acctype, needsAtomize, getter,
pcOffset, holder, holderShape);
}
static ICGetElem_NativePrototypeCallNative *Clone(JSContext *cx, ICStubSpace *space,
ICStub *firstMonitorStub,
ICGetElem_NativePrototypeCallNative &other);
};
class ICGetElem_NativePrototypeCallScripted : public ICGetElemNativePrototypeCallStub
@ -3167,10 +3173,10 @@ class ICGetElem_NativePrototypeCallScripted : public ICGetElemNativePrototypeCal
friend class ICStubSpace;
ICGetElem_NativePrototypeCallScripted(JitCode *stubCode, ICStub *firstMonitorStub,
HandleShape shape, HandlePropertyName name,
AccessType acctype, bool needsAtomize,
HandleFunction getter, uint32_t pcOffset,
HandleObject holder, HandleShape holderShape)
HandleShape shape, HandlePropertyName name,
AccessType acctype, bool needsAtomize,
HandleFunction getter, uint32_t pcOffset,
HandleObject holder, HandleShape holderShape)
: ICGetElemNativePrototypeCallStub(GetElem_NativePrototypeCallScripted,
stubCode, firstMonitorStub, shape, name,
acctype, needsAtomize, getter, pcOffset, holder,
@ -3190,6 +3196,11 @@ class ICGetElem_NativePrototypeCallScripted : public ICGetElemNativePrototypeCal
code, firstMonitorStub, shape, name, acctype, needsAtomize, getter,
pcOffset, holder, holderShape);
}
static ICGetElem_NativePrototypeCallScripted *
Clone(JSContext *cx, ICStubSpace *space,
ICStub *firstMonitorStub,
ICGetElem_NativePrototypeCallScripted &other);
};
// Compiler for GetElem_NativeSlot and GetElem_NativePrototypeSlot stubs.
@ -3339,6 +3350,9 @@ class ICGetElem_Dense : public ICMonitoredStub
return space->allocate<ICGetElem_Dense>(code, firstMonitorStub, shape);
}
static ICGetElem_Dense *Clone(JSContext *cx, ICStubSpace *space, ICStub *firstMonitorStub,
ICGetElem_Dense &other);
static size_t offsetOfShape() {
return offsetof(ICGetElem_Dense, shape_);
}
@ -3449,6 +3463,9 @@ class ICGetElem_Arguments : public ICMonitoredStub
return space->allocate<ICGetElem_Arguments>(code, firstMonitorStub, which);
}
static ICGetElem_Arguments *Clone(JSContext *, ICStubSpace *space, ICStub *firstMonitorStub,
ICGetElem_Arguments &other);
Which which() const {
return static_cast<Which>(extra_);
}
@ -4095,8 +4112,7 @@ class ICGetProp_Fallback : public ICMonitoredFallbackStub
class Compiler : public ICStubCompiler {
protected:
uint32_t returnFromIonOffset_;
uint32_t returnFromStubOffset_;
uint32_t returnOffset_;
bool generateStubCode(MacroAssembler &masm);
bool postGenerateStubCode(MacroAssembler &masm, Handle<JitCode *> code);
@ -4322,6 +4338,9 @@ class ICGetProp_Native : public ICGetPropNativeStub
return nullptr;
return space->allocate<ICGetProp_Native>(code, firstMonitorStub, shape, offset);
}
static ICGetProp_Native *Clone(JSContext *cx, ICStubSpace *space, ICStub *firstMonitorStub,
ICGetProp_Native &other);
};
// Stub for accessing a property on a native object's prototype. Note that due to
@ -4351,6 +4370,10 @@ class ICGetProp_NativePrototype : public ICGetPropNativeStub
holder, holderShape);
}
static ICGetProp_NativePrototype *Clone(JSContext *cx, ICStubSpace *space,
ICStub *firstMonitorStub,
ICGetProp_NativePrototype &other);
public:
HeapPtrObject &holder() {
return holder_;
@ -4554,6 +4577,9 @@ class ICGetProp_CallScripted : public ICGetPropCallPrototypeGetter
pcOffset);
}
static ICGetProp_CallScripted *Clone(JSContext *cx, ICStubSpace *space,
ICStub *firstMonitorStub, ICGetProp_CallScripted &other);
class Compiler : public ICGetPropCallPrototypeGetter::Compiler {
protected:
bool generateStubCode(MacroAssembler &masm);
@ -4600,6 +4626,9 @@ class ICGetProp_CallNative : public ICGetPropCallGetter
getter, pcOffset);
}
static ICGetProp_CallNative *Clone(JSContext *cx, ICStubSpace *space, ICStub *firstMonitorStub,
ICGetProp_CallNative &other);
class Compiler : public ICGetPropCallGetter::Compiler
{
bool inputDefinitelyObject_;
@ -4653,6 +4682,10 @@ class ICGetProp_CallNativePrototype : public ICGetPropCallPrototypeGetter
getter, pcOffset);
}
static ICGetProp_CallNativePrototype *Clone(JSContext *cx, ICStubSpace *space,
ICStub *firstMonitorStub,
ICGetProp_CallNativePrototype &other);
class Compiler : public ICGetPropCallPrototypeGetter::Compiler {
protected:
bool generateStubCode(MacroAssembler &masm);
@ -4771,6 +4804,10 @@ class ICGetProp_CallDOMProxyNative : public ICGetPropCallDOMProxyNativeStub
proxyHandler, expandoShape, holder,
holderShape, getter, pcOffset);
}
static ICGetProp_CallDOMProxyNative *Clone(JSContext *cx, ICStubSpace *space,
ICStub *firstMonitorStub,
ICGetProp_CallDOMProxyNative &other);
};
class ICGetProp_CallDOMProxyWithGenerationNative : public ICGetPropCallDOMProxyNativeStub
@ -4809,6 +4846,10 @@ class ICGetProp_CallDOMProxyWithGenerationNative : public ICGetPropCallDOMProxyN
getter, pcOffset);
}
static ICGetProp_CallDOMProxyWithGenerationNative *
Clone(JSContext *cx, ICStubSpace *space, ICStub *firstMonitorStub,
ICGetProp_CallDOMProxyWithGenerationNative &other);
void *expandoAndGeneration() const {
return expandoAndGeneration_;
}
@ -4873,6 +4914,10 @@ class ICGetProp_DOMProxyShadowed : public ICMonitoredStub
proxyHandler, name, pcOffset);
}
static ICGetProp_DOMProxyShadowed *Clone(JSContext *cx, ICStubSpace *space,
ICStub *firstMonitorStub,
ICGetProp_DOMProxyShadowed &other);
HeapPtrShape &shape() {
return shape_;
}
@ -4989,8 +5034,7 @@ class ICSetProp_Fallback : public ICFallbackStub
class Compiler : public ICStubCompiler {
protected:
uint32_t returnFromIonOffset_;
uint32_t returnFromStubOffset_;
uint32_t returnOffset_;
bool generateStubCode(MacroAssembler &masm);
bool postGenerateStubCode(MacroAssembler &masm, Handle<JitCode *> code);
@ -5274,6 +5318,9 @@ class ICSetProp_CallScripted : public ICSetPropCallSetter
pcOffset);
}
static ICSetProp_CallScripted *Clone(JSContext *cx, ICStubSpace *space, ICStub *,
ICSetProp_CallScripted &other);
class Compiler : public ICSetPropCallSetter::Compiler {
protected:
bool generateStubCode(MacroAssembler &masm);
@ -5318,6 +5365,9 @@ class ICSetProp_CallNative : public ICSetPropCallSetter
pcOffset);
}
static ICSetProp_CallNative *Clone(JSContext *cx, ICStubSpace *space, ICStub *,
ICSetProp_CallNative &other);
class Compiler : public ICSetPropCallSetter::Compiler {
protected:
bool generateStubCode(MacroAssembler &masm);
@ -5414,8 +5464,7 @@ class ICCall_Fallback : public ICMonitoredFallbackStub
class Compiler : public ICCallStubCompiler {
protected:
bool isConstructing_;
uint32_t returnFromIonOffset_;
uint32_t returnFromStubOffset_;
uint32_t returnOffset_;
bool generateStubCode(MacroAssembler &masm);
bool postGenerateStubCode(MacroAssembler &masm, Handle<JitCode *> code);
@ -5459,6 +5508,9 @@ class ICCall_Scripted : public ICMonitoredStub
calleeScript, templateObject, pcOffset);
}
static ICCall_Scripted *Clone(JSContext *cx, ICStubSpace *space, ICStub *firstMonitorStub,
ICCall_Scripted &other);
HeapPtrScript &calleeScript() {
return calleeScript_;
}
@ -5495,6 +5547,9 @@ class ICCall_AnyScripted : public ICMonitoredStub
return space->allocate<ICCall_AnyScripted>(code, firstMonitorStub, pcOffset);
}
static ICCall_AnyScripted *Clone(JSContext *, ICStubSpace *space, ICStub *firstMonitorStub,
ICCall_AnyScripted &other);
static size_t offsetOfPCOffset() {
return offsetof(ICCall_AnyScripted, pcOffset_);
}
@ -5574,6 +5629,9 @@ class ICCall_Native : public ICMonitoredStub
callee, templateObject, pcOffset);
}
static ICCall_Native *Clone(JSContext *cx, ICStubSpace *space, ICStub *firstMonitorStub,
ICCall_Native &other);
HeapPtrFunction &callee() {
return callee_;
}
@ -5653,6 +5711,10 @@ class ICCall_ScriptedApplyArray : public ICMonitoredStub
return space->allocate<ICCall_ScriptedApplyArray>(code, firstMonitorStub, pcOffset);
}
static ICCall_ScriptedApplyArray *Clone(JSContext *, ICStubSpace *space,
ICStub *firstMonitorStub,
ICCall_ScriptedApplyArray &other);
static size_t offsetOfPCOffset() {
return offsetof(ICCall_ScriptedApplyArray, pcOffset_);
}
@ -5703,6 +5765,10 @@ class ICCall_ScriptedApplyArguments : public ICMonitoredStub
return space->allocate<ICCall_ScriptedApplyArguments>(code, firstMonitorStub, pcOffset);
}
static ICCall_ScriptedApplyArguments *Clone(JSContext *, ICStubSpace *space,
ICStub *firstMonitorStub,
ICCall_ScriptedApplyArguments &other);
static size_t offsetOfPCOffset() {
return offsetof(ICCall_ScriptedApplyArguments, pcOffset_);
}
@ -5754,6 +5820,9 @@ class ICCall_ScriptedFunCall : public ICMonitoredStub
return space->allocate<ICCall_ScriptedFunCall>(code, firstMonitorStub, pcOffset);
}
static ICCall_ScriptedFunCall *Clone(JSContext *, ICStubSpace *space, ICStub *firstMonitorStub,
ICCall_ScriptedFunCall &other);
static size_t offsetOfPCOffset() {
return offsetof(ICCall_ScriptedFunCall, pcOffset_);
}

View File

@ -458,12 +458,9 @@ jit::RequestInterruptForIonCode(JSRuntime *rt, JSRuntime::InterruptMode mode)
JitCompartment::JitCompartment()
: stubCodes_(nullptr),
baselineCallReturnFromIonAddr_(nullptr),
baselineGetPropReturnFromIonAddr_(nullptr),
baselineSetPropReturnFromIonAddr_(nullptr),
baselineCallReturnFromStubAddr_(nullptr),
baselineGetPropReturnFromStubAddr_(nullptr),
baselineSetPropReturnFromStubAddr_(nullptr),
baselineCallReturnAddr_(nullptr),
baselineGetPropReturnAddr_(nullptr),
baselineSetPropReturnAddr_(nullptr),
stringConcatStub_(nullptr),
parallelStringConcatStub_(nullptr),
activeParallelEntryScripts_(nullptr)
@ -626,19 +623,13 @@ JitCompartment::sweep(FreeOp *fop)
stubCodes_->sweep(fop);
// If the sweep removed the ICCall_Fallback stub, nullptr the baselineCallReturnAddr_ field.
if (!stubCodes_->lookup(static_cast<uint32_t>(ICStub::Call_Fallback))) {
baselineCallReturnFromIonAddr_ = nullptr;
baselineCallReturnFromStubAddr_ = nullptr;
}
if (!stubCodes_->lookup(static_cast<uint32_t>(ICStub::Call_Fallback)))
baselineCallReturnAddr_ = nullptr;
// Similarly for the ICGetProp_Fallback stub.
if (!stubCodes_->lookup(static_cast<uint32_t>(ICStub::GetProp_Fallback))) {
baselineGetPropReturnFromIonAddr_ = nullptr;
baselineGetPropReturnFromStubAddr_ = nullptr;
}
if (!stubCodes_->lookup(static_cast<uint32_t>(ICStub::SetProp_Fallback))) {
baselineSetPropReturnFromIonAddr_ = nullptr;
baselineSetPropReturnFromStubAddr_ = nullptr;
}
if (!stubCodes_->lookup(static_cast<uint32_t>(ICStub::GetProp_Fallback)))
baselineGetPropReturnAddr_ = nullptr;
if (!stubCodes_->lookup(static_cast<uint32_t>(ICStub::SetProp_Fallback)))
baselineSetPropReturnAddr_ = nullptr;
if (stringConcatStub_ && !IsJitCodeMarked(stringConcatStub_.unsafeGet()))
stringConcatStub_ = nullptr;

View File

@ -227,6 +227,13 @@ JitFrameIterator::baselineScriptAndPc(JSScript **scriptRes, jsbytecode **pcRes)
*scriptRes = script;
uint8_t *retAddr = returnAddressToFp();
// If we have unwound the scope due to exception handling to a different
// pc, the frame should behave as if it were settled on that pc.
if (jsbytecode *overridePc = baselineFrame()->getUnwoundScopeOverridePc()) {
*pcRes = overridePc;
return;
}
// If we are in the middle of a recompile handler, get the real return
// address as stashed in the RecompileInfo.
if (BaselineDebugModeOSRInfo *info = baselineFrame()->getDebugModeOSRInfo())
@ -520,8 +527,19 @@ HandleExceptionBaseline(JSContext *cx, const JitFrameIterator &frame, ResumeFrom
continue;
// Unwind scope chain (pop block objects).
if (cx->isExceptionPending())
UnwindScope(cx, si, script->main() + tn->start);
if (cx->isExceptionPending()) {
jsbytecode *unwindPc = script->main() + tn->start;
UnwindScope(cx, si, unwindPc);
// If we still need to call DebugEpilogue, we must remember the pc
// we unwound the scope chain to, as it will be out of sync with
// the frame's actual pc.
if (tn->kind != JSTRY_CATCH && tn->kind != JSTRY_FINALLY &&
cx->compartment()->debugMode() && !*calledDebugEpilogue)
{
frame.baselineFrame()->setUnwoundScopeOverridePc(unwindPc);
}
}
// Compute base pointer and stack pointer.
rfe->framePointer = frame.fp() - BaselineFrame::FramePointerOffset;

View File

@ -364,16 +364,9 @@ class JitCompartment
// Keep track of offset into various baseline stubs' code at return
// point from called script.
void *baselineCallReturnFromIonAddr_;
void *baselineGetPropReturnFromIonAddr_;
void *baselineSetPropReturnFromIonAddr_;
// Same as above, but is used for return from a baseline stub. This is
// used for recompiles of on-stack baseline scripts (e.g., for debug
// mode).
void *baselineCallReturnFromStubAddr_;
void *baselineGetPropReturnFromStubAddr_;
void *baselineSetPropReturnFromStubAddr_;
void *baselineCallReturnAddr_;
void *baselineGetPropReturnAddr_;
void *baselineSetPropReturnAddr_;
// Stub to concatenate two strings inline. Note that it can't be
// stored in JitRuntime because masm.newGCString bakes in zone-specific
@ -405,54 +398,29 @@ class JitCompartment
ICStubCodeMap::AddPtr p = stubCodes_->lookupForAdd(key);
return stubCodes_->add(p, key, stubCode.get());
}
void initBaselineCallReturnFromIonAddr(void *addr) {
JS_ASSERT(baselineCallReturnFromIonAddr_ == nullptr);
baselineCallReturnFromIonAddr_ = addr;
void initBaselineCallReturnAddr(void *addr) {
JS_ASSERT(baselineCallReturnAddr_ == nullptr);
baselineCallReturnAddr_ = addr;
}
void *baselineCallReturnFromIonAddr() {
JS_ASSERT(baselineCallReturnFromIonAddr_ != nullptr);
return baselineCallReturnFromIonAddr_;
void *baselineCallReturnAddr() {
JS_ASSERT(baselineCallReturnAddr_ != nullptr);
return baselineCallReturnAddr_;
}
void initBaselineGetPropReturnFromIonAddr(void *addr) {
JS_ASSERT(baselineGetPropReturnFromIonAddr_ == nullptr);
baselineGetPropReturnFromIonAddr_ = addr;
void initBaselineGetPropReturnAddr(void *addr) {
JS_ASSERT(baselineGetPropReturnAddr_ == nullptr);
baselineGetPropReturnAddr_ = addr;
}
void *baselineGetPropReturnFromIonAddr() {
JS_ASSERT(baselineGetPropReturnFromIonAddr_ != nullptr);
return baselineGetPropReturnFromIonAddr_;
void *baselineGetPropReturnAddr() {
JS_ASSERT(baselineGetPropReturnAddr_ != nullptr);
return baselineGetPropReturnAddr_;
}
void initBaselineSetPropReturnFromIonAddr(void *addr) {
JS_ASSERT(baselineSetPropReturnFromIonAddr_ == nullptr);
baselineSetPropReturnFromIonAddr_ = addr;
void initBaselineSetPropReturnAddr(void *addr) {
JS_ASSERT(baselineSetPropReturnAddr_ == nullptr);
baselineSetPropReturnAddr_ = addr;
}
void *baselineSetPropReturnFromIonAddr() {
JS_ASSERT(baselineSetPropReturnFromIonAddr_ != nullptr);
return baselineSetPropReturnFromIonAddr_;
}
void initBaselineCallReturnFromStubAddr(void *addr) {
MOZ_ASSERT(baselineCallReturnFromStubAddr_ == nullptr);
baselineCallReturnFromStubAddr_ = addr;;
}
void *baselineCallReturnFromStubAddr() {
JS_ASSERT(baselineCallReturnFromStubAddr_ != nullptr);
return baselineCallReturnFromStubAddr_;
}
void initBaselineGetPropReturnFromStubAddr(void *addr) {
JS_ASSERT(baselineGetPropReturnFromStubAddr_ == nullptr);
baselineGetPropReturnFromStubAddr_ = addr;
}
void *baselineGetPropReturnFromStubAddr() {
JS_ASSERT(baselineGetPropReturnFromStubAddr_ != nullptr);
return baselineGetPropReturnFromStubAddr_;
}
void initBaselineSetPropReturnFromStubAddr(void *addr) {
JS_ASSERT(baselineSetPropReturnFromStubAddr_ == nullptr);
baselineSetPropReturnFromStubAddr_ = addr;
}
void *baselineSetPropReturnFromStubAddr() {
JS_ASSERT(baselineSetPropReturnFromStubAddr_ != nullptr);
return baselineSetPropReturnFromStubAddr_;
void *baselineSetPropReturnAddr() {
JS_ASSERT(baselineSetPropReturnAddr_ != nullptr);
return baselineSetPropReturnAddr_;
}
bool notifyOfActiveParallelEntryScript(JSContext *cx, HandleScript script);

View File

@ -1903,7 +1903,7 @@ IonBuilder::inlineAssertFloat32(CallInfo &callInfo)
JS_ASSERT(secondArg->type() == MIRType_Boolean);
JS_ASSERT(secondArg->isConstant());
bool mustBeFloat32 = JSVAL_TO_BOOLEAN(secondArg->toConstant()->value());
bool mustBeFloat32 = secondArg->toConstant()->value().toBoolean();
current->add(MAssertFloat32::New(alloc(), callInfo.getArg(0), mustBeFloat32));
MConstant *undefined = MConstant::New(alloc(), UndefinedValue());

View File

@ -777,7 +777,9 @@ DebugEpilogue(JSContext *cx, BaselineFrame *frame, jsbytecode *pc, bool ok)
{
// Unwind scope chain to stack depth 0.
ScopeIter si(frame, pc, cx);
UnwindScope(cx, si, frame->script()->main());
jsbytecode *unwindPc = frame->script()->main();
UnwindScope(cx, si, unwindPc);
frame->setUnwoundScopeOverridePc(unwindPc);
// If ScriptDebugEpilogue returns |true| we have to return the frame's
// return value. If it returns |false|, the debugger threw an exception.

View File

@ -160,7 +160,7 @@ EmitEnterStubFrame(MacroAssembler &masm, Register scratch)
}
inline void
EmitLeaveStubFrameHead(MacroAssembler &masm, bool calledIntoIon = false)
EmitLeaveStubFrame(MacroAssembler &masm, bool calledIntoIon = false)
{
// Ion frames do not save and restore the frame pointer. If we called
// into Ion, we have to restore the stack pointer from the frame descriptor.
@ -173,11 +173,7 @@ EmitLeaveStubFrameHead(MacroAssembler &masm, bool calledIntoIon = false)
} else {
masm.mov(BaselineFrameReg, BaselineStackReg);
}
}
inline void
EmitLeaveStubFrameCommonTail(MacroAssembler &masm)
{
masm.pop(BaselineFrameReg);
masm.pop(BaselineStubReg);
@ -188,13 +184,6 @@ EmitLeaveStubFrameCommonTail(MacroAssembler &masm)
masm.pop(ScratchRegister);
}
inline void
EmitLeaveStubFrame(MacroAssembler &masm, bool calledIntoIon = false)
{
EmitLeaveStubFrameHead(masm, calledIntoIon);
EmitLeaveStubFrameCommonTail(masm);
}
inline void
EmitStowICValues(MacroAssembler &masm, int values)
{

View File

@ -141,7 +141,7 @@ EmitEnterStubFrame(MacroAssembler &masm, Register)
}
inline void
EmitLeaveStubFrameHead(MacroAssembler &masm, bool calledIntoIon = false)
EmitLeaveStubFrame(MacroAssembler &masm, bool calledIntoIon = false)
{
// Ion frames do not save and restore the frame pointer. If we called
// into Ion, we have to restore the stack pointer from the frame descriptor.
@ -154,11 +154,7 @@ EmitLeaveStubFrameHead(MacroAssembler &masm, bool calledIntoIon = false)
} else {
masm.mov(BaselineFrameReg, BaselineStackReg);
}
}
inline void
EmitLeaveStubFrameCommonTail(MacroAssembler &masm)
{
masm.pop(BaselineFrameReg);
masm.pop(BaselineStubReg);
@ -170,13 +166,6 @@ EmitLeaveStubFrameCommonTail(MacroAssembler &masm)
masm.storePtr(BaselineTailCallReg, Address(BaselineStackReg, 0));
}
inline void
EmitLeaveStubFrame(MacroAssembler &masm, bool calledIntoIon = false)
{
EmitLeaveStubFrameHead(masm, calledIntoIon);
EmitLeaveStubFrameCommonTail(masm);
}
inline void
EmitStowICValues(MacroAssembler &masm, int values)
{

View File

@ -146,7 +146,7 @@ EmitEnterStubFrame(MacroAssembler &masm, Register scratch)
}
inline void
EmitLeaveStubFrameHead(MacroAssembler &masm, bool calledIntoIon = false)
EmitLeaveStubFrame(MacroAssembler &masm, bool calledIntoIon = false)
{
// Ion frames do not save and restore the frame pointer. If we called
// into Ion, we have to restore the stack pointer from the frame descriptor.
@ -160,11 +160,7 @@ EmitLeaveStubFrameHead(MacroAssembler &masm, bool calledIntoIon = false)
} else {
masm.mov(BaselineFrameReg, BaselineStackReg);
}
}
inline void
EmitLeaveStubFrameCommonTail(MacroAssembler &masm)
{
masm.pop(BaselineFrameReg);
masm.pop(BaselineStubReg);
@ -176,13 +172,6 @@ EmitLeaveStubFrameCommonTail(MacroAssembler &masm)
masm.storePtr(BaselineTailCallReg, Address(BaselineStackReg, 0));
}
inline void
EmitLeaveStubFrame(MacroAssembler &masm, bool calledIntoIon = false)
{
EmitLeaveStubFrameHead(masm, calledIntoIon);
EmitLeaveStubFrameCommonTail(masm);
}
inline void
EmitStowICValues(MacroAssembler &masm, int values)
{

View File

@ -53,7 +53,7 @@ BEGIN_TEST(testAddPropertyHook)
obj = JS_NewObject(cx, &AddPropertyClass, JS::NullPtr(), JS::NullPtr());
CHECK(obj);
JS::RootedValue vobj(cx, OBJECT_TO_JSVAL(obj));
JS::RootedObject arrObj(cx, JSVAL_TO_OBJECT(arr));
JS::RootedObject arrObj(cx, arr.toObjectOrNull());
CHECK(JS_DefineElement(cx, arrObj, i, vobj,
JS_PropertyStub, JS_StrictPropertyStub,
JSPROP_ENUMERATE));

View File

@ -83,7 +83,7 @@ ExhaustiveTest(const char funcode[])
EVAL(funcode, &v);
EVAL(CALL_CODES[ArgCount], &v);
Rooted<ArgumentsObject*> argsobj(cx, &JSVAL_TO_OBJECT(v)->as<ArgumentsObject>());
Rooted<ArgumentsObject*> argsobj(cx, &v.toObjectOrNull()->as<ArgumentsObject>());
JS::AutoValueArray<MAX_ELEMS> elems(cx);

Some files were not shown because too many files have changed in this diff Show More