| OLD | NEW |
| 1 // Copyright 2007-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2009 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 7011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7022 i::Vector<const i::uc16> data_; | 7022 i::Vector<const i::uc16> data_; |
| 7023 }; | 7023 }; |
| 7024 | 7024 |
| 7025 | 7025 |
| 7026 static void MorphAString(i::String* string, | 7026 static void MorphAString(i::String* string, |
| 7027 AsciiVectorResource* ascii_resource, | 7027 AsciiVectorResource* ascii_resource, |
| 7028 UC16VectorResource* uc16_resource) { | 7028 UC16VectorResource* uc16_resource) { |
| 7029 CHECK(i::StringShape(string).IsExternal()); | 7029 CHECK(i::StringShape(string).IsExternal()); |
| 7030 if (string->IsAsciiRepresentation()) { | 7030 if (string->IsAsciiRepresentation()) { |
| 7031 // Check old map is not symbol or long. | 7031 // Check old map is not symbol or long. |
| 7032 CHECK(string->map() == i::Heap::short_external_ascii_string_map() || | 7032 CHECK(string->map() == i::Heap::external_ascii_string_map()); |
| 7033 string->map() == i::Heap::medium_external_ascii_string_map()); | |
| 7034 // Morph external string to be TwoByte string. | 7033 // Morph external string to be TwoByte string. |
| 7035 if (string->length() <= i::String::kMaxShortSize) { | 7034 string->set_map(i::Heap::external_string_map()); |
| 7036 string->set_map(i::Heap::short_external_string_map()); | |
| 7037 } else { | |
| 7038 string->set_map(i::Heap::medium_external_string_map()); | |
| 7039 } | |
| 7040 i::ExternalTwoByteString* morphed = | 7035 i::ExternalTwoByteString* morphed = |
| 7041 i::ExternalTwoByteString::cast(string); | 7036 i::ExternalTwoByteString::cast(string); |
| 7042 morphed->set_resource(uc16_resource); | 7037 morphed->set_resource(uc16_resource); |
| 7043 } else { | 7038 } else { |
| 7044 // Check old map is not symbol or long. | 7039 // Check old map is not symbol or long. |
| 7045 CHECK(string->map() == i::Heap::short_external_string_map() || | 7040 CHECK(string->map() == i::Heap::external_string_map()); |
| 7046 string->map() == i::Heap::medium_external_string_map()); | |
| 7047 // Morph external string to be ASCII string. | 7041 // Morph external string to be ASCII string. |
| 7048 if (string->length() <= i::String::kMaxShortSize) { | 7042 string->set_map(i::Heap::external_ascii_string_map()); |
| 7049 string->set_map(i::Heap::short_external_ascii_string_map()); | |
| 7050 } else { | |
| 7051 string->set_map(i::Heap::medium_external_ascii_string_map()); | |
| 7052 } | |
| 7053 i::ExternalAsciiString* morphed = | 7043 i::ExternalAsciiString* morphed = |
| 7054 i::ExternalAsciiString::cast(string); | 7044 i::ExternalAsciiString::cast(string); |
| 7055 morphed->set_resource(ascii_resource); | 7045 morphed->set_resource(ascii_resource); |
| 7056 } | 7046 } |
| 7057 } | 7047 } |
| 7058 | 7048 |
| 7059 | 7049 |
| 7060 // Test that we can still flatten a string if the components it is built up | 7050 // Test that we can still flatten a string if the components it is built up |
| 7061 // from have been turned into 16 bit strings in the mean time. | 7051 // from have been turned into 16 bit strings in the mean time. |
| 7062 THREADED_TEST(MorphCompositeStringTest) { | 7052 THREADED_TEST(MorphCompositeStringTest) { |
| (...skipping 1339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8402 " i++;" | 8392 " i++;" |
| 8403 " return s(o);" | 8393 " return s(o);" |
| 8404 " }" | 8394 " }" |
| 8405 " }" | 8395 " }" |
| 8406 "};" | 8396 "};" |
| 8407 "s(o);"); | 8397 "s(o);"); |
| 8408 CHECK(try_catch.HasCaught()); | 8398 CHECK(try_catch.HasCaught()); |
| 8409 v8::String::Utf8Value value(try_catch.Exception()); | 8399 v8::String::Utf8Value value(try_catch.Exception()); |
| 8410 CHECK_EQ(0, strcmp(*value, "Hey!")); | 8400 CHECK_EQ(0, strcmp(*value, "Hey!")); |
| 8411 } | 8401 } |
| OLD | NEW |