Bug 844059 - Prevent int-specialized GetElementIC to produce stub for float typed arrays. r=dvander

This commit is contained in:
Nicolas B. Pierron 2013-02-25 15:34:31 -08:00
parent cae1fe3168
commit 94b681eea6
2 changed files with 27 additions and 4 deletions

View File

@ -1618,7 +1618,13 @@ GetElementIC::attachTypedArrayElement(JSContext *cx, IonScript *ion, JSObject *o
MacroAssembler masm;
// The array type is the object within the table of typed array classes.
int arrayType = obj->getClass() - &TypedArray::classes[0];
int arrayType = TypedArray::type(obj);
// The output register is not yet specialized as a float register, the only
// way to accept float typed arrays for now is to return a Value type.
bool floatOutput = arrayType == TypedArray::TYPE_FLOAT32 ||
arrayType == TypedArray::TYPE_FLOAT64;
JS_ASSERT_IF(!output().hasValue(), !floatOutput);
Register tmpReg = output().scratchReg().gpr();
JS_ASSERT(tmpReg != InvalidReg);
@ -1723,9 +1729,14 @@ GetElementIC::update(JSContext *cx, size_t cacheIndex, HandleObject obj,
return false;
attachedStub = true;
} else if (obj->isTypedArray() && idval.isInt32()) {
if (!cache.attachTypedArrayElement(cx, ion, obj, idval))
return false;
attachedStub = true;
int arrayType = TypedArray::type(obj);
bool floatOutput = arrayType == TypedArray::TYPE_FLOAT32 ||
arrayType == TypedArray::TYPE_FLOAT64;
if (!floatOutput || cache.output().hasValue()) {
if (!cache.attachTypedArrayElement(cx, ion, obj, idval))
return false;
attachedStub = true;
}
}
}

View File

@ -0,0 +1,12 @@
function assertArraysFirstEqual(a, b) {
assertEq(a[0], b[0]);
}
function check(b) {
var a = deserialize(serialize(b));
assertArraysFirstEqual(a, b);
}
check(new Int8Array(1));
check(new Float64Array(1));