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

Side by Side Diff: src/scopes.cc

Issue 7060010: Merge bleeding edge into the GC branch up to 7948. The asserts (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 9 years, 7 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/scopes.h ('k') | src/spaces.h » ('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 2010 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
11 // with the distribution. 11 // with the distribution.
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 function_ = NULL; 192 function_ = NULL;
193 arguments_ = NULL; 193 arguments_ = NULL;
194 arguments_shadow_ = NULL; 194 arguments_shadow_ = NULL;
195 illegal_redecl_ = NULL; 195 illegal_redecl_ = NULL;
196 scope_inside_with_ = false; 196 scope_inside_with_ = false;
197 scope_contains_with_ = false; 197 scope_contains_with_ = false;
198 scope_calls_eval_ = false; 198 scope_calls_eval_ = false;
199 // Inherit the strict mode from the parent scope. 199 // Inherit the strict mode from the parent scope.
200 strict_mode_ = (outer_scope != NULL) && outer_scope->strict_mode_; 200 strict_mode_ = (outer_scope != NULL) && outer_scope->strict_mode_;
201 outer_scope_calls_eval_ = false; 201 outer_scope_calls_eval_ = false;
202 outer_scope_calls_non_strict_eval_ = false;
202 inner_scope_calls_eval_ = false; 203 inner_scope_calls_eval_ = false;
203 outer_scope_is_eval_scope_ = false; 204 outer_scope_is_eval_scope_ = false;
204 force_eager_compilation_ = false; 205 force_eager_compilation_ = false;
206 num_var_or_const_ = 0;
205 num_stack_slots_ = 0; 207 num_stack_slots_ = 0;
206 num_heap_slots_ = 0; 208 num_heap_slots_ = 0;
207 scope_info_ = scope_info; 209 scope_info_ = scope_info;
208 } 210 }
209 211
210 212
211 Scope* Scope::DeserializeScopeChain(CompilationInfo* info, 213 Scope* Scope::DeserializeScopeChain(CompilationInfo* info,
212 Scope* global_scope) { 214 Scope* global_scope) {
213 ASSERT(!info->closure().is_null()); 215 ASSERT(!info->closure().is_null());
214 // If we have a serialized scope info, reuse it. 216 // If we have a serialized scope info, reuse it.
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 } 359 }
358 360
359 361
360 Variable* Scope::DeclareFunctionVar(Handle<String> name) { 362 Variable* Scope::DeclareFunctionVar(Handle<String> name) {
361 ASSERT(is_function_scope() && function_ == NULL); 363 ASSERT(is_function_scope() && function_ == NULL);
362 function_ = new Variable(this, name, Variable::CONST, true, Variable::NORMAL); 364 function_ = new Variable(this, name, Variable::CONST, true, Variable::NORMAL);
363 return function_; 365 return function_;
364 } 366 }
365 367
366 368
367 Variable* Scope::DeclareLocal(Handle<String> name, Variable::Mode mode) { 369 Variable* Scope::DeclareLocal(Handle<String> name,
370 Variable::Mode mode,
371 LocalType type) {
368 // DYNAMIC variables are introduces during variable allocation, 372 // DYNAMIC variables are introduces during variable allocation,
369 // INTERNAL variables are allocated explicitly, and TEMPORARY 373 // INTERNAL variables are allocated explicitly, and TEMPORARY
370 // variables are allocated via NewTemporary(). 374 // variables are allocated via NewTemporary().
371 ASSERT(!resolved()); 375 ASSERT(!resolved());
372 ASSERT(mode == Variable::VAR || mode == Variable::CONST); 376 ASSERT(mode == Variable::VAR || mode == Variable::CONST);
377 if (type == VAR_OR_CONST) {
378 num_var_or_const_++;
379 }
373 return variables_.Declare(this, name, mode, true, Variable::NORMAL); 380 return variables_.Declare(this, name, mode, true, Variable::NORMAL);
374 } 381 }
375 382
376 383
377 Variable* Scope::DeclareGlobal(Handle<String> name) { 384 Variable* Scope::DeclareGlobal(Handle<String> name) {
378 ASSERT(is_global_scope()); 385 ASSERT(is_global_scope());
379 return variables_.Declare(this, name, Variable::DYNAMIC_GLOBAL, true, 386 return variables_.Declare(this, name, Variable::DYNAMIC_GLOBAL, true,
380 Variable::NORMAL); 387 Variable::NORMAL);
381 } 388 }
382 389
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 483
477 void Scope::AllocateVariables(Handle<Context> context) { 484 void Scope::AllocateVariables(Handle<Context> context) {
478 ASSERT(outer_scope_ == NULL); // eval or global scopes only 485 ASSERT(outer_scope_ == NULL); // eval or global scopes only
479 486
480 // 1) Propagate scope information. 487 // 1) Propagate scope information.
481 // If we are in an eval scope, we may have other outer scopes about 488 // If we are in an eval scope, we may have other outer scopes about
482 // which we don't know anything at this point. Thus we must be conservative 489 // which we don't know anything at this point. Thus we must be conservative
483 // and assume they may invoke eval themselves. Eventually we could capture 490 // and assume they may invoke eval themselves. Eventually we could capture
484 // this information in the ScopeInfo and then use it here (by traversing 491 // this information in the ScopeInfo and then use it here (by traversing
485 // the call chain stack, at compile time). 492 // the call chain stack, at compile time).
493
486 bool eval_scope = is_eval_scope(); 494 bool eval_scope = is_eval_scope();
487 PropagateScopeInfo(eval_scope, eval_scope); 495 bool outer_scope_calls_eval = false;
496 bool outer_scope_calls_non_strict_eval = false;
497 if (!is_global_scope()) {
498 context->ComputeEvalScopeInfo(&outer_scope_calls_eval,
499 &outer_scope_calls_non_strict_eval);
500 }
501 PropagateScopeInfo(outer_scope_calls_eval,
502 outer_scope_calls_non_strict_eval,
503 eval_scope);
488 504
489 // 2) Resolve variables. 505 // 2) Resolve variables.
490 Scope* global_scope = NULL; 506 Scope* global_scope = NULL;
491 if (is_global_scope()) global_scope = this; 507 if (is_global_scope()) global_scope = this;
492 ResolveVariablesRecursively(global_scope, context); 508 ResolveVariablesRecursively(global_scope, context);
493 509
494 // 3) Allocate variables. 510 // 3) Allocate variables.
495 AllocateVariablesRecursively(); 511 AllocateVariablesRecursively();
496 } 512 }
497 513
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 if (function_ != NULL) { 625 if (function_ != NULL) {
610 Indent(n1, "// (local) function name: "); 626 Indent(n1, "// (local) function name: ");
611 PrintName(function_->name()); 627 PrintName(function_->name());
612 PrintF("\n"); 628 PrintF("\n");
613 } 629 }
614 630
615 // Scope info. 631 // Scope info.
616 if (HasTrivialOuterContext()) { 632 if (HasTrivialOuterContext()) {
617 Indent(n1, "// scope has trivial outer context\n"); 633 Indent(n1, "// scope has trivial outer context\n");
618 } 634 }
635 if (is_strict_mode()) Indent(n1, "// strict mode scope\n");
619 if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n"); 636 if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n");
620 if (scope_contains_with_) Indent(n1, "// scope contains 'with'\n"); 637 if (scope_contains_with_) Indent(n1, "// scope contains 'with'\n");
621 if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n"); 638 if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n");
622 if (outer_scope_calls_eval_) Indent(n1, "// outer scope calls 'eval'\n"); 639 if (outer_scope_calls_eval_) Indent(n1, "// outer scope calls 'eval'\n");
640 if (outer_scope_calls_non_strict_eval_) {
641 Indent(n1, "// outer scope calls 'eval' in non-strict context\n");
642 }
623 if (inner_scope_calls_eval_) Indent(n1, "// inner scope calls 'eval'\n"); 643 if (inner_scope_calls_eval_) Indent(n1, "// inner scope calls 'eval'\n");
624 if (outer_scope_is_eval_scope_) { 644 if (outer_scope_is_eval_scope_) {
625 Indent(n1, "// outer scope is 'eval' scope\n"); 645 Indent(n1, "// outer scope is 'eval' scope\n");
626 } 646 }
627 if (num_stack_slots_ > 0) { Indent(n1, "// "); 647 if (num_stack_slots_ > 0) { Indent(n1, "// ");
628 PrintF("%d stack slots\n", num_stack_slots_); } 648 PrintF("%d stack slots\n", num_stack_slots_); }
629 if (num_heap_slots_ > 0) { Indent(n1, "// "); 649 if (num_heap_slots_ > 0) { Indent(n1, "// ");
630 PrintF("%d heap slots\n", num_heap_slots_); } 650 PrintF("%d heap slots\n", num_heap_slots_); }
631 651
632 // Print locals. 652 // Print locals.
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 } 859 }
840 860
841 // Resolve unresolved variables for inner scopes. 861 // Resolve unresolved variables for inner scopes.
842 for (int i = 0; i < inner_scopes_.length(); i++) { 862 for (int i = 0; i < inner_scopes_.length(); i++) {
843 inner_scopes_[i]->ResolveVariablesRecursively(global_scope, context); 863 inner_scopes_[i]->ResolveVariablesRecursively(global_scope, context);
844 } 864 }
845 } 865 }
846 866
847 867
848 bool Scope::PropagateScopeInfo(bool outer_scope_calls_eval, 868 bool Scope::PropagateScopeInfo(bool outer_scope_calls_eval,
869 bool outer_scope_calls_non_strict_eval,
849 bool outer_scope_is_eval_scope) { 870 bool outer_scope_is_eval_scope) {
850 if (outer_scope_calls_eval) { 871 if (outer_scope_calls_eval) {
851 outer_scope_calls_eval_ = true; 872 outer_scope_calls_eval_ = true;
852 } 873 }
853 874
875 if (outer_scope_calls_non_strict_eval) {
876 outer_scope_calls_non_strict_eval_ = true;
877 }
878
854 if (outer_scope_is_eval_scope) { 879 if (outer_scope_is_eval_scope) {
855 outer_scope_is_eval_scope_ = true; 880 outer_scope_is_eval_scope_ = true;
856 } 881 }
857 882
858 bool calls_eval = scope_calls_eval_ || outer_scope_calls_eval_; 883 bool calls_eval = scope_calls_eval_ || outer_scope_calls_eval_;
859 bool is_eval = is_eval_scope() || outer_scope_is_eval_scope_; 884 bool is_eval = is_eval_scope() || outer_scope_is_eval_scope_;
885 bool calls_non_strict_eval =
886 (scope_calls_eval_ && !is_strict_mode()) ||
887 outer_scope_calls_non_strict_eval_;
860 for (int i = 0; i < inner_scopes_.length(); i++) { 888 for (int i = 0; i < inner_scopes_.length(); i++) {
861 Scope* inner_scope = inner_scopes_[i]; 889 Scope* inner_scope = inner_scopes_[i];
862 if (inner_scope->PropagateScopeInfo(calls_eval, is_eval)) { 890 if (inner_scope->PropagateScopeInfo(calls_eval,
891 calls_non_strict_eval,
892 is_eval)) {
863 inner_scope_calls_eval_ = true; 893 inner_scope_calls_eval_ = true;
864 } 894 }
865 if (inner_scope->force_eager_compilation_) { 895 if (inner_scope->force_eager_compilation_) {
866 force_eager_compilation_ = true; 896 force_eager_compilation_ = true;
867 } 897 }
868 } 898 }
869 899
870 return scope_calls_eval_ || inner_scope_calls_eval_; 900 return scope_calls_eval_ || inner_scope_calls_eval_;
871 } 901 }
872 902
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS && 1141 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS &&
1112 !must_have_local_context) { 1142 !must_have_local_context) {
1113 num_heap_slots_ = 0; 1143 num_heap_slots_ = 0;
1114 } 1144 }
1115 1145
1116 // Allocation done. 1146 // Allocation done.
1117 ASSERT(num_heap_slots_ == 0 || num_heap_slots_ >= Context::MIN_CONTEXT_SLOTS); 1147 ASSERT(num_heap_slots_ == 0 || num_heap_slots_ >= Context::MIN_CONTEXT_SLOTS);
1118 } 1148 }
1119 1149
1120 } } // namespace v8::internal 1150 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/scopes.h ('k') | src/spaces.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698