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 13813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13824 template <class FixedTypedArrayClass, i::ElementsKind elements_kind, | 13824 template <class FixedTypedArrayClass, i::ElementsKind elements_kind, |
13825 class ElementType> | 13825 class ElementType> |
13826 static void FixedTypedArrayTestHelper(i::ExternalArrayType array_type, | 13826 static void FixedTypedArrayTestHelper(i::ExternalArrayType array_type, |
13827 ElementType low, ElementType high) { | 13827 ElementType low, ElementType high) { |
13828 i::FLAG_allow_natives_syntax = true; | 13828 i::FLAG_allow_natives_syntax = true; |
13829 LocalContext context; | 13829 LocalContext context; |
13830 i::Isolate* isolate = CcTest::i_isolate(); | 13830 i::Isolate* isolate = CcTest::i_isolate(); |
13831 i::Factory* factory = isolate->factory(); | 13831 i::Factory* factory = isolate->factory(); |
13832 v8::HandleScope scope(context->GetIsolate()); | 13832 v8::HandleScope scope(context->GetIsolate()); |
13833 const int kElementCount = 260; | 13833 const int kElementCount = 260; |
13834 i::Handle<FixedTypedArrayClass> fixed_array = | 13834 i::Handle<i::JSTypedArray> jsobj = |
13835 i::Handle<FixedTypedArrayClass>::cast( | 13835 factory->NewJSTypedArray(elements_kind, kElementCount); |
13836 factory->NewFixedTypedArray(kElementCount, array_type)); | 13836 i::Handle<FixedTypedArrayClass> fixed_array( |
| 13837 FixedTypedArrayClass::cast(jsobj->elements())); |
13837 CHECK_EQ(FixedTypedArrayClass::kInstanceType, | 13838 CHECK_EQ(FixedTypedArrayClass::kInstanceType, |
13838 fixed_array->map()->instance_type()); | 13839 fixed_array->map()->instance_type()); |
13839 CHECK_EQ(kElementCount, fixed_array->length()); | 13840 CHECK_EQ(kElementCount, fixed_array->length()); |
13840 CcTest::heap()->CollectAllGarbage(); | 13841 CcTest::heap()->CollectAllGarbage(); |
13841 for (int i = 0; i < kElementCount; i++) { | 13842 for (int i = 0; i < kElementCount; i++) { |
13842 fixed_array->set(i, static_cast<ElementType>(i)); | 13843 fixed_array->set(i, static_cast<ElementType>(i)); |
13843 } | 13844 } |
13844 // Force GC to trigger verification. | 13845 // Force GC to trigger verification. |
13845 CcTest::heap()->CollectAllGarbage(); | 13846 CcTest::heap()->CollectAllGarbage(); |
13846 for (int i = 0; i < kElementCount; i++) { | 13847 for (int i = 0; i < kElementCount; i++) { |
13847 CHECK_EQ(static_cast<int64_t>(static_cast<ElementType>(i)), | 13848 CHECK_EQ(static_cast<int64_t>(static_cast<ElementType>(i)), |
13848 static_cast<int64_t>(fixed_array->get_scalar(i))); | 13849 static_cast<int64_t>(fixed_array->get_scalar(i))); |
13849 } | 13850 } |
13850 v8::Handle<v8::Object> obj = v8::Object::New(CcTest::isolate()); | 13851 v8::Handle<v8::Object> obj = v8::Utils::ToLocal(jsobj); |
13851 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj); | |
13852 i::Handle<i::Map> fixed_array_map = | |
13853 i::JSObject::GetElementsTransitionMap(jsobj, elements_kind); | |
13854 jsobj->set_map(*fixed_array_map); | |
13855 jsobj->set_elements(*fixed_array); | |
13856 | 13852 |
13857 ObjectWithExternalArrayTestHelper<FixedTypedArrayClass, ElementType>( | 13853 ObjectWithExternalArrayTestHelper<FixedTypedArrayClass, ElementType>( |
13858 context.local(), obj, kElementCount, array_type, | 13854 context.local(), obj, kElementCount, array_type, |
13859 static_cast<int64_t>(low), | 13855 static_cast<int64_t>(low), |
13860 static_cast<int64_t>(high)); | 13856 static_cast<int64_t>(high)); |
13861 } | 13857 } |
13862 | 13858 |
13863 | 13859 |
13864 THREADED_TEST(FixedUint8Array) { | 13860 THREADED_TEST(FixedUint8Array) { |
13865 FixedTypedArrayTestHelper<i::FixedUint8Array, i::UINT8_ELEMENTS, uint8_t>( | 13861 FixedTypedArrayTestHelper<i::FixedUint8Array, i::UINT8_ELEMENTS, uint8_t>( |
(...skipping 7211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21077 | 21073 |
21078 { | 21074 { |
21079 v8::HandleScope handle_scope(isolate); | 21075 v8::HandleScope handle_scope(isolate); |
21080 | 21076 |
21081 // Should work | 21077 // Should work |
21082 v8::Local<v8::Object> obj = v8::Object::New(isolate); | 21078 v8::Local<v8::Object> obj = v8::Object::New(isolate); |
21083 | 21079 |
21084 USE(obj); | 21080 USE(obj); |
21085 } | 21081 } |
21086 } | 21082 } |
OLD | NEW |