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

Side by Side Diff: src/parser.cc

Issue 7792098: Avoid dynamic lookup when initializing let declared variables. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | src/x64/full-codegen-x64.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 1831 matching lines...) Expand 10 before | Expand all | Expand 10 after
1842 new(zone()) CallRuntime( 1842 new(zone()) CallRuntime(
1843 isolate(), 1843 isolate(),
1844 isolate()->factory()->InitializeVarGlobal_symbol(), 1844 isolate()->factory()->InitializeVarGlobal_symbol(),
1845 Runtime::FunctionForId(Runtime::kInitializeVarGlobal), 1845 Runtime::FunctionForId(Runtime::kInitializeVarGlobal),
1846 arguments); 1846 arguments);
1847 } 1847 }
1848 1848
1849 block->AddStatement(new(zone()) ExpressionStatement(initialize)); 1849 block->AddStatement(new(zone()) ExpressionStatement(initialize));
1850 } 1850 }
1851 1851
1852 // Add an assignment node to the initialization statement block if 1852 // Add an assignment node to the initialization statement block if we still
1853 // we still have a pending initialization value. We must distinguish 1853 // have a pending initialization value. We must distinguish between
1854 // between variables and constants: Variable initializations are simply 1854 // different kinds of declarations: 'var' initializations are simply
1855 // assignments (with all the consequences if they are inside a 'with' 1855 // assignments (with all the consequences if they are inside a 'with'
1856 // statement - they may change a 'with' object property). Constant 1856 // statement - they may change a 'with' object property). Constant
1857 // initializations always assign to the declared constant which is 1857 // initializations always assign to the declared constant which is
1858 // always at the function scope level. This is only relevant for 1858 // always at the function scope level. This is only relevant for
1859 // dynamically looked-up variables and constants (the start context 1859 // dynamically looked-up variables and constants (the start context
1860 // for constant lookups is always the function context, while it is 1860 // for constant lookups is always the function context, while it is
1861 // the top context for variables). Sigh... 1861 // the top context for var declared variables). Sigh...
1862 // For 'let' declared variables the initialization is in the same scope
1863 // as the declaration. Thus dynamic lookups are unnecessary even if the
1864 // block scope is inside a with.
1862 if (value != NULL) { 1865 if (value != NULL) {
1863 bool in_with = is_const ? false : inside_with(); 1866 bool in_with = mode == Variable::VAR ? inside_with() : false;
1864 VariableProxy* proxy = 1867 VariableProxy* proxy =
1865 initialization_scope->NewUnresolved(name, in_with); 1868 initialization_scope->NewUnresolved(name, in_with);
1866 Assignment* assignment = 1869 Assignment* assignment =
1867 new(zone()) Assignment(isolate(), init_op, proxy, value, position); 1870 new(zone()) Assignment(isolate(), init_op, proxy, value, position);
1868 if (block) { 1871 if (block) {
1869 block->AddStatement(new(zone()) ExpressionStatement(assignment)); 1872 block->AddStatement(new(zone()) ExpressionStatement(assignment));
1870 } 1873 }
1871 } 1874 }
1872 1875
1873 if (fni_ != NULL) fni_->Leave(); 1876 if (fni_ != NULL) fni_->Leave();
(...skipping 3366 matching lines...) Expand 10 before | Expand all | Expand 10 after
5240 result = parser.ParseProgram(source, 5243 result = parser.ParseProgram(source,
5241 info->is_global(), 5244 info->is_global(),
5242 info->StrictMode()); 5245 info->StrictMode());
5243 } 5246 }
5244 } 5247 }
5245 info->SetFunction(result); 5248 info->SetFunction(result);
5246 return (result != NULL); 5249 return (result != NULL);
5247 } 5250 }
5248 5251
5249 } } // namespace v8::internal 5252 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698