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

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

Issue 1668853002: [proxies] allow duplicate keys for [[OwnPropertyKeys]] trap. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: enabling test again Created 4 years, 10 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
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 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 // Third fill all context locals. 469 // Third fill all context locals.
470 Handle<Context> function_context(frame_context->closure_context()); 470 Handle<Context> function_context(frame_context->closure_context());
471 CopyContextLocalsToScopeObject(scope_info, function_context, local_scope); 471 CopyContextLocalsToScopeObject(scope_info, function_context, local_scope);
472 472
473 // Finally copy any properties from the function context extension. 473 // Finally copy any properties from the function context extension.
474 // These will be variables introduced by eval. 474 // These will be variables introduced by eval.
475 if (function_context->closure() == *function && 475 if (function_context->closure() == *function &&
476 function_context->has_extension() && 476 function_context->has_extension() &&
477 !function_context->IsNativeContext()) { 477 !function_context->IsNativeContext()) {
478 bool success = CopyContextExtensionToScopeObject( 478 bool success = CopyContextExtensionToScopeObject(
479 handle(function_context->extension_object(), isolate_), 479 handle(function_context->extension_object(), isolate_), local_scope,
480 local_scope, JSReceiver::INCLUDE_PROTOS); 480 KeyCollectionType::INCLUDE_PROTOS);
481 if (!success) return MaybeHandle<JSObject>(); 481 if (!success) return MaybeHandle<JSObject>();
482 } 482 }
483 483
484 return local_scope; 484 return local_scope;
485 } 485 }
486 486
487 487
488 // Create a plain JSObject which materializes the closure content for the 488 // Create a plain JSObject which materializes the closure content for the
489 // context. 489 // context.
490 Handle<JSObject> ScopeIterator::MaterializeClosure() { 490 Handle<JSObject> ScopeIterator::MaterializeClosure() {
491 Handle<Context> context = CurrentContext(); 491 Handle<Context> context = CurrentContext();
492 DCHECK(context->IsFunctionContext()); 492 DCHECK(context->IsFunctionContext());
493 493
494 Handle<SharedFunctionInfo> shared(context->closure()->shared()); 494 Handle<SharedFunctionInfo> shared(context->closure()->shared());
495 Handle<ScopeInfo> scope_info(shared->scope_info()); 495 Handle<ScopeInfo> scope_info(shared->scope_info());
496 496
497 // Allocate and initialize a JSObject with all the content of this function 497 // Allocate and initialize a JSObject with all the content of this function
498 // closure. 498 // closure.
499 Handle<JSObject> closure_scope = 499 Handle<JSObject> closure_scope =
500 isolate_->factory()->NewJSObject(isolate_->object_function()); 500 isolate_->factory()->NewJSObject(isolate_->object_function());
501 501
502 // Fill all context locals to the context extension. 502 // Fill all context locals to the context extension.
503 CopyContextLocalsToScopeObject(scope_info, context, closure_scope); 503 CopyContextLocalsToScopeObject(scope_info, context, closure_scope);
504 504
505 // Finally copy any properties from the function context extension. This will 505 // Finally copy any properties from the function context extension. This will
506 // be variables introduced by eval. 506 // be variables introduced by eval.
507 if (context->has_extension()) { 507 if (context->has_extension()) {
508 bool success = CopyContextExtensionToScopeObject( 508 bool success = CopyContextExtensionToScopeObject(
509 handle(context->extension_object(), isolate_), closure_scope, 509 handle(context->extension_object(), isolate_), closure_scope,
510 JSReceiver::OWN_ONLY); 510 KeyCollectionType::OWN_ONLY);
511 DCHECK(success); 511 DCHECK(success);
512 USE(success); 512 USE(success);
513 } 513 }
514 514
515 return closure_scope; 515 return closure_scope;
516 } 516 }
517 517
518 518
519 // Create a plain JSObject which materializes the scope for the specified 519 // Create a plain JSObject which materializes the scope for the specified
520 // catch context. 520 // catch context.
(...skipping 28 matching lines...) Expand all
549 } 549 }
550 550
551 if (!context.is_null()) { 551 if (!context.is_null()) {
552 // Fill all context locals. 552 // Fill all context locals.
553 CopyContextLocalsToScopeObject(handle(context->scope_info()), 553 CopyContextLocalsToScopeObject(handle(context->scope_info()),
554 context, block_scope); 554 context, block_scope);
555 // Fill all extension variables. 555 // Fill all extension variables.
556 if (context->extension_object() != nullptr) { 556 if (context->extension_object() != nullptr) {
557 bool success = CopyContextExtensionToScopeObject( 557 bool success = CopyContextExtensionToScopeObject(
558 handle(context->extension_object()), block_scope, 558 handle(context->extension_object()), block_scope,
559 JSReceiver::OWN_ONLY); 559 KeyCollectionType::OWN_ONLY);
560 DCHECK(success); 560 DCHECK(success);
561 USE(success); 561 USE(success);
562 } 562 }
563 } 563 }
564 return block_scope; 564 return block_scope;
565 } 565 }
566 566
567 567
568 // Create a plain JSObject which materializes the module scope for the specified 568 // Create a plain JSObject which materializes the module scope for the specified
569 // module context. 569 // module context.
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 if (value->IsTheHole()) continue; 787 if (value->IsTheHole()) continue;
788 // This should always succeed. 788 // This should always succeed.
789 // TODO(verwaest): Use AddDataProperty instead. 789 // TODO(verwaest): Use AddDataProperty instead.
790 JSObject::SetOwnPropertyIgnoreAttributes( 790 JSObject::SetOwnPropertyIgnoreAttributes(
791 scope_object, handle(String::cast(scope_info->get(i + start))), value, 791 scope_object, handle(String::cast(scope_info->get(i + start))), value,
792 NONE) 792 NONE)
793 .Check(); 793 .Check();
794 } 794 }
795 } 795 }
796 796
797
798 bool ScopeIterator::CopyContextExtensionToScopeObject( 797 bool ScopeIterator::CopyContextExtensionToScopeObject(
799 Handle<JSObject> extension, Handle<JSObject> scope_object, 798 Handle<JSObject> extension, Handle<JSObject> scope_object,
800 JSReceiver::KeyCollectionType type) { 799 KeyCollectionType type) {
801 Handle<FixedArray> keys; 800 Handle<FixedArray> keys;
802 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 801 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
803 isolate_, keys, JSReceiver::GetKeys(extension, type, ENUMERABLE_STRINGS), 802 isolate_, keys, JSReceiver::GetKeys(extension, type, ENUMERABLE_STRINGS),
804 false); 803 false);
805 804
806 for (int i = 0; i < keys->length(); i++) { 805 for (int i = 0; i < keys->length(); i++) {
807 // Names of variables introduced by eval are strings. 806 // Names of variables introduced by eval are strings.
808 DCHECK(keys->get(i)->IsString()); 807 DCHECK(keys->get(i)->IsString());
809 Handle<String> key(String::cast(keys->get(i))); 808 Handle<String> key(String::cast(keys->get(i)));
810 Handle<Object> value; 809 Handle<Object> value;
811 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 810 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
812 isolate_, value, Object::GetPropertyOrElement(extension, key), false); 811 isolate_, value, Object::GetPropertyOrElement(extension, key), false);
813 RETURN_ON_EXCEPTION_VALUE( 812 RETURN_ON_EXCEPTION_VALUE(
814 isolate_, JSObject::SetOwnPropertyIgnoreAttributes( 813 isolate_, JSObject::SetOwnPropertyIgnoreAttributes(
815 scope_object, key, value, NONE), false); 814 scope_object, key, value, NONE), false);
816 } 815 }
817 return true; 816 return true;
818 } 817 }
819 818
820 } // namespace internal 819 } // namespace internal
821 } // namespace v8 820 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698