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

Unified Diff: src/parser.cc

Issue 379893002: Clean up and update const / var (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comment Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.cc ('k') | src/runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index f37eae5d379156947d316b44ae9da162f558f812..3f35930248f6664bce89a433ac2e7d7e1e278612 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -1689,7 +1689,7 @@ void Parser::Declare(Declaration* declaration, bool resolve, bool* ok) {
// same variable if it is declared several times. This is not a
// semantic issue as long as we keep the source order, but it may be
// a performance issue since it may lead to repeated
- // RuntimeHidden_DeclareContextSlot calls.
+ // RuntimeHidden_DeclareLookupSlot calls.
declaration_scope->AddDeclaration(declaration);
if (mode == CONST_LEGACY && declaration_scope->is_global_scope()) {
@@ -1703,7 +1703,7 @@ void Parser::Declare(Declaration* declaration, bool resolve, bool* ok) {
declaration_scope->strict_mode() == SLOPPY) {
// For variable declarations in a sloppy eval scope the proxy is bound
// to a lookup variable to force a dynamic declaration using the
- // DeclareContextSlot runtime function.
+ // DeclareLookupSlot runtime function.
Variable::Kind kind = Variable::NORMAL;
var = new(zone()) Variable(
declaration_scope, name, mode, true, kind,
@@ -2186,21 +2186,22 @@ Block* Parser::ParseVariableDeclarations(
if (value != NULL && !inside_with()) {
arguments->Add(value, zone());
value = NULL; // zap the value to avoid the unnecessary assignment
+ // Construct the call to Runtime_InitializeVarGlobal
+ // and add it to the initialization statement block.
+ initialize = factory()->NewCallRuntime(
+ ast_value_factory_->initialize_var_global_string(),
+ Runtime::FunctionForId(Runtime::kInitializeVarGlobal), arguments,
+ pos);
+ } else {
+ initialize = NULL;
}
-
- // Construct the call to Runtime_InitializeVarGlobal
- // and add it to the initialization statement block.
- // Note that the function does different things depending on
- // the number of arguments (2 or 3).
- initialize = factory()->NewCallRuntime(
- ast_value_factory_->initialize_var_global_string(),
- Runtime::FunctionForId(Runtime::kInitializeVarGlobal),
- arguments, pos);
}
- block->AddStatement(
- factory()->NewExpressionStatement(initialize, RelocInfo::kNoPosition),
- zone());
+ if (initialize != NULL) {
+ block->AddStatement(factory()->NewExpressionStatement(
+ initialize, RelocInfo::kNoPosition),
+ zone());
+ }
} else if (needs_init) {
// Constant initializations always assign to the declared constant which
// is always at the function scope level. This is only relevant for
« no previous file with comments | « src/objects.cc ('k') | src/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698