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 11360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11371 break; | 11371 break; |
11372 case v8::kExternalShortArray: | 11372 case v8::kExternalShortArray: |
11373 case v8::kExternalUnsignedShortArray: | 11373 case v8::kExternalUnsignedShortArray: |
11374 return 2; | 11374 return 2; |
11375 break; | 11375 break; |
11376 case v8::kExternalIntArray: | 11376 case v8::kExternalIntArray: |
11377 case v8::kExternalUnsignedIntArray: | 11377 case v8::kExternalUnsignedIntArray: |
11378 case v8::kExternalFloatArray: | 11378 case v8::kExternalFloatArray: |
11379 return 4; | 11379 return 4; |
11380 break; | 11380 break; |
| 11381 case v8::kExternalDoubleArray: |
| 11382 return 8; |
| 11383 break; |
11381 default: | 11384 default: |
11382 UNREACHABLE(); | 11385 UNREACHABLE(); |
11383 return -1; | 11386 return -1; |
11384 } | 11387 } |
11385 UNREACHABLE(); | 11388 UNREACHABLE(); |
11386 return -1; | 11389 return -1; |
11387 } | 11390 } |
11388 | 11391 |
11389 | 11392 |
11390 template <class ExternalArrayClass, class ElementType> | 11393 template <class ExternalArrayClass, class ElementType> |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11560 0, static_cast<int>(jsobj->GetElement(7)->ToObjectChecked()->Number())); | 11563 0, static_cast<int>(jsobj->GetElement(7)->ToObjectChecked()->Number())); |
11561 | 11564 |
11562 result = CompileRun("for (var i = 0; i < 8; i++) {" | 11565 result = CompileRun("for (var i = 0; i < 8; i++) {" |
11563 " ext_array[6] = '2.3';" | 11566 " ext_array[6] = '2.3';" |
11564 "}" | 11567 "}" |
11565 "ext_array[6];"); | 11568 "ext_array[6];"); |
11566 CHECK_EQ(2, result->Int32Value()); | 11569 CHECK_EQ(2, result->Int32Value()); |
11567 CHECK_EQ( | 11570 CHECK_EQ( |
11568 2, static_cast<int>(jsobj->GetElement(6)->ToObjectChecked()->Number())); | 11571 2, static_cast<int>(jsobj->GetElement(6)->ToObjectChecked()->Number())); |
11569 | 11572 |
11570 if (array_type != v8::kExternalFloatArray) { | 11573 if (array_type != v8::kExternalFloatArray && |
| 11574 array_type != v8::kExternalDoubleArray) { |
11571 // Though the specification doesn't state it, be explicit about | 11575 // Though the specification doesn't state it, be explicit about |
11572 // converting NaNs and +/-Infinity to zero. | 11576 // converting NaNs and +/-Infinity to zero. |
11573 result = CompileRun("for (var i = 0; i < 8; i++) {" | 11577 result = CompileRun("for (var i = 0; i < 8; i++) {" |
11574 " ext_array[i] = 5;" | 11578 " ext_array[i] = 5;" |
11575 "}" | 11579 "}" |
11576 "for (var i = 0; i < 8; i++) {" | 11580 "for (var i = 0; i < 8; i++) {" |
11577 " ext_array[i] = NaN;" | 11581 " ext_array[i] = NaN;" |
11578 "}" | 11582 "}" |
11579 "ext_array[5];"); | 11583 "ext_array[5];"); |
11580 CHECK_EQ(0, result->Int32Value()); | 11584 CHECK_EQ(0, result->Int32Value()); |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11957 | 11961 |
11958 | 11962 |
11959 THREADED_TEST(ExternalFloatArray) { | 11963 THREADED_TEST(ExternalFloatArray) { |
11960 ExternalArrayTestHelper<i::ExternalFloatArray, float>( | 11964 ExternalArrayTestHelper<i::ExternalFloatArray, float>( |
11961 v8::kExternalFloatArray, | 11965 v8::kExternalFloatArray, |
11962 -500, | 11966 -500, |
11963 500); | 11967 500); |
11964 } | 11968 } |
11965 | 11969 |
11966 | 11970 |
| 11971 THREADED_TEST(ExternalDoubleArray) { |
| 11972 ExternalArrayTestHelper<i::ExternalDoubleArray, double>( |
| 11973 v8::kExternalDoubleArray, |
| 11974 -500, |
| 11975 500); |
| 11976 } |
| 11977 |
| 11978 |
11967 THREADED_TEST(ExternalArrays) { | 11979 THREADED_TEST(ExternalArrays) { |
11968 TestExternalByteArray(); | 11980 TestExternalByteArray(); |
11969 TestExternalUnsignedByteArray(); | 11981 TestExternalUnsignedByteArray(); |
11970 TestExternalShortArray(); | 11982 TestExternalShortArray(); |
11971 TestExternalUnsignedShortArray(); | 11983 TestExternalUnsignedShortArray(); |
11972 TestExternalIntArray(); | 11984 TestExternalIntArray(); |
11973 TestExternalUnsignedIntArray(); | 11985 TestExternalUnsignedIntArray(); |
11974 TestExternalFloatArray(); | 11986 TestExternalFloatArray(); |
11975 } | 11987 } |
11976 | 11988 |
(...skipping 17 matching lines...) Expand all Loading... |
11994 | 12006 |
11995 | 12007 |
11996 THREADED_TEST(ExternalArrayInfo) { | 12008 THREADED_TEST(ExternalArrayInfo) { |
11997 ExternalArrayInfoTestHelper(v8::kExternalByteArray); | 12009 ExternalArrayInfoTestHelper(v8::kExternalByteArray); |
11998 ExternalArrayInfoTestHelper(v8::kExternalUnsignedByteArray); | 12010 ExternalArrayInfoTestHelper(v8::kExternalUnsignedByteArray); |
11999 ExternalArrayInfoTestHelper(v8::kExternalShortArray); | 12011 ExternalArrayInfoTestHelper(v8::kExternalShortArray); |
12000 ExternalArrayInfoTestHelper(v8::kExternalUnsignedShortArray); | 12012 ExternalArrayInfoTestHelper(v8::kExternalUnsignedShortArray); |
12001 ExternalArrayInfoTestHelper(v8::kExternalIntArray); | 12013 ExternalArrayInfoTestHelper(v8::kExternalIntArray); |
12002 ExternalArrayInfoTestHelper(v8::kExternalUnsignedIntArray); | 12014 ExternalArrayInfoTestHelper(v8::kExternalUnsignedIntArray); |
12003 ExternalArrayInfoTestHelper(v8::kExternalFloatArray); | 12015 ExternalArrayInfoTestHelper(v8::kExternalFloatArray); |
| 12016 ExternalArrayInfoTestHelper(v8::kExternalDoubleArray); |
12004 ExternalArrayInfoTestHelper(v8::kExternalPixelArray); | 12017 ExternalArrayInfoTestHelper(v8::kExternalPixelArray); |
12005 } | 12018 } |
12006 | 12019 |
12007 | 12020 |
12008 THREADED_TEST(ScriptContextDependence) { | 12021 THREADED_TEST(ScriptContextDependence) { |
12009 v8::HandleScope scope; | 12022 v8::HandleScope scope; |
12010 LocalContext c1; | 12023 LocalContext c1; |
12011 const char *source = "foo"; | 12024 const char *source = "foo"; |
12012 v8::Handle<v8::Script> dep = v8::Script::Compile(v8::String::New(source)); | 12025 v8::Handle<v8::Script> dep = v8::Script::Compile(v8::String::New(source)); |
12013 v8::Handle<v8::Script> indep = v8::Script::New(v8::String::New(source)); | 12026 v8::Handle<v8::Script> indep = v8::Script::New(v8::String::New(source)); |
(...skipping 1875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13889 CHECK(func2->CreationContext() == context2); | 13902 CHECK(func2->CreationContext() == context2); |
13890 CheckContextId(func2, 2); | 13903 CheckContextId(func2, 2); |
13891 CHECK(instance2->CreationContext() == context2); | 13904 CHECK(instance2->CreationContext() == context2); |
13892 CheckContextId(instance2, 2); | 13905 CheckContextId(instance2, 2); |
13893 } | 13906 } |
13894 | 13907 |
13895 context1.Dispose(); | 13908 context1.Dispose(); |
13896 context2.Dispose(); | 13909 context2.Dispose(); |
13897 context3.Dispose(); | 13910 context3.Dispose(); |
13898 } | 13911 } |
OLD | NEW |