Commit 77204cb3 authored by sgjesse@chromium.org's avatar sgjesse@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2735 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent dfcfacf1
......@@ -183,7 +183,8 @@ uc32 TwoByteStringUTF16Buffer::Advance() {
void TwoByteStringUTF16Buffer::PushBack(uc32 ch) {
pos_--;
ASSERT(pos_ >= 0 && raw_data_[pos_] == ch);
ASSERT(pos_ >= Scanner::kCharacterLookaheadBufferSize);
ASSERT(raw_data_[pos_ - Scanner::kCharacterLookaheadBufferSize] == ch);
}
......
......@@ -212,6 +212,8 @@ class Scanner {
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 @@ class Scanner {
bool has_line_terminator_before_next_;
bool is_pre_parsing_;
static const int kCharacterLookaheadBufferSize = 1;
// Literal buffer support
void StartLiteral();
void AddChar(uc32 ch);
......
......@@ -7150,6 +7150,30 @@ THREADED_TEST(MorphCompositeStringTest) {
}
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 {
public:
RegExpStringModificationTest()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment