| 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 12612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12623 virtual const i::uc16* data() const { return data_.start(); } | 12623 virtual const i::uc16* data() const { return data_.start(); } |
| 12624 private: | 12624 private: |
| 12625 i::Vector<const i::uc16> data_; | 12625 i::Vector<const i::uc16> data_; |
| 12626 }; | 12626 }; |
| 12627 | 12627 |
| 12628 | 12628 |
| 12629 static void MorphAString(i::String* string, | 12629 static void MorphAString(i::String* string, |
| 12630 AsciiVectorResource* ascii_resource, | 12630 AsciiVectorResource* ascii_resource, |
| 12631 UC16VectorResource* uc16_resource) { | 12631 UC16VectorResource* uc16_resource) { |
| 12632 CHECK(i::StringShape(string).IsExternal()); | 12632 CHECK(i::StringShape(string).IsExternal()); |
| 12633 if (string->IsAsciiRepresentation()) { | 12633 if (string->IsOneByteRepresentation()) { |
| 12634 // Check old map is not symbol or long. | 12634 // Check old map is not symbol or long. |
| 12635 CHECK(string->map() == HEAP->external_ascii_string_map()); | 12635 CHECK(string->map() == HEAP->external_ascii_string_map()); |
| 12636 // Morph external string to be TwoByte string. | 12636 // Morph external string to be TwoByte string. |
| 12637 string->set_map(HEAP->external_string_map()); | 12637 string->set_map(HEAP->external_string_map()); |
| 12638 i::ExternalTwoByteString* morphed = | 12638 i::ExternalTwoByteString* morphed = |
| 12639 i::ExternalTwoByteString::cast(string); | 12639 i::ExternalTwoByteString::cast(string); |
| 12640 morphed->set_resource(uc16_resource); | 12640 morphed->set_resource(uc16_resource); |
| 12641 } else { | 12641 } else { |
| 12642 // Check old map is not symbol or long. | 12642 // Check old map is not symbol or long. |
| 12643 CHECK(string->map() == HEAP->external_string_map()); | 12643 CHECK(string->map() == HEAP->external_string_map()); |
| (...skipping 3138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15782 "var str2 = str1 + str1 + str1;" | 15782 "var str2 = str1 + str1 + str1;" |
| 15783 "str2;"; | 15783 "str2;"; |
| 15784 Local<Value> result = CompileRun(init_code); | 15784 Local<Value> result = CompileRun(init_code); |
| 15785 | 15785 |
| 15786 Local<Value> indexof = CompileRun("str2.indexOf('els')"); | 15786 Local<Value> indexof = CompileRun("str2.indexOf('els')"); |
| 15787 Local<Value> lastindexof = CompileRun("str2.lastIndexOf('dab')"); | 15787 Local<Value> lastindexof = CompileRun("str2.lastIndexOf('dab')"); |
| 15788 | 15788 |
| 15789 CHECK(result->IsString()); | 15789 CHECK(result->IsString()); |
| 15790 i::Handle<i::String> string = v8::Utils::OpenHandle(String::Cast(*result)); | 15790 i::Handle<i::String> string = v8::Utils::OpenHandle(String::Cast(*result)); |
| 15791 int length = string->length(); | 15791 int length = string->length(); |
| 15792 CHECK(string->IsAsciiRepresentation()); | 15792 CHECK(string->IsOneByteRepresentation()); |
| 15793 | 15793 |
| 15794 FlattenString(string); | 15794 FlattenString(string); |
| 15795 i::Handle<i::String> flat_string = FlattenGetString(string); | 15795 i::Handle<i::String> flat_string = FlattenGetString(string); |
| 15796 | 15796 |
| 15797 CHECK(string->IsAsciiRepresentation()); | 15797 CHECK(string->IsOneByteRepresentation()); |
| 15798 CHECK(flat_string->IsAsciiRepresentation()); | 15798 CHECK(flat_string->IsOneByteRepresentation()); |
| 15799 | 15799 |
| 15800 // Create external resource. | 15800 // Create external resource. |
| 15801 uint16_t* uc16_buffer = new uint16_t[length + 1]; | 15801 uint16_t* uc16_buffer = new uint16_t[length + 1]; |
| 15802 | 15802 |
| 15803 i::String::WriteToFlat(*flat_string, uc16_buffer, 0, length); | 15803 i::String::WriteToFlat(*flat_string, uc16_buffer, 0, length); |
| 15804 uc16_buffer[length] = 0; | 15804 uc16_buffer[length] = 0; |
| 15805 | 15805 |
| 15806 TestResource resource(uc16_buffer); | 15806 TestResource resource(uc16_buffer); |
| 15807 | 15807 |
| 15808 flat_string->MakeExternal(&resource); | 15808 flat_string->MakeExternal(&resource); |
| 15809 | 15809 |
| 15810 CHECK(flat_string->IsTwoByteRepresentation()); | 15810 CHECK(flat_string->IsTwoByteRepresentation()); |
| 15811 | 15811 |
| 15812 // At this point, we should have a Cons string which is flat and ASCII, | 15812 // At this point, we should have a Cons string which is flat and ASCII, |
| 15813 // with a first half that is a two-byte string (although it only contains | 15813 // with a first half that is a two-byte string (although it only contains |
| 15814 // ASCII characters). This is a valid sequence of steps, and it can happen | 15814 // ASCII characters). This is a valid sequence of steps, and it can happen |
| 15815 // in real pages. | 15815 // in real pages. |
| 15816 | 15816 |
| 15817 CHECK(string->IsAsciiRepresentation()); | 15817 CHECK(string->IsOneByteRepresentation()); |
| 15818 i::ConsString* cons = i::ConsString::cast(*string); | 15818 i::ConsString* cons = i::ConsString::cast(*string); |
| 15819 CHECK_EQ(0, cons->second()->length()); | 15819 CHECK_EQ(0, cons->second()->length()); |
| 15820 CHECK(cons->first()->IsTwoByteRepresentation()); | 15820 CHECK(cons->first()->IsTwoByteRepresentation()); |
| 15821 | 15821 |
| 15822 // Check that some string operations work. | 15822 // Check that some string operations work. |
| 15823 | 15823 |
| 15824 // Atom RegExp. | 15824 // Atom RegExp. |
| 15825 Local<Value> reresult = CompileRun("str2.match(/abel/g).length;"); | 15825 Local<Value> reresult = CompileRun("str2.match(/abel/g).length;"); |
| 15826 CHECK_EQ(6, reresult->Int32Value()); | 15826 CHECK_EQ(6, reresult->Int32Value()); |
| 15827 | 15827 |
| (...skipping 2168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17996 | 17996 |
| 17997 i::Semaphore* sem_; | 17997 i::Semaphore* sem_; |
| 17998 volatile int sem_value_; | 17998 volatile int sem_value_; |
| 17999 }; | 17999 }; |
| 18000 | 18000 |
| 18001 | 18001 |
| 18002 THREADED_TEST(SemaphoreInterruption) { | 18002 THREADED_TEST(SemaphoreInterruption) { |
| 18003 ThreadInterruptTest().RunTest(); | 18003 ThreadInterruptTest().RunTest(); |
| 18004 } | 18004 } |
| 18005 #endif // WIN32 | 18005 #endif // WIN32 |
| OLD | NEW |