| 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); | 257 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); |
| 258 for (int i = 0; programs[i]; i++) { | 258 for (int i = 0; programs[i]; i++) { |
| 259 const char* program = programs[i]; | 259 const char* program = programs[i]; |
| 260 i::Utf8ToUtf16CharacterStream stream( | 260 i::Utf8ToUtf16CharacterStream stream( |
| 261 reinterpret_cast<const i::byte*>(program), | 261 reinterpret_cast<const i::byte*>(program), |
| 262 static_cast<unsigned>(strlen(program))); | 262 static_cast<unsigned>(strlen(program))); |
| 263 i::CompleteParserRecorder log; | 263 i::CompleteParserRecorder log; |
| 264 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); | 264 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); |
| 265 scanner.Initialize(&stream); | 265 scanner.Initialize(&stream); |
| 266 | 266 |
| 267 v8::preparser::PreParser preparser(&scanner, &log, stack_limit); | 267 i::PreParser preparser(&scanner, &log, stack_limit); |
| 268 preparser.set_allow_lazy(true); | 268 preparser.set_allow_lazy(true); |
| 269 preparser.set_allow_natives_syntax(true); | 269 preparser.set_allow_natives_syntax(true); |
| 270 v8::preparser::PreParser::PreParseResult result = | 270 i::PreParser::PreParseResult result = preparser.PreParseProgram(); |
| 271 preparser.PreParseProgram(); | 271 CHECK_EQ(i::PreParser::kPreParseSuccess, result); |
| 272 CHECK_EQ(v8::preparser::PreParser::kPreParseSuccess, result); | |
| 273 i::ScriptDataImpl data(log.ExtractData()); | 272 i::ScriptDataImpl data(log.ExtractData()); |
| 274 CHECK(!data.has_error()); | 273 CHECK(!data.has_error()); |
| 275 } | 274 } |
| 276 } | 275 } |
| 277 | 276 |
| 278 | 277 |
| 279 TEST(StandAlonePreParserNoNatives) { | 278 TEST(StandAlonePreParserNoNatives) { |
| 280 v8::V8::Initialize(); | 279 v8::V8::Initialize(); |
| 281 | 280 |
| 282 int marker; | 281 int marker; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 293 for (int i = 0; programs[i]; i++) { | 292 for (int i = 0; programs[i]; i++) { |
| 294 const char* program = programs[i]; | 293 const char* program = programs[i]; |
| 295 i::Utf8ToUtf16CharacterStream stream( | 294 i::Utf8ToUtf16CharacterStream stream( |
| 296 reinterpret_cast<const i::byte*>(program), | 295 reinterpret_cast<const i::byte*>(program), |
| 297 static_cast<unsigned>(strlen(program))); | 296 static_cast<unsigned>(strlen(program))); |
| 298 i::CompleteParserRecorder log; | 297 i::CompleteParserRecorder log; |
| 299 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); | 298 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); |
| 300 scanner.Initialize(&stream); | 299 scanner.Initialize(&stream); |
| 301 | 300 |
| 302 // Preparser defaults to disallowing natives syntax. | 301 // Preparser defaults to disallowing natives syntax. |
| 303 v8::preparser::PreParser preparser(&scanner, &log, stack_limit); | 302 i::PreParser preparser(&scanner, &log, stack_limit); |
| 304 preparser.set_allow_lazy(true); | 303 preparser.set_allow_lazy(true); |
| 305 v8::preparser::PreParser::PreParseResult result = | 304 i::PreParser::PreParseResult result = preparser.PreParseProgram(); |
| 306 preparser.PreParseProgram(); | 305 CHECK_EQ(i::PreParser::kPreParseSuccess, result); |
| 307 CHECK_EQ(v8::preparser::PreParser::kPreParseSuccess, result); | |
| 308 i::ScriptDataImpl data(log.ExtractData()); | 306 i::ScriptDataImpl data(log.ExtractData()); |
| 309 // Data contains syntax error. | 307 // Data contains syntax error. |
| 310 CHECK(data.has_error()); | 308 CHECK(data.has_error()); |
| 311 } | 309 } |
| 312 } | 310 } |
| 313 | 311 |
| 314 | 312 |
| 315 TEST(RegressChromium62639) { | 313 TEST(RegressChromium62639) { |
| 316 v8::V8::Initialize(); | 314 v8::V8::Initialize(); |
| 317 i::Isolate* isolate = CcTest::i_isolate(); | 315 i::Isolate* isolate = CcTest::i_isolate(); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 | 393 |
| 396 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); | 394 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); |
| 397 | 395 |
| 398 i::Utf8ToUtf16CharacterStream stream( | 396 i::Utf8ToUtf16CharacterStream stream( |
| 399 reinterpret_cast<const i::byte*>(*program), | 397 reinterpret_cast<const i::byte*>(*program), |
| 400 static_cast<unsigned>(kProgramSize)); | 398 static_cast<unsigned>(kProgramSize)); |
| 401 i::CompleteParserRecorder log; | 399 i::CompleteParserRecorder log; |
| 402 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); | 400 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); |
| 403 scanner.Initialize(&stream); | 401 scanner.Initialize(&stream); |
| 404 | 402 |
| 405 v8::preparser::PreParser preparser(&scanner, &log, stack_limit); | 403 i::PreParser preparser(&scanner, &log, stack_limit); |
| 406 preparser.set_allow_lazy(true); | 404 preparser.set_allow_lazy(true); |
| 407 v8::preparser::PreParser::PreParseResult result = | 405 i::PreParser::PreParseResult result = preparser.PreParseProgram(); |
| 408 preparser.PreParseProgram(); | 406 CHECK_EQ(i::PreParser::kPreParseStackOverflow, result); |
| 409 CHECK_EQ(v8::preparser::PreParser::kPreParseStackOverflow, result); | |
| 410 } | 407 } |
| 411 | 408 |
| 412 | 409 |
| 413 class TestExternalResource: public v8::String::ExternalStringResource { | 410 class TestExternalResource: public v8::String::ExternalStringResource { |
| 414 public: | 411 public: |
| 415 explicit TestExternalResource(uint16_t* data, int length) | 412 explicit TestExternalResource(uint16_t* data, int length) |
| 416 : data_(data), length_(static_cast<size_t>(length)) { } | 413 : data_(data), length_(static_cast<size_t>(length)) { } |
| 417 | 414 |
| 418 ~TestExternalResource() { } | 415 ~TestExternalResource() { } |
| 419 | 416 |
| (...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1114 i::Isolate* isolate = CcTest::i_isolate(); | 1111 i::Isolate* isolate = CcTest::i_isolate(); |
| 1115 i::Factory* factory = isolate->factory(); | 1112 i::Factory* factory = isolate->factory(); |
| 1116 | 1113 |
| 1117 uintptr_t stack_limit = isolate->stack_guard()->real_climit(); | 1114 uintptr_t stack_limit = isolate->stack_guard()->real_climit(); |
| 1118 | 1115 |
| 1119 // Preparse the data. | 1116 // Preparse the data. |
| 1120 i::CompleteParserRecorder log; | 1117 i::CompleteParserRecorder log; |
| 1121 { | 1118 { |
| 1122 i::Scanner scanner(isolate->unicode_cache()); | 1119 i::Scanner scanner(isolate->unicode_cache()); |
| 1123 i::GenericStringUtf16CharacterStream stream(source, 0, source->length()); | 1120 i::GenericStringUtf16CharacterStream stream(source, 0, source->length()); |
| 1124 v8::preparser::PreParser preparser(&scanner, &log, stack_limit); | 1121 i::PreParser preparser(&scanner, &log, stack_limit); |
| 1125 SET_PARSER_FLAGS(preparser, flags); | 1122 SET_PARSER_FLAGS(preparser, flags); |
| 1126 scanner.Initialize(&stream); | 1123 scanner.Initialize(&stream); |
| 1127 v8::preparser::PreParser::PreParseResult result = | 1124 i::PreParser::PreParseResult result = preparser.PreParseProgram(); |
| 1128 preparser.PreParseProgram(); | 1125 CHECK_EQ(i::PreParser::kPreParseSuccess, result); |
| 1129 CHECK_EQ(v8::preparser::PreParser::kPreParseSuccess, result); | |
| 1130 } | 1126 } |
| 1131 i::ScriptDataImpl data(log.ExtractData()); | 1127 i::ScriptDataImpl data(log.ExtractData()); |
| 1132 | 1128 |
| 1133 // Parse the data | 1129 // Parse the data |
| 1134 i::FunctionLiteral* function; | 1130 i::FunctionLiteral* function; |
| 1135 { | 1131 { |
| 1136 i::Handle<i::Script> script = factory->NewScript(source); | 1132 i::Handle<i::Script> script = factory->NewScript(source); |
| 1137 i::CompilationInfoWithZone info(script); | 1133 i::CompilationInfoWithZone info(script); |
| 1138 i::Parser parser(&info); | 1134 i::Parser parser(&info); |
| 1139 SET_PARSER_FLAGS(parser, flags); | 1135 SET_PARSER_FLAGS(parser, flags); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1320 " b = function() { \n" | 1316 " b = function() { \n" |
| 1321 " 01; \n" | 1317 " 01; \n" |
| 1322 " }; \n" | 1318 " }; \n" |
| 1323 "}; \n"; | 1319 "}; \n"; |
| 1324 v8::Script::Compile(v8::String::New(script)); | 1320 v8::Script::Compile(v8::String::New(script)); |
| 1325 CHECK(try_catch.HasCaught()); | 1321 CHECK(try_catch.HasCaught()); |
| 1326 v8::String::Utf8Value exception(try_catch.Exception()); | 1322 v8::String::Utf8Value exception(try_catch.Exception()); |
| 1327 CHECK_EQ("SyntaxError: Octal literals are not allowed in strict mode.", | 1323 CHECK_EQ("SyntaxError: Octal literals are not allowed in strict mode.", |
| 1328 *exception); | 1324 *exception); |
| 1329 } | 1325 } |
| OLD | NEW |