Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: test/cctest/test-api.cc

Issue 437052: Fixed incorrect instruction usage in KeyedLoadIC for byte and word... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/x64/ic-x64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2007-2009 the V8 project authors. All rights reserved. 1 // Copyright 2007-2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 8031 matching lines...) Expand 10 before | Expand all | Expand 10 after
8042 result = CompileRun("ext_array[1] = 23;" 8042 result = CompileRun("ext_array[1] = 23;"
8043 "ext_array.__proto__ = [];" 8043 "ext_array.__proto__ = [];"
8044 "js_array.__proto__ = ext_array;" 8044 "js_array.__proto__ = ext_array;"
8045 "js_array.concat(ext_array);"); 8045 "js_array.concat(ext_array);");
8046 CHECK_EQ(77, v8::Object::Cast(*result)->Get(v8_str("0"))->Int32Value()); 8046 CHECK_EQ(77, v8::Object::Cast(*result)->Get(v8_str("0"))->Int32Value());
8047 CHECK_EQ(23, v8::Object::Cast(*result)->Get(v8_str("1"))->Int32Value()); 8047 CHECK_EQ(23, v8::Object::Cast(*result)->Get(v8_str("1"))->Int32Value());
8048 8048
8049 result = CompileRun("ext_array[1] = 23;"); 8049 result = CompileRun("ext_array[1] = 23;");
8050 CHECK_EQ(23, result->Int32Value()); 8050 CHECK_EQ(23, result->Int32Value());
8051 8051
8052 // Test more complex manipulations which cause eax to contain values
8053 // that won't be completely overwritten by loads from the arrays.
8054 // This catches bugs in the instructions used for the KeyedLoadIC
8055 // for byte and word types.
8056 {
8057 const int kXSize = 300;
8058 const int kYSize = 300;
8059 const int kLargeElementCount = kXSize * kYSize * 4;
8060 ElementType* large_array_data =
8061 static_cast<ElementType*>(malloc(kLargeElementCount * element_size));
8062 i::Handle<ExternalArrayClass> large_array =
8063 i::Handle<ExternalArrayClass>::cast(
8064 i::Factory::NewExternalArray(kElementCount, array_type, array_data)) ;
8065 v8::Handle<v8::Object> large_obj = v8::Object::New();
8066 // Set the elements to be the external array.
8067 large_obj->SetIndexedPropertiesToExternalArrayData(large_array_data,
8068 array_type,
8069 kLargeElementCount);
8070 context->Global()->Set(v8_str("large_array"), large_obj);
8071 result = CompileRun("for (var y = 0; y < 300; y++) {"
8072 " for (var x = 0; x < 300; x++) {"
8073 " large_array[4 * 300 * y + 4 * x + 0] = 127;"
8074 " large_array[4 * 300 * y + 4 * x + 1] = 0;"
8075 " large_array[4 * 300 * y + 4 * x + 2] = 0;"
8076 " large_array[4 * 300 * y + 4 * x + 3] = 127;"
8077 " }"
8078 "}"
8079 "var failed = false;"
8080 "var offset = 0;"
8081 "for (var i = 0; i < 300; i++) {"
8082 " if (large_array[4 * i] != 127 ||"
8083 " large_array[4 * i + 1] != 0 ||"
8084 " large_array[4 * i + 2] != 0 ||"
8085 " large_array[4 * i + 3] != 127) {"
8086 " failed = true;"
8087 " }"
8088 "}"
8089 "offset = 150 * 300 * 4;"
8090 "for (var i = 0; i < 300; i++) {"
8091 " if (large_array[offset + 4 * i] != 127 ||"
8092 " large_array[offset + 4 * i + 1] != 0 ||"
8093 " large_array[offset + 4 * i + 2] != 0 ||"
8094 " large_array[offset + 4 * i + 3] != 127) {"
8095 " failed = true;"
8096 " }"
8097 "}"
8098 "offset = 298 * 300 * 4;"
8099 "for (var i = 0; i < 300; i++) {"
8100 " if (large_array[offset + 4 * i] != 127 ||"
8101 " large_array[offset + 4 * i + 1] != 0 ||"
8102 " large_array[offset + 4 * i + 2] != 0 ||"
8103 " large_array[offset + 4 * i + 3] != 127) {"
8104 " failed = true;"
8105 " }"
8106 "}"
8107 "!failed;");
8108 CHECK_EQ(true, result->BooleanValue());
8109 free(large_array_data);
8110 }
8111
8052 free(array_data); 8112 free(array_data);
8053 } 8113 }
8054 8114
8055 8115
8056 THREADED_TEST(ExternalByteArray) { 8116 THREADED_TEST(ExternalByteArray) {
8057 ExternalArrayTestHelper<v8::internal::ExternalByteArray, int8_t>( 8117 ExternalArrayTestHelper<v8::internal::ExternalByteArray, int8_t>(
8058 v8::kExternalByteArray, 8118 v8::kExternalByteArray,
8059 -128, 8119 -128,
8060 127); 8120 127);
8061 } 8121 }
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
8392 " i++;" 8452 " i++;"
8393 " return s(o);" 8453 " return s(o);"
8394 " }" 8454 " }"
8395 " }" 8455 " }"
8396 "};" 8456 "};"
8397 "s(o);"); 8457 "s(o);");
8398 CHECK(try_catch.HasCaught()); 8458 CHECK(try_catch.HasCaught());
8399 v8::String::Utf8Value value(try_catch.Exception()); 8459 v8::String::Utf8Value value(try_catch.Exception());
8400 CHECK_EQ(0, strcmp(*value, "Hey!")); 8460 CHECK_EQ(0, strcmp(*value, "Hey!"));
8401 } 8461 }
OLDNEW
« no previous file with comments | « src/x64/ic-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698