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 11580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11591 " large_array[offset + 4 * i + 2] != 0 ||" | 11591 " large_array[offset + 4 * i + 2] != 0 ||" |
11592 " large_array[offset + 4 * i + 3] != 127) {" | 11592 " large_array[offset + 4 * i + 3] != 127) {" |
11593 " failed = true;" | 11593 " failed = true;" |
11594 " }" | 11594 " }" |
11595 "}" | 11595 "}" |
11596 "!failed;"); | 11596 "!failed;"); |
11597 CHECK_EQ(true, result->BooleanValue()); | 11597 CHECK_EQ(true, result->BooleanValue()); |
11598 free(large_array_data); | 11598 free(large_array_data); |
11599 } | 11599 } |
11600 | 11600 |
| 11601 // The "" property descriptor is overloaded to store information about |
| 11602 // the external array. Ensure that setting and accessing the "" property |
| 11603 // works (it should overwrite the information cached about the external |
| 11604 // array in the DescriptorArray) in various situations. |
| 11605 result = CompileRun("ext_array[''] = 23; ext_array['']"); |
| 11606 CHECK_EQ(23, result->Int32Value()); |
| 11607 |
| 11608 // Property "" set after the external array is associated with the object. |
| 11609 { |
| 11610 v8::Handle<v8::Object> obj2 = v8::Object::New(); |
| 11611 obj2->Set(v8_str("ee_test_field"), v8::Int32::New(256)); |
| 11612 obj2->Set(v8_str(""), v8::Int32::New(1503)); |
| 11613 // Set the elements to be the external array. |
| 11614 obj2->SetIndexedPropertiesToExternalArrayData(array_data, |
| 11615 array_type, |
| 11616 kElementCount); |
| 11617 context->Global()->Set(v8_str("ext_array"), obj2); |
| 11618 result = CompileRun("ext_array['']"); |
| 11619 CHECK_EQ(1503, result->Int32Value()); |
| 11620 } |
| 11621 |
| 11622 // Property "" set after the external array is associated with the object. |
| 11623 { |
| 11624 v8::Handle<v8::Object> obj2 = v8::Object::New(); |
| 11625 obj2->Set(v8_str("ee_test_field_2"), v8::Int32::New(256)); |
| 11626 // Set the elements to be the external array. |
| 11627 obj2->SetIndexedPropertiesToExternalArrayData(array_data, |
| 11628 array_type, |
| 11629 kElementCount); |
| 11630 obj2->Set(v8_str(""), v8::Int32::New(1503)); |
| 11631 context->Global()->Set(v8_str("ext_array"), obj2); |
| 11632 result = CompileRun("ext_array['']"); |
| 11633 CHECK_EQ(1503, result->Int32Value()); |
| 11634 } |
| 11635 |
| 11636 // Should reuse the map from previous test. |
| 11637 { |
| 11638 v8::Handle<v8::Object> obj2 = v8::Object::New(); |
| 11639 obj2->Set(v8_str("ee_test_field_2"), v8::Int32::New(256)); |
| 11640 // Set the elements to be the external array. Should re-use the map |
| 11641 // from previous test. |
| 11642 obj2->SetIndexedPropertiesToExternalArrayData(array_data, |
| 11643 array_type, |
| 11644 kElementCount); |
| 11645 context->Global()->Set(v8_str("ext_array"), obj2); |
| 11646 result = CompileRun("ext_array['']"); |
| 11647 } |
| 11648 |
| 11649 // Property "" is a constant function that shouldn't not be interfered with |
| 11650 // when an external array is set. |
| 11651 { |
| 11652 v8::Handle<v8::Object> obj2 = v8::Object::New(); |
| 11653 // Start |
| 11654 obj2->Set(v8_str("ee_test_field3"), v8::Int32::New(256)); |
| 11655 |
| 11656 // Add a constant function to an object. |
| 11657 context->Global()->Set(v8_str("ext_array"), obj2); |
| 11658 result = CompileRun("ext_array[''] = function() {return 1503;};" |
| 11659 "ext_array['']();"); |
| 11660 |
| 11661 // Add an external array transition to the same map that |
| 11662 // has the constant transition. |
| 11663 v8::Handle<v8::Object> obj3 = v8::Object::New(); |
| 11664 obj3->Set(v8_str("ee_test_field3"), v8::Int32::New(256)); |
| 11665 obj3->SetIndexedPropertiesToExternalArrayData(array_data, |
| 11666 array_type, |
| 11667 kElementCount); |
| 11668 context->Global()->Set(v8_str("ext_array"), obj3); |
| 11669 } |
| 11670 |
| 11671 // If a external array transition is in the map, it should get clobbered |
| 11672 // by a constant function. |
| 11673 { |
| 11674 // Add an external array transition. |
| 11675 v8::Handle<v8::Object> obj3 = v8::Object::New(); |
| 11676 obj3->Set(v8_str("ee_test_field4"), v8::Int32::New(256)); |
| 11677 obj3->SetIndexedPropertiesToExternalArrayData(array_data, |
| 11678 array_type, |
| 11679 kElementCount); |
| 11680 |
| 11681 // Add a constant function to the same map that just got an external array |
| 11682 // transition. |
| 11683 v8::Handle<v8::Object> obj2 = v8::Object::New(); |
| 11684 obj2->Set(v8_str("ee_test_field4"), v8::Int32::New(256)); |
| 11685 context->Global()->Set(v8_str("ext_array"), obj2); |
| 11686 result = CompileRun("ext_array[''] = function() {return 1503;};" |
| 11687 "ext_array['']();"); |
| 11688 } |
| 11689 |
11601 free(array_data); | 11690 free(array_data); |
11602 } | 11691 } |
11603 | 11692 |
11604 | 11693 |
11605 THREADED_TEST(ExternalByteArray) { | 11694 THREADED_TEST(ExternalByteArray) { |
11606 ExternalArrayTestHelper<i::ExternalByteArray, int8_t>( | 11695 ExternalArrayTestHelper<i::ExternalByteArray, int8_t>( |
11607 v8::kExternalByteArray, | 11696 v8::kExternalByteArray, |
11608 -128, | 11697 -128, |
11609 127); | 11698 127); |
11610 } | 11699 } |
(...skipping 1864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13475 v8::Handle<v8::Function> define_property = | 13564 v8::Handle<v8::Function> define_property = |
13476 CompileRun("(function() {" | 13565 CompileRun("(function() {" |
13477 " Object.defineProperty(" | 13566 " Object.defineProperty(" |
13478 " this," | 13567 " this," |
13479 " 1," | 13568 " 1," |
13480 " { configurable: true, enumerable: true, value: 3 });" | 13569 " { configurable: true, enumerable: true, value: 3 });" |
13481 "})").As<Function>(); | 13570 "})").As<Function>(); |
13482 context->DetachGlobal(); | 13571 context->DetachGlobal(); |
13483 define_property->Call(proxy, 0, NULL); | 13572 define_property->Call(proxy, 0, NULL); |
13484 } | 13573 } |
OLD | NEW |