| OLD | NEW |
| 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 8065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8076 result = CompileRun("ext_array[1] = 23;" | 8076 result = CompileRun("ext_array[1] = 23;" |
| 8077 "ext_array.__proto__ = [];" | 8077 "ext_array.__proto__ = [];" |
| 8078 "js_array.__proto__ = ext_array;" | 8078 "js_array.__proto__ = ext_array;" |
| 8079 "js_array.concat(ext_array);"); | 8079 "js_array.concat(ext_array);"); |
| 8080 CHECK_EQ(77, v8::Object::Cast(*result)->Get(v8_str("0"))->Int32Value()); | 8080 CHECK_EQ(77, v8::Object::Cast(*result)->Get(v8_str("0"))->Int32Value()); |
| 8081 CHECK_EQ(23, v8::Object::Cast(*result)->Get(v8_str("1"))->Int32Value()); | 8081 CHECK_EQ(23, v8::Object::Cast(*result)->Get(v8_str("1"))->Int32Value()); |
| 8082 | 8082 |
| 8083 result = CompileRun("ext_array[1] = 23;"); | 8083 result = CompileRun("ext_array[1] = 23;"); |
| 8084 CHECK_EQ(23, result->Int32Value()); | 8084 CHECK_EQ(23, result->Int32Value()); |
| 8085 | 8085 |
| 8086 // Test more complex manipulations which cause eax to contain values | |
| 8087 // that won't be completely overwritten by loads from the arrays. | |
| 8088 // This catches bugs in the instructions used for the KeyedLoadIC | |
| 8089 // for byte and word types. | |
| 8090 { | |
| 8091 const int kXSize = 300; | |
| 8092 const int kYSize = 300; | |
| 8093 const int kLargeElementCount = kXSize * kYSize * 4; | |
| 8094 ElementType* large_array_data = | |
| 8095 static_cast<ElementType*>(malloc(kLargeElementCount * element_size)); | |
| 8096 i::Handle<ExternalArrayClass> large_array = | |
| 8097 i::Handle<ExternalArrayClass>::cast( | |
| 8098 i::Factory::NewExternalArray(kLargeElementCount, | |
| 8099 array_type, | |
| 8100 array_data)); | |
| 8101 v8::Handle<v8::Object> large_obj = v8::Object::New(); | |
| 8102 // Set the elements to be the external array. | |
| 8103 large_obj->SetIndexedPropertiesToExternalArrayData(large_array_data, | |
| 8104 array_type, | |
| 8105 kLargeElementCount); | |
| 8106 context->Global()->Set(v8_str("large_array"), large_obj); | |
| 8107 result = CompileRun("for (var y = 0; y < 300; y++) {" | |
| 8108 " for (var x = 0; x < 300; x++) {" | |
| 8109 " large_array[4 * 300 * y + 4 * x + 0] = 127;" | |
| 8110 " large_array[4 * 300 * y + 4 * x + 1] = 0;" | |
| 8111 " large_array[4 * 300 * y + 4 * x + 2] = 0;" | |
| 8112 " large_array[4 * 300 * y + 4 * x + 3] = 127;" | |
| 8113 " }" | |
| 8114 "}" | |
| 8115 "var failed = false;" | |
| 8116 "var offset = 0;" | |
| 8117 "for (var i = 0; i < 300; i++) {" | |
| 8118 " if (large_array[4 * i] != 127 ||" | |
| 8119 " large_array[4 * i + 1] != 0 ||" | |
| 8120 " large_array[4 * i + 2] != 0 ||" | |
| 8121 " large_array[4 * i + 3] != 127) {" | |
| 8122 " failed = true;" | |
| 8123 " }" | |
| 8124 "}" | |
| 8125 "offset = 150 * 300 * 4;" | |
| 8126 "for (var i = 0; i < 300; i++) {" | |
| 8127 " if (large_array[offset + 4 * i] != 127 ||" | |
| 8128 " large_array[offset + 4 * i + 1] != 0 ||" | |
| 8129 " large_array[offset + 4 * i + 2] != 0 ||" | |
| 8130 " large_array[offset + 4 * i + 3] != 127) {" | |
| 8131 " failed = true;" | |
| 8132 " }" | |
| 8133 "}" | |
| 8134 "offset = 298 * 300 * 4;" | |
| 8135 "for (var i = 0; i < 300; i++) {" | |
| 8136 " if (large_array[offset + 4 * i] != 127 ||" | |
| 8137 " large_array[offset + 4 * i + 1] != 0 ||" | |
| 8138 " large_array[offset + 4 * i + 2] != 0 ||" | |
| 8139 " large_array[offset + 4 * i + 3] != 127) {" | |
| 8140 " failed = true;" | |
| 8141 " }" | |
| 8142 "}" | |
| 8143 "!failed;"); | |
| 8144 CHECK_EQ(true, result->BooleanValue()); | |
| 8145 free(large_array_data); | |
| 8146 } | |
| 8147 | |
| 8148 free(array_data); | 8086 free(array_data); |
| 8149 } | 8087 } |
| 8150 | 8088 |
| 8151 | 8089 |
| 8152 THREADED_TEST(ExternalByteArray) { | 8090 THREADED_TEST(ExternalByteArray) { |
| 8153 ExternalArrayTestHelper<v8::internal::ExternalByteArray, int8_t>( | 8091 ExternalArrayTestHelper<v8::internal::ExternalByteArray, int8_t>( |
| 8154 v8::kExternalByteArray, | 8092 v8::kExternalByteArray, |
| 8155 -128, | 8093 -128, |
| 8156 127); | 8094 127); |
| 8157 } | 8095 } |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8488 " i++;" | 8426 " i++;" |
| 8489 " return s(o);" | 8427 " return s(o);" |
| 8490 " }" | 8428 " }" |
| 8491 " }" | 8429 " }" |
| 8492 "};" | 8430 "};" |
| 8493 "s(o);"); | 8431 "s(o);"); |
| 8494 CHECK(try_catch.HasCaught()); | 8432 CHECK(try_catch.HasCaught()); |
| 8495 v8::String::Utf8Value value(try_catch.Exception()); | 8433 v8::String::Utf8Value value(try_catch.Exception()); |
| 8496 CHECK_EQ(0, strcmp(*value, "Hey!")); | 8434 CHECK_EQ(0, strcmp(*value, "Hey!")); |
| 8497 } | 8435 } |
| OLD | NEW |