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

Side by Side Diff: src/scopes.cc

Issue 1093183003: Function scopes only must have a context if they call sloppy eval (Closed) Base URL: https://chromium.googlesource.com/v8/v8@master
Patch Set: Fix ScopeInfo context slot calculation Created 5 years, 8 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
« no previous file with comments | « src/scopeinfo.cc ('k') | test/mjsunit/harmony/regress/regress-4056.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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/bootstrapper.h" 8 #include "src/bootstrapper.h"
9 #include "src/messages.h" 9 #include "src/messages.h"
10 #include "src/parser.h" 10 #include "src/parser.h"
(...skipping 1446 matching lines...) Expand 10 before | Expand all | Expand 10 after
1457 // Allocate variables for this scope. 1457 // Allocate variables for this scope.
1458 // Parameters must be allocated first, if any. 1458 // Parameters must be allocated first, if any.
1459 if (is_function_scope()) AllocateParameterLocals(isolate); 1459 if (is_function_scope()) AllocateParameterLocals(isolate);
1460 AllocateNonParameterLocals(isolate); 1460 AllocateNonParameterLocals(isolate);
1461 1461
1462 // Force allocation of a context for this scope if necessary. For a 'with' 1462 // Force allocation of a context for this scope if necessary. For a 'with'
1463 // scope and for a function scope that makes an 'eval' call we need a context, 1463 // scope and for a function scope that makes an 'eval' call we need a context,
1464 // even if no local variables were statically allocated in the scope. 1464 // even if no local variables were statically allocated in the scope.
1465 // Likewise for modules. 1465 // Likewise for modules.
1466 bool must_have_context = is_with_scope() || is_module_scope() || 1466 bool must_have_context = is_with_scope() || is_module_scope() ||
1467 (is_function_scope() && calls_eval()); 1467 (is_function_scope() && calls_sloppy_eval());
1468 1468
1469 // If we didn't allocate any locals in the local context, then we only 1469 // If we didn't allocate any locals in the local context, then we only
1470 // need the minimal number of slots if we must have a context. 1470 // need the minimal number of slots if we must have a context.
1471 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS && !must_have_context) { 1471 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS && !must_have_context) {
1472 num_heap_slots_ = 0; 1472 num_heap_slots_ = 0;
1473 } 1473 }
1474 1474
1475 // Allocation done. 1475 // Allocation done.
1476 DCHECK(num_heap_slots_ == 0 || num_heap_slots_ >= Context::MIN_CONTEXT_SLOTS); 1476 DCHECK(num_heap_slots_ == 0 || num_heap_slots_ >= Context::MIN_CONTEXT_SLOTS);
1477 } 1477 }
(...skipping 20 matching lines...) Expand all
1498 (function_ != NULL && function_->proxy()->var()->IsStackLocal() ? 1 : 0); 1498 (function_ != NULL && function_->proxy()->var()->IsStackLocal() ? 1 : 0);
1499 } 1499 }
1500 1500
1501 1501
1502 int Scope::ContextLocalCount() const { 1502 int Scope::ContextLocalCount() const {
1503 if (num_heap_slots() == 0) return 0; 1503 if (num_heap_slots() == 0) return 0;
1504 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 1504 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
1505 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); 1505 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0);
1506 } 1506 }
1507 } } // namespace v8::internal 1507 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/scopeinfo.cc ('k') | test/mjsunit/harmony/regress/regress-4056.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698