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

Side by Side Diff: src/scopes.cc

Issue 7309002: Fix a bug in with and catch context allocation. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 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 | « src/scopes.h ('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 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 int Scope::ContextChainLength(Scope* scope) { 537 int Scope::ContextChainLength(Scope* scope) {
538 int n = 0; 538 int n = 0;
539 for (Scope* s = this; s != scope; s = s->outer_scope_) { 539 for (Scope* s = this; s != scope; s = s->outer_scope_) {
540 ASSERT(s != NULL); // scope must be in the scope chain 540 ASSERT(s != NULL); // scope must be in the scope chain
541 if (s->num_heap_slots() > 0) n++; 541 if (s->num_heap_slots() > 0) n++;
542 } 542 }
543 return n; 543 return n;
544 } 544 }
545 545
546 546
547 Scope* Scope::DeclarationScope() {
548 Scope* scope = this;
549 while (scope->is_catch_scope()) {
550 scope = scope->outer_scope();
551 }
552 return scope;
553 }
554
555
547 #ifdef DEBUG 556 #ifdef DEBUG
548 static const char* Header(Scope::Type type) { 557 static const char* Header(Scope::Type type) {
549 switch (type) { 558 switch (type) {
550 case Scope::EVAL_SCOPE: return "eval"; 559 case Scope::EVAL_SCOPE: return "eval";
551 case Scope::FUNCTION_SCOPE: return "function"; 560 case Scope::FUNCTION_SCOPE: return "function";
552 case Scope::GLOBAL_SCOPE: return "global"; 561 case Scope::GLOBAL_SCOPE: return "global";
553 case Scope::CATCH_SCOPE: return "catch"; 562 case Scope::CATCH_SCOPE: return "catch";
554 } 563 }
555 UNREACHABLE(); 564 UNREACHABLE();
556 return NULL; 565 return NULL;
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS && 1088 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS &&
1080 !must_have_local_context) { 1089 !must_have_local_context) {
1081 num_heap_slots_ = 0; 1090 num_heap_slots_ = 0;
1082 } 1091 }
1083 1092
1084 // Allocation done. 1093 // Allocation done.
1085 ASSERT(num_heap_slots_ == 0 || num_heap_slots_ >= Context::MIN_CONTEXT_SLOTS); 1094 ASSERT(num_heap_slots_ == 0 || num_heap_slots_ >= Context::MIN_CONTEXT_SLOTS);
1086 } 1095 }
1087 1096
1088 } } // namespace v8::internal 1097 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/scopes.h ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698