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

Side by Side Diff: src/debug/debug-scopes.cc

Issue 1928463002: [debugger] use object with null proto to materialize scopes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | src/runtime/runtime-debug.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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/debug/debug-scopes.h" 5 #include "src/debug/debug-scopes.h"
6 6
7 #include "src/ast/scopes.h" 7 #include "src/ast/scopes.h"
8 #include "src/debug/debug.h" 8 #include "src/debug/debug.h"
9 #include "src/frames-inl.h" 9 #include "src/frames-inl.h"
10 #include "src/globals.h" 10 #include "src/globals.h"
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 } 446 }
447 } 447 }
448 448
449 449
450 MaybeHandle<JSObject> ScopeIterator::MaterializeScriptScope() { 450 MaybeHandle<JSObject> ScopeIterator::MaterializeScriptScope() {
451 Handle<JSGlobalObject> global(CurrentContext()->global_object()); 451 Handle<JSGlobalObject> global(CurrentContext()->global_object());
452 Handle<ScriptContextTable> script_contexts( 452 Handle<ScriptContextTable> script_contexts(
453 global->native_context()->script_context_table()); 453 global->native_context()->script_context_table());
454 454
455 Handle<JSObject> script_scope = 455 Handle<JSObject> script_scope =
456 isolate_->factory()->NewJSObject(isolate_->object_function()); 456 isolate_->factory()->NewJSObjectWithNullProto();
457 457
458 for (int context_index = 0; context_index < script_contexts->used(); 458 for (int context_index = 0; context_index < script_contexts->used();
459 context_index++) { 459 context_index++) {
460 Handle<Context> context = 460 Handle<Context> context =
461 ScriptContextTable::GetContext(script_contexts, context_index); 461 ScriptContextTable::GetContext(script_contexts, context_index);
462 Handle<ScopeInfo> scope_info(context->scope_info()); 462 Handle<ScopeInfo> scope_info(context->scope_info());
463 CopyContextLocalsToScopeObject(scope_info, context, script_scope); 463 CopyContextLocalsToScopeObject(scope_info, context, script_scope);
464 } 464 }
465 return script_scope; 465 return script_scope;
466 } 466 }
467 467
468 468
469 MaybeHandle<JSObject> ScopeIterator::MaterializeLocalScope() { 469 MaybeHandle<JSObject> ScopeIterator::MaterializeLocalScope() {
470 Handle<JSFunction> function = GetFunction(); 470 Handle<JSFunction> function = GetFunction();
471 471
472 Handle<JSObject> local_scope = 472 Handle<JSObject> local_scope =
473 isolate_->factory()->NewJSObject(isolate_->object_function()); 473 isolate_->factory()->NewJSObjectWithNullProto();
474 frame_inspector_->MaterializeStackLocals(local_scope, function); 474 frame_inspector_->MaterializeStackLocals(local_scope, function);
475 475
476 Handle<Context> frame_context = 476 Handle<Context> frame_context =
477 Handle<Context>::cast(frame_inspector_->GetContext()); 477 Handle<Context>::cast(frame_inspector_->GetContext());
478 478
479 HandleScope scope(isolate_); 479 HandleScope scope(isolate_);
480 Handle<SharedFunctionInfo> shared(function->shared()); 480 Handle<SharedFunctionInfo> shared(function->shared());
481 Handle<ScopeInfo> scope_info(shared->scope_info()); 481 Handle<ScopeInfo> scope_info(shared->scope_info());
482 482
483 if (!scope_info->HasContext()) return local_scope; 483 if (!scope_info->HasContext()) return local_scope;
(...skipping 22 matching lines...) Expand all
506 Handle<JSObject> ScopeIterator::MaterializeClosure() { 506 Handle<JSObject> ScopeIterator::MaterializeClosure() {
507 Handle<Context> context = CurrentContext(); 507 Handle<Context> context = CurrentContext();
508 DCHECK(context->IsFunctionContext()); 508 DCHECK(context->IsFunctionContext());
509 509
510 Handle<SharedFunctionInfo> shared(context->closure()->shared()); 510 Handle<SharedFunctionInfo> shared(context->closure()->shared());
511 Handle<ScopeInfo> scope_info(shared->scope_info()); 511 Handle<ScopeInfo> scope_info(shared->scope_info());
512 512
513 // Allocate and initialize a JSObject with all the content of this function 513 // Allocate and initialize a JSObject with all the content of this function
514 // closure. 514 // closure.
515 Handle<JSObject> closure_scope = 515 Handle<JSObject> closure_scope =
516 isolate_->factory()->NewJSObject(isolate_->object_function()); 516 isolate_->factory()->NewJSObjectWithNullProto();
517 517
518 // Fill all context locals to the context extension. 518 // Fill all context locals to the context extension.
519 CopyContextLocalsToScopeObject(scope_info, context, closure_scope); 519 CopyContextLocalsToScopeObject(scope_info, context, closure_scope);
520 520
521 // Finally copy any properties from the function context extension. This will 521 // Finally copy any properties from the function context extension. This will
522 // be variables introduced by eval. 522 // be variables introduced by eval.
523 if (context->has_extension()) { 523 if (context->has_extension()) {
524 bool success = CopyContextExtensionToScopeObject( 524 bool success = CopyContextExtensionToScopeObject(
525 handle(context->extension_object(), isolate_), closure_scope, OWN_ONLY); 525 handle(context->extension_object(), isolate_), closure_scope, OWN_ONLY);
526 DCHECK(success); 526 DCHECK(success);
527 USE(success); 527 USE(success);
528 } 528 }
529 529
530 return closure_scope; 530 return closure_scope;
531 } 531 }
532 532
533 533
534 // Create a plain JSObject which materializes the scope for the specified 534 // Create a plain JSObject which materializes the scope for the specified
535 // catch context. 535 // catch context.
536 Handle<JSObject> ScopeIterator::MaterializeCatchScope() { 536 Handle<JSObject> ScopeIterator::MaterializeCatchScope() {
537 Handle<Context> context = CurrentContext(); 537 Handle<Context> context = CurrentContext();
538 DCHECK(context->IsCatchContext()); 538 DCHECK(context->IsCatchContext());
539 Handle<String> name(context->catch_name()); 539 Handle<String> name(context->catch_name());
540 Handle<Object> thrown_object(context->get(Context::THROWN_OBJECT_INDEX), 540 Handle<Object> thrown_object(context->get(Context::THROWN_OBJECT_INDEX),
541 isolate_); 541 isolate_);
542 Handle<JSObject> catch_scope = 542 Handle<JSObject> catch_scope =
543 isolate_->factory()->NewJSObject(isolate_->object_function()); 543 isolate_->factory()->NewJSObjectWithNullProto();
544 JSObject::SetOwnPropertyIgnoreAttributes(catch_scope, name, thrown_object, 544 JSObject::SetOwnPropertyIgnoreAttributes(catch_scope, name, thrown_object,
545 NONE) 545 NONE)
546 .Check(); 546 .Check();
547 return catch_scope; 547 return catch_scope;
548 } 548 }
549 549
550 // Retrieve the with-context extension object. If the extension object is 550 // Retrieve the with-context extension object. If the extension object is
551 // a proxy, return an empty object. 551 // a proxy, return an empty object.
552 Handle<JSObject> ScopeIterator::WithContextExtension() { 552 Handle<JSObject> ScopeIterator::WithContextExtension() {
553 Handle<Context> context = CurrentContext(); 553 Handle<Context> context = CurrentContext();
554 DCHECK(context->IsWithContext()); 554 DCHECK(context->IsWithContext());
555 if (context->extension_receiver()->IsJSProxy()) { 555 if (context->extension_receiver()->IsJSProxy()) {
556 return isolate_->factory()->NewJSObjectWithNullProto(); 556 return isolate_->factory()->NewJSObjectWithNullProto();
557 } 557 }
558 return handle(JSObject::cast(context->extension_receiver())); 558 return handle(JSObject::cast(context->extension_receiver()));
559 } 559 }
560 560
561 // Create a plain JSObject which materializes the block scope for the specified 561 // Create a plain JSObject which materializes the block scope for the specified
562 // block context. 562 // block context.
563 Handle<JSObject> ScopeIterator::MaterializeBlockScope() { 563 Handle<JSObject> ScopeIterator::MaterializeBlockScope() {
564 Handle<JSObject> block_scope = 564 Handle<JSObject> block_scope =
565 isolate_->factory()->NewJSObject(isolate_->object_function()); 565 isolate_->factory()->NewJSObjectWithNullProto();
566 566
567 Handle<Context> context = Handle<Context>::null(); 567 Handle<Context> context = Handle<Context>::null();
568 if (!nested_scope_chain_.is_empty()) { 568 if (!nested_scope_chain_.is_empty()) {
569 Handle<ScopeInfo> scope_info = nested_scope_chain_.last().scope_info; 569 Handle<ScopeInfo> scope_info = nested_scope_chain_.last().scope_info;
570 frame_inspector_->MaterializeStackLocals(block_scope, scope_info); 570 frame_inspector_->MaterializeStackLocals(block_scope, scope_info);
571 if (scope_info->HasContext()) context = CurrentContext(); 571 if (scope_info->HasContext()) context = CurrentContext();
572 } else { 572 } else {
573 context = CurrentContext(); 573 context = CurrentContext();
574 } 574 }
575 575
(...skipping 16 matching lines...) Expand all
592 // Create a plain JSObject which materializes the module scope for the specified 592 // Create a plain JSObject which materializes the module scope for the specified
593 // module context. 593 // module context.
594 MaybeHandle<JSObject> ScopeIterator::MaterializeModuleScope() { 594 MaybeHandle<JSObject> ScopeIterator::MaterializeModuleScope() {
595 Handle<Context> context = CurrentContext(); 595 Handle<Context> context = CurrentContext();
596 DCHECK(context->IsModuleContext()); 596 DCHECK(context->IsModuleContext());
597 Handle<ScopeInfo> scope_info(context->scope_info()); 597 Handle<ScopeInfo> scope_info(context->scope_info());
598 598
599 // Allocate and initialize a JSObject with all the members of the debugged 599 // Allocate and initialize a JSObject with all the members of the debugged
600 // module. 600 // module.
601 Handle<JSObject> module_scope = 601 Handle<JSObject> module_scope =
602 isolate_->factory()->NewJSObject(isolate_->object_function()); 602 isolate_->factory()->NewJSObjectWithNullProto();
603 603
604 // Fill all context locals. 604 // Fill all context locals.
605 CopyContextLocalsToScopeObject(scope_info, context, module_scope); 605 CopyContextLocalsToScopeObject(scope_info, context, module_scope);
606 606
607 return module_scope; 607 return module_scope;
608 } 608 }
609 609
610 610
611 // Set the context local variable value. 611 // Set the context local variable value.
612 bool ScopeIterator::SetContextLocalValue(Handle<ScopeInfo> scope_info, 612 bool ScopeIterator::SetContextLocalValue(Handle<ScopeInfo> scope_info,
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 DCHECK((beg_pos >= 0 && end_pos >= 0) || inner_scope->is_hidden()); 851 DCHECK((beg_pos >= 0 && end_pos >= 0) || inner_scope->is_hidden());
852 if (beg_pos <= position && position < end_pos) { 852 if (beg_pos <= position && position < end_pos) {
853 GetNestedScopeChain(isolate, inner_scope, position); 853 GetNestedScopeChain(isolate, inner_scope, position);
854 return; 854 return;
855 } 855 }
856 } 856 }
857 } 857 }
858 858
859 } // namespace internal 859 } // namespace internal
860 } // namespace v8 860 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/runtime/runtime-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698