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 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 | 936 |
937 LocalContext context; | 937 LocalContext context; |
938 v8::HandleScope handle_scope(CcTest::isolate()); | 938 v8::HandleScope handle_scope(CcTest::isolate()); |
939 | 939 |
940 // Make sure we cover all always-flat lengths and at least one above. | 940 // Make sure we cover all always-flat lengths and at least one above. |
941 static const int kMaxLength = 20; | 941 static const int kMaxLength = 20; |
942 CHECK_GT(kMaxLength, i::ConsString::kMinLength); | 942 CHECK_GT(kMaxLength, i::ConsString::kMinLength); |
943 | 943 |
944 // Allocate two JavaScript arrays for holding short strings. | 944 // Allocate two JavaScript arrays for holding short strings. |
945 v8::Handle<v8::Array> ascii_external_strings = | 945 v8::Handle<v8::Array> ascii_external_strings = |
946 v8::Array::New(kMaxLength + 1); | 946 v8::Array::New(CcTest::isolate(), kMaxLength + 1); |
947 v8::Handle<v8::Array> non_ascii_external_strings = | 947 v8::Handle<v8::Array> non_ascii_external_strings = |
948 v8::Array::New(kMaxLength + 1); | 948 v8::Array::New(CcTest::isolate(), kMaxLength + 1); |
949 | 949 |
950 // Generate short ascii and non-ascii external strings. | 950 // Generate short ascii and non-ascii external strings. |
951 for (int i = 0; i <= kMaxLength; i++) { | 951 for (int i = 0; i <= kMaxLength; i++) { |
952 char* ascii = zone.NewArray<char>(i + 1); | 952 char* ascii = zone.NewArray<char>(i + 1); |
953 for (int j = 0; j < i; j++) { | 953 for (int j = 0; j < i; j++) { |
954 ascii[j] = 'a'; | 954 ascii[j] = 'a'; |
955 } | 955 } |
956 // Terminating '\0' is left out on purpose. It is not required for external | 956 // Terminating '\0' is left out on purpose. It is not required for external |
957 // string data. | 957 // string data. |
958 AsciiResource* ascii_resource = | 958 AsciiResource* ascii_resource = |
959 new(&zone) AsciiResource(Vector<const char>(ascii, i)); | 959 new(&zone) AsciiResource(Vector<const char>(ascii, i)); |
960 v8::Local<v8::String> ascii_external_string = | 960 v8::Local<v8::String> ascii_external_string = |
961 v8::String::NewExternal(ascii_resource); | 961 v8::String::NewExternal(CcTest::isolate(), ascii_resource); |
962 | 962 |
963 ascii_external_strings->Set(v8::Integer::New(i), ascii_external_string); | 963 ascii_external_strings->Set(v8::Integer::New(i), ascii_external_string); |
964 uc16* non_ascii = zone.NewArray<uc16>(i + 1); | 964 uc16* non_ascii = zone.NewArray<uc16>(i + 1); |
965 for (int j = 0; j < i; j++) { | 965 for (int j = 0; j < i; j++) { |
966 non_ascii[j] = 0x1234; | 966 non_ascii[j] = 0x1234; |
967 } | 967 } |
968 // Terminating '\0' is left out on purpose. It is not required for external | 968 // Terminating '\0' is left out on purpose. It is not required for external |
969 // string data. | 969 // string data. |
970 Resource* resource = new(&zone) Resource(Vector<const uc16>(non_ascii, i)); | 970 Resource* resource = new(&zone) Resource(Vector<const uc16>(non_ascii, i)); |
971 v8::Local<v8::String> non_ascii_external_string = | 971 v8::Local<v8::String> non_ascii_external_string = |
972 v8::String::NewExternal(resource); | 972 v8::String::NewExternal(CcTest::isolate(), resource); |
973 non_ascii_external_strings->Set(v8::Integer::New(i), | 973 non_ascii_external_strings->Set(v8::Integer::New(i), |
974 non_ascii_external_string); | 974 non_ascii_external_string); |
975 } | 975 } |
976 | 976 |
977 // Add the arrays with the short external strings in the global object. | 977 // Add the arrays with the short external strings in the global object. |
978 v8::Handle<v8::Object> global = context->Global(); | 978 v8::Handle<v8::Object> global = context->Global(); |
979 global->Set(v8_str("external_ascii"), ascii_external_strings); | 979 global->Set(v8_str("external_ascii"), ascii_external_strings); |
980 global->Set(v8_str("external_non_ascii"), non_ascii_external_strings); | 980 global->Set(v8_str("external_non_ascii"), non_ascii_external_strings); |
981 global->Set(v8_str("max_length"), v8::Integer::New(kMaxLength)); | 981 global->Set(v8_str("max_length"), v8::Integer::New(kMaxLength)); |
982 | 982 |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1380 CheckCanonicalEquivalence(c, test); | 1380 CheckCanonicalEquivalence(c, test); |
1381 continue; | 1381 continue; |
1382 } | 1382 } |
1383 if (upper != c && lower != c) { | 1383 if (upper != c && lower != c) { |
1384 CheckCanonicalEquivalence(c, test); | 1384 CheckCanonicalEquivalence(c, test); |
1385 continue; | 1385 continue; |
1386 } | 1386 } |
1387 CHECK_EQ(Min(upper, lower), test); | 1387 CHECK_EQ(Min(upper, lower), test); |
1388 } | 1388 } |
1389 } | 1389 } |
OLD | NEW |