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

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

Issue 868883002: Remove the dependency of Zone on Isolate (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix compilation issues Created 5 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-liveedit.cc ('k') | test/cctest/test-regexp.cc » ('j') | 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 CcTest::i_isolate()->stack_guard()->SetStackLimit( 150 CcTest::i_isolate()->stack_guard()->SetStackLimit(
151 i::GetCurrentStackPosition() - 128 * 1024); 151 i::GetCurrentStackPosition() - 128 * 1024);
152 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); 152 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit();
153 for (int i = 0; tests[i]; i++) { 153 for (int i = 0; tests[i]; i++) {
154 const i::byte* source = 154 const i::byte* source =
155 reinterpret_cast<const i::byte*>(tests[i]); 155 reinterpret_cast<const i::byte*>(tests[i]);
156 i::Utf8ToUtf16CharacterStream stream(source, i::StrLength(tests[i])); 156 i::Utf8ToUtf16CharacterStream stream(source, i::StrLength(tests[i]));
157 i::CompleteParserRecorder log; 157 i::CompleteParserRecorder log;
158 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); 158 i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
159 scanner.Initialize(&stream); 159 scanner.Initialize(&stream);
160 i::PreParser preparser(&scanner, &log, stack_limit); 160 i::PreParser preparser(CcTest::i_isolate(), &scanner, &log, stack_limit);
161 preparser.set_allow_lazy(true); 161 preparser.set_allow_lazy(true);
162 i::PreParser::PreParseResult result = preparser.PreParseProgram(); 162 i::PreParser::PreParseResult result = preparser.PreParseProgram();
163 CHECK_EQ(i::PreParser::kPreParseSuccess, result); 163 CHECK_EQ(i::PreParser::kPreParseSuccess, result);
164 CHECK(!log.HasError()); 164 CHECK(!log.HasError());
165 } 165 }
166 166
167 for (int i = 0; fail_tests[i]; i++) { 167 for (int i = 0; fail_tests[i]; i++) {
168 const i::byte* source = 168 const i::byte* source =
169 reinterpret_cast<const i::byte*>(fail_tests[i]); 169 reinterpret_cast<const i::byte*>(fail_tests[i]);
170 i::Utf8ToUtf16CharacterStream stream(source, i::StrLength(fail_tests[i])); 170 i::Utf8ToUtf16CharacterStream stream(source, i::StrLength(fail_tests[i]));
171 i::CompleteParserRecorder log; 171 i::CompleteParserRecorder log;
172 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); 172 i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
173 scanner.Initialize(&stream); 173 scanner.Initialize(&stream);
174 i::PreParser preparser(&scanner, &log, stack_limit); 174 i::PreParser preparser(CcTest::i_isolate(), &scanner, &log, stack_limit);
175 preparser.set_allow_lazy(true); 175 preparser.set_allow_lazy(true);
176 i::PreParser::PreParseResult result = preparser.PreParseProgram(); 176 i::PreParser::PreParseResult result = preparser.PreParseProgram();
177 // Even in the case of a syntax error, kPreParseSuccess is returned. 177 // Even in the case of a syntax error, kPreParseSuccess is returned.
178 CHECK_EQ(i::PreParser::kPreParseSuccess, result); 178 CHECK_EQ(i::PreParser::kPreParseSuccess, result);
179 CHECK(log.HasError()); 179 CHECK(log.HasError());
180 } 180 }
181 } 181 }
182 182
183 183
184 class ScriptResource : public v8::String::ExternalOneByteStringResource { 184 class ScriptResource : public v8::String::ExternalOneByteStringResource {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); 310 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit();
311 for (int i = 0; programs[i]; i++) { 311 for (int i = 0; programs[i]; i++) {
312 const char* program = programs[i]; 312 const char* program = programs[i];
313 i::Utf8ToUtf16CharacterStream stream( 313 i::Utf8ToUtf16CharacterStream stream(
314 reinterpret_cast<const i::byte*>(program), 314 reinterpret_cast<const i::byte*>(program),
315 static_cast<unsigned>(strlen(program))); 315 static_cast<unsigned>(strlen(program)));
316 i::CompleteParserRecorder log; 316 i::CompleteParserRecorder log;
317 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); 317 i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
318 scanner.Initialize(&stream); 318 scanner.Initialize(&stream);
319 319
320 i::PreParser preparser(&scanner, &log, stack_limit); 320 i::PreParser preparser(CcTest::i_isolate(), &scanner, &log, stack_limit);
321 preparser.set_allow_lazy(true); 321 preparser.set_allow_lazy(true);
322 preparser.set_allow_natives(true); 322 preparser.set_allow_natives(true);
323 preparser.set_allow_harmony_arrow_functions(true); 323 preparser.set_allow_harmony_arrow_functions(true);
324 i::PreParser::PreParseResult result = preparser.PreParseProgram(); 324 i::PreParser::PreParseResult result = preparser.PreParseProgram();
325 CHECK_EQ(i::PreParser::kPreParseSuccess, result); 325 CHECK_EQ(i::PreParser::kPreParseSuccess, result);
326 CHECK(!log.HasError()); 326 CHECK(!log.HasError());
327 } 327 }
328 } 328 }
329 329
330 330
(...skipping 13 matching lines...) Expand all
344 for (int i = 0; programs[i]; i++) { 344 for (int i = 0; programs[i]; i++) {
345 const char* program = programs[i]; 345 const char* program = programs[i];
346 i::Utf8ToUtf16CharacterStream stream( 346 i::Utf8ToUtf16CharacterStream stream(
347 reinterpret_cast<const i::byte*>(program), 347 reinterpret_cast<const i::byte*>(program),
348 static_cast<unsigned>(strlen(program))); 348 static_cast<unsigned>(strlen(program)));
349 i::CompleteParserRecorder log; 349 i::CompleteParserRecorder log;
350 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); 350 i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
351 scanner.Initialize(&stream); 351 scanner.Initialize(&stream);
352 352
353 // Preparser defaults to disallowing natives syntax. 353 // Preparser defaults to disallowing natives syntax.
354 i::PreParser preparser(&scanner, &log, stack_limit); 354 i::PreParser preparser(CcTest::i_isolate(), &scanner, &log, stack_limit);
355 preparser.set_allow_lazy(true); 355 preparser.set_allow_lazy(true);
356 i::PreParser::PreParseResult result = preparser.PreParseProgram(); 356 i::PreParser::PreParseResult result = preparser.PreParseProgram();
357 CHECK_EQ(i::PreParser::kPreParseSuccess, result); 357 CHECK_EQ(i::PreParser::kPreParseSuccess, result);
358 CHECK(log.HasError()); 358 CHECK(log.HasError());
359 } 359 }
360 } 360 }
361 361
362 362
363 TEST(PreparsingObjectLiterals) { 363 TEST(PreparsingObjectLiterals) {
364 // Regression test for a bug where the symbol stream produced by PreParser 364 // Regression test for a bug where the symbol stream produced by PreParser
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 // Before fix, didn't check *ok after Expect(Token::Identifier, ok), 409 // Before fix, didn't check *ok after Expect(Token::Identifier, ok),
410 // and then used the invalid currently scanned literal. This always 410 // and then used the invalid currently scanned literal. This always
411 // failed in debug mode, and sometimes crashed in release mode. 411 // failed in debug mode, and sometimes crashed in release mode.
412 412
413 i::Utf8ToUtf16CharacterStream stream( 413 i::Utf8ToUtf16CharacterStream stream(
414 reinterpret_cast<const i::byte*>(program), 414 reinterpret_cast<const i::byte*>(program),
415 static_cast<unsigned>(strlen(program))); 415 static_cast<unsigned>(strlen(program)));
416 i::CompleteParserRecorder log; 416 i::CompleteParserRecorder log;
417 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); 417 i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
418 scanner.Initialize(&stream); 418 scanner.Initialize(&stream);
419 i::PreParser preparser(&scanner, &log, 419 i::PreParser preparser(CcTest::i_isolate(), &scanner, &log,
420 CcTest::i_isolate()->stack_guard()->real_climit()); 420 CcTest::i_isolate()->stack_guard()->real_climit());
421 preparser.set_allow_lazy(true); 421 preparser.set_allow_lazy(true);
422 i::PreParser::PreParseResult result = preparser.PreParseProgram(); 422 i::PreParser::PreParseResult result = preparser.PreParseProgram();
423 // Even in the case of a syntax error, kPreParseSuccess is returned. 423 // Even in the case of a syntax error, kPreParseSuccess is returned.
424 CHECK_EQ(i::PreParser::kPreParseSuccess, result); 424 CHECK_EQ(i::PreParser::kPreParseSuccess, result);
425 CHECK(log.HasError()); 425 CHECK(log.HasError());
426 } 426 }
427 427
428 428
429 TEST(Regress928) { 429 TEST(Regress928) {
(...skipping 11 matching lines...) Expand all
441 const char* program = 441 const char* program =
442 "try { } catch (e) { var foo = function () { /* first */ } }" 442 "try { } catch (e) { var foo = function () { /* first */ } }"
443 "var bar = function () { /* second */ }"; 443 "var bar = function () { /* second */ }";
444 444
445 v8::HandleScope handles(CcTest::isolate()); 445 v8::HandleScope handles(CcTest::isolate());
446 i::Handle<i::String> source = factory->NewStringFromAsciiChecked(program); 446 i::Handle<i::String> source = factory->NewStringFromAsciiChecked(program);
447 i::GenericStringUtf16CharacterStream stream(source, 0, source->length()); 447 i::GenericStringUtf16CharacterStream stream(source, 0, source->length());
448 i::CompleteParserRecorder log; 448 i::CompleteParserRecorder log;
449 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); 449 i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
450 scanner.Initialize(&stream); 450 scanner.Initialize(&stream);
451 i::PreParser preparser(&scanner, &log, 451 i::PreParser preparser(CcTest::i_isolate(), &scanner, &log,
452 CcTest::i_isolate()->stack_guard()->real_climit()); 452 CcTest::i_isolate()->stack_guard()->real_climit());
453 preparser.set_allow_lazy(true); 453 preparser.set_allow_lazy(true);
454 i::PreParser::PreParseResult result = preparser.PreParseProgram(); 454 i::PreParser::PreParseResult result = preparser.PreParseProgram();
455 CHECK_EQ(i::PreParser::kPreParseSuccess, result); 455 CHECK_EQ(i::PreParser::kPreParseSuccess, result);
456 i::ScriptData* sd = log.GetScriptData(); 456 i::ScriptData* sd = log.GetScriptData();
457 i::ParseData* pd = i::ParseData::FromCachedData(sd); 457 i::ParseData* pd = i::ParseData::FromCachedData(sd);
458 pd->Initialize(); 458 pd->Initialize();
459 459
460 int first_function = 460 int first_function =
461 static_cast<int>(strstr(program, "function") - program); 461 static_cast<int>(strstr(program, "function") - program);
(...skipping 28 matching lines...) Expand all
490 490
491 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); 491 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit();
492 492
493 i::Utf8ToUtf16CharacterStream stream( 493 i::Utf8ToUtf16CharacterStream stream(
494 reinterpret_cast<const i::byte*>(program.get()), 494 reinterpret_cast<const i::byte*>(program.get()),
495 static_cast<unsigned>(kProgramSize)); 495 static_cast<unsigned>(kProgramSize));
496 i::CompleteParserRecorder log; 496 i::CompleteParserRecorder log;
497 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); 497 i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
498 scanner.Initialize(&stream); 498 scanner.Initialize(&stream);
499 499
500 i::PreParser preparser(&scanner, &log, stack_limit); 500 i::PreParser preparser(CcTest::i_isolate(), &scanner, &log, stack_limit);
501 preparser.set_allow_lazy(true); 501 preparser.set_allow_lazy(true);
502 preparser.set_allow_harmony_arrow_functions(true); 502 preparser.set_allow_harmony_arrow_functions(true);
503 i::PreParser::PreParseResult result = preparser.PreParseProgram(); 503 i::PreParser::PreParseResult result = preparser.PreParseProgram();
504 CHECK_EQ(i::PreParser::kPreParseStackOverflow, result); 504 CHECK_EQ(i::PreParser::kPreParseStackOverflow, result);
505 } 505 }
506 506
507 507
508 class TestExternalResource: public v8::String::ExternalStringResource { 508 class TestExternalResource: public v8::String::ExternalStringResource {
509 public: 509 public:
510 explicit TestExternalResource(uint16_t* data, int length) 510 explicit TestExternalResource(uint16_t* data, int length)
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 reinterpret_cast<const i::byte*>(re_source), 798 reinterpret_cast<const i::byte*>(re_source),
799 static_cast<unsigned>(strlen(re_source))); 799 static_cast<unsigned>(strlen(re_source)));
800 i::HandleScope scope(CcTest::i_isolate()); 800 i::HandleScope scope(CcTest::i_isolate());
801 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); 801 i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
802 scanner.Initialize(&stream); 802 scanner.Initialize(&stream);
803 803
804 i::Token::Value start = scanner.peek(); 804 i::Token::Value start = scanner.peek();
805 CHECK(start == i::Token::DIV || start == i::Token::ASSIGN_DIV); 805 CHECK(start == i::Token::DIV || start == i::Token::ASSIGN_DIV);
806 CHECK(scanner.ScanRegExpPattern(start == i::Token::ASSIGN_DIV)); 806 CHECK(scanner.ScanRegExpPattern(start == i::Token::ASSIGN_DIV));
807 scanner.Next(); // Current token is now the regexp literal. 807 scanner.Next(); // Current token is now the regexp literal.
808 i::Zone zone(CcTest::i_isolate()); 808 i::Zone zone;
809 i::AstValueFactory ast_value_factory(&zone, 809 i::AstValueFactory ast_value_factory(&zone,
810 CcTest::i_isolate()->heap()->HashSeed()); 810 CcTest::i_isolate()->heap()->HashSeed());
811 ast_value_factory.Internalize(CcTest::i_isolate()); 811 ast_value_factory.Internalize(CcTest::i_isolate());
812 i::Handle<i::String> val = 812 i::Handle<i::String> val =
813 scanner.CurrentSymbol(&ast_value_factory)->string(); 813 scanner.CurrentSymbol(&ast_value_factory)->string();
814 i::DisallowHeapAllocation no_alloc; 814 i::DisallowHeapAllocation no_alloc;
815 i::String::FlatContent content = val->GetFlatContent(); 815 i::String::FlatContent content = val->GetFlatContent();
816 CHECK(content.IsOneByte()); 816 CHECK(content.IsOneByte());
817 i::Vector<const uint8_t> actual = content.ToOneByteVector(); 817 i::Vector<const uint8_t> actual = content.ToOneByteVector();
818 for (int i = 0; i < actual.length(); i++) { 818 for (int i = 0; i < actual.length(); i++) {
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 1399
1400 uintptr_t stack_limit = isolate->stack_guard()->real_climit(); 1400 uintptr_t stack_limit = isolate->stack_guard()->real_climit();
1401 int preparser_materialized_literals = -1; 1401 int preparser_materialized_literals = -1;
1402 int parser_materialized_literals = -2; 1402 int parser_materialized_literals = -2;
1403 1403
1404 // Preparse the data. 1404 // Preparse the data.
1405 i::CompleteParserRecorder log; 1405 i::CompleteParserRecorder log;
1406 { 1406 {
1407 i::Scanner scanner(isolate->unicode_cache()); 1407 i::Scanner scanner(isolate->unicode_cache());
1408 i::GenericStringUtf16CharacterStream stream(source, 0, source->length()); 1408 i::GenericStringUtf16CharacterStream stream(source, 0, source->length());
1409 i::PreParser preparser(&scanner, &log, stack_limit); 1409 i::PreParser preparser(CcTest::i_isolate(), &scanner, &log, stack_limit);
1410 SetParserFlags(&preparser, flags); 1410 SetParserFlags(&preparser, flags);
1411 scanner.Initialize(&stream); 1411 scanner.Initialize(&stream);
1412 i::PreParser::PreParseResult result = preparser.PreParseProgram( 1412 i::PreParser::PreParseResult result = preparser.PreParseProgram(
1413 &preparser_materialized_literals); 1413 &preparser_materialized_literals);
1414 CHECK_EQ(i::PreParser::kPreParseSuccess, result); 1414 CHECK_EQ(i::PreParser::kPreParseSuccess, result);
1415 } 1415 }
1416 1416
1417 bool preparse_error = log.HasError(); 1417 bool preparse_error = log.HasError();
1418 1418
1419 // Parse the data 1419 // Parse the data
(...skipping 1669 matching lines...) Expand 10 before | Expand all | Expand 10 after
3089 " assertResult([2]);" 3089 " assertResult([2]);"
3090 " return f;" 3090 " return f;"
3091 "};" 3091 "};"
3092 "h();"; 3092 "h();";
3093 3093
3094 i::ScopedVector<char> program(Utf8LengthHelper(src) + 1); 3094 i::ScopedVector<char> program(Utf8LengthHelper(src) + 1);
3095 i::SNPrintF(program, "%s", src); 3095 i::SNPrintF(program, "%s", src);
3096 i::Handle<i::String> source = factory->InternalizeUtf8String(program.start()); 3096 i::Handle<i::String> source = factory->InternalizeUtf8String(program.start());
3097 source->PrintOn(stdout); 3097 source->PrintOn(stdout);
3098 printf("\n"); 3098 printf("\n");
3099 i::Zone zone(isolate); 3099 i::Zone zone;
3100 v8::Local<v8::Value> v = CompileRun(src); 3100 v8::Local<v8::Value> v = CompileRun(src);
3101 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v); 3101 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v);
3102 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o); 3102 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o);
3103 i::Context* context = f->context(); 3103 i::Context* context = f->context();
3104 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed()); 3104 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed());
3105 avf.Internalize(isolate); 3105 avf.Internalize(isolate);
3106 const i::AstRawString* name = avf.GetOneByteString("result"); 3106 const i::AstRawString* name = avf.GetOneByteString("result");
3107 i::Handle<i::String> str = name->string(); 3107 i::Handle<i::String> str = name->string();
3108 CHECK(str->IsInternalizedString()); 3108 CHECK(str->IsInternalizedString());
3109 i::Scope* script_scope = 3109 i::Scope* script_scope =
3110 new (&zone) i::Scope(NULL, i::SCRIPT_SCOPE, &avf, &zone); 3110 new (&zone) i::Scope(isolate, &zone, NULL, i::SCRIPT_SCOPE, &avf);
3111 script_scope->Initialize(); 3111 script_scope->Initialize();
3112 i::Scope* s = i::Scope::DeserializeScopeChain(context, script_scope, &zone); 3112 i::Scope* s =
3113 i::Scope::DeserializeScopeChain(isolate, &zone, context, script_scope);
3113 DCHECK(s != script_scope); 3114 DCHECK(s != script_scope);
3114 DCHECK(name != NULL); 3115 DCHECK(name != NULL);
3115 3116
3116 // Get result from h's function context (that is f's context) 3117 // Get result from h's function context (that is f's context)
3117 i::Variable* var = s->Lookup(name); 3118 i::Variable* var = s->Lookup(name);
3118 3119
3119 CHECK(var != NULL); 3120 CHECK(var != NULL);
3120 // Maybe assigned should survive deserialization 3121 // Maybe assigned should survive deserialization
3121 CHECK(var->maybe_assigned() == i::kMaybeAssigned); 3122 CHECK(var->maybe_assigned() == i::kMaybeAssigned);
3122 // TODO(sigurds) Figure out if is_used should survive context serialization. 3123 // TODO(sigurds) Figure out if is_used should survive context serialization.
(...skipping 15 matching lines...) Expand all
3138 " };" 3139 " };"
3139 " return g;" 3140 " return g;"
3140 " }" 3141 " }"
3141 "f(0);"; 3142 "f(0);";
3142 3143
3143 i::ScopedVector<char> program(Utf8LengthHelper(src) + 1); 3144 i::ScopedVector<char> program(Utf8LengthHelper(src) + 1);
3144 i::SNPrintF(program, "%s", src); 3145 i::SNPrintF(program, "%s", src);
3145 i::Handle<i::String> source = factory->InternalizeUtf8String(program.start()); 3146 i::Handle<i::String> source = factory->InternalizeUtf8String(program.start());
3146 source->PrintOn(stdout); 3147 source->PrintOn(stdout);
3147 printf("\n"); 3148 printf("\n");
3148 i::Zone zone(isolate); 3149 i::Zone zone;
3149 v8::Local<v8::Value> v = CompileRun(src); 3150 v8::Local<v8::Value> v = CompileRun(src);
3150 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v); 3151 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v);
3151 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o); 3152 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o);
3152 i::Context* context = f->context(); 3153 i::Context* context = f->context();
3153 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed()); 3154 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed());
3154 avf.Internalize(isolate); 3155 avf.Internalize(isolate);
3155 3156
3156 i::Scope* script_scope = 3157 i::Scope* script_scope =
3157 new (&zone) i::Scope(NULL, i::SCRIPT_SCOPE, &avf, &zone); 3158 new (&zone) i::Scope(isolate, &zone, NULL, i::SCRIPT_SCOPE, &avf);
3158 script_scope->Initialize(); 3159 script_scope->Initialize();
3159 i::Scope* s = i::Scope::DeserializeScopeChain(context, script_scope, &zone); 3160 i::Scope* s =
3161 i::Scope::DeserializeScopeChain(isolate, &zone, context, script_scope);
3160 DCHECK(s != script_scope); 3162 DCHECK(s != script_scope);
3161 const i::AstRawString* name_x = avf.GetOneByteString("x"); 3163 const i::AstRawString* name_x = avf.GetOneByteString("x");
3162 3164
3163 // Get result from f's function context (that is g's outer context) 3165 // Get result from f's function context (that is g's outer context)
3164 i::Variable* var_x = s->Lookup(name_x); 3166 i::Variable* var_x = s->Lookup(name_x);
3165 CHECK(var_x != NULL); 3167 CHECK(var_x != NULL);
3166 CHECK(var_x->maybe_assigned() == i::kMaybeAssigned); 3168 CHECK(var_x->maybe_assigned() == i::kMaybeAssigned);
3167 } 3169 }
3168 3170
3169 3171
(...skipping 15 matching lines...) Expand all
3185 " module B {}" 3187 " module B {}"
3186 " export module C {}" 3188 " export module C {}"
3187 "};" 3189 "};"
3188 "A.f"; 3190 "A.f";
3189 3191
3190 i::ScopedVector<char> program(Utf8LengthHelper(src) + 1); 3192 i::ScopedVector<char> program(Utf8LengthHelper(src) + 1);
3191 i::SNPrintF(program, "%s", src); 3193 i::SNPrintF(program, "%s", src);
3192 i::Handle<i::String> source = factory->InternalizeUtf8String(program.start()); 3194 i::Handle<i::String> source = factory->InternalizeUtf8String(program.start());
3193 source->PrintOn(stdout); 3195 source->PrintOn(stdout);
3194 printf("\n"); 3196 printf("\n");
3195 i::Zone zone(isolate); 3197 i::Zone zone;
3196 v8::Local<v8::Value> v = CompileRun(src); 3198 v8::Local<v8::Value> v = CompileRun(src);
3197 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v); 3199 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v);
3198 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o); 3200 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o);
3199 i::Context* context = f->context(); 3201 i::Context* context = f->context();
3200 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed()); 3202 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed());
3201 avf.Internalize(isolate); 3203 avf.Internalize(isolate);
3202 3204
3203 i::Scope* script_scope = 3205 i::Scope* script_scope =
3204 new (&zone) i::Scope(NULL, i::SCRIPT_SCOPE, &avf, &zone); 3206 new (&zone) i::Scope(isolate, &zone, NULL, i::SCRIPT_SCOPE, &avf);
3205 script_scope->Initialize(); 3207 script_scope->Initialize();
3206 i::Scope* s = i::Scope::DeserializeScopeChain(context, script_scope, &zone); 3208 i::Scope* s =
3209 i::Scope::DeserializeScopeChain(isolate, &zone, context, script_scope);
3207 DCHECK(s != script_scope); 3210 DCHECK(s != script_scope);
3208 const i::AstRawString* name_x = avf.GetOneByteString("x"); 3211 const i::AstRawString* name_x = avf.GetOneByteString("x");
3209 const i::AstRawString* name_f = avf.GetOneByteString("f"); 3212 const i::AstRawString* name_f = avf.GetOneByteString("f");
3210 const i::AstRawString* name_y = avf.GetOneByteString("y"); 3213 const i::AstRawString* name_y = avf.GetOneByteString("y");
3211 const i::AstRawString* name_B = avf.GetOneByteString("B"); 3214 const i::AstRawString* name_B = avf.GetOneByteString("B");
3212 const i::AstRawString* name_C = avf.GetOneByteString("C"); 3215 const i::AstRawString* name_C = avf.GetOneByteString("C");
3213 3216
3214 // Get result from h's function context (that is f's context) 3217 // Get result from h's function context (that is f's context)
3215 i::Variable* var_x = s->Lookup(name_x); 3218 i::Variable* var_x = s->Lookup(name_x);
3216 CHECK(var_x != NULL); 3219 CHECK(var_x != NULL);
(...skipping 1441 matching lines...) Expand 10 before | Expand all | Expand 10 after
4658 4661
4659 static const ParserFlag always_flags[] = { 4662 static const ParserFlag always_flags[] = {
4660 kAllowHarmonyClasses, 4663 kAllowHarmonyClasses,
4661 kAllowHarmonyComputedPropertyNames, 4664 kAllowHarmonyComputedPropertyNames,
4662 kAllowHarmonyObjectLiterals, 4665 kAllowHarmonyObjectLiterals,
4663 kAllowHarmonySloppy, 4666 kAllowHarmonySloppy,
4664 }; 4667 };
4665 RunParserSyncTest(context_data, error_data, kError, NULL, 0, 4668 RunParserSyncTest(context_data, error_data, kError, NULL, 0,
4666 always_flags, arraysize(always_flags)); 4669 always_flags, arraysize(always_flags));
4667 } 4670 }
OLDNEW
« no previous file with comments | « test/cctest/test-liveedit.cc ('k') | test/cctest/test-regexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698