| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 "x --> is eol-comment\nvar y = 37;\n", | 136 "x --> is eol-comment\nvar y = 37;\n", |
| 137 "\"\\n\" --> is eol-comment\nvar y = 37;\n", | 137 "\"\\n\" --> is eol-comment\nvar y = 37;\n", |
| 138 "x/* precomment */ --> is eol-comment\nvar y = 37;\n", | 138 "x/* precomment */ --> is eol-comment\nvar y = 37;\n", |
| 139 "x/* precomment\n */ --> is eol-comment\nvar y = 37;\n", | 139 "x/* precomment\n */ --> is eol-comment\nvar y = 37;\n", |
| 140 "var x = 42; --> is eol-comment\nvar y = 37;\n", | 140 "var x = 42; --> is eol-comment\nvar y = 37;\n", |
| 141 "var x = 42; /* precomment\n */ --> is eol-comment\nvar y = 37;\n", | 141 "var x = 42; /* precomment\n */ --> is eol-comment\nvar y = 37;\n", |
| 142 NULL | 142 NULL |
| 143 }; | 143 }; |
| 144 | 144 |
| 145 // Parser/Scanner needs a stack limit. | 145 // Parser/Scanner needs a stack limit. |
| 146 int marker; | 146 CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() - |
| 147 CcTest::i_isolate()->stack_guard()->SetStackLimit( | 147 128 * 1024); |
| 148 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); | |
| 149 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); | 148 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); |
| 150 for (int i = 0; tests[i]; i++) { | 149 for (int i = 0; tests[i]; i++) { |
| 151 const i::byte* source = | 150 const i::byte* source = |
| 152 reinterpret_cast<const i::byte*>(tests[i]); | 151 reinterpret_cast<const i::byte*>(tests[i]); |
| 153 i::Utf8ToUtf16CharacterStream stream(source, i::StrLength(tests[i])); | 152 i::Utf8ToUtf16CharacterStream stream(source, i::StrLength(tests[i])); |
| 154 i::CompleteParserRecorder log; | 153 i::CompleteParserRecorder log; |
| 155 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); | 154 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); |
| 156 scanner.Initialize(&stream); | 155 scanner.Initialize(&stream); |
| 157 i::PreParser preparser(&scanner, &log, stack_limit); | 156 i::PreParser preparser(&scanner, &log, stack_limit); |
| 158 preparser.set_allow_lazy(true); | 157 preparser.set_allow_lazy(true); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 const char* data_; | 191 const char* data_; |
| 193 size_t length_; | 192 size_t length_; |
| 194 }; | 193 }; |
| 195 | 194 |
| 196 | 195 |
| 197 TEST(UsingCachedData) { | 196 TEST(UsingCachedData) { |
| 198 v8::Isolate* isolate = CcTest::isolate(); | 197 v8::Isolate* isolate = CcTest::isolate(); |
| 199 v8::HandleScope handles(isolate); | 198 v8::HandleScope handles(isolate); |
| 200 v8::Local<v8::Context> context = v8::Context::New(isolate); | 199 v8::Local<v8::Context> context = v8::Context::New(isolate); |
| 201 v8::Context::Scope context_scope(context); | 200 v8::Context::Scope context_scope(context); |
| 202 int marker; | 201 CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() - |
| 203 CcTest::i_isolate()->stack_guard()->SetStackLimit( | 202 128 * 1024); |
| 204 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); | |
| 205 | 203 |
| 206 // Source containing functions that might be lazily compiled and all types | 204 // Source containing functions that might be lazily compiled and all types |
| 207 // of symbols (string, propertyName, regexp). | 205 // of symbols (string, propertyName, regexp). |
| 208 const char* source = | 206 const char* source = |
| 209 "var x = 42;" | 207 "var x = 42;" |
| 210 "function foo(a) { return function nolazy(b) { return a + b; } }" | 208 "function foo(a) { return function nolazy(b) { return a + b; } }" |
| 211 "function bar(a) { if (a) return function lazy(b) { return b; } }" | 209 "function bar(a) { if (a) return function lazy(b) { return b; } }" |
| 212 "var z = {'string': 'string literal', bareword: 'propertyName', " | 210 "var z = {'string': 'string literal', bareword: 'propertyName', " |
| 213 " 42: 'number literal', for: 'keyword as propertyName', " | 211 " 42: 'number literal', for: 'keyword as propertyName', " |
| 214 " f\\u006fr: 'keyword propertyname with escape'};" | 212 " f\\u006fr: 'keyword propertyname with escape'};" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 240 // This tests that we actually do use the function data generated by the | 238 // This tests that we actually do use the function data generated by the |
| 241 // preparser. | 239 // preparser. |
| 242 | 240 |
| 243 // Make preparsing work for short scripts. | 241 // Make preparsing work for short scripts. |
| 244 i::FLAG_min_preparse_length = 0; | 242 i::FLAG_min_preparse_length = 0; |
| 245 | 243 |
| 246 v8::Isolate* isolate = CcTest::isolate(); | 244 v8::Isolate* isolate = CcTest::isolate(); |
| 247 v8::HandleScope handles(isolate); | 245 v8::HandleScope handles(isolate); |
| 248 v8::Local<v8::Context> context = v8::Context::New(isolate); | 246 v8::Local<v8::Context> context = v8::Context::New(isolate); |
| 249 v8::Context::Scope context_scope(context); | 247 v8::Context::Scope context_scope(context); |
| 250 int marker; | 248 CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() - |
| 251 CcTest::i_isolate()->stack_guard()->SetStackLimit( | 249 128 * 1024); |
| 252 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); | |
| 253 | 250 |
| 254 const char* good_code = | 251 const char* good_code = |
| 255 "function this_is_lazy() { var a; } function foo() { return 25; } foo();"; | 252 "function this_is_lazy() { var a; } function foo() { return 25; } foo();"; |
| 256 | 253 |
| 257 // Insert a syntax error inside the lazy function. | 254 // Insert a syntax error inside the lazy function. |
| 258 const char* bad_code = | 255 const char* bad_code = |
| 259 "function this_is_lazy() { if ( } function foo() { return 25; } foo();"; | 256 "function this_is_lazy() { if ( } function foo() { return 25; } foo();"; |
| 260 | 257 |
| 261 v8::ScriptCompiler::Source good_source(v8_str(good_code)); | 258 v8::ScriptCompiler::Source good_source(v8_str(good_code)); |
| 262 v8::ScriptCompiler::Compile(isolate, &good_source, | 259 v8::ScriptCompiler::Compile(isolate, &good_source, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 275 v8::Local<v8::Value> result = | 272 v8::Local<v8::Value> result = |
| 276 v8::ScriptCompiler::Compile(isolate, &bad_source)->Run(); | 273 v8::ScriptCompiler::Compile(isolate, &bad_source)->Run(); |
| 277 CHECK(result->IsInt32()); | 274 CHECK(result->IsInt32()); |
| 278 CHECK_EQ(25, result->Int32Value()); | 275 CHECK_EQ(25, result->Int32Value()); |
| 279 } | 276 } |
| 280 | 277 |
| 281 | 278 |
| 282 TEST(StandAlonePreParser) { | 279 TEST(StandAlonePreParser) { |
| 283 v8::V8::Initialize(); | 280 v8::V8::Initialize(); |
| 284 | 281 |
| 285 int marker; | 282 CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() - |
| 286 CcTest::i_isolate()->stack_guard()->SetStackLimit( | 283 128 * 1024); |
| 287 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); | |
| 288 | 284 |
| 289 const char* programs[] = { | 285 const char* programs[] = { |
| 290 "{label: 42}", | 286 "{label: 42}", |
| 291 "var x = 42;", | 287 "var x = 42;", |
| 292 "function foo(x, y) { return x + y; }", | 288 "function foo(x, y) { return x + y; }", |
| 293 "%ArgleBargle(glop);", | 289 "%ArgleBargle(glop);", |
| 294 "var x = new new Function('this.x = 42');", | 290 "var x = new new Function('this.x = 42');", |
| 295 NULL | 291 NULL |
| 296 }; | 292 }; |
| 297 | 293 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 312 CHECK_EQ(i::PreParser::kPreParseSuccess, result); | 308 CHECK_EQ(i::PreParser::kPreParseSuccess, result); |
| 313 i::ScriptData data(log.ExtractData()); | 309 i::ScriptData data(log.ExtractData()); |
| 314 CHECK(!data.has_error()); | 310 CHECK(!data.has_error()); |
| 315 } | 311 } |
| 316 } | 312 } |
| 317 | 313 |
| 318 | 314 |
| 319 TEST(StandAlonePreParserNoNatives) { | 315 TEST(StandAlonePreParserNoNatives) { |
| 320 v8::V8::Initialize(); | 316 v8::V8::Initialize(); |
| 321 | 317 |
| 322 int marker; | 318 CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() - |
| 323 CcTest::i_isolate()->stack_guard()->SetStackLimit( | 319 128 * 1024); |
| 324 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); | |
| 325 | 320 |
| 326 const char* programs[] = { | 321 const char* programs[] = { |
| 327 "%ArgleBargle(glop);", | 322 "%ArgleBargle(glop);", |
| 328 "var x = %_IsSmi(42);", | 323 "var x = %_IsSmi(42);", |
| 329 NULL | 324 NULL |
| 330 }; | 325 }; |
| 331 | 326 |
| 332 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); | 327 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); |
| 333 for (int i = 0; programs[i]; i++) { | 328 for (int i = 0; programs[i]; i++) { |
| 334 const char* program = programs[i]; | 329 const char* program = programs[i]; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 351 } | 346 } |
| 352 | 347 |
| 353 | 348 |
| 354 TEST(PreparsingObjectLiterals) { | 349 TEST(PreparsingObjectLiterals) { |
| 355 // Regression test for a bug where the symbol stream produced by PreParser | 350 // Regression test for a bug where the symbol stream produced by PreParser |
| 356 // didn't match what Parser wanted to consume. | 351 // didn't match what Parser wanted to consume. |
| 357 v8::Isolate* isolate = CcTest::isolate(); | 352 v8::Isolate* isolate = CcTest::isolate(); |
| 358 v8::HandleScope handles(isolate); | 353 v8::HandleScope handles(isolate); |
| 359 v8::Local<v8::Context> context = v8::Context::New(isolate); | 354 v8::Local<v8::Context> context = v8::Context::New(isolate); |
| 360 v8::Context::Scope context_scope(context); | 355 v8::Context::Scope context_scope(context); |
| 361 int marker; | 356 CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() - |
| 362 CcTest::i_isolate()->stack_guard()->SetStackLimit( | 357 128 * 1024); |
| 363 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); | |
| 364 | 358 |
| 365 { | 359 { |
| 366 const char* source = "var myo = {if: \"foo\"}; myo.if;"; | 360 const char* source = "var myo = {if: \"foo\"}; myo.if;"; |
| 367 v8::Local<v8::Value> result = PreCompileCompileRun(source); | 361 v8::Local<v8::Value> result = PreCompileCompileRun(source); |
| 368 CHECK(result->IsString()); | 362 CHECK(result->IsString()); |
| 369 v8::String::Utf8Value utf8(result); | 363 v8::String::Utf8Value utf8(result); |
| 370 CHECK_EQ("foo", *utf8); | 364 CHECK_EQ("foo", *utf8); |
| 371 } | 365 } |
| 372 | 366 |
| 373 { | 367 { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 385 v8::String::Utf8Value utf8(result); | 379 v8::String::Utf8Value utf8(result); |
| 386 CHECK_EQ("foo", *utf8); | 380 CHECK_EQ("foo", *utf8); |
| 387 } | 381 } |
| 388 } | 382 } |
| 389 | 383 |
| 390 | 384 |
| 391 TEST(RegressChromium62639) { | 385 TEST(RegressChromium62639) { |
| 392 v8::V8::Initialize(); | 386 v8::V8::Initialize(); |
| 393 i::Isolate* isolate = CcTest::i_isolate(); | 387 i::Isolate* isolate = CcTest::i_isolate(); |
| 394 | 388 |
| 395 int marker; | 389 isolate->stack_guard()->SetStackLimit(GetCurrentStackPosition() - 128 * 1024); |
| 396 isolate->stack_guard()->SetStackLimit( | |
| 397 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); | |
| 398 | 390 |
| 399 const char* program = "var x = 'something';\n" | 391 const char* program = "var x = 'something';\n" |
| 400 "escape: function() {}"; | 392 "escape: function() {}"; |
| 401 // Fails parsing expecting an identifier after "function". | 393 // Fails parsing expecting an identifier after "function". |
| 402 // Before fix, didn't check *ok after Expect(Token::Identifier, ok), | 394 // Before fix, didn't check *ok after Expect(Token::Identifier, ok), |
| 403 // and then used the invalid currently scanned literal. This always | 395 // and then used the invalid currently scanned literal. This always |
| 404 // failed in debug mode, and sometimes crashed in release mode. | 396 // failed in debug mode, and sometimes crashed in release mode. |
| 405 | 397 |
| 406 i::Utf8ToUtf16CharacterStream stream( | 398 i::Utf8ToUtf16CharacterStream stream( |
| 407 reinterpret_cast<const i::byte*>(program), | 399 reinterpret_cast<const i::byte*>(program), |
| (...skipping 14 matching lines...) Expand all Loading... |
| 422 | 414 |
| 423 TEST(Regress928) { | 415 TEST(Regress928) { |
| 424 v8::V8::Initialize(); | 416 v8::V8::Initialize(); |
| 425 i::Isolate* isolate = CcTest::i_isolate(); | 417 i::Isolate* isolate = CcTest::i_isolate(); |
| 426 i::Factory* factory = isolate->factory(); | 418 i::Factory* factory = isolate->factory(); |
| 427 | 419 |
| 428 // Preparsing didn't consider the catch clause of a try statement | 420 // Preparsing didn't consider the catch clause of a try statement |
| 429 // as with-content, which made it assume that a function inside | 421 // as with-content, which made it assume that a function inside |
| 430 // the block could be lazily compiled, and an extra, unexpected, | 422 // the block could be lazily compiled, and an extra, unexpected, |
| 431 // entry was added to the data. | 423 // entry was added to the data. |
| 432 int marker; | 424 isolate->stack_guard()->SetStackLimit(GetCurrentStackPosition() - 128 * 1024); |
| 433 isolate->stack_guard()->SetStackLimit( | |
| 434 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); | |
| 435 | 425 |
| 436 const char* program = | 426 const char* program = |
| 437 "try { } catch (e) { var foo = function () { /* first */ } }" | 427 "try { } catch (e) { var foo = function () { /* first */ } }" |
| 438 "var bar = function () { /* second */ }"; | 428 "var bar = function () { /* second */ }"; |
| 439 | 429 |
| 440 v8::HandleScope handles(CcTest::isolate()); | 430 v8::HandleScope handles(CcTest::isolate()); |
| 441 i::Handle<i::String> source = factory->NewStringFromAsciiChecked(program); | 431 i::Handle<i::String> source = factory->NewStringFromAsciiChecked(program); |
| 442 i::GenericStringUtf16CharacterStream stream(source, 0, source->length()); | 432 i::GenericStringUtf16CharacterStream stream(source, 0, source->length()); |
| 443 i::CompleteParserRecorder log; | 433 i::CompleteParserRecorder log; |
| 444 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); | 434 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 466 CHECK_EQ('{', program[second_lbrace]); | 456 CHECK_EQ('{', program[second_lbrace]); |
| 467 i::FunctionEntry entry2 = data.GetFunctionEntry(second_lbrace); | 457 i::FunctionEntry entry2 = data.GetFunctionEntry(second_lbrace); |
| 468 CHECK(entry2.is_valid()); | 458 CHECK(entry2.is_valid()); |
| 469 CHECK_EQ('}', program[entry2.end_pos() - 1]); | 459 CHECK_EQ('}', program[entry2.end_pos() - 1]); |
| 470 } | 460 } |
| 471 | 461 |
| 472 | 462 |
| 473 TEST(PreParseOverflow) { | 463 TEST(PreParseOverflow) { |
| 474 v8::V8::Initialize(); | 464 v8::V8::Initialize(); |
| 475 | 465 |
| 476 int marker; | 466 CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() - |
| 477 CcTest::i_isolate()->stack_guard()->SetStackLimit( | 467 128 * 1024); |
| 478 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); | |
| 479 | 468 |
| 480 size_t kProgramSize = 1024 * 1024; | 469 size_t kProgramSize = 1024 * 1024; |
| 481 i::SmartArrayPointer<char> program(i::NewArray<char>(kProgramSize + 1)); | 470 i::SmartArrayPointer<char> program(i::NewArray<char>(kProgramSize + 1)); |
| 482 memset(program.get(), '(', kProgramSize); | 471 memset(program.get(), '(', kProgramSize); |
| 483 program[kProgramSize] = '\0'; | 472 program[kProgramSize] = '\0'; |
| 484 | 473 |
| 485 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); | 474 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); |
| 486 | 475 |
| 487 i::Utf8ToUtf16CharacterStream stream( | 476 i::Utf8ToUtf16CharacterStream stream( |
| 488 reinterpret_cast<const i::byte*>(program.get()), | 477 reinterpret_cast<const i::byte*>(program.get()), |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1090 { NULL, NULL, NULL, i::EVAL_SCOPE, i::SLOPPY } | 1079 { NULL, NULL, NULL, i::EVAL_SCOPE, i::SLOPPY } |
| 1091 }; | 1080 }; |
| 1092 | 1081 |
| 1093 i::Isolate* isolate = CcTest::i_isolate(); | 1082 i::Isolate* isolate = CcTest::i_isolate(); |
| 1094 i::Factory* factory = isolate->factory(); | 1083 i::Factory* factory = isolate->factory(); |
| 1095 | 1084 |
| 1096 v8::HandleScope handles(CcTest::isolate()); | 1085 v8::HandleScope handles(CcTest::isolate()); |
| 1097 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate()); | 1086 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate()); |
| 1098 v8::Context::Scope context_scope(context); | 1087 v8::Context::Scope context_scope(context); |
| 1099 | 1088 |
| 1100 int marker; | 1089 isolate->stack_guard()->SetStackLimit(GetCurrentStackPosition() - 128 * 1024); |
| 1101 isolate->stack_guard()->SetStackLimit( | |
| 1102 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); | |
| 1103 | 1090 |
| 1104 for (int i = 0; source_data[i].outer_prefix; i++) { | 1091 for (int i = 0; source_data[i].outer_prefix; i++) { |
| 1105 int kPrefixLen = Utf8LengthHelper(source_data[i].outer_prefix); | 1092 int kPrefixLen = Utf8LengthHelper(source_data[i].outer_prefix); |
| 1106 int kInnerLen = Utf8LengthHelper(source_data[i].inner_source); | 1093 int kInnerLen = Utf8LengthHelper(source_data[i].inner_source); |
| 1107 int kSuffixLen = Utf8LengthHelper(source_data[i].outer_suffix); | 1094 int kSuffixLen = Utf8LengthHelper(source_data[i].outer_suffix); |
| 1108 int kPrefixByteLen = i::StrLength(source_data[i].outer_prefix); | 1095 int kPrefixByteLen = i::StrLength(source_data[i].outer_prefix); |
| 1109 int kInnerByteLen = i::StrLength(source_data[i].inner_source); | 1096 int kInnerByteLen = i::StrLength(source_data[i].inner_source); |
| 1110 int kSuffixByteLen = i::StrLength(source_data[i].outer_suffix); | 1097 int kSuffixByteLen = i::StrLength(source_data[i].outer_suffix); |
| 1111 int kProgramSize = kPrefixLen + kInnerLen + kSuffixLen; | 1098 int kProgramSize = kPrefixLen + kInnerLen + kSuffixLen; |
| 1112 int kProgramByteSize = kPrefixByteLen + kInnerByteLen + kSuffixByteLen; | 1099 int kProgramByteSize = kPrefixByteLen + kInnerByteLen + kSuffixByteLen; |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1393 "\n", | 1380 "\n", |
| 1394 ";\n", | 1381 ";\n", |
| 1395 "\n;", | 1382 "\n;", |
| 1396 NULL | 1383 NULL |
| 1397 }; | 1384 }; |
| 1398 | 1385 |
| 1399 v8::HandleScope handles(CcTest::isolate()); | 1386 v8::HandleScope handles(CcTest::isolate()); |
| 1400 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate()); | 1387 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate()); |
| 1401 v8::Context::Scope context_scope(context); | 1388 v8::Context::Scope context_scope(context); |
| 1402 | 1389 |
| 1403 int marker; | 1390 CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() - |
| 1404 CcTest::i_isolate()->stack_guard()->SetStackLimit( | 1391 128 * 1024); |
| 1405 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); | |
| 1406 | 1392 |
| 1407 static const ParserFlag flags1[] = { | 1393 static const ParserFlag flags1[] = { |
| 1408 kAllowLazy, kAllowHarmonyScoping, kAllowModules, kAllowGenerators, | 1394 kAllowLazy, kAllowHarmonyScoping, kAllowModules, kAllowGenerators, |
| 1409 kAllowForOf | 1395 kAllowForOf |
| 1410 }; | 1396 }; |
| 1411 for (int i = 0; context_data[i][0] != NULL; ++i) { | 1397 for (int i = 0; context_data[i][0] != NULL; ++i) { |
| 1412 for (int j = 0; statement_data[j] != NULL; ++j) { | 1398 for (int j = 0; statement_data[j] != NULL; ++j) { |
| 1413 for (int k = 0; termination_data[k] != NULL; ++k) { | 1399 for (int k = 0; termination_data[k] != NULL; ++k) { |
| 1414 int kPrefixLen = i::StrLength(context_data[i][0]); | 1400 int kPrefixLen = i::StrLength(context_data[i][0]); |
| 1415 int kStatementLen = i::StrLength(statement_data[j]); | 1401 int kStatementLen = i::StrLength(statement_data[j]); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1471 const char* statement_data[], | 1457 const char* statement_data[], |
| 1472 ParserSyncTestResult result, | 1458 ParserSyncTestResult result, |
| 1473 const ParserFlag* flags = NULL, | 1459 const ParserFlag* flags = NULL, |
| 1474 int flags_len = 0, | 1460 int flags_len = 0, |
| 1475 const ParserFlag* always_true_flags = NULL, | 1461 const ParserFlag* always_true_flags = NULL, |
| 1476 int always_true_flags_len = 0) { | 1462 int always_true_flags_len = 0) { |
| 1477 v8::HandleScope handles(CcTest::isolate()); | 1463 v8::HandleScope handles(CcTest::isolate()); |
| 1478 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate()); | 1464 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate()); |
| 1479 v8::Context::Scope context_scope(context); | 1465 v8::Context::Scope context_scope(context); |
| 1480 | 1466 |
| 1481 int marker; | 1467 CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() - |
| 1482 CcTest::i_isolate()->stack_guard()->SetStackLimit( | 1468 128 * 1024); |
| 1483 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); | |
| 1484 | 1469 |
| 1485 static const ParserFlag default_flags[] = { | 1470 static const ParserFlag default_flags[] = { |
| 1486 kAllowLazy, kAllowHarmonyScoping, kAllowModules, kAllowGenerators, | 1471 kAllowLazy, kAllowHarmonyScoping, kAllowModules, kAllowGenerators, |
| 1487 kAllowForOf, kAllowNativesSyntax | 1472 kAllowForOf, kAllowNativesSyntax |
| 1488 }; | 1473 }; |
| 1489 ParserFlag* generated_flags = NULL; | 1474 ParserFlag* generated_flags = NULL; |
| 1490 if (flags == NULL) { | 1475 if (flags == NULL) { |
| 1491 flags = default_flags; | 1476 flags = default_flags; |
| 1492 flags_len = ARRAY_SIZE(default_flags); | 1477 flags_len = ARRAY_SIZE(default_flags); |
| 1493 if (always_true_flags != NULL) { | 1478 if (always_true_flags != NULL) { |
| (...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2146 } | 2131 } |
| 2147 | 2132 |
| 2148 | 2133 |
| 2149 TEST(DontRegressPreParserDataSizes) { | 2134 TEST(DontRegressPreParserDataSizes) { |
| 2150 // These tests make sure that Parser doesn't start producing less "preparse | 2135 // These tests make sure that Parser doesn't start producing less "preparse |
| 2151 // data" (data which the embedder can cache). | 2136 // data" (data which the embedder can cache). |
| 2152 v8::V8::Initialize(); | 2137 v8::V8::Initialize(); |
| 2153 v8::Isolate* isolate = CcTest::isolate(); | 2138 v8::Isolate* isolate = CcTest::isolate(); |
| 2154 v8::HandleScope handles(isolate); | 2139 v8::HandleScope handles(isolate); |
| 2155 | 2140 |
| 2156 int marker; | 2141 CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() - |
| 2157 CcTest::i_isolate()->stack_guard()->SetStackLimit( | 2142 128 * 1024); |
| 2158 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); | |
| 2159 | 2143 |
| 2160 struct TestCase { | 2144 struct TestCase { |
| 2161 const char* program; | 2145 const char* program; |
| 2162 int functions; | 2146 int functions; |
| 2163 } test_cases[] = { | 2147 } test_cases[] = { |
| 2164 // No functions. | 2148 // No functions. |
| 2165 {"var x = 42;", 0}, | 2149 {"var x = 42;", 0}, |
| 2166 // Functions. | 2150 // Functions. |
| 2167 {"function foo() {}", 1}, {"function foo() {} function bar() {}", 2}, | 2151 {"function foo() {}", 1}, {"function foo() {} function bar() {}", 2}, |
| 2168 // Getter / setter functions are recorded as functions if they're on the top | 2152 // Getter / setter functions are recorded as functions if they're on the top |
| (...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2911 LocalContext env; | 2895 LocalContext env; |
| 2912 int use_counts[v8::Isolate::kUseCounterFeatureCount] = {}; | 2896 int use_counts[v8::Isolate::kUseCounterFeatureCount] = {}; |
| 2913 global_use_counts = use_counts; | 2897 global_use_counts = use_counts; |
| 2914 CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback); | 2898 CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback); |
| 2915 CompileRun("\"use asm\";\n" | 2899 CompileRun("\"use asm\";\n" |
| 2916 "var foo = 1;\n" | 2900 "var foo = 1;\n" |
| 2917 "\"use asm\";\n" // Only the first one counts. | 2901 "\"use asm\";\n" // Only the first one counts. |
| 2918 "function bar() { \"use asm\"; var baz = 1; }"); | 2902 "function bar() { \"use asm\"; var baz = 1; }"); |
| 2919 CHECK_EQ(2, use_counts[v8::Isolate::kUseAsm]); | 2903 CHECK_EQ(2, use_counts[v8::Isolate::kUseAsm]); |
| 2920 } | 2904 } |
| OLD | NEW |