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

Side by Side Diff: src/runtime.cc

Issue 202005: Add ScopeTypeCatch to ScopeIterator (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 3 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/mirror-delay.js ('k') | test/mjsunit/debug-scopes.js » ('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 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 6323 matching lines...) Expand 10 before | Expand all | Expand 10 after
6334 6334
6335 // Iterate over the actual scopes visible from a stack frame. All scopes are 6335 // Iterate over the actual scopes visible from a stack frame. All scopes are
6336 // backed by an actual context except the local scope, which is inserted 6336 // backed by an actual context except the local scope, which is inserted
6337 // "artifically" in the context chain. 6337 // "artifically" in the context chain.
6338 class ScopeIterator { 6338 class ScopeIterator {
6339 public: 6339 public:
6340 enum ScopeType { 6340 enum ScopeType {
6341 ScopeTypeGlobal = 0, 6341 ScopeTypeGlobal = 0,
6342 ScopeTypeLocal, 6342 ScopeTypeLocal,
6343 ScopeTypeWith, 6343 ScopeTypeWith,
6344 ScopeTypeClosure 6344 ScopeTypeClosure,
6345 // Every catch block contains an implicit with block (its parameter is
6346 // a JSContextExtensionObject) that extends current scope with a variable
6347 // holding exception object. Such with blocks are treated as scopes of their
6348 // own type.
6349 ScopeTypeCatch
6345 }; 6350 };
6346 6351
6347 explicit ScopeIterator(JavaScriptFrame* frame) 6352 explicit ScopeIterator(JavaScriptFrame* frame)
6348 : frame_(frame), 6353 : frame_(frame),
6349 function_(JSFunction::cast(frame->function())), 6354 function_(JSFunction::cast(frame->function())),
6350 context_(Context::cast(frame->context())), 6355 context_(Context::cast(frame->context())),
6351 local_done_(false), 6356 local_done_(false),
6352 at_local_(false) { 6357 at_local_(false) {
6353 6358
6354 // Check whether the first scope is actually a local scope. 6359 // Check whether the first scope is actually a local scope.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
6410 return ScopeTypeLocal; 6415 return ScopeTypeLocal;
6411 } 6416 }
6412 if (context_->IsGlobalContext()) { 6417 if (context_->IsGlobalContext()) {
6413 ASSERT(context_->global()->IsGlobalObject()); 6418 ASSERT(context_->global()->IsGlobalObject());
6414 return ScopeTypeGlobal; 6419 return ScopeTypeGlobal;
6415 } 6420 }
6416 if (context_->is_function_context()) { 6421 if (context_->is_function_context()) {
6417 return ScopeTypeClosure; 6422 return ScopeTypeClosure;
6418 } 6423 }
6419 ASSERT(context_->has_extension()); 6424 ASSERT(context_->has_extension());
6420 ASSERT(!context_->extension()->IsJSContextExtensionObject()); 6425 // Current scope is either an explicit with statement or a with statement
6426 // implicitely generated for a catch block.
6427 // If the extension object here is a JSContextExtensionObject then
6428 // current with statement is one frome a catch block otherwise it's a
6429 // regular with statement.
6430 if (context_->extension()->IsJSContextExtensionObject()) {
6431 return ScopeTypeCatch;
6432 }
6421 return ScopeTypeWith; 6433 return ScopeTypeWith;
6422 } 6434 }
6423 6435
6424 // Return the JavaScript object with the content of the current scope. 6436 // Return the JavaScript object with the content of the current scope.
6425 Handle<JSObject> ScopeObject() { 6437 Handle<JSObject> ScopeObject() {
6426 switch (Type()) { 6438 switch (Type()) {
6427 case ScopeIterator::ScopeTypeGlobal: 6439 case ScopeIterator::ScopeTypeGlobal:
6428 return Handle<JSObject>(CurrentContext()->global()); 6440 return Handle<JSObject>(CurrentContext()->global());
6429 break; 6441 break;
6430 case ScopeIterator::ScopeTypeLocal: 6442 case ScopeIterator::ScopeTypeLocal:
6431 // Materialize the content of the local scope into a JSObject. 6443 // Materialize the content of the local scope into a JSObject.
6432 return MaterializeLocalScope(frame_); 6444 return MaterializeLocalScope(frame_);
6433 break; 6445 break;
6434 case ScopeIterator::ScopeTypeWith: 6446 case ScopeIterator::ScopeTypeWith:
6447 case ScopeIterator::ScopeTypeCatch:
6435 // Return the with object. 6448 // Return the with object.
6436 return Handle<JSObject>(CurrentContext()->extension()); 6449 return Handle<JSObject>(CurrentContext()->extension());
6437 break; 6450 break;
6438 case ScopeIterator::ScopeTypeClosure: 6451 case ScopeIterator::ScopeTypeClosure:
6439 // Materialize the content of the closure scope into a JSObject. 6452 // Materialize the content of the closure scope into a JSObject.
6440 return MaterializeClosure(CurrentContext()); 6453 return MaterializeClosure(CurrentContext());
6441 break; 6454 break;
6442 } 6455 }
6443 UNREACHABLE(); 6456 UNREACHABLE();
6444 return Handle<JSObject>(); 6457 return Handle<JSObject>();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
6481 } 6494 }
6482 6495
6483 case ScopeIterator::ScopeTypeWith: { 6496 case ScopeIterator::ScopeTypeWith: {
6484 PrintF("With:\n"); 6497 PrintF("With:\n");
6485 Handle<JSObject> extension = 6498 Handle<JSObject> extension =
6486 Handle<JSObject>(CurrentContext()->extension()); 6499 Handle<JSObject>(CurrentContext()->extension());
6487 extension->Print(); 6500 extension->Print();
6488 break; 6501 break;
6489 } 6502 }
6490 6503
6504 case ScopeIterator::ScopeTypeCatch: {
6505 PrintF("Catch:\n");
6506 Handle<JSObject> extension =
6507 Handle<JSObject>(CurrentContext()->extension());
6508 extension->Print();
6509 break;
6510 }
6511
6491 case ScopeIterator::ScopeTypeClosure: { 6512 case ScopeIterator::ScopeTypeClosure: {
6492 PrintF("Closure:\n"); 6513 PrintF("Closure:\n");
6493 CurrentContext()->Print(); 6514 CurrentContext()->Print();
6494 if (CurrentContext()->has_extension()) { 6515 if (CurrentContext()->has_extension()) {
6495 Handle<JSObject> extension = 6516 Handle<JSObject> extension =
6496 Handle<JSObject>(CurrentContext()->extension()); 6517 Handle<JSObject>(CurrentContext()->extension());
6497 if (extension->IsJSContextExtensionObject()) { 6518 if (extension->IsJSContextExtensionObject()) {
6498 extension->Print(); 6519 extension->Print();
6499 } 6520 }
6500 } 6521 }
(...skipping 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after
7671 } else { 7692 } else {
7672 // Handle last resort GC and make sure to allow future allocations 7693 // Handle last resort GC and make sure to allow future allocations
7673 // to grow the heap without causing GCs (if possible). 7694 // to grow the heap without causing GCs (if possible).
7674 Counters::gc_last_resort_from_js.Increment(); 7695 Counters::gc_last_resort_from_js.Increment();
7675 Heap::CollectAllGarbage(false); 7696 Heap::CollectAllGarbage(false);
7676 } 7697 }
7677 } 7698 }
7678 7699
7679 7700
7680 } } // namespace v8::internal 7701 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/mirror-delay.js ('k') | test/mjsunit/debug-scopes.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698