OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 13710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13721 template <class FixedTypedArrayClass, i::ElementsKind elements_kind, | 13721 template <class FixedTypedArrayClass, i::ElementsKind elements_kind, |
13722 class ElementType> | 13722 class ElementType> |
13723 static void FixedTypedArrayTestHelper(i::ExternalArrayType array_type, | 13723 static void FixedTypedArrayTestHelper(i::ExternalArrayType array_type, |
13724 ElementType low, ElementType high) { | 13724 ElementType low, ElementType high) { |
13725 i::FLAG_allow_natives_syntax = true; | 13725 i::FLAG_allow_natives_syntax = true; |
13726 LocalContext context; | 13726 LocalContext context; |
13727 i::Isolate* isolate = CcTest::i_isolate(); | 13727 i::Isolate* isolate = CcTest::i_isolate(); |
13728 i::Factory* factory = isolate->factory(); | 13728 i::Factory* factory = isolate->factory(); |
13729 v8::HandleScope scope(context->GetIsolate()); | 13729 v8::HandleScope scope(context->GetIsolate()); |
13730 const int kElementCount = 260; | 13730 const int kElementCount = 260; |
13731 i::Handle<FixedTypedArrayClass> fixed_array = | 13731 i::Handle<i::JSTypedArray> jsobj = |
13732 i::Handle<FixedTypedArrayClass>::cast( | 13732 factory->NewJSTypedArray(elements_kind, kElementCount); |
13733 factory->NewFixedTypedArray(kElementCount, array_type)); | 13733 i::Handle<FixedTypedArrayClass> fixed_array( |
| 13734 FixedTypedArrayClass::cast(jsobj->elements())); |
13734 CHECK_EQ(FixedTypedArrayClass::kInstanceType, | 13735 CHECK_EQ(FixedTypedArrayClass::kInstanceType, |
13735 fixed_array->map()->instance_type()); | 13736 fixed_array->map()->instance_type()); |
13736 CHECK_EQ(kElementCount, fixed_array->length()); | 13737 CHECK_EQ(kElementCount, fixed_array->length()); |
13737 CcTest::heap()->CollectAllGarbage(); | 13738 CcTest::heap()->CollectAllGarbage(); |
13738 for (int i = 0; i < kElementCount; i++) { | 13739 for (int i = 0; i < kElementCount; i++) { |
13739 fixed_array->set(i, static_cast<ElementType>(i)); | 13740 fixed_array->set(i, static_cast<ElementType>(i)); |
13740 } | 13741 } |
13741 // Force GC to trigger verification. | 13742 // Force GC to trigger verification. |
13742 CcTest::heap()->CollectAllGarbage(); | 13743 CcTest::heap()->CollectAllGarbage(); |
13743 for (int i = 0; i < kElementCount; i++) { | 13744 for (int i = 0; i < kElementCount; i++) { |
13744 CHECK_EQ(static_cast<int64_t>(static_cast<ElementType>(i)), | 13745 CHECK_EQ(static_cast<int64_t>(static_cast<ElementType>(i)), |
13745 static_cast<int64_t>(fixed_array->get_scalar(i))); | 13746 static_cast<int64_t>(fixed_array->get_scalar(i))); |
13746 } | 13747 } |
13747 v8::Handle<v8::Object> obj = v8::Object::New(CcTest::isolate()); | 13748 v8::Handle<v8::Object> obj = v8::Utils::ToLocal(jsobj); |
13748 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj); | |
13749 i::Handle<i::Map> fixed_array_map = | |
13750 i::JSObject::GetElementsTransitionMap(jsobj, elements_kind); | |
13751 jsobj->set_map(*fixed_array_map); | |
13752 jsobj->set_elements(*fixed_array); | |
13753 | 13749 |
13754 ObjectWithExternalArrayTestHelper<FixedTypedArrayClass, ElementType>( | 13750 ObjectWithExternalArrayTestHelper<FixedTypedArrayClass, ElementType>( |
13755 context.local(), obj, kElementCount, array_type, | 13751 context.local(), obj, kElementCount, array_type, |
13756 static_cast<int64_t>(low), | 13752 static_cast<int64_t>(low), |
13757 static_cast<int64_t>(high)); | 13753 static_cast<int64_t>(high)); |
13758 } | 13754 } |
13759 | 13755 |
13760 | 13756 |
13761 THREADED_TEST(FixedUint8Array) { | 13757 THREADED_TEST(FixedUint8Array) { |
13762 FixedTypedArrayTestHelper<i::FixedUint8Array, i::UINT8_ELEMENTS, uint8_t>( | 13758 FixedTypedArrayTestHelper<i::FixedUint8Array, i::UINT8_ELEMENTS, uint8_t>( |
(...skipping 7213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20976 | 20972 |
20977 { | 20973 { |
20978 v8::HandleScope handle_scope(isolate); | 20974 v8::HandleScope handle_scope(isolate); |
20979 | 20975 |
20980 // Should work | 20976 // Should work |
20981 v8::Local<v8::Object> obj = v8::Object::New(isolate); | 20977 v8::Local<v8::Object> obj = v8::Object::New(isolate); |
20982 | 20978 |
20983 USE(obj); | 20979 USE(obj); |
20984 } | 20980 } |
20985 } | 20981 } |
OLD | NEW |