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

Side by Side Diff: runtime/vm/scopes.cc

Issue 1361423004: Don't use a special var descriptor for :async_op since it can now be either stack or context alloca… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: also assert async op is either closure or null Created 5 years, 2 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
« runtime/vm/object.cc ('K') | « runtime/vm/raw_object.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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/scopes.h" 5 #include "vm/scopes.h"
6 6
7 #include "vm/object.h" 7 #include "vm/object.h"
8 #include "vm/stack_frame.h" 8 #include "vm/stack_frame.h"
9 #include "vm/symbols.h" 9 #include "vm/symbols.h"
10 10
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 if (child_frame_index < min_frame_index) { 243 if (child_frame_index < min_frame_index) {
244 min_frame_index = child_frame_index; 244 min_frame_index = child_frame_index;
245 } 245 }
246 child = child->sibling(); 246 child = child->sibling();
247 } 247 }
248 return min_frame_index; 248 return min_frame_index;
249 } 249 }
250 250
251 251
252 // The parser creates internal variables that start with ":" 252 // The parser creates internal variables that start with ":"
253 static bool IsInternalIdentifier(const String& str) { 253 static bool IsFilteredIdentifier(const String& str) {
254 ASSERT(str.Length() > 0); 254 ASSERT(str.Length() > 0);
255 if (str.raw() == Symbols::AsyncOperation().raw()) {
256 // Keep :async_op for asynchronous debugging.
257 return false;
258 }
255 return str.CharAt(0) == ':'; 259 return str.CharAt(0) == ':';
256 } 260 }
257 261
258 262
259 RawLocalVarDescriptors* LocalScope::GetVarDescriptors(const Function& func) { 263 RawLocalVarDescriptors* LocalScope::GetVarDescriptors(const Function& func) {
260 GrowableArray<VarDesc> vars(8); 264 GrowableArray<VarDesc> vars(8);
261 // First enter all variables from scopes of outer functions. 265 // First enter all variables from scopes of outer functions.
262 const ContextScope& context_scope = 266 const ContextScope& context_scope =
263 ContextScope::Handle(func.context_scope()); 267 ContextScope::Handle(func.context_scope());
264 if (!context_scope.IsNull()) { 268 if (!context_scope.IsNull()) {
265 ASSERT(func.IsLocalFunction()); 269 ASSERT(func.IsLocalFunction());
266 for (int i = 0; i < context_scope.num_variables(); i++) { 270 for (int i = 0; i < context_scope.num_variables(); i++) {
267 String& name = String::Handle(context_scope.NameAt(i)); 271 String& name = String::Handle(context_scope.NameAt(i));
268 RawLocalVarDescriptors::VarInfoKind kind; 272 RawLocalVarDescriptors::VarInfoKind kind;
269 if (!IsInternalIdentifier(name)) { 273 if (!IsFilteredIdentifier(name)) {
270 kind = RawLocalVarDescriptors::kContextVar; 274 kind = RawLocalVarDescriptors::kContextVar;
271 } else if (name.raw() == Symbols::AsyncOperation().raw()) {
272 kind = RawLocalVarDescriptors::kAsyncOperation;
273 } else { 275 } else {
274 continue; 276 continue;
275 } 277 }
276 278
277 VarDesc desc; 279 VarDesc desc;
278 desc.name = &name; 280 desc.name = &name;
279 desc.info.set_kind(kind); 281 desc.info.set_kind(kind);
280 desc.info.scope_id = context_scope.ContextLevelAt(i); 282 desc.info.scope_id = context_scope.ContextLevelAt(i);
281 desc.info.begin_pos = begin_token_pos(); 283 desc.info.begin_pos = begin_token_pos();
282 desc.info.end_pos = end_token_pos(); 284 desc.info.end_pos = end_token_pos();
(...skipping 29 matching lines...) Expand all
312 desc.info.set_kind(RawLocalVarDescriptors::kContextLevel); 314 desc.info.set_kind(RawLocalVarDescriptors::kContextLevel);
313 desc.info.scope_id = *scope_id; 315 desc.info.scope_id = *scope_id;
314 desc.info.begin_pos = begin_token_pos(); 316 desc.info.begin_pos = begin_token_pos();
315 desc.info.end_pos = end_token_pos(); 317 desc.info.end_pos = end_token_pos();
316 desc.info.set_index(context_level()); 318 desc.info.set_index(context_level());
317 vars->Add(desc); 319 vars->Add(desc);
318 } 320 }
319 for (int i = 0; i < this->variables_.length(); i++) { 321 for (int i = 0; i < this->variables_.length(); i++) {
320 LocalVariable* var = variables_[i]; 322 LocalVariable* var = variables_[i];
321 if ((var->owner() == this) && !var->is_invisible()) { 323 if ((var->owner() == this) && !var->is_invisible()) {
322 if (!IsInternalIdentifier(var->name())) { 324 if (var->name().raw() == Symbols::CurrentContextVar().raw()) {
323 // This is a regular Dart variable, either stack-based or captured.
324 VarDesc desc;
325 desc.name = &var->name();
326 if (var->is_captured()) {
327 desc.info.set_kind(RawLocalVarDescriptors::kContextVar);
328 ASSERT(var->owner() != NULL);
329 ASSERT(var->owner()->context_level() >= 0);
330 desc.info.scope_id = var->owner()->context_level();
331 } else {
332 desc.info.set_kind(RawLocalVarDescriptors::kStackVar);
333 desc.info.scope_id = *scope_id;
334 }
335 desc.info.begin_pos = var->token_pos();
336 desc.info.end_pos = var->owner()->end_token_pos();
337 desc.info.set_index(var->index());
338 vars->Add(desc);
339 } else if (var->name().raw() == Symbols::CurrentContextVar().raw()) {
340 // This is the local variable in which the function saves its 325 // This is the local variable in which the function saves its
341 // own context before calling a closure function. 326 // own context before calling a closure function.
342 VarDesc desc; 327 VarDesc desc;
343 desc.name = &var->name(); 328 desc.name = &var->name();
344 desc.info.set_kind(RawLocalVarDescriptors::kSavedCurrentContext); 329 desc.info.set_kind(RawLocalVarDescriptors::kSavedCurrentContext);
345 desc.info.scope_id = 0; 330 desc.info.scope_id = 0;
346 desc.info.begin_pos = 0; 331 desc.info.begin_pos = 0;
347 desc.info.end_pos = 0; 332 desc.info.end_pos = 0;
348 desc.info.set_index(var->index()); 333 desc.info.set_index(var->index());
349 vars->Add(desc); 334 vars->Add(desc);
350 } else if (var->name().raw() == Symbols::AsyncOperation().raw()) { 335 } else if (!IsFilteredIdentifier(var->name())) {
351 // The async continuation. 336 // This is a regular Dart variable, either stack-based or captured.
352 ASSERT(var->is_captured());
353 VarDesc desc; 337 VarDesc desc;
354 desc.name = &var->name(); 338 desc.name = &var->name();
355 desc.info.set_kind(RawLocalVarDescriptors::kAsyncOperation);
356 if (var->is_captured()) { 339 if (var->is_captured()) {
340 desc.info.set_kind(RawLocalVarDescriptors::kContextVar);
357 ASSERT(var->owner() != NULL); 341 ASSERT(var->owner() != NULL);
358 ASSERT(var->owner()->context_level() >= 0); 342 ASSERT(var->owner()->context_level() >= 0);
359 desc.info.scope_id = var->owner()->context_level(); 343 desc.info.scope_id = var->owner()->context_level();
360 } else { 344 } else {
345 desc.info.set_kind(RawLocalVarDescriptors::kStackVar);
361 desc.info.scope_id = *scope_id; 346 desc.info.scope_id = *scope_id;
362 } 347 }
363 desc.info.begin_pos = 0; 348 desc.info.begin_pos = var->token_pos();
364 desc.info.end_pos = 0; 349 desc.info.end_pos = var->owner()->end_token_pos();
365 desc.info.set_index(var->index()); 350 desc.info.set_index(var->index());
366 vars->Add(desc); 351 vars->Add(desc);
367 } 352 }
368 } 353 }
369 } 354 }
370 LocalScope* child = this->child(); 355 LocalScope* child = this->child();
371 while (child != NULL) { 356 while (child != NULL) {
372 child->CollectLocalVariables(vars, scope_id); 357 child->CollectLocalVariables(vars, scope_id);
373 child = child->sibling(); 358 child = child->sibling();
374 } 359 }
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 return fixed_parameter_count - (index() - kParamEndSlotFromFp); 668 return fixed_parameter_count - (index() - kParamEndSlotFromFp);
684 } else { 669 } else {
685 // Shift negative indexes so that the lowest one is 0 (they are still 670 // Shift negative indexes so that the lowest one is 0 (they are still
686 // non-positive). 671 // non-positive).
687 return fixed_parameter_count - (index() - kFirstLocalSlotFromFp); 672 return fixed_parameter_count - (index() - kFirstLocalSlotFromFp);
688 } 673 }
689 } 674 }
690 675
691 676
692 } // namespace dart 677 } // namespace dart
OLDNEW
« runtime/vm/object.cc ('K') | « runtime/vm/raw_object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698