Revision: 2735 Author: [email protected] Date: Thu Aug 20 23:30:59 2009 Log: Fix an ASSERT in the scanner.
The assert when performing a push back on a two byte string was wrong. Added a small regression test. Review URL: http://codereview.chromium.org/173116 http://code.google.com/p/v8/source/detail?r=2735 Modified: /branches/bleeding_edge/src/scanner.cc /branches/bleeding_edge/src/scanner.h /branches/bleeding_edge/test/cctest/test-api.cc ======================================= --- /branches/bleeding_edge/src/scanner.cc Tue Aug 18 00:14:02 2009 +++ /branches/bleeding_edge/src/scanner.cc Thu Aug 20 23:30:59 2009 @@ -183,7 +183,8 @@ void TwoByteStringUTF16Buffer::PushBack(uc32 ch) { pos_--; - ASSERT(pos_ >= 0 && raw_data_[pos_] == ch); + ASSERT(pos_ >= Scanner::kCharacterLookaheadBufferSize); + ASSERT(raw_data_[pos_ - Scanner::kCharacterLookaheadBufferSize] == ch); } ======================================= --- /branches/bleeding_edge/src/scanner.h Tue Aug 18 00:14:02 2009 +++ /branches/bleeding_edge/src/scanner.h Thu Aug 20 23:30:59 2009 @@ -212,6 +212,8 @@ static unibrow::Predicate<unibrow::LineTerminator, 128> kIsLineTerminator; static unibrow::Predicate<unibrow::WhiteSpace, 128> kIsWhiteSpace; + static const int kCharacterLookaheadBufferSize = 1; + private: CharacterStreamUTF16Buffer char_stream_buffer_; TwoByteStringUTF16Buffer two_byte_string_buffer_; @@ -242,8 +244,6 @@ bool has_line_terminator_before_next_; bool is_pre_parsing_; - static const int kCharacterLookaheadBufferSize = 1; - // Literal buffer support void StartLiteral(); void AddChar(uc32 ch); ======================================= --- /branches/bleeding_edge/test/cctest/test-api.cc Thu Aug 20 03:32:11 2009 +++ /branches/bleeding_edge/test/cctest/test-api.cc Thu Aug 20 23:30:59 2009 @@ -7148,6 +7148,30 @@ env->Global()->Get(v8_str("slice_on_cons"))); } } + + +TEST(CompileExternalTwoByteSource) { + v8::HandleScope scope; + LocalContext context; + + // This is a very short list of sources, which currently is to check for a + // regression caused by r2703. + const char* ascii_sources[] = { + "0.5", + "-0.5", // This mainly testes PushBack in the Scanner. + "--0.5", // This mainly testes PushBack in the Scanner. + NULL + }; + + // Compile the sources as external two byte strings. + for (int i = 0; ascii_sources[i] != NULL; i++) { + uint16_t* two_byte_string = AsciiToTwoByteString(ascii_sources[i]); + UC16VectorResource uc16_resource( + i::Vector<const uint16_t>(two_byte_string, strlen(ascii_sources[i]))); + v8::Local<v8::String> source = v8::String::NewExternal(&uc16_resource); + v8::Script::Compile(source); + } +} class RegExpStringModificationTest { --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---
