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

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

Issue 2198043002: Add a mode to completely deserialize scope chains (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 4 years, 4 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
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 3378 matching lines...) Expand 10 before | Expand all | Expand 10 after
3389 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v); 3389 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v);
3390 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o); 3390 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o);
3391 i::Context* context = f->context(); 3391 i::Context* context = f->context();
3392 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed()); 3392 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed());
3393 avf.Internalize(isolate); 3393 avf.Internalize(isolate);
3394 const i::AstRawString* name = avf.GetOneByteString("result"); 3394 const i::AstRawString* name = avf.GetOneByteString("result");
3395 i::Handle<i::String> str = name->string(); 3395 i::Handle<i::String> str = name->string();
3396 CHECK(str->IsInternalizedString()); 3396 CHECK(str->IsInternalizedString());
3397 i::Scope* script_scope = 3397 i::Scope* script_scope =
3398 new (&zone) i::Scope(&zone, nullptr, i::SCRIPT_SCOPE); 3398 new (&zone) i::Scope(&zone, nullptr, i::SCRIPT_SCOPE);
3399 i::Scope* s = i::Scope::DeserializeScopeChain(isolate, &zone, context, 3399 i::Scope* s = i::Scope::DeserializeScopeChain(
3400 script_scope, &avf); 3400 isolate, &zone, context, script_scope, &avf,
3401 i::Scope::DeserializationMode::kKeepScopeInfo);
3401 CHECK(s != script_scope); 3402 CHECK(s != script_scope);
3402 CHECK(name != NULL); 3403 CHECK(name != NULL);
3403 3404
3404 // Get result from h's function context (that is f's context) 3405 // Get result from h's function context (that is f's context)
3405 i::Variable* var = s->Lookup(name); 3406 i::Variable* var = s->Lookup(name);
3406 3407
3407 CHECK(var != NULL); 3408 CHECK(var != NULL);
3408 // Maybe assigned should survive deserialization 3409 // Maybe assigned should survive deserialization
3409 CHECK(var->maybe_assigned() == i::kMaybeAssigned); 3410 CHECK(var->maybe_assigned() == i::kMaybeAssigned);
3410 // TODO(sigurds) Figure out if is_used should survive context serialization. 3411 // TODO(sigurds) Figure out if is_used should survive context serialization.
(...skipping 25 matching lines...) Expand all
3436 i::Zone zone(CcTest::i_isolate()->allocator()); 3437 i::Zone zone(CcTest::i_isolate()->allocator());
3437 v8::Local<v8::Value> v = CompileRun(src); 3438 v8::Local<v8::Value> v = CompileRun(src);
3438 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v); 3439 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v);
3439 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o); 3440 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o);
3440 i::Context* context = f->context(); 3441 i::Context* context = f->context();
3441 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed()); 3442 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed());
3442 avf.Internalize(isolate); 3443 avf.Internalize(isolate);
3443 3444
3444 i::Scope* script_scope = 3445 i::Scope* script_scope =
3445 new (&zone) i::Scope(&zone, nullptr, i::SCRIPT_SCOPE); 3446 new (&zone) i::Scope(&zone, nullptr, i::SCRIPT_SCOPE);
3446 i::Scope* s = i::Scope::DeserializeScopeChain(isolate, &zone, context, 3447 i::Scope* s = i::Scope::DeserializeScopeChain(
3447 script_scope, &avf); 3448 isolate, &zone, context, script_scope, &avf,
3449 i::Scope::DeserializationMode::kKeepScopeInfo);
3448 CHECK(s != script_scope); 3450 CHECK(s != script_scope);
3449 const i::AstRawString* name_x = avf.GetOneByteString("x"); 3451 const i::AstRawString* name_x = avf.GetOneByteString("x");
3450 3452
3451 // Get result from f's function context (that is g's outer context) 3453 // Get result from f's function context (that is g's outer context)
3452 i::Variable* var_x = s->Lookup(name_x); 3454 i::Variable* var_x = s->Lookup(name_x);
3453 CHECK(var_x != NULL); 3455 CHECK(var_x != NULL);
3454 CHECK(var_x->maybe_assigned() == i::kMaybeAssigned); 3456 CHECK(var_x->maybe_assigned() == i::kMaybeAssigned);
3455 } 3457 }
3456 3458
3457 3459
(...skipping 4528 matching lines...) Expand 10 before | Expand all | Expand 10 after
7986 "(a,);", 7988 "(a,);",
7987 "(a,b,c,);", 7989 "(a,b,c,);",
7988 NULL 7990 NULL
7989 }; 7991 };
7990 // clang-format on 7992 // clang-format on
7991 7993
7992 static const ParserFlag always_flags[] = {kAllowHarmonyTrailingCommas}; 7994 static const ParserFlag always_flags[] = {kAllowHarmonyTrailingCommas};
7993 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, 7995 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
7994 arraysize(always_flags)); 7996 arraysize(always_flags));
7995 } 7997 }
OLDNEW
« no previous file with comments | « src/parsing/parser.cc ('k') | test/unittests/compiler-dispatcher/compiler-dispatcher-job-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698