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

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

Issue 2328593002: [Parser] Don't internalize on-the-fly. (Closed)
Patch Set: Created 4 years, 3 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
« src/parsing/rewriter.cc ('K') | « test/cctest/asmjs/test-asm-typer.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 801 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); 812 i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
813 scanner.Initialize(&stream); 813 scanner.Initialize(&stream);
814 814
815 i::Token::Value start = scanner.peek(); 815 i::Token::Value start = scanner.peek();
816 CHECK(start == i::Token::DIV || start == i::Token::ASSIGN_DIV); 816 CHECK(start == i::Token::DIV || start == i::Token::ASSIGN_DIV);
817 CHECK(scanner.ScanRegExpPattern()); 817 CHECK(scanner.ScanRegExpPattern());
818 scanner.Next(); // Current token is now the regexp literal. 818 scanner.Next(); // Current token is now the regexp literal.
819 i::Zone zone(CcTest::i_isolate()->allocator()); 819 i::Zone zone(CcTest::i_isolate()->allocator());
820 i::AstValueFactory ast_value_factory(&zone, 820 i::AstValueFactory ast_value_factory(&zone,
821 CcTest::i_isolate()->heap()->HashSeed()); 821 CcTest::i_isolate()->heap()->HashSeed());
822 const i::AstRawString* current_symbol =
823 scanner.CurrentSymbol(&ast_value_factory);
822 ast_value_factory.Internalize(CcTest::i_isolate()); 824 ast_value_factory.Internalize(CcTest::i_isolate());
823 i::Handle<i::String> val = 825 i::Handle<i::String> val = current_symbol->string();
824 scanner.CurrentSymbol(&ast_value_factory)->string();
825 i::DisallowHeapAllocation no_alloc; 826 i::DisallowHeapAllocation no_alloc;
826 i::String::FlatContent content = val->GetFlatContent(); 827 i::String::FlatContent content = val->GetFlatContent();
827 CHECK(content.IsOneByte()); 828 CHECK(content.IsOneByte());
828 i::Vector<const uint8_t> actual = content.ToOneByteVector(); 829 i::Vector<const uint8_t> actual = content.ToOneByteVector();
829 for (int i = 0; i < actual.length(); i++) { 830 for (int i = 0; i < actual.length(); i++) {
830 CHECK_NE('\0', expected[i]); 831 CHECK_NE('\0', expected[i]);
831 CHECK_EQ(expected[i], actual[i]); 832 CHECK_EQ(expected[i], actual[i]);
832 } 833 }
833 } 834 }
834 835
(...skipping 2555 matching lines...) Expand 10 before | Expand all | Expand 10 after
3390 i::SNPrintF(program, "%s", src); 3391 i::SNPrintF(program, "%s", src);
3391 i::Handle<i::String> source = factory->InternalizeUtf8String(program.start()); 3392 i::Handle<i::String> source = factory->InternalizeUtf8String(program.start());
3392 source->PrintOn(stdout); 3393 source->PrintOn(stdout);
3393 printf("\n"); 3394 printf("\n");
3394 i::Zone zone(CcTest::i_isolate()->allocator()); 3395 i::Zone zone(CcTest::i_isolate()->allocator());
3395 v8::Local<v8::Value> v = CompileRun(src); 3396 v8::Local<v8::Value> v = CompileRun(src);
3396 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v); 3397 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v);
3397 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o); 3398 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o);
3398 i::Context* context = f->context(); 3399 i::Context* context = f->context();
3399 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed()); 3400 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed());
3401 const i::AstRawString* name = avf.GetOneByteString("result");
3400 avf.Internalize(isolate); 3402 avf.Internalize(isolate);
3401 const i::AstRawString* name = avf.GetOneByteString("result");
3402 i::Handle<i::String> str = name->string(); 3403 i::Handle<i::String> str = name->string();
3403 CHECK(str->IsInternalizedString()); 3404 CHECK(str->IsInternalizedString());
3404 i::DeclarationScope* script_scope = 3405 i::DeclarationScope* script_scope =
3405 new (&zone) i::DeclarationScope(&zone, &avf); 3406 new (&zone) i::DeclarationScope(&zone, &avf);
3406 i::Scope* s = i::Scope::DeserializeScopeChainForTesting( 3407 i::Scope* s = i::Scope::DeserializeScopeChainForTesting(
3407 isolate, &zone, context, script_scope, &avf); 3408 isolate, &zone, context, script_scope, &avf);
3408 CHECK(s != script_scope); 3409 CHECK(s != script_scope);
3409 CHECK(name != NULL); 3410 CHECK(name != NULL);
3410 3411
3411 // Get result from h's function context (that is f's context) 3412 // Get result from h's function context (that is f's context)
(...skipping 27 matching lines...) Expand all
3439 i::SNPrintF(program, "%s", src); 3440 i::SNPrintF(program, "%s", src);
3440 i::Handle<i::String> source = factory->InternalizeUtf8String(program.start()); 3441 i::Handle<i::String> source = factory->InternalizeUtf8String(program.start());
3441 source->PrintOn(stdout); 3442 source->PrintOn(stdout);
3442 printf("\n"); 3443 printf("\n");
3443 i::Zone zone(CcTest::i_isolate()->allocator()); 3444 i::Zone zone(CcTest::i_isolate()->allocator());
3444 v8::Local<v8::Value> v = CompileRun(src); 3445 v8::Local<v8::Value> v = CompileRun(src);
3445 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v); 3446 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v);
3446 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o); 3447 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o);
3447 i::Context* context = f->context(); 3448 i::Context* context = f->context();
3448 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed()); 3449 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed());
3450 const i::AstRawString* name_x = avf.GetOneByteString("x");
3449 avf.Internalize(isolate); 3451 avf.Internalize(isolate);
3450 3452
3451 i::DeclarationScope* script_scope = 3453 i::DeclarationScope* script_scope =
3452 new (&zone) i::DeclarationScope(&zone, &avf); 3454 new (&zone) i::DeclarationScope(&zone, &avf);
3453 i::Scope* s = i::Scope::DeserializeScopeChainForTesting( 3455 i::Scope* s = i::Scope::DeserializeScopeChainForTesting(
3454 isolate, &zone, context, script_scope, &avf); 3456 isolate, &zone, context, script_scope, &avf);
3455 CHECK(s != script_scope); 3457 CHECK(s != script_scope);
3456 const i::AstRawString* name_x = avf.GetOneByteString("x");
3457 3458
3458 // Get result from f's function context (that is g's outer context) 3459 // Get result from f's function context (that is g's outer context)
3459 i::Variable* var_x = s->Lookup(name_x); 3460 i::Variable* var_x = s->Lookup(name_x);
3460 CHECK(var_x != NULL); 3461 CHECK(var_x != NULL);
3461 CHECK(var_x->maybe_assigned() == i::kMaybeAssigned); 3462 CHECK(var_x->maybe_assigned() == i::kMaybeAssigned);
3462 } 3463 }
3463 3464
3464 3465
3465 TEST(InnerAssignment) { 3466 TEST(InnerAssignment) {
3466 i::Isolate* isolate = CcTest::i_isolate(); 3467 i::Isolate* isolate = CcTest::i_isolate();
(...skipping 4879 matching lines...) Expand 10 before | Expand all | Expand 10 after
8346 const char* data[] = { 8347 const char* data[] = {
8347 "const arguments = 1", 8348 "const arguments = 1",
8348 "let arguments", 8349 "let arguments",
8349 "var arguments", 8350 "var arguments",
8350 NULL 8351 NULL
8351 }; 8352 };
8352 // clang-format on 8353 // clang-format on
8353 RunParserSyncTest(context_data, data, kSuccess); 8354 RunParserSyncTest(context_data, data, kSuccess);
8354 } 8355 }
8355 } 8356 }
OLDNEW
« src/parsing/rewriter.cc ('K') | « test/cctest/asmjs/test-asm-typer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698