Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(262)

Side by Side Diff: test/cctest/test-parsing.cc

Issue 2630343002: [Parser] Introduce AstStringConstants to share constants across AstValueFactory (Closed)
Patch Set: Fix test Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/test-ast.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 CcTest::i_isolate()->stack_guard()->SetStackLimit( 168 CcTest::i_isolate()->stack_guard()->SetStackLimit(
169 i::GetCurrentStackPosition() - 128 * 1024); 169 i::GetCurrentStackPosition() - 128 * 1024);
170 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); 170 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit();
171 for (int i = 0; tests[i]; i++) { 171 for (int i = 0; tests[i]; i++) {
172 const char* source = tests[i]; 172 const char* source = tests[i];
173 auto stream = i::ScannerStream::ForTesting(source); 173 auto stream = i::ScannerStream::ForTesting(source);
174 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); 174 i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
175 scanner.Initialize(stream.get()); 175 scanner.Initialize(stream.get());
176 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); 176 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
177 i::AstValueFactory ast_value_factory( 177 i::AstValueFactory ast_value_factory(
178 &zone, CcTest::i_isolate()->heap()->HashSeed()); 178 &zone, CcTest::i_isolate()->ast_string_constants(),
179 CcTest::i_isolate()->heap()->HashSeed());
179 i::PendingCompilationErrorHandler pending_error_handler; 180 i::PendingCompilationErrorHandler pending_error_handler;
180 i::PreParser preparser( 181 i::PreParser preparser(
181 &zone, &scanner, stack_limit, &ast_value_factory, 182 &zone, &scanner, stack_limit, &ast_value_factory,
182 &pending_error_handler, 183 &pending_error_handler,
183 CcTest::i_isolate()->counters()->runtime_call_stats()); 184 CcTest::i_isolate()->counters()->runtime_call_stats());
184 i::PreParser::PreParseResult result = preparser.PreParseProgram(); 185 i::PreParser::PreParseResult result = preparser.PreParseProgram();
185 CHECK_EQ(i::PreParser::kPreParseSuccess, result); 186 CHECK_EQ(i::PreParser::kPreParseSuccess, result);
186 CHECK(!pending_error_handler.has_pending_error()); 187 CHECK(!pending_error_handler.has_pending_error());
187 } 188 }
188 189
189 for (int i = 0; fail_tests[i]; i++) { 190 for (int i = 0; fail_tests[i]; i++) {
190 const char* source = fail_tests[i]; 191 const char* source = fail_tests[i];
191 auto stream = i::ScannerStream::ForTesting(source); 192 auto stream = i::ScannerStream::ForTesting(source);
192 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); 193 i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
193 scanner.Initialize(stream.get()); 194 scanner.Initialize(stream.get());
194 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); 195 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
195 i::AstValueFactory ast_value_factory( 196 i::AstValueFactory ast_value_factory(
196 &zone, CcTest::i_isolate()->heap()->HashSeed()); 197 &zone, CcTest::i_isolate()->ast_string_constants(),
198 CcTest::i_isolate()->heap()->HashSeed());
197 i::PendingCompilationErrorHandler pending_error_handler; 199 i::PendingCompilationErrorHandler pending_error_handler;
198 i::PreParser preparser( 200 i::PreParser preparser(
199 &zone, &scanner, stack_limit, &ast_value_factory, 201 &zone, &scanner, stack_limit, &ast_value_factory,
200 &pending_error_handler, 202 &pending_error_handler,
201 CcTest::i_isolate()->counters()->runtime_call_stats()); 203 CcTest::i_isolate()->counters()->runtime_call_stats());
202 i::PreParser::PreParseResult result = preparser.PreParseProgram(); 204 i::PreParser::PreParseResult result = preparser.PreParseProgram();
203 // Even in the case of a syntax error, kPreParseSuccess is returned. 205 // Even in the case of a syntax error, kPreParseSuccess is returned.
204 CHECK_EQ(i::PreParser::kPreParseSuccess, result); 206 CHECK_EQ(i::PreParser::kPreParseSuccess, result);
205 CHECK(pending_error_handler.has_pending_error()); 207 CHECK(pending_error_handler.has_pending_error());
206 } 208 }
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 }; 359 };
358 360
359 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); 361 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit();
360 for (int i = 0; programs[i]; i++) { 362 for (int i = 0; programs[i]; i++) {
361 auto stream = i::ScannerStream::ForTesting(programs[i]); 363 auto stream = i::ScannerStream::ForTesting(programs[i]);
362 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); 364 i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
363 scanner.Initialize(stream.get()); 365 scanner.Initialize(stream.get());
364 366
365 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); 367 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
366 i::AstValueFactory ast_value_factory( 368 i::AstValueFactory ast_value_factory(
367 &zone, CcTest::i_isolate()->heap()->HashSeed()); 369 &zone, CcTest::i_isolate()->ast_string_constants(),
370 CcTest::i_isolate()->heap()->HashSeed());
368 i::PendingCompilationErrorHandler pending_error_handler; 371 i::PendingCompilationErrorHandler pending_error_handler;
369 i::PreParser preparser( 372 i::PreParser preparser(
370 &zone, &scanner, stack_limit, &ast_value_factory, 373 &zone, &scanner, stack_limit, &ast_value_factory,
371 &pending_error_handler, 374 &pending_error_handler,
372 CcTest::i_isolate()->counters()->runtime_call_stats()); 375 CcTest::i_isolate()->counters()->runtime_call_stats());
373 preparser.set_allow_natives(true); 376 preparser.set_allow_natives(true);
374 i::PreParser::PreParseResult result = preparser.PreParseProgram(); 377 i::PreParser::PreParseResult result = preparser.PreParseProgram();
375 CHECK_EQ(i::PreParser::kPreParseSuccess, result); 378 CHECK_EQ(i::PreParser::kPreParseSuccess, result);
376 CHECK(!pending_error_handler.has_pending_error()); 379 CHECK(!pending_error_handler.has_pending_error());
377 } 380 }
(...skipping 15 matching lines...) Expand all
393 396
394 uintptr_t stack_limit = isolate->stack_guard()->real_climit(); 397 uintptr_t stack_limit = isolate->stack_guard()->real_climit();
395 for (int i = 0; programs[i]; i++) { 398 for (int i = 0; programs[i]; i++) {
396 auto stream = i::ScannerStream::ForTesting(programs[i]); 399 auto stream = i::ScannerStream::ForTesting(programs[i]);
397 i::Scanner scanner(isolate->unicode_cache()); 400 i::Scanner scanner(isolate->unicode_cache());
398 scanner.Initialize(stream.get()); 401 scanner.Initialize(stream.get());
399 402
400 // Preparser defaults to disallowing natives syntax. 403 // Preparser defaults to disallowing natives syntax.
401 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); 404 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
402 i::AstValueFactory ast_value_factory( 405 i::AstValueFactory ast_value_factory(
403 &zone, CcTest::i_isolate()->heap()->HashSeed()); 406 &zone, CcTest::i_isolate()->ast_string_constants(),
407 CcTest::i_isolate()->heap()->HashSeed());
404 i::PendingCompilationErrorHandler pending_error_handler; 408 i::PendingCompilationErrorHandler pending_error_handler;
405 i::PreParser preparser(&zone, &scanner, stack_limit, &ast_value_factory, 409 i::PreParser preparser(&zone, &scanner, stack_limit, &ast_value_factory,
406 &pending_error_handler, 410 &pending_error_handler,
407 isolate->counters()->runtime_call_stats()); 411 isolate->counters()->runtime_call_stats());
408 i::PreParser::PreParseResult result = preparser.PreParseProgram(); 412 i::PreParser::PreParseResult result = preparser.PreParseProgram();
409 CHECK_EQ(i::PreParser::kPreParseSuccess, result); 413 CHECK_EQ(i::PreParser::kPreParseSuccess, result);
410 CHECK(pending_error_handler.has_pending_error()); 414 CHECK(pending_error_handler.has_pending_error());
411 } 415 }
412 } 416 }
413 417
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 "escape: function() {}"; 463 "escape: function() {}";
460 // Fails parsing expecting an identifier after "function". 464 // Fails parsing expecting an identifier after "function".
461 // Before fix, didn't check *ok after Expect(Token::Identifier, ok), 465 // Before fix, didn't check *ok after Expect(Token::Identifier, ok),
462 // and then used the invalid currently scanned literal. This always 466 // and then used the invalid currently scanned literal. This always
463 // failed in debug mode, and sometimes crashed in release mode. 467 // failed in debug mode, and sometimes crashed in release mode.
464 468
465 auto stream = i::ScannerStream::ForTesting(program); 469 auto stream = i::ScannerStream::ForTesting(program);
466 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); 470 i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
467 scanner.Initialize(stream.get()); 471 scanner.Initialize(stream.get());
468 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); 472 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
469 i::AstValueFactory ast_value_factory(&zone, 473 i::AstValueFactory ast_value_factory(
470 CcTest::i_isolate()->heap()->HashSeed()); 474 &zone, CcTest::i_isolate()->ast_string_constants(),
475 CcTest::i_isolate()->heap()->HashSeed());
471 i::PendingCompilationErrorHandler pending_error_handler; 476 i::PendingCompilationErrorHandler pending_error_handler;
472 i::PreParser preparser(&zone, &scanner, 477 i::PreParser preparser(&zone, &scanner,
473 CcTest::i_isolate()->stack_guard()->real_climit(), 478 CcTest::i_isolate()->stack_guard()->real_climit(),
474 &ast_value_factory, &pending_error_handler, 479 &ast_value_factory, &pending_error_handler,
475 isolate->counters()->runtime_call_stats()); 480 isolate->counters()->runtime_call_stats());
476 i::PreParser::PreParseResult result = preparser.PreParseProgram(); 481 i::PreParser::PreParseResult result = preparser.PreParseProgram();
477 // Even in the case of a syntax error, kPreParseSuccess is returned. 482 // Even in the case of a syntax error, kPreParseSuccess is returned.
478 CHECK_EQ(i::PreParser::kPreParseSuccess, result); 483 CHECK_EQ(i::PreParser::kPreParseSuccess, result);
479 CHECK(pending_error_handler.has_pending_error()); 484 CHECK(pending_error_handler.has_pending_error());
480 } 485 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 memset(program.get(), '(', kProgramSize); 539 memset(program.get(), '(', kProgramSize);
535 program[kProgramSize] = '\0'; 540 program[kProgramSize] = '\0';
536 541
537 uintptr_t stack_limit = isolate->stack_guard()->real_climit(); 542 uintptr_t stack_limit = isolate->stack_guard()->real_climit();
538 543
539 auto stream = i::ScannerStream::ForTesting(program.get(), kProgramSize); 544 auto stream = i::ScannerStream::ForTesting(program.get(), kProgramSize);
540 i::Scanner scanner(isolate->unicode_cache()); 545 i::Scanner scanner(isolate->unicode_cache());
541 scanner.Initialize(stream.get()); 546 scanner.Initialize(stream.get());
542 547
543 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); 548 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
544 i::AstValueFactory ast_value_factory(&zone, 549 i::AstValueFactory ast_value_factory(
545 CcTest::i_isolate()->heap()->HashSeed()); 550 &zone, CcTest::i_isolate()->ast_string_constants(),
551 CcTest::i_isolate()->heap()->HashSeed());
546 i::PendingCompilationErrorHandler pending_error_handler; 552 i::PendingCompilationErrorHandler pending_error_handler;
547 i::PreParser preparser(&zone, &scanner, stack_limit, &ast_value_factory, 553 i::PreParser preparser(&zone, &scanner, stack_limit, &ast_value_factory,
548 &pending_error_handler, 554 &pending_error_handler,
549 isolate->counters()->runtime_call_stats()); 555 isolate->counters()->runtime_call_stats());
550 i::PreParser::PreParseResult result = preparser.PreParseProgram(); 556 i::PreParser::PreParseResult result = preparser.PreParseProgram();
551 CHECK_EQ(i::PreParser::kPreParseStackOverflow, result); 557 CHECK_EQ(i::PreParser::kPreParseStackOverflow, result);
552 } 558 }
553 559
554 560
555 void TestStreamScanner(i::Utf16CharacterStream* stream, 561 void TestStreamScanner(i::Utf16CharacterStream* stream,
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 auto stream = i::ScannerStream::ForTesting(re_source); 641 auto stream = i::ScannerStream::ForTesting(re_source);
636 i::HandleScope scope(CcTest::i_isolate()); 642 i::HandleScope scope(CcTest::i_isolate());
637 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); 643 i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
638 scanner.Initialize(stream.get()); 644 scanner.Initialize(stream.get());
639 645
640 i::Token::Value start = scanner.peek(); 646 i::Token::Value start = scanner.peek();
641 CHECK(start == i::Token::DIV || start == i::Token::ASSIGN_DIV); 647 CHECK(start == i::Token::DIV || start == i::Token::ASSIGN_DIV);
642 CHECK(scanner.ScanRegExpPattern()); 648 CHECK(scanner.ScanRegExpPattern());
643 scanner.Next(); // Current token is now the regexp literal. 649 scanner.Next(); // Current token is now the regexp literal.
644 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); 650 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
645 i::AstValueFactory ast_value_factory(&zone, 651 i::AstValueFactory ast_value_factory(
646 CcTest::i_isolate()->heap()->HashSeed()); 652 &zone, CcTest::i_isolate()->ast_string_constants(),
653 CcTest::i_isolate()->heap()->HashSeed());
647 const i::AstRawString* current_symbol = 654 const i::AstRawString* current_symbol =
648 scanner.CurrentSymbol(&ast_value_factory); 655 scanner.CurrentSymbol(&ast_value_factory);
649 ast_value_factory.Internalize(CcTest::i_isolate()); 656 ast_value_factory.Internalize(CcTest::i_isolate());
650 i::Handle<i::String> val = current_symbol->string(); 657 i::Handle<i::String> val = current_symbol->string();
651 i::DisallowHeapAllocation no_alloc; 658 i::DisallowHeapAllocation no_alloc;
652 i::String::FlatContent content = val->GetFlatContent(); 659 i::String::FlatContent content = val->GetFlatContent();
653 CHECK(content.IsOneByte()); 660 CHECK(content.IsOneByte());
654 i::Vector<const uint8_t> actual = content.ToOneByteVector(); 661 i::Vector<const uint8_t> actual = content.ToOneByteVector();
655 for (int i = 0; i < actual.length(); i++) { 662 for (int i = 0; i < actual.length(); i++) {
656 CHECK_NE('\0', expected[i]); 663 CHECK_NE('\0', expected[i]);
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
1323 int parser_materialized_literals = -2; 1330 int parser_materialized_literals = -2;
1324 1331
1325 // Preparse the data. 1332 // Preparse the data.
1326 i::PendingCompilationErrorHandler pending_error_handler; 1333 i::PendingCompilationErrorHandler pending_error_handler;
1327 if (test_preparser) { 1334 if (test_preparser) {
1328 i::Scanner scanner(isolate->unicode_cache()); 1335 i::Scanner scanner(isolate->unicode_cache());
1329 std::unique_ptr<i::Utf16CharacterStream> stream( 1336 std::unique_ptr<i::Utf16CharacterStream> stream(
1330 i::ScannerStream::For(source)); 1337 i::ScannerStream::For(source));
1331 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); 1338 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
1332 i::AstValueFactory ast_value_factory( 1339 i::AstValueFactory ast_value_factory(
1333 &zone, CcTest::i_isolate()->heap()->HashSeed()); 1340 &zone, CcTest::i_isolate()->ast_string_constants(),
1341 CcTest::i_isolate()->heap()->HashSeed());
1334 i::PreParser preparser(&zone, &scanner, stack_limit, &ast_value_factory, 1342 i::PreParser preparser(&zone, &scanner, stack_limit, &ast_value_factory,
1335 &pending_error_handler, 1343 &pending_error_handler,
1336 isolate->counters()->runtime_call_stats()); 1344 isolate->counters()->runtime_call_stats());
1337 SetParserFlags(&preparser, flags); 1345 SetParserFlags(&preparser, flags);
1338 scanner.Initialize(stream.get()); 1346 scanner.Initialize(stream.get());
1339 i::PreParser::PreParseResult result = 1347 i::PreParser::PreParseResult result =
1340 preparser.PreParseProgram(&preparser_materialized_literals, is_module); 1348 preparser.PreParseProgram(&preparser_materialized_literals, is_module);
1341 CHECK_EQ(i::PreParser::kPreParseSuccess, result); 1349 CHECK_EQ(i::PreParser::kPreParseSuccess, result);
1342 } 1350 }
1343 1351
(...skipping 1813 matching lines...) Expand 10 before | Expand all | Expand 10 after
3157 i::ScopedVector<char> program(Utf8LengthHelper(src) + 1); 3165 i::ScopedVector<char> program(Utf8LengthHelper(src) + 1);
3158 i::SNPrintF(program, "%s", src); 3166 i::SNPrintF(program, "%s", src);
3159 i::Handle<i::String> source = factory->InternalizeUtf8String(program.start()); 3167 i::Handle<i::String> source = factory->InternalizeUtf8String(program.start());
3160 source->PrintOn(stdout); 3168 source->PrintOn(stdout);
3161 printf("\n"); 3169 printf("\n");
3162 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); 3170 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
3163 v8::Local<v8::Value> v = CompileRun(src); 3171 v8::Local<v8::Value> v = CompileRun(src);
3164 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v); 3172 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v);
3165 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o); 3173 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o);
3166 i::Context* context = f->context(); 3174 i::Context* context = f->context();
3167 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed()); 3175 i::AstValueFactory avf(&zone, isolate->ast_string_constants(),
3176 isolate->heap()->HashSeed());
3168 const i::AstRawString* name = avf.GetOneByteString("result"); 3177 const i::AstRawString* name = avf.GetOneByteString("result");
3169 avf.Internalize(isolate); 3178 avf.Internalize(isolate);
3170 i::Handle<i::String> str = name->string(); 3179 i::Handle<i::String> str = name->string();
3171 CHECK(str->IsInternalizedString()); 3180 CHECK(str->IsInternalizedString());
3172 i::DeclarationScope* script_scope = 3181 i::DeclarationScope* script_scope =
3173 new (&zone) i::DeclarationScope(&zone, &avf); 3182 new (&zone) i::DeclarationScope(&zone, &avf);
3174 i::Scope* s = i::Scope::DeserializeScopeChain( 3183 i::Scope* s = i::Scope::DeserializeScopeChain(
3175 isolate, &zone, context->scope_info(), script_scope, &avf, 3184 isolate, &zone, context->scope_info(), script_scope, &avf,
3176 i::Scope::DeserializationMode::kIncludingVariables); 3185 i::Scope::DeserializationMode::kIncludingVariables);
3177 CHECK(s != script_scope); 3186 CHECK(s != script_scope);
(...skipping 28 matching lines...) Expand all
3206 i::ScopedVector<char> program(Utf8LengthHelper(src) + 1); 3215 i::ScopedVector<char> program(Utf8LengthHelper(src) + 1);
3207 i::SNPrintF(program, "%s", src); 3216 i::SNPrintF(program, "%s", src);
3208 i::Handle<i::String> source = factory->InternalizeUtf8String(program.start()); 3217 i::Handle<i::String> source = factory->InternalizeUtf8String(program.start());
3209 source->PrintOn(stdout); 3218 source->PrintOn(stdout);
3210 printf("\n"); 3219 printf("\n");
3211 i::Zone zone(isolate->allocator(), ZONE_NAME); 3220 i::Zone zone(isolate->allocator(), ZONE_NAME);
3212 v8::Local<v8::Value> v = CompileRun(src); 3221 v8::Local<v8::Value> v = CompileRun(src);
3213 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v); 3222 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v);
3214 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o); 3223 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o);
3215 i::Context* context = f->context(); 3224 i::Context* context = f->context();
3216 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed()); 3225 i::AstValueFactory avf(&zone, isolate->ast_string_constants(),
3226 isolate->heap()->HashSeed());
3217 const i::AstRawString* name_x = avf.GetOneByteString("x"); 3227 const i::AstRawString* name_x = avf.GetOneByteString("x");
3218 avf.Internalize(isolate); 3228 avf.Internalize(isolate);
3219 3229
3220 i::DeclarationScope* script_scope = 3230 i::DeclarationScope* script_scope =
3221 new (&zone) i::DeclarationScope(&zone, &avf); 3231 new (&zone) i::DeclarationScope(&zone, &avf);
3222 i::Scope* s = i::Scope::DeserializeScopeChain( 3232 i::Scope* s = i::Scope::DeserializeScopeChain(
3223 isolate, &zone, context->scope_info(), script_scope, &avf, 3233 isolate, &zone, context->scope_info(), script_scope, &avf,
3224 i::Scope::DeserializationMode::kIncludingVariables); 3234 i::Scope::DeserializationMode::kIncludingVariables);
3225 CHECK(s != script_scope); 3235 CHECK(s != script_scope);
3226 3236
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
3502 bool is_maybe_assigned = var->maybe_assigned() == i::kMaybeAssigned; 3512 bool is_maybe_assigned = var->maybe_assigned() == i::kMaybeAssigned;
3503 CHECK_EQ(is_maybe_assigned, assigned); 3513 CHECK_EQ(is_maybe_assigned, assigned);
3504 } 3514 }
3505 } 3515 }
3506 } 3516 }
3507 3517
3508 namespace { 3518 namespace {
3509 3519
3510 i::Scope* DeserializeFunctionScope(i::Isolate* isolate, i::Zone* zone, 3520 i::Scope* DeserializeFunctionScope(i::Isolate* isolate, i::Zone* zone,
3511 i::Handle<i::JSObject> m, const char* name) { 3521 i::Handle<i::JSObject> m, const char* name) {
3512 i::AstValueFactory avf(zone, isolate->heap()->HashSeed()); 3522 i::AstValueFactory avf(zone, isolate->ast_string_constants(),
3523 isolate->heap()->HashSeed());
3513 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast( 3524 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(
3514 i::JSReceiver::GetProperty(isolate, m, name).ToHandleChecked()); 3525 i::JSReceiver::GetProperty(isolate, m, name).ToHandleChecked());
3515 i::DeclarationScope* script_scope = 3526 i::DeclarationScope* script_scope =
3516 new (zone) i::DeclarationScope(zone, &avf); 3527 new (zone) i::DeclarationScope(zone, &avf);
3517 i::Scope* s = i::Scope::DeserializeScopeChain( 3528 i::Scope* s = i::Scope::DeserializeScopeChain(
3518 isolate, zone, f->context()->scope_info(), script_scope, &avf, 3529 isolate, zone, f->context()->scope_info(), script_scope, &avf,
3519 i::Scope::DeserializationMode::kIncludingVariables); 3530 i::Scope::DeserializationMode::kIncludingVariables);
3520 return s; 3531 return s;
3521 } 3532 }
3522 3533
(...skipping 5335 matching lines...) Expand 10 before | Expand all | Expand 10 after
8858 DCHECK_NOT_NULL(scope); 8869 DCHECK_NOT_NULL(scope);
8859 DCHECK_NULL(scope->sibling()); 8870 DCHECK_NULL(scope->sibling());
8860 DCHECK(scope->is_function_scope()); 8871 DCHECK(scope->is_function_scope());
8861 const i::AstRawString* var_name = 8872 const i::AstRawString* var_name =
8862 info.ast_value_factory()->GetOneByteString("my_var"); 8873 info.ast_value_factory()->GetOneByteString("my_var");
8863 i::Variable* var = scope->Lookup(var_name); 8874 i::Variable* var = scope->Lookup(var_name);
8864 CHECK_EQ(inners[i].ctxt_allocate, 8875 CHECK_EQ(inners[i].ctxt_allocate,
8865 i::ScopeTestHelper::MustAllocateInContext(var)); 8876 i::ScopeTestHelper::MustAllocateInContext(var));
8866 } 8877 }
8867 } 8878 }
OLDNEW
« no previous file with comments | « test/cctest/test-ast.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698