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

Side by Side Diff: src/scopes.cc

Issue 6806014: Merge r7519 to 3.1 branch (Closed) Base URL: http://v8.googlecode.com/svn/branches/3.1/
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « src/scopes.h ('k') | src/version.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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 112
113 // Dummy constructor 113 // Dummy constructor
114 Scope::Scope(Type type) 114 Scope::Scope(Type type)
115 : inner_scopes_(0), 115 : inner_scopes_(0),
116 variables_(false), 116 variables_(false),
117 temps_(0), 117 temps_(0),
118 params_(0), 118 params_(0),
119 unresolved_(0), 119 unresolved_(0),
120 decls_(0) { 120 decls_(0) {
121 SetDefaults(type, NULL, NULL); 121 SetDefaults(type, NULL, Handle<SerializedScopeInfo>::null());
122 ASSERT(!resolved()); 122 ASSERT(!resolved());
123 } 123 }
124 124
125 125
126 Scope::Scope(Scope* outer_scope, Type type) 126 Scope::Scope(Scope* outer_scope, Type type)
127 : inner_scopes_(4), 127 : inner_scopes_(4),
128 variables_(), 128 variables_(),
129 temps_(4), 129 temps_(4),
130 params_(4), 130 params_(4),
131 unresolved_(16), 131 unresolved_(16),
132 decls_(4) { 132 decls_(4) {
133 SetDefaults(type, outer_scope, NULL); 133 SetDefaults(type, outer_scope, Handle<SerializedScopeInfo>::null());
134 // At some point we might want to provide outer scopes to 134 // At some point we might want to provide outer scopes to
135 // eval scopes (by walking the stack and reading the scope info). 135 // eval scopes (by walking the stack and reading the scope info).
136 // In that case, the ASSERT below needs to be adjusted. 136 // In that case, the ASSERT below needs to be adjusted.
137 ASSERT((type == GLOBAL_SCOPE || type == EVAL_SCOPE) == (outer_scope == NULL)); 137 ASSERT((type == GLOBAL_SCOPE || type == EVAL_SCOPE) == (outer_scope == NULL));
138 ASSERT(!HasIllegalRedeclaration()); 138 ASSERT(!HasIllegalRedeclaration());
139 ASSERT(!resolved()); 139 ASSERT(!resolved());
140 } 140 }
141 141
142 142
143 Scope::Scope(Scope* inner_scope, SerializedScopeInfo* scope_info) 143 Scope::Scope(Scope* inner_scope, Handle<SerializedScopeInfo> scope_info)
144 : inner_scopes_(4), 144 : inner_scopes_(4),
145 variables_(), 145 variables_(),
146 temps_(4), 146 temps_(4),
147 params_(4), 147 params_(4),
148 unresolved_(16), 148 unresolved_(16),
149 decls_(4) { 149 decls_(4) {
150 ASSERT(scope_info != NULL); 150 ASSERT(!scope_info.is_null());
151 SetDefaults(FUNCTION_SCOPE, NULL, scope_info); 151 SetDefaults(FUNCTION_SCOPE, NULL, scope_info);
152 ASSERT(resolved()); 152 ASSERT(resolved());
153 if (scope_info->HasHeapAllocatedLocals()) { 153 if (scope_info->HasHeapAllocatedLocals()) {
154 num_heap_slots_ = scope_info_->NumberOfContextSlots(); 154 num_heap_slots_ = scope_info_->NumberOfContextSlots();
155 } 155 }
156 156
157 AddInnerScope(inner_scope); 157 AddInnerScope(inner_scope);
158 158
159 // This scope's arguments shadow (if present) is context-allocated if an inner 159 // This scope's arguments shadow (if present) is context-allocated if an inner
160 // scope accesses this one's parameters. Allocate the arguments_shadow_ 160 // scope accesses this one's parameters. Allocate the arguments_shadow_
161 // variable if necessary. 161 // variable if necessary.
162 Variable::Mode mode; 162 Variable::Mode mode;
163 int arguments_shadow_index = 163 int arguments_shadow_index =
164 scope_info_->ContextSlotIndex(Heap::arguments_shadow_symbol(), &mode); 164 scope_info_->ContextSlotIndex(Heap::arguments_shadow_symbol(), &mode);
165 if (arguments_shadow_index >= 0) { 165 if (arguments_shadow_index >= 0) {
166 ASSERT(mode == Variable::INTERNAL); 166 ASSERT(mode == Variable::INTERNAL);
167 arguments_shadow_ = new Variable(this, 167 arguments_shadow_ = new Variable(this,
168 Factory::arguments_shadow_symbol(), 168 Factory::arguments_shadow_symbol(),
169 Variable::INTERNAL, 169 Variable::INTERNAL,
170 true, 170 true,
171 Variable::ARGUMENTS); 171 Variable::ARGUMENTS);
172 arguments_shadow_->set_rewrite( 172 arguments_shadow_->set_rewrite(
173 new Slot(arguments_shadow_, Slot::CONTEXT, arguments_shadow_index)); 173 new Slot(arguments_shadow_, Slot::CONTEXT, arguments_shadow_index));
174 arguments_shadow_->set_is_used(true); 174 arguments_shadow_->set_is_used(true);
175 } 175 }
176 } 176 }
177 177
178 178
179 void Scope::SetDefaults(Type type,
180 Scope* outer_scope,
181 Handle<SerializedScopeInfo> scope_info) {
182 outer_scope_ = outer_scope;
183 type_ = type;
184 scope_name_ = Factory::empty_symbol();
185 dynamics_ = NULL;
186 receiver_ = NULL;
187 function_ = NULL;
188 arguments_ = NULL;
189 arguments_shadow_ = NULL;
190 illegal_redecl_ = NULL;
191 scope_inside_with_ = false;
192 scope_contains_with_ = false;
193 scope_calls_eval_ = false;
194 outer_scope_calls_eval_ = false;
195 inner_scope_calls_eval_ = false;
196 outer_scope_is_eval_scope_ = false;
197 force_eager_compilation_ = false;
198 num_stack_slots_ = 0;
199 num_heap_slots_ = 0;
200 scope_info_ = scope_info;
201 }
202
203
179 Scope* Scope::DeserializeScopeChain(CompilationInfo* info, 204 Scope* Scope::DeserializeScopeChain(CompilationInfo* info,
180 Scope* global_scope) { 205 Scope* global_scope) {
181 ASSERT(!info->closure().is_null()); 206 ASSERT(!info->closure().is_null());
182 // If we have a serialized scope info, reuse it. 207 // If we have a serialized scope info, reuse it.
183 Scope* innermost_scope = NULL; 208 Scope* innermost_scope = NULL;
184 Scope* scope = NULL; 209 Scope* scope = NULL;
185 210
186 SerializedScopeInfo* scope_info = info->closure()->shared()->scope_info(); 211 SerializedScopeInfo* scope_info = info->closure()->shared()->scope_info();
187 if (scope_info != SerializedScopeInfo::Empty()) { 212 if (scope_info != SerializedScopeInfo::Empty()) {
188 JSFunction* current = *info->closure(); 213 JSFunction* current = *info->closure();
189 do { 214 do {
190 current = current->context()->closure(); 215 current = current->context()->closure();
191 SerializedScopeInfo* scope_info = current->shared()->scope_info(); 216 Handle<SerializedScopeInfo> scope_info(current->shared()->scope_info());
192 if (scope_info != SerializedScopeInfo::Empty()) { 217 if (*scope_info != SerializedScopeInfo::Empty()) {
193 scope = new Scope(scope, scope_info); 218 scope = new Scope(scope, scope_info);
194 if (innermost_scope == NULL) innermost_scope = scope; 219 if (innermost_scope == NULL) innermost_scope = scope;
195 } else { 220 } else {
196 ASSERT(current->context()->IsGlobalContext()); 221 ASSERT(current->context()->IsGlobalContext());
197 } 222 }
198 } while (!current->context()->IsGlobalContext()); 223 } while (!current->context()->IsGlobalContext());
199 } 224 }
200 225
201 global_scope->AddInnerScope(scope); 226 global_scope->AddInnerScope(scope);
202 if (innermost_scope == NULL) innermost_scope = global_scope; 227 if (innermost_scope == NULL) innermost_scope = global_scope;
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after
1065 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS && 1090 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS &&
1066 !must_have_local_context) { 1091 !must_have_local_context) {
1067 num_heap_slots_ = 0; 1092 num_heap_slots_ = 0;
1068 } 1093 }
1069 1094
1070 // Allocation done. 1095 // Allocation done.
1071 ASSERT(num_heap_slots_ == 0 || num_heap_slots_ >= Context::MIN_CONTEXT_SLOTS); 1096 ASSERT(num_heap_slots_ == 0 || num_heap_slots_ >= Context::MIN_CONTEXT_SLOTS);
1072 } 1097 }
1073 1098
1074 } } // namespace v8::internal 1099 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/scopes.h ('k') | src/version.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698