Reviewers: Kevin Millikin,
Message:
Just a very early draft to check overall direction of the patch. There is a
good
chance altogether different approach I cannot see is far superior...
Thank you!
Martin
http://codereview.chromium.org/6628073/diff/1/src/code-stubs.h
File src/code-stubs.h (right):
http://codereview.chromium.org/6628073/diff/1/src/code-stubs.h#newcode291
src/code-stubs.h:291: ASSERT(slots_ >= 0 && slots <= kMaximumSlots);
eval code may not allocate any context slots but in strict mode it needs
context so that locals do not leak outside of it.
This scope's extension will then accumulate the locals created by eval
code.
http://codereview.chromium.org/6628073/diff/1/src/ia32/full-codegen-ia32.cc
File src/ia32/full-codegen-ia32.cc (right):
http://codereview.chromium.org/6628073/diff/1/src/ia32/full-codegen-ia32.cc#newcode1054
src/ia32/full-codegen-ia32.cc:1054: // Check that extension is NULL.
As we walk up the scope chain, we need to sniff every extension that may
have been created. calling eval is one way to have extension, being
strict mode eval scope is another.
Description:
Eval has own scope in strict mode.
BUG=
TEST=
Please review this at http://codereview.chromium.org/6628073/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/code-stubs.h
M src/ia32/full-codegen-ia32.cc
M src/scopes.cc
Index: src/code-stubs.h
diff --git a/src/code-stubs.h b/src/code-stubs.h
index
96ac7335cfa86f51eb3e41905d4accbfeb7127d2..bd37618d19ecd03f3c55711b9233ebb340e43422
100644
--- a/src/code-stubs.h
+++ b/src/code-stubs.h
@@ -288,7 +288,7 @@ class FastNewContextStub : public CodeStub {
static const int kMaximumSlots = 64;
explicit FastNewContextStub(int slots) : slots_(slots) {
- ASSERT(slots_ > 0 && slots <= kMaximumSlots);
+ ASSERT(slots_ >= 0 && slots <= kMaximumSlots);
}
void Generate(MacroAssembler* masm);
Index: src/ia32/full-codegen-ia32.cc
diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc
index
608aebe69db5913d5d5701ef3757c31b9e239791..d93059556b4bdec72a3e68f440c284a560e3bc5b
100644
--- a/src/ia32/full-codegen-ia32.cc
+++ b/src/ia32/full-codegen-ia32.cc
@@ -142,7 +142,7 @@ void FullCodeGenerator::Generate(CompilationInfo* info)
{
// Possibly allocate a local context.
int heap_slots = scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS;
- if (heap_slots > 0) {
+ if (heap_slots >= 0) {
Comment cmnt(masm_, "[ Allocate local context");
// Argument to NewContext is the function, which is still in edi.
__ push(edi);
@@ -1050,8 +1050,10 @@ void
FullCodeGenerator::EmitLoadGlobalSlotCheckExtensions(
Scope* s = scope();
while (s != NULL) {
if (s->num_heap_slots() > 0) {
- if (s->calls_eval()) {
+ if (s->calls_eval() || (s->is_eval_scope() && s->is_strict_mode())) {
// Check that extension is NULL.
+ // TODO(mmaly): Look for all places using Context::EXTENSION_INDEX
+ // because more of them may have to be made aware of strict mode
and eval.
__ cmp(ContextOperand(context, Context::EXTENSION_INDEX),
Immediate(0));
__ j(not_equal, slow);
Index: src/scopes.cc
diff --git a/src/scopes.cc b/src/scopes.cc
index
a03dbdde9691c7129e9cc1622528b2b3d06c453d..dbaeab4623b98082dfd2ee3dbaa46b4d3345ed32
100644
--- a/src/scopes.cc
+++ b/src/scopes.cc
@@ -1061,6 +1061,11 @@ void Scope::AllocateVariablesRecursively() {
must_have_local_context = is_function_scope();
}
+ // Strict mode eval scope must have own context too.
+ if (!must_have_local_context && is_eval_scope() && is_strict_mode()) {
+ must_have_local_context = true;
+ }
+
// If we didn't allocate any locals in the local context, then we only
// need the minimal number of slots if we must have a local context.
if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS &&
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev