Return the original value when assigning to a pixel array.
After fast-case assignment to a pixel array the original value assigned is now returned. Before the un-tagged smi value was returned causing crashes. BUG=22913 TEST=cctest/test-api/PixelArray Review URL: http://codereview.chromium.org/248033 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2985 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
928bfae405
commit
70821329a5
@ -421,6 +421,7 @@ void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm) {
|
||||
__ sar(ebx, kSmiTagSize); // Untag the index.
|
||||
__ cmp(ebx, FieldOperand(ecx, PixelArray::kLengthOffset));
|
||||
__ j(above_equal, &slow);
|
||||
__ mov(edx, eax); // Save the value.
|
||||
__ sar(eax, kSmiTagSize); // Untag the value.
|
||||
{ // Clamp the value to [0..255].
|
||||
Label done, check_255;
|
||||
@ -436,6 +437,7 @@ void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm) {
|
||||
}
|
||||
__ mov(ecx, FieldOperand(ecx, PixelArray::kExternalPointerOffset));
|
||||
__ mov_b(Operand(ecx, ebx, times_1, 0), eax);
|
||||
__ mov(eax, edx); // Return the original value.
|
||||
__ ret(0);
|
||||
|
||||
// Extra capacity case: Check if there is extra capacity to
|
||||
|
@ -7729,6 +7729,42 @@ THREADED_TEST(PixelArray) {
|
||||
CHECK_EQ(1503, result->Int32Value());
|
||||
result = CompileRun("pixels[1]");
|
||||
CHECK_EQ(1, result->Int32Value());
|
||||
|
||||
result = CompileRun("var sum = 0;"
|
||||
"for (var i = 0; i < 8; i++) {"
|
||||
" sum += pixels[i] = pixels[i] = -i;"
|
||||
"}"
|
||||
"sum;");
|
||||
CHECK_EQ(-28, result->Int32Value());
|
||||
|
||||
result = CompileRun("var sum = 0;"
|
||||
"for (var i = 0; i < 8; i++) {"
|
||||
" sum += pixels[i] = pixels[i] = 0;"
|
||||
"}"
|
||||
"sum;");
|
||||
CHECK_EQ(0, result->Int32Value());
|
||||
|
||||
result = CompileRun("var sum = 0;"
|
||||
"for (var i = 0; i < 8; i++) {"
|
||||
" sum += pixels[i] = pixels[i] = 255;"
|
||||
"}"
|
||||
"sum;");
|
||||
CHECK_EQ(8 * 255, result->Int32Value());
|
||||
|
||||
result = CompileRun("var sum = 0;"
|
||||
"for (var i = 0; i < 8; i++) {"
|
||||
" sum += pixels[i] = pixels[i] = 256 + i;"
|
||||
"}"
|
||||
"sum;");
|
||||
CHECK_EQ(2076, result->Int32Value());
|
||||
|
||||
result = CompileRun("var sum = 0;"
|
||||
"for (var i = 0; i < 8; i++) {"
|
||||
" sum += pixels[i] = pixels[i] = i;"
|
||||
"}"
|
||||
"sum;");
|
||||
CHECK_EQ(28, result->Int32Value());
|
||||
|
||||
result = CompileRun("var sum = 0;"
|
||||
"for (var i = 0; i < 8; i++) {"
|
||||
" sum += pixels[i];"
|
||||
@ -7839,6 +7875,9 @@ THREADED_TEST(PixelArray) {
|
||||
CHECK_EQ(77, v8::Object::Cast(*result)->Get(v8_str("0"))->Int32Value());
|
||||
CHECK_EQ(23, v8::Object::Cast(*result)->Get(v8_str("1"))->Int32Value());
|
||||
|
||||
result = CompileRun("pixels[1] = 23;");
|
||||
CHECK_EQ(23, result->Int32Value());
|
||||
|
||||
free(pixel_data);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user