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 13801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13812 template <class FixedTypedArrayClass, i::ElementsKind elements_kind, | 13812 template <class FixedTypedArrayClass, i::ElementsKind elements_kind, |
13813 class ElementType> | 13813 class ElementType> |
13814 static void FixedTypedArrayTestHelper(i::ExternalArrayType array_type, | 13814 static void FixedTypedArrayTestHelper(i::ExternalArrayType array_type, |
13815 ElementType low, ElementType high) { | 13815 ElementType low, ElementType high) { |
13816 i::FLAG_allow_natives_syntax = true; | 13816 i::FLAG_allow_natives_syntax = true; |
13817 LocalContext context; | 13817 LocalContext context; |
13818 i::Isolate* isolate = CcTest::i_isolate(); | 13818 i::Isolate* isolate = CcTest::i_isolate(); |
13819 i::Factory* factory = isolate->factory(); | 13819 i::Factory* factory = isolate->factory(); |
13820 v8::HandleScope scope(context->GetIsolate()); | 13820 v8::HandleScope scope(context->GetIsolate()); |
13821 const int kElementCount = 260; | 13821 const int kElementCount = 260; |
13822 i::Handle<FixedTypedArrayClass> fixed_array = | 13822 i::Handle<i::JSTypedArray> jsobj = |
13823 i::Handle<FixedTypedArrayClass>::cast( | 13823 factory->NewJSTypedArray(elements_kind, kElementCount); |
13824 factory->NewFixedTypedArray(kElementCount, array_type)); | 13824 i::Handle<FixedTypedArrayClass> fixed_array( |
| 13825 FixedTypedArrayClass::cast(jsobj->elements())); |
13825 CHECK_EQ(FixedTypedArrayClass::kInstanceType, | 13826 CHECK_EQ(FixedTypedArrayClass::kInstanceType, |
13826 fixed_array->map()->instance_type()); | 13827 fixed_array->map()->instance_type()); |
13827 CHECK_EQ(kElementCount, fixed_array->length()); | 13828 CHECK_EQ(kElementCount, fixed_array->length()); |
13828 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 13829 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
13829 for (int i = 0; i < kElementCount; i++) { | 13830 for (int i = 0; i < kElementCount; i++) { |
13830 fixed_array->set(i, static_cast<ElementType>(i)); | 13831 fixed_array->set(i, static_cast<ElementType>(i)); |
13831 } | 13832 } |
13832 // Force GC to trigger verification. | 13833 // Force GC to trigger verification. |
13833 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 13834 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
13834 for (int i = 0; i < kElementCount; i++) { | 13835 for (int i = 0; i < kElementCount; i++) { |
13835 CHECK_EQ(static_cast<int64_t>(static_cast<ElementType>(i)), | 13836 CHECK_EQ(static_cast<int64_t>(static_cast<ElementType>(i)), |
13836 static_cast<int64_t>(fixed_array->get_scalar(i))); | 13837 static_cast<int64_t>(fixed_array->get_scalar(i))); |
13837 } | 13838 } |
13838 v8::Handle<v8::Object> obj = v8::Object::New(CcTest::isolate()); | 13839 v8::Handle<v8::Object> obj = v8::Utils::ToLocal(jsobj); |
13839 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj); | |
13840 i::Handle<i::Map> fixed_array_map = | |
13841 i::JSObject::GetElementsTransitionMap(jsobj, elements_kind); | |
13842 jsobj->set_map(*fixed_array_map); | |
13843 jsobj->set_elements(*fixed_array); | |
13844 | 13840 |
13845 ObjectWithExternalArrayTestHelper<FixedTypedArrayClass, ElementType>( | 13841 ObjectWithExternalArrayTestHelper<FixedTypedArrayClass, ElementType>( |
13846 context.local(), obj, kElementCount, array_type, | 13842 context.local(), obj, kElementCount, array_type, |
13847 static_cast<int64_t>(low), | 13843 static_cast<int64_t>(low), |
13848 static_cast<int64_t>(high)); | 13844 static_cast<int64_t>(high)); |
13849 } | 13845 } |
13850 | 13846 |
13851 | 13847 |
13852 THREADED_TEST(FixedUint8Array) { | 13848 THREADED_TEST(FixedUint8Array) { |
13853 FixedTypedArrayTestHelper<i::FixedUint8Array, i::UINT8_ELEMENTS, uint8_t>( | 13849 FixedTypedArrayTestHelper<i::FixedUint8Array, i::UINT8_ELEMENTS, uint8_t>( |
(...skipping 7165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21019 | 21015 |
21020 { | 21016 { |
21021 v8::HandleScope handle_scope(isolate); | 21017 v8::HandleScope handle_scope(isolate); |
21022 | 21018 |
21023 // Should work | 21019 // Should work |
21024 v8::Local<v8::Object> obj = v8::Object::New(isolate); | 21020 v8::Local<v8::Object> obj = v8::Object::New(isolate); |
21025 | 21021 |
21026 USE(obj); | 21022 USE(obj); |
21027 } | 21023 } |
21028 } | 21024 } |
OLD | NEW |