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

Side by Side Diff: src/parser.cc

Issue 10698032: Fix lazy parsing heuristics to respect outer scope. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-crbug-135008.js » ('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 4503 matching lines...) Expand 10 before | Expand all | Expand 10 after
4514 VariableProxy* proxy = factory()->NewVariableProxy(fvar); 4514 VariableProxy* proxy = factory()->NewVariableProxy(fvar);
4515 VariableDeclaration* fvar_declaration = 4515 VariableDeclaration* fvar_declaration =
4516 factory()->NewVariableDeclaration(proxy, fvar_mode, top_scope_); 4516 factory()->NewVariableDeclaration(proxy, fvar_mode, top_scope_);
4517 top_scope_->DeclareFunctionVar(fvar_declaration); 4517 top_scope_->DeclareFunctionVar(fvar_declaration);
4518 } 4518 }
4519 4519
4520 // Determine whether the function will be lazily compiled. 4520 // Determine whether the function will be lazily compiled.
4521 // The heuristics are: 4521 // The heuristics are:
4522 // - It must not have been prohibited by the caller to Parse (some callers 4522 // - It must not have been prohibited by the caller to Parse (some callers
4523 // need a full AST). 4523 // need a full AST).
4524 // - The outer scope must allow lazy compilation of inner functions.
4524 // - The function mustn't be a function expression with an open parenthesis 4525 // - The function mustn't be a function expression with an open parenthesis
4525 // before; we consider that a hint that the function will be called 4526 // before; we consider that a hint that the function will be called
4526 // immediately, and it would be a waste of time to make it lazily 4527 // immediately, and it would be a waste of time to make it lazily
4527 // compiled. 4528 // compiled.
4528 // These are all things we can know at this point, without looking at the 4529 // These are all things we can know at this point, without looking at the
4529 // function itself. 4530 // function itself.
4530 bool is_lazily_compiled = (mode() == PARSE_LAZILY && 4531 bool is_lazily_compiled = (mode() == PARSE_LAZILY &&
4532 top_scope_->AllowsLazyCompilation() &&
4531 !parenthesized_function_); 4533 !parenthesized_function_);
4532 parenthesized_function_ = false; // The bit was set for this function only. 4534 parenthesized_function_ = false; // The bit was set for this function only.
4533 4535
4534 if (is_lazily_compiled) { 4536 if (is_lazily_compiled) {
4535 int function_block_pos = scanner().location().beg_pos; 4537 int function_block_pos = scanner().location().beg_pos;
4536 FunctionEntry entry; 4538 FunctionEntry entry;
4537 if (pre_data_ != NULL) { 4539 if (pre_data_ != NULL) {
4538 // If we have pre_data_, we use it to skip parsing the function body. 4540 // If we have pre_data_, we use it to skip parsing the function body.
4539 // the preparser data contains the information we need to construct the 4541 // the preparser data contains the information we need to construct the
4540 // lazy function. 4542 // lazy function.
(...skipping 1521 matching lines...) Expand 10 before | Expand all | Expand 10 after
6062 ASSERT(info->isolate()->has_pending_exception()); 6064 ASSERT(info->isolate()->has_pending_exception());
6063 } else { 6065 } else {
6064 result = parser.ParseProgram(); 6066 result = parser.ParseProgram();
6065 } 6067 }
6066 } 6068 }
6067 info->SetFunction(result); 6069 info->SetFunction(result);
6068 return (result != NULL); 6070 return (result != NULL);
6069 } 6071 }
6070 6072
6071 } } // namespace v8::internal 6073 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-crbug-135008.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698