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

Side by Side Diff: src/scopes.cc

Issue 6805013: Add a missing handle for serialized scope info (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Pass handle to Scope constructor 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') | no next file » | 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 113
114 114
115 // Dummy constructor 115 // Dummy constructor
116 Scope::Scope(Type type) 116 Scope::Scope(Type type)
117 : inner_scopes_(0), 117 : inner_scopes_(0),
118 variables_(false), 118 variables_(false),
119 temps_(0), 119 temps_(0),
120 params_(0), 120 params_(0),
121 unresolved_(0), 121 unresolved_(0),
122 decls_(0) { 122 decls_(0) {
123 SetDefaults(type, NULL, NULL); 123 SetDefaults(type, NULL, Handle<SerializedScopeInfo>::null());
124 ASSERT(!resolved()); 124 ASSERT(!resolved());
125 } 125 }
126 126
127 127
128 Scope::Scope(Scope* outer_scope, Type type) 128 Scope::Scope(Scope* outer_scope, Type type)
129 : inner_scopes_(4), 129 : inner_scopes_(4),
130 variables_(), 130 variables_(),
131 temps_(4), 131 temps_(4),
132 params_(4), 132 params_(4),
133 unresolved_(16), 133 unresolved_(16),
134 decls_(4) { 134 decls_(4) {
135 SetDefaults(type, outer_scope, NULL); 135 SetDefaults(type, outer_scope, Handle<SerializedScopeInfo>::null());
136 // At some point we might want to provide outer scopes to 136 // At some point we might want to provide outer scopes to
137 // eval scopes (by walking the stack and reading the scope info). 137 // eval scopes (by walking the stack and reading the scope info).
138 // In that case, the ASSERT below needs to be adjusted. 138 // In that case, the ASSERT below needs to be adjusted.
139 ASSERT((type == GLOBAL_SCOPE || type == EVAL_SCOPE) == (outer_scope == NULL)); 139 ASSERT((type == GLOBAL_SCOPE || type == EVAL_SCOPE) == (outer_scope == NULL));
140 ASSERT(!HasIllegalRedeclaration()); 140 ASSERT(!HasIllegalRedeclaration());
141 ASSERT(!resolved()); 141 ASSERT(!resolved());
142 } 142 }
143 143
144 144
145 Scope::Scope(Scope* inner_scope, SerializedScopeInfo* scope_info) 145 Scope::Scope(Scope* inner_scope, Handle<SerializedScopeInfo> scope_info)
146 : inner_scopes_(4), 146 : inner_scopes_(4),
147 variables_(), 147 variables_(),
148 temps_(4), 148 temps_(4),
149 params_(4), 149 params_(4),
150 unresolved_(16), 150 unresolved_(16),
151 decls_(4) { 151 decls_(4) {
152 ASSERT(scope_info != NULL); 152 ASSERT(!scope_info.is_null());
153 SetDefaults(FUNCTION_SCOPE, NULL, scope_info); 153 SetDefaults(FUNCTION_SCOPE, NULL, scope_info);
154 ASSERT(resolved()); 154 ASSERT(resolved());
155 if (scope_info->HasHeapAllocatedLocals()) { 155 if (scope_info->HasHeapAllocatedLocals()) {
156 num_heap_slots_ = scope_info_->NumberOfContextSlots(); 156 num_heap_slots_ = scope_info_->NumberOfContextSlots();
157 } 157 }
158 158
159 AddInnerScope(inner_scope); 159 AddInnerScope(inner_scope);
160 160
161 // This scope's arguments shadow (if present) is context-allocated if an inner 161 // This scope's arguments shadow (if present) is context-allocated if an inner
162 // scope accesses this one's parameters. Allocate the arguments_shadow_ 162 // scope accesses this one's parameters. Allocate the arguments_shadow_
(...skipping 11 matching lines...) Expand all
174 Variable::INTERNAL, 174 Variable::INTERNAL,
175 true, 175 true,
176 Variable::ARGUMENTS); 176 Variable::ARGUMENTS);
177 arguments_shadow_->set_rewrite( 177 arguments_shadow_->set_rewrite(
178 new Slot(arguments_shadow_, Slot::CONTEXT, arguments_shadow_index)); 178 new Slot(arguments_shadow_, Slot::CONTEXT, arguments_shadow_index));
179 arguments_shadow_->set_is_used(true); 179 arguments_shadow_->set_is_used(true);
180 } 180 }
181 } 181 }
182 182
183 183
184 void Scope::SetDefaults(Type type,
185 Scope* outer_scope,
186 Handle<SerializedScopeInfo> scope_info) {
187 outer_scope_ = outer_scope;
188 type_ = type;
189 scope_name_ = FACTORY->empty_symbol();
190 dynamics_ = NULL;
191 receiver_ = NULL;
192 function_ = NULL;
193 arguments_ = NULL;
194 arguments_shadow_ = NULL;
195 illegal_redecl_ = NULL;
196 scope_inside_with_ = false;
197 scope_contains_with_ = false;
198 scope_calls_eval_ = false;
199 // Inherit the strict mode from the parent scope.
200 strict_mode_ = (outer_scope != NULL) && outer_scope->strict_mode_;
201 outer_scope_calls_eval_ = false;
202 inner_scope_calls_eval_ = false;
203 outer_scope_is_eval_scope_ = false;
204 force_eager_compilation_ = false;
205 num_stack_slots_ = 0;
206 num_heap_slots_ = 0;
207 scope_info_ = scope_info;
208 }
209
210
184 Scope* Scope::DeserializeScopeChain(CompilationInfo* info, 211 Scope* Scope::DeserializeScopeChain(CompilationInfo* info,
185 Scope* global_scope) { 212 Scope* global_scope) {
186 ASSERT(!info->closure().is_null()); 213 ASSERT(!info->closure().is_null());
187 // If we have a serialized scope info, reuse it. 214 // If we have a serialized scope info, reuse it.
188 Scope* innermost_scope = NULL; 215 Scope* innermost_scope = NULL;
189 Scope* scope = NULL; 216 Scope* scope = NULL;
190 217
191 SerializedScopeInfo* scope_info = info->closure()->shared()->scope_info(); 218 SerializedScopeInfo* scope_info = info->closure()->shared()->scope_info();
192 if (scope_info != SerializedScopeInfo::Empty()) { 219 if (scope_info != SerializedScopeInfo::Empty()) {
193 JSFunction* current = *info->closure(); 220 JSFunction* current = *info->closure();
194 do { 221 do {
195 current = current->context()->closure(); 222 current = current->context()->closure();
196 SerializedScopeInfo* scope_info = current->shared()->scope_info(); 223 Handle<SerializedScopeInfo> scope_info(current->shared()->scope_info());
197 if (scope_info != SerializedScopeInfo::Empty()) { 224 if (*scope_info != SerializedScopeInfo::Empty()) {
198 scope = new Scope(scope, scope_info); 225 scope = new Scope(scope, scope_info);
199 if (innermost_scope == NULL) innermost_scope = scope; 226 if (innermost_scope == NULL) innermost_scope = scope;
200 } else { 227 } else {
201 ASSERT(current->context()->IsGlobalContext()); 228 ASSERT(current->context()->IsGlobalContext());
202 } 229 }
203 } while (!current->context()->IsGlobalContext()); 230 } while (!current->context()->IsGlobalContext());
204 } 231 }
205 232
206 global_scope->AddInnerScope(scope); 233 global_scope->AddInnerScope(scope);
207 if (innermost_scope == NULL) innermost_scope = global_scope; 234 if (innermost_scope == NULL) innermost_scope = global_scope;
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS && 1111 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS &&
1085 !must_have_local_context) { 1112 !must_have_local_context) {
1086 num_heap_slots_ = 0; 1113 num_heap_slots_ = 0;
1087 } 1114 }
1088 1115
1089 // Allocation done. 1116 // Allocation done.
1090 ASSERT(num_heap_slots_ == 0 || num_heap_slots_ >= Context::MIN_CONTEXT_SLOTS); 1117 ASSERT(num_heap_slots_ == 0 || num_heap_slots_ >= Context::MIN_CONTEXT_SLOTS);
1091 } 1118 }
1092 1119
1093 } } // namespace v8::internal 1120 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/scopes.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698