OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 3542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3553 CHECK_EQ(v8_num(5), result); | 3553 CHECK_EQ(v8_num(5), result); |
3554 result = setter_script->Run(); | 3554 result = setter_script->Run(); |
3555 CHECK_EQ(v8_num(23), result); | 3555 CHECK_EQ(v8_num(23), result); |
3556 result = interceptor_setter_script->Run(); | 3556 result = interceptor_setter_script->Run(); |
3557 CHECK_EQ(v8_num(23), result); | 3557 CHECK_EQ(v8_num(23), result); |
3558 result = interceptor_getter_script->Run(); | 3558 result = interceptor_getter_script->Run(); |
3559 CHECK_EQ(v8_num(625), result); | 3559 CHECK_EQ(v8_num(625), result); |
3560 } | 3560 } |
3561 | 3561 |
3562 | 3562 |
| 3563 static v8::Handle<Value> UnboxedDoubleIndexedPropertyGetter( |
| 3564 uint32_t index, |
| 3565 const AccessorInfo& info) { |
| 3566 ApiTestFuzzer::Fuzz(); |
| 3567 if (index < 25) { |
| 3568 return v8::Handle<Value>(v8_num(index)); |
| 3569 } |
| 3570 return v8::Handle<Value>(); |
| 3571 } |
| 3572 |
| 3573 |
| 3574 static v8::Handle<Value> UnboxedDoubleIndexedPropertySetter( |
| 3575 uint32_t index, |
| 3576 Local<Value> value, |
| 3577 const AccessorInfo& info) { |
| 3578 ApiTestFuzzer::Fuzz(); |
| 3579 if (index < 25) { |
| 3580 return v8::Handle<Value>(v8_num(index)); |
| 3581 } |
| 3582 return v8::Handle<Value>(); |
| 3583 } |
| 3584 |
| 3585 |
| 3586 Handle<v8::Array> UnboxedDoubleIndexedPropertyEnumerator( |
| 3587 const AccessorInfo& info) { |
| 3588 // Force the list of returned keys to be stored in a FastDoubleArray. |
| 3589 Local<Script> indexed_property_names_script = Script::Compile(v8_str( |
| 3590 "keys = new Array(); keys[125000] = 1;" |
| 3591 "for(i = 0; i < 80000; i++) { keys[i] = i; };" |
| 3592 "keys.length = 25; keys;")); |
| 3593 Local<Value> result = indexed_property_names_script->Run(); |
| 3594 return Local<v8::Array>(::v8::Array::Cast(*result)); |
| 3595 } |
| 3596 |
| 3597 |
| 3598 // Make sure that the the interceptor code in the runtime properly handles |
| 3599 // merging property name lists for double-array-backed arrays. |
| 3600 THREADED_TEST(IndexedInterceptorUnboxedDoubleWithIndexedAccessor) { |
| 3601 v8::HandleScope scope; |
| 3602 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 3603 templ->SetIndexedPropertyHandler(UnboxedDoubleIndexedPropertyGetter, |
| 3604 UnboxedDoubleIndexedPropertySetter, |
| 3605 0, |
| 3606 0, |
| 3607 UnboxedDoubleIndexedPropertyEnumerator); |
| 3608 LocalContext context; |
| 3609 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
| 3610 // When obj is created, force it to be Stored in a FastDoubleArray. |
| 3611 Local<Script> create_unboxed_double_script = Script::Compile(v8_str( |
| 3612 "obj[125000] = 1; for(i = 0; i < 80000; i+=2) { obj[i] = i; } " |
| 3613 "key_count = 0; " |
| 3614 "for (x in obj) {key_count++;};" |
| 3615 "obj;")); |
| 3616 Local<Value> result = create_unboxed_double_script->Run(); |
| 3617 CHECK(result->ToObject()->HasRealIndexedProperty(2000)); |
| 3618 Local<Script> key_count_check = Script::Compile(v8_str( |
| 3619 "key_count;")); |
| 3620 result = key_count_check->Run(); |
| 3621 CHECK_EQ(v8_num(40013), result); |
| 3622 } |
| 3623 |
| 3624 |
3563 static v8::Handle<Value> IdentityIndexedPropertyGetter( | 3625 static v8::Handle<Value> IdentityIndexedPropertyGetter( |
3564 uint32_t index, | 3626 uint32_t index, |
3565 const AccessorInfo& info) { | 3627 const AccessorInfo& info) { |
3566 return v8::Integer::NewFromUnsigned(index); | 3628 return v8::Integer::NewFromUnsigned(index); |
3567 } | 3629 } |
3568 | 3630 |
3569 | 3631 |
3570 THREADED_TEST(IndexedInterceptorWithGetOwnPropertyDescriptor) { | 3632 THREADED_TEST(IndexedInterceptorWithGetOwnPropertyDescriptor) { |
3571 v8::HandleScope scope; | 3633 v8::HandleScope scope; |
3572 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 3634 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
(...skipping 11214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14787 } | 14849 } |
14788 | 14850 |
14789 i::Isolate::Current()->heap()->CollectAllGarbage(true); | 14851 i::Isolate::Current()->heap()->CollectAllGarbage(true); |
14790 { i::Object* raw_map_cache = i::Isolate::Current()->context()->map_cache(); | 14852 { i::Object* raw_map_cache = i::Isolate::Current()->context()->map_cache(); |
14791 if (raw_map_cache != i::Isolate::Current()->heap()->undefined_value()) { | 14853 if (raw_map_cache != i::Isolate::Current()->heap()->undefined_value()) { |
14792 i::MapCache* map_cache = i::MapCache::cast(raw_map_cache); | 14854 i::MapCache* map_cache = i::MapCache::cast(raw_map_cache); |
14793 CHECK_GT(elements, map_cache->NumberOfElements()); | 14855 CHECK_GT(elements, map_cache->NumberOfElements()); |
14794 } | 14856 } |
14795 } | 14857 } |
14796 } | 14858 } |
OLD | NEW |