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

Side by Side Diff: src/v8natives.js

Issue 514613002: Remove false checks since GetOwnProperty now throws an exception on access check violation. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | « no previous file | 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 // This file relies on the fact that the following declarations have been made 5 // This file relies on the fact that the following declarations have been made
6 // in runtime.js: 6 // in runtime.js:
7 // var $Object = global.Object; 7 // var $Object = global.Object;
8 // var $Boolean = global.Boolean; 8 // var $Boolean = global.Boolean;
9 // var $Number = global.Number; 9 // var $Number = global.Number;
10 // var $Function = global.Function; 10 // var $Function = global.Function;
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 }, 564 },
565 "hasSetter", function() { 565 "hasSetter", function() {
566 return this.hasSetter_; 566 return this.hasSetter_;
567 })); 567 }));
568 568
569 569
570 // Converts an array returned from Runtime_GetOwnProperty to an actual 570 // Converts an array returned from Runtime_GetOwnProperty to an actual
571 // property descriptor. For a description of the array layout please 571 // property descriptor. For a description of the array layout please
572 // see the runtime.cc file. 572 // see the runtime.cc file.
573 function ConvertDescriptorArrayToDescriptor(desc_array) { 573 function ConvertDescriptorArrayToDescriptor(desc_array) {
574 if (desc_array === false) {
575 throw 'Internal error: invalid desc_array';
576 }
577
578 if (IS_UNDEFINED(desc_array)) { 574 if (IS_UNDEFINED(desc_array)) {
579 return UNDEFINED; 575 return UNDEFINED;
580 } 576 }
581 577
582 var desc = new PropertyDescriptor(); 578 var desc = new PropertyDescriptor();
583 // This is an accessor. 579 // This is an accessor.
584 if (desc_array[IS_ACCESSOR_INDEX]) { 580 if (desc_array[IS_ACCESSOR_INDEX]) {
585 desc.setGet(desc_array[GETTER_INDEX]); 581 desc.setGet(desc_array[GETTER_INDEX]);
586 desc.setSet(desc_array[SETTER_INDEX]); 582 desc.setSet(desc_array[SETTER_INDEX]);
587 } else { 583 } else {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 [handler, "getOwnPropertyDescriptor", p, descriptor]); 638 [handler, "getOwnPropertyDescriptor", p, descriptor]);
643 } 639 }
644 return desc; 640 return desc;
645 } 641 }
646 642
647 // GetOwnProperty returns an array indexed by the constants 643 // GetOwnProperty returns an array indexed by the constants
648 // defined in macros.py. 644 // defined in macros.py.
649 // If p is not a property on obj undefined is returned. 645 // If p is not a property on obj undefined is returned.
650 var props = %GetOwnProperty(ToObject(obj), p); 646 var props = %GetOwnProperty(ToObject(obj), p);
651 647
652 // A false value here means that access checks failed.
653 if (props === false) return UNDEFINED;
654
655 return ConvertDescriptorArrayToDescriptor(props); 648 return ConvertDescriptorArrayToDescriptor(props);
656 } 649 }
657 650
658 651
659 // ES5 section 8.12.7. 652 // ES5 section 8.12.7.
660 function Delete(obj, p, should_throw) { 653 function Delete(obj, p, should_throw) {
661 var desc = GetOwnPropertyJS(obj, p); 654 var desc = GetOwnPropertyJS(obj, p);
662 if (IS_UNDEFINED(desc)) return true; 655 if (IS_UNDEFINED(desc)) return true;
663 if (desc.isConfigurable()) { 656 if (desc.isConfigurable()) {
664 %DeleteProperty(obj, p, 0); 657 %DeleteProperty(obj, p, 0);
(...skipping 20 matching lines...) Expand all
685 } else { 678 } else {
686 return false; 679 return false;
687 } 680 }
688 } 681 }
689 return true; 682 return true;
690 } 683 }
691 684
692 685
693 // ES5 8.12.9. 686 // ES5 8.12.9.
694 function DefineObjectProperty(obj, p, desc, should_throw) { 687 function DefineObjectProperty(obj, p, desc, should_throw) {
695 var current_or_access = %GetOwnProperty(ToObject(obj), ToName(p)); 688 var current_array = %GetOwnProperty(ToObject(obj), ToName(p));
696 // A false value here means that access checks failed. 689 var current = ConvertDescriptorArrayToDescriptor(current_array);
697 if (current_or_access === false) return UNDEFINED;
698
699 var current = ConvertDescriptorArrayToDescriptor(current_or_access);
700 var extensible = %IsExtensible(ToObject(obj)); 690 var extensible = %IsExtensible(ToObject(obj));
701 691
702 // Error handling according to spec. 692 // Error handling according to spec.
703 // Step 3 693 // Step 3
704 if (IS_UNDEFINED(current) && !extensible) { 694 if (IS_UNDEFINED(current) && !extensible) {
705 if (should_throw) { 695 if (should_throw) {
706 throw MakeTypeError("define_disallowed", [p]); 696 throw MakeTypeError("define_disallowed", [p]);
707 } else { 697 } else {
708 return false; 698 return false;
709 } 699 }
(...skipping 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1911 } 1901 }
1912 if (!IS_SPEC_FUNCTION(method)) { 1902 if (!IS_SPEC_FUNCTION(method)) {
1913 throw MakeTypeError('not_iterable', [obj]); 1903 throw MakeTypeError('not_iterable', [obj]);
1914 } 1904 }
1915 var iterator = %_CallFunction(obj, method); 1905 var iterator = %_CallFunction(obj, method);
1916 if (!IS_SPEC_OBJECT(iterator)) { 1906 if (!IS_SPEC_OBJECT(iterator)) {
1917 throw MakeTypeError('not_an_iterator', [iterator]); 1907 throw MakeTypeError('not_an_iterator', [iterator]);
1918 } 1908 }
1919 return iterator; 1909 return iterator;
1920 } 1910 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698