| 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 21 matching lines...) Expand all Loading... |
| 32 #include "api.h" | 32 #include "api.h" |
| 33 #include "compilation-cache.h" | 33 #include "compilation-cache.h" |
| 34 #include "execution.h" | 34 #include "execution.h" |
| 35 #include "snapshot.h" | 35 #include "snapshot.h" |
| 36 #include "platform.h" | 36 #include "platform.h" |
| 37 #include "utils.h" | 37 #include "utils.h" |
| 38 #include "cctest.h" | 38 #include "cctest.h" |
| 39 #include "parser.h" | 39 #include "parser.h" |
| 40 #include "unicode-inl.h" | 40 #include "unicode-inl.h" |
| 41 | 41 |
| 42 static const bool kLogThreading = true; | 42 static const bool kLogThreading = false; |
| 43 | 43 |
| 44 static bool IsNaN(double x) { | 44 static bool IsNaN(double x) { |
| 45 #ifdef WIN32 | 45 #ifdef WIN32 |
| 46 return _isnan(x); | 46 return _isnan(x); |
| 47 #else | 47 #else |
| 48 return isnan(x); | 48 return isnan(x); |
| 49 #endif | 49 #endif |
| 50 } | 50 } |
| 51 | 51 |
| 52 using ::v8::AccessorInfo; | 52 using ::v8::AccessorInfo; |
| (...skipping 11320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11373 break; | 11373 break; |
| 11374 case v8::kExternalShortArray: | 11374 case v8::kExternalShortArray: |
| 11375 case v8::kExternalUnsignedShortArray: | 11375 case v8::kExternalUnsignedShortArray: |
| 11376 return 2; | 11376 return 2; |
| 11377 break; | 11377 break; |
| 11378 case v8::kExternalIntArray: | 11378 case v8::kExternalIntArray: |
| 11379 case v8::kExternalUnsignedIntArray: | 11379 case v8::kExternalUnsignedIntArray: |
| 11380 case v8::kExternalFloatArray: | 11380 case v8::kExternalFloatArray: |
| 11381 return 4; | 11381 return 4; |
| 11382 break; | 11382 break; |
| 11383 case v8::kExternalDoubleArray: |
| 11384 return 8; |
| 11385 break; |
| 11383 default: | 11386 default: |
| 11384 UNREACHABLE(); | 11387 UNREACHABLE(); |
| 11385 return -1; | 11388 return -1; |
| 11386 } | 11389 } |
| 11387 UNREACHABLE(); | 11390 UNREACHABLE(); |
| 11388 return -1; | 11391 return -1; |
| 11389 } | 11392 } |
| 11390 | 11393 |
| 11391 | 11394 |
| 11392 template <class ExternalArrayClass, class ElementType> | 11395 template <class ExternalArrayClass, class ElementType> |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11562 0, static_cast<int>(jsobj->GetElement(7)->ToObjectChecked()->Number())); | 11565 0, static_cast<int>(jsobj->GetElement(7)->ToObjectChecked()->Number())); |
| 11563 | 11566 |
| 11564 result = CompileRun("for (var i = 0; i < 8; i++) {" | 11567 result = CompileRun("for (var i = 0; i < 8; i++) {" |
| 11565 " ext_array[6] = '2.3';" | 11568 " ext_array[6] = '2.3';" |
| 11566 "}" | 11569 "}" |
| 11567 "ext_array[6];"); | 11570 "ext_array[6];"); |
| 11568 CHECK_EQ(2, result->Int32Value()); | 11571 CHECK_EQ(2, result->Int32Value()); |
| 11569 CHECK_EQ( | 11572 CHECK_EQ( |
| 11570 2, static_cast<int>(jsobj->GetElement(6)->ToObjectChecked()->Number())); | 11573 2, static_cast<int>(jsobj->GetElement(6)->ToObjectChecked()->Number())); |
| 11571 | 11574 |
| 11572 if (array_type != v8::kExternalFloatArray) { | 11575 if (array_type != v8::kExternalFloatArray && |
| 11576 array_type != v8::kExternalDoubleArray) { |
| 11573 // Though the specification doesn't state it, be explicit about | 11577 // Though the specification doesn't state it, be explicit about |
| 11574 // converting NaNs and +/-Infinity to zero. | 11578 // converting NaNs and +/-Infinity to zero. |
| 11575 result = CompileRun("for (var i = 0; i < 8; i++) {" | 11579 result = CompileRun("for (var i = 0; i < 8; i++) {" |
| 11576 " ext_array[i] = 5;" | 11580 " ext_array[i] = 5;" |
| 11577 "}" | 11581 "}" |
| 11578 "for (var i = 0; i < 8; i++) {" | 11582 "for (var i = 0; i < 8; i++) {" |
| 11579 " ext_array[i] = NaN;" | 11583 " ext_array[i] = NaN;" |
| 11580 "}" | 11584 "}" |
| 11581 "ext_array[5];"); | 11585 "ext_array[5];"); |
| 11582 CHECK_EQ(0, result->Int32Value()); | 11586 CHECK_EQ(0, result->Int32Value()); |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11959 | 11963 |
| 11960 | 11964 |
| 11961 THREADED_TEST(ExternalFloatArray) { | 11965 THREADED_TEST(ExternalFloatArray) { |
| 11962 ExternalArrayTestHelper<i::ExternalFloatArray, float>( | 11966 ExternalArrayTestHelper<i::ExternalFloatArray, float>( |
| 11963 v8::kExternalFloatArray, | 11967 v8::kExternalFloatArray, |
| 11964 -500, | 11968 -500, |
| 11965 500); | 11969 500); |
| 11966 } | 11970 } |
| 11967 | 11971 |
| 11968 | 11972 |
| 11973 THREADED_TEST(ExternalDoubleArray) { |
| 11974 ExternalArrayTestHelper<i::ExternalDoubleArray, double>( |
| 11975 v8::kExternalDoubleArray, |
| 11976 -500, |
| 11977 500); |
| 11978 } |
| 11979 |
| 11980 |
| 11969 THREADED_TEST(ExternalArrays) { | 11981 THREADED_TEST(ExternalArrays) { |
| 11970 TestExternalByteArray(); | 11982 TestExternalByteArray(); |
| 11971 TestExternalUnsignedByteArray(); | 11983 TestExternalUnsignedByteArray(); |
| 11972 TestExternalShortArray(); | 11984 TestExternalShortArray(); |
| 11973 TestExternalUnsignedShortArray(); | 11985 TestExternalUnsignedShortArray(); |
| 11974 TestExternalIntArray(); | 11986 TestExternalIntArray(); |
| 11975 TestExternalUnsignedIntArray(); | 11987 TestExternalUnsignedIntArray(); |
| 11976 TestExternalFloatArray(); | 11988 TestExternalFloatArray(); |
| 11977 } | 11989 } |
| 11978 | 11990 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 11996 | 12008 |
| 11997 | 12009 |
| 11998 THREADED_TEST(ExternalArrayInfo) { | 12010 THREADED_TEST(ExternalArrayInfo) { |
| 11999 ExternalArrayInfoTestHelper(v8::kExternalByteArray); | 12011 ExternalArrayInfoTestHelper(v8::kExternalByteArray); |
| 12000 ExternalArrayInfoTestHelper(v8::kExternalUnsignedByteArray); | 12012 ExternalArrayInfoTestHelper(v8::kExternalUnsignedByteArray); |
| 12001 ExternalArrayInfoTestHelper(v8::kExternalShortArray); | 12013 ExternalArrayInfoTestHelper(v8::kExternalShortArray); |
| 12002 ExternalArrayInfoTestHelper(v8::kExternalUnsignedShortArray); | 12014 ExternalArrayInfoTestHelper(v8::kExternalUnsignedShortArray); |
| 12003 ExternalArrayInfoTestHelper(v8::kExternalIntArray); | 12015 ExternalArrayInfoTestHelper(v8::kExternalIntArray); |
| 12004 ExternalArrayInfoTestHelper(v8::kExternalUnsignedIntArray); | 12016 ExternalArrayInfoTestHelper(v8::kExternalUnsignedIntArray); |
| 12005 ExternalArrayInfoTestHelper(v8::kExternalFloatArray); | 12017 ExternalArrayInfoTestHelper(v8::kExternalFloatArray); |
| 12018 ExternalArrayInfoTestHelper(v8::kExternalDoubleArray); |
| 12006 ExternalArrayInfoTestHelper(v8::kExternalPixelArray); | 12019 ExternalArrayInfoTestHelper(v8::kExternalPixelArray); |
| 12007 } | 12020 } |
| 12008 | 12021 |
| 12009 | 12022 |
| 12010 THREADED_TEST(ScriptContextDependence) { | 12023 THREADED_TEST(ScriptContextDependence) { |
| 12011 v8::HandleScope scope; | 12024 v8::HandleScope scope; |
| 12012 LocalContext c1; | 12025 LocalContext c1; |
| 12013 const char *source = "foo"; | 12026 const char *source = "foo"; |
| 12014 v8::Handle<v8::Script> dep = v8::Script::Compile(v8::String::New(source)); | 12027 v8::Handle<v8::Script> dep = v8::Script::Compile(v8::String::New(source)); |
| 12015 v8::Handle<v8::Script> indep = v8::Script::New(v8::String::New(source)); | 12028 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... |
| 13891 CHECK(func2->CreationContext() == context2); | 13904 CHECK(func2->CreationContext() == context2); |
| 13892 CheckContextId(func2, 2); | 13905 CheckContextId(func2, 2); |
| 13893 CHECK(instance2->CreationContext() == context2); | 13906 CHECK(instance2->CreationContext() == context2); |
| 13894 CheckContextId(instance2, 2); | 13907 CheckContextId(instance2, 2); |
| 13895 } | 13908 } |
| 13896 | 13909 |
| 13897 context1.Dispose(); | 13910 context1.Dispose(); |
| 13898 context2.Dispose(); | 13911 context2.Dispose(); |
| 13899 context3.Dispose(); | 13912 context3.Dispose(); |
| 13900 } | 13913 } |
| OLD | NEW |