Uniformly handle 'undefined' store to Float64Array and Float32Array.
Previous behavior diverged in ICs and Crankshaft. When storing to a Float32Array or Float64Array, the ICs treated undefined as zero while Crankshaft treated it as NaN. Now both ICs and Crankshaft treat it as NaN, which is consistent with the WebGL & ECMAScript spec. R=mstarzinger@chromium.org Review URL: https://chromiumcodereview.appspot.com/9402008 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10714 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
bc7e01534d
commit
bd79e299e5
@ -11757,7 +11757,7 @@ MaybeObject* ExternalUnsignedIntArray::SetValue(uint32_t index, Object* value) {
|
||||
|
||||
|
||||
MaybeObject* ExternalFloatArray::SetValue(uint32_t index, Object* value) {
|
||||
float cast_value = 0;
|
||||
float cast_value = OS::nan_value();
|
||||
Heap* heap = GetHeap();
|
||||
if (index < static_cast<uint32_t>(length())) {
|
||||
if (value->IsSmi()) {
|
||||
@ -11767,7 +11767,7 @@ MaybeObject* ExternalFloatArray::SetValue(uint32_t index, Object* value) {
|
||||
double double_value = HeapNumber::cast(value)->value();
|
||||
cast_value = static_cast<float>(double_value);
|
||||
} else {
|
||||
// Clamp undefined to zero (default). All other types have been
|
||||
// Clamp undefined to NaN (default). All other types have been
|
||||
// converted to a number type further up in the call chain.
|
||||
ASSERT(value->IsUndefined());
|
||||
}
|
||||
@ -11778,7 +11778,7 @@ MaybeObject* ExternalFloatArray::SetValue(uint32_t index, Object* value) {
|
||||
|
||||
|
||||
MaybeObject* ExternalDoubleArray::SetValue(uint32_t index, Object* value) {
|
||||
double double_value = 0;
|
||||
double double_value = OS::nan_value();
|
||||
Heap* heap = GetHeap();
|
||||
if (index < static_cast<uint32_t>(length())) {
|
||||
if (value->IsSmi()) {
|
||||
@ -11787,7 +11787,7 @@ MaybeObject* ExternalDoubleArray::SetValue(uint32_t index, Object* value) {
|
||||
} else if (value->IsHeapNumber()) {
|
||||
double_value = HeapNumber::cast(value)->value();
|
||||
} else {
|
||||
// Clamp undefined to zero (default). All other types have been
|
||||
// Clamp undefined to NaN (default). All other types have been
|
||||
// converted to a number type further up in the call chain.
|
||||
ASSERT(value->IsUndefined());
|
||||
}
|
||||
|
@ -12902,8 +12902,15 @@ static void ExternalArrayTestHelper(v8::ExternalArrayType array_type,
|
||||
"}"
|
||||
"ext_array[7];");
|
||||
CHECK_EQ(0, result->Int32Value());
|
||||
CHECK_EQ(
|
||||
0, static_cast<int>(jsobj->GetElement(7)->ToObjectChecked()->Number()));
|
||||
if (array_type == kExternalDoubleArray ||
|
||||
array_type == kExternalFloatArray) {
|
||||
CHECK_EQ(
|
||||
static_cast<int>(0x80000000),
|
||||
static_cast<int>(jsobj->GetElement(7)->ToObjectChecked()->Number()));
|
||||
} else {
|
||||
CHECK_EQ(0, static_cast<int>(
|
||||
jsobj->GetElement(7)->ToObjectChecked()->Number()));
|
||||
}
|
||||
|
||||
result = CompileRun("for (var i = 0; i < 8; i++) {"
|
||||
" ext_array[6] = '2.3';"
|
||||
|
@ -317,3 +317,37 @@ for (var t = 0; t < types.length; t++) {
|
||||
%DeoptimizeFunction(array_load_set_smi_check2);
|
||||
gc(); // Makes V8 forget about type information for array_load_set_smi_check.
|
||||
}
|
||||
|
||||
// Check handling of undefined in 32- and 64-bit external float arrays.
|
||||
|
||||
function store_float32_undefined(ext_array) {
|
||||
ext_array[0] = undefined;
|
||||
}
|
||||
|
||||
var float32_array = new Float32Array(1);
|
||||
// Make sure runtime does it right
|
||||
store_float32_undefined(float32_array);
|
||||
assertTrue(isNaN(float32_array[0]));
|
||||
// Make sure the ICs do it right
|
||||
store_float32_undefined(float32_array);
|
||||
assertTrue(isNaN(float32_array[0]));
|
||||
// Make sure that Cranskshft does it right.
|
||||
%OptimizeFunctionOnNextCall(store_float32_undefined);
|
||||
store_float32_undefined(float32_array);
|
||||
assertTrue(isNaN(float32_array[0]));
|
||||
|
||||
function store_float64_undefined(ext_array) {
|
||||
ext_array[0] = undefined;
|
||||
}
|
||||
|
||||
var float64_array = new Float64Array(1);
|
||||
// Make sure runtime does it right
|
||||
store_float64_undefined(float64_array);
|
||||
assertTrue(isNaN(float64_array[0]));
|
||||
// Make sure the ICs do it right
|
||||
store_float64_undefined(float64_array);
|
||||
assertTrue(isNaN(float64_array[0]));
|
||||
// Make sure that Cranskshft does it right.
|
||||
%OptimizeFunctionOnNextCall(store_float64_undefined);
|
||||
store_float64_undefined(float64_array);
|
||||
assertTrue(isNaN(float64_array[0]));
|
||||
|
Loading…
Reference in New Issue
Block a user