Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
|
Karl Klose
2011/04/12 07:55:40
Please update to 2011.
| |
| 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 258 NULL | 258 NULL |
| 259 }; | 259 }; |
| 260 | 260 |
| 261 uintptr_t stack_limit = ISOLATE->stack_guard()->real_climit(); | 261 uintptr_t stack_limit = ISOLATE->stack_guard()->real_climit(); |
| 262 for (int i = 0; programs[i]; i++) { | 262 for (int i = 0; programs[i]; i++) { |
| 263 const char* program = programs[i]; | 263 const char* program = programs[i]; |
| 264 i::Utf8ToUC16CharacterStream stream( | 264 i::Utf8ToUC16CharacterStream stream( |
| 265 reinterpret_cast<const i::byte*>(program), | 265 reinterpret_cast<const i::byte*>(program), |
| 266 static_cast<unsigned>(strlen(program))); | 266 static_cast<unsigned>(strlen(program))); |
| 267 i::CompleteParserRecorder log; | 267 i::CompleteParserRecorder log; |
| 268 i::V8JavaScriptScanner scanner(ISOLATE->scanner_constants()); | 268 i::V8JavaScriptScanner scanner(ISOLATE->unicode_cache()); |
|
Karl Klose
2011/04/12 07:55:40
You could cache the isolate* here.
Lasse Reichstein
2011/04/12 08:18:47
I've removed the ISOLATE macro everywhere, but jus
| |
| 269 scanner.Initialize(&stream); | 269 scanner.Initialize(&stream); |
| 270 | 270 |
| 271 v8::preparser::PreParser::PreParseResult result = | 271 v8::preparser::PreParser::PreParseResult result = |
| 272 v8::preparser::PreParser::PreParseProgram(&scanner, | 272 v8::preparser::PreParser::PreParseProgram(&scanner, |
| 273 &log, | 273 &log, |
| 274 true, | 274 true, |
| 275 stack_limit); | 275 stack_limit); |
| 276 CHECK_EQ(v8::preparser::PreParser::kPreParseSuccess, result); | 276 CHECK_EQ(v8::preparser::PreParser::kPreParseSuccess, result); |
| 277 i::ScriptDataImpl data(log.ExtractData()); | 277 i::ScriptDataImpl data(log.ExtractData()); |
| 278 CHECK(!data.has_error()); | 278 CHECK(!data.has_error()); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 351 reinterpret_cast<char*>(malloc(kProgramSize + 1))); | 351 reinterpret_cast<char*>(malloc(kProgramSize + 1))); |
| 352 memset(*program, '(', kProgramSize); | 352 memset(*program, '(', kProgramSize); |
| 353 program[kProgramSize] = '\0'; | 353 program[kProgramSize] = '\0'; |
| 354 | 354 |
| 355 uintptr_t stack_limit = ISOLATE->stack_guard()->real_climit(); | 355 uintptr_t stack_limit = ISOLATE->stack_guard()->real_climit(); |
| 356 | 356 |
| 357 i::Utf8ToUC16CharacterStream stream( | 357 i::Utf8ToUC16CharacterStream stream( |
| 358 reinterpret_cast<const i::byte*>(*program), | 358 reinterpret_cast<const i::byte*>(*program), |
| 359 static_cast<unsigned>(kProgramSize)); | 359 static_cast<unsigned>(kProgramSize)); |
| 360 i::CompleteParserRecorder log; | 360 i::CompleteParserRecorder log; |
| 361 i::V8JavaScriptScanner scanner(ISOLATE->scanner_constants()); | 361 i::V8JavaScriptScanner scanner(ISOLATE->unicode_cache()); |
|
Karl Klose
2011/04/12 07:55:40
Ditto.
| |
| 362 scanner.Initialize(&stream); | 362 scanner.Initialize(&stream); |
| 363 | 363 |
| 364 | 364 |
| 365 v8::preparser::PreParser::PreParseResult result = | 365 v8::preparser::PreParser::PreParseResult result = |
| 366 v8::preparser::PreParser::PreParseProgram(&scanner, | 366 v8::preparser::PreParser::PreParseProgram(&scanner, |
| 367 &log, | 367 &log, |
| 368 true, | 368 true, |
| 369 stack_limit); | 369 stack_limit); |
| 370 CHECK_EQ(v8::preparser::PreParser::kPreParseStackOverflow, result); | 370 CHECK_EQ(v8::preparser::PreParser::kPreParseStackOverflow, result); |
| 371 } | 371 } |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 569 CHECK_EQU(i, stream.pos()); | 569 CHECK_EQU(i, stream.pos()); |
| 570 } | 570 } |
| 571 } | 571 } |
| 572 | 572 |
| 573 #undef CHECK_EQU | 573 #undef CHECK_EQU |
| 574 | 574 |
| 575 void TestStreamScanner(i::UC16CharacterStream* stream, | 575 void TestStreamScanner(i::UC16CharacterStream* stream, |
| 576 i::Token::Value* expected_tokens, | 576 i::Token::Value* expected_tokens, |
| 577 int skip_pos = 0, // Zero means not skipping. | 577 int skip_pos = 0, // Zero means not skipping. |
| 578 int skip_to = 0) { | 578 int skip_to = 0) { |
| 579 i::V8JavaScriptScanner scanner(ISOLATE->scanner_constants()); | 579 i::V8JavaScriptScanner scanner(ISOLATE->unicode_cache()); |
| 580 scanner.Initialize(stream); | 580 scanner.Initialize(stream); |
| 581 | 581 |
| 582 int i = 0; | 582 int i = 0; |
| 583 do { | 583 do { |
| 584 i::Token::Value expected = expected_tokens[i]; | 584 i::Token::Value expected = expected_tokens[i]; |
| 585 i::Token::Value actual = scanner.Next(); | 585 i::Token::Value actual = scanner.Next(); |
| 586 CHECK_EQ(i::Token::String(expected), i::Token::String(actual)); | 586 CHECK_EQ(i::Token::String(expected), i::Token::String(actual)); |
| 587 if (scanner.location().end_pos == skip_pos) { | 587 if (scanner.location().end_pos == skip_pos) { |
| 588 scanner.SeekForward(skip_to); | 588 scanner.SeekForward(skip_to); |
| 589 } | 589 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 648 static_cast<unsigned>(strlen(str3))); | 648 static_cast<unsigned>(strlen(str3))); |
| 649 TestStreamScanner(&stream3, expectations3, 1, 1 + i); | 649 TestStreamScanner(&stream3, expectations3, 1, 1 + i); |
| 650 } | 650 } |
| 651 } | 651 } |
| 652 | 652 |
| 653 | 653 |
| 654 void TestScanRegExp(const char* re_source, const char* expected) { | 654 void TestScanRegExp(const char* re_source, const char* expected) { |
| 655 i::Utf8ToUC16CharacterStream stream( | 655 i::Utf8ToUC16CharacterStream stream( |
| 656 reinterpret_cast<const i::byte*>(re_source), | 656 reinterpret_cast<const i::byte*>(re_source), |
| 657 static_cast<unsigned>(strlen(re_source))); | 657 static_cast<unsigned>(strlen(re_source))); |
| 658 i::V8JavaScriptScanner scanner(ISOLATE->scanner_constants()); | 658 i::V8JavaScriptScanner scanner(ISOLATE->unicode_cache()); |
| 659 scanner.Initialize(&stream); | 659 scanner.Initialize(&stream); |
| 660 | 660 |
| 661 i::Token::Value start = scanner.peek(); | 661 i::Token::Value start = scanner.peek(); |
| 662 CHECK(start == i::Token::DIV || start == i::Token::ASSIGN_DIV); | 662 CHECK(start == i::Token::DIV || start == i::Token::ASSIGN_DIV); |
| 663 CHECK(scanner.ScanRegExpPattern(start == i::Token::ASSIGN_DIV)); | 663 CHECK(scanner.ScanRegExpPattern(start == i::Token::ASSIGN_DIV)); |
| 664 scanner.Next(); // Current token is now the regexp literal. | 664 scanner.Next(); // Current token is now the regexp literal. |
| 665 CHECK(scanner.is_literal_ascii()); | 665 CHECK(scanner.is_literal_ascii()); |
| 666 i::Vector<const char> actual = scanner.literal_ascii_string(); | 666 i::Vector<const char> actual = scanner.literal_ascii_string(); |
| 667 for (int i = 0; i < actual.length(); i++) { | 667 for (int i = 0; i < actual.length(); i++) { |
| 668 CHECK_NE('\0', expected[i]); | 668 CHECK_NE('\0', expected[i]); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 697 TestScanRegExp("/[\\u12]/flipperwald", "[\\u12]"); | 697 TestScanRegExp("/[\\u12]/flipperwald", "[\\u12]"); |
| 698 TestScanRegExp("/[\\u123]/flipperwald", "[\\u123]"); | 698 TestScanRegExp("/[\\u123]/flipperwald", "[\\u123]"); |
| 699 // Escaped ']'s wont end the character class. | 699 // Escaped ']'s wont end the character class. |
| 700 TestScanRegExp("/[\\]/]/flipperwald", "[\\]/]"); | 700 TestScanRegExp("/[\\]/]/flipperwald", "[\\]/]"); |
| 701 // Escaped slashes are not terminating. | 701 // Escaped slashes are not terminating. |
| 702 TestScanRegExp("/\\//flipperwald", "\\/"); | 702 TestScanRegExp("/\\//flipperwald", "\\/"); |
| 703 // Starting with '=' works too. | 703 // Starting with '=' works too. |
| 704 TestScanRegExp("/=/", "="); | 704 TestScanRegExp("/=/", "="); |
| 705 TestScanRegExp("/=?/", "=?"); | 705 TestScanRegExp("/=?/", "=?"); |
| 706 } | 706 } |
| OLD | NEW |