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

Side by Side Diff: src/messages.js

Issue 50011: Revert change 1509 that flush ICs when adding setters on an object or... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 9 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/ic.cc ('k') | src/objects.h » ('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-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 // Error implementation 595 // Error implementation
596 596
597 // If this object gets passed to an error constructor the error will 597 // If this object gets passed to an error constructor the error will
598 // get an accessor for .message that constructs a descriptive error 598 // get an accessor for .message that constructs a descriptive error
599 // message on access. 599 // message on access.
600 var kAddMessageAccessorsMarker = { }; 600 var kAddMessageAccessorsMarker = { };
601 601
602 // Defines accessors for a property that is calculated the first time 602 // Defines accessors for a property that is calculated the first time
603 // the property is read and then replaces the accessor with the value. 603 // the property is read and then replaces the accessor with the value.
604 // Also, setting the property causes the accessors to be deleted. 604 // Also, setting the property causes the accessors to be deleted.
605 function DefineOneShotAccessor(obj, name, fun, never_used) { 605 function DefineOneShotAccessor(obj, name, fun) {
606 // Note that the accessors consistently operate on 'obj', not 'this'. 606 // Note that the accessors consistently operate on 'obj', not 'this'.
607 // Since the object may occur in someone else's prototype chain we 607 // Since the object may occur in someone else's prototype chain we
608 // can't rely on 'this' being the same as 'obj'. 608 // can't rely on 'this' being the same as 'obj'.
609 obj.__defineGetter__(name, function () { 609 obj.__defineGetter__(name, function () {
610 var value = fun(obj); 610 var value = fun(obj);
611 obj[name] = value; 611 obj[name] = value;
612 return value; 612 return value;
613 }); 613 });
614 %DefineAccessor(ToObject(obj), ToString(name), SETTER, function (v) { 614 obj.__defineSetter__(name, function (v) {
615 delete obj[name]; 615 delete obj[name];
616 obj[name] = v; 616 obj[name] = v;
617 }, 0, never_used); 617 });
618 } 618 }
619 619
620 function DefineError(f) { 620 function DefineError(f) {
621 // Store the error function in both the global object 621 // Store the error function in both the global object
622 // and the runtime object. The function is fetched 622 // and the runtime object. The function is fetched
623 // from the runtime object when throwing errors from 623 // from the runtime object when throwing errors from
624 // within the runtime system to avoid strange side 624 // within the runtime system to avoid strange side
625 // effects when overwriting the error functions from 625 // effects when overwriting the error functions from
626 // user code. 626 // user code.
627 var name = f.name; 627 var name = f.name;
(...skipping 13 matching lines...) Expand all
641 %FunctionSetPrototype(f, new $Error()); 641 %FunctionSetPrototype(f, new $Error());
642 } 642 }
643 %FunctionSetInstanceClassName(f, 'Error'); 643 %FunctionSetInstanceClassName(f, 'Error');
644 %SetProperty(f.prototype, 'constructor', f, DONT_ENUM); 644 %SetProperty(f.prototype, 'constructor', f, DONT_ENUM);
645 f.prototype.name = name; 645 f.prototype.name = name;
646 %SetCode(f, function(m) { 646 %SetCode(f, function(m) {
647 if (%IsConstructCall()) { 647 if (%IsConstructCall()) {
648 if (m === kAddMessageAccessorsMarker) { 648 if (m === kAddMessageAccessorsMarker) {
649 DefineOneShotAccessor(this, 'message', function (obj) { 649 DefineOneShotAccessor(this, 'message', function (obj) {
650 return FormatMessage({type: obj.type, args: obj.arguments}); 650 return FormatMessage({type: obj.type, args: obj.arguments});
651 }, true); 651 });
652 } else if (!IS_UNDEFINED(m)) { 652 } else if (!IS_UNDEFINED(m)) {
653 this.message = ToString(m); 653 this.message = ToString(m);
654 } 654 }
655 } else { 655 } else {
656 return new f(m); 656 return new f(m);
657 } 657 }
658 }); 658 });
659 } 659 }
660 660
661 $Math.__proto__ = global.Object.prototype; 661 $Math.__proto__ = global.Object.prototype;
(...skipping 15 matching lines...) Expand all
677 return this.name + ": " + FormatMessage({ type: type, args: this.arguments } ); 677 return this.name + ": " + FormatMessage({ type: type, args: this.arguments } );
678 } 678 }
679 var message = this.message; 679 var message = this.message;
680 return this.name + (message ? (": " + message) : ""); 680 return this.name + (message ? (": " + message) : "");
681 }, DONT_ENUM); 681 }, DONT_ENUM);
682 682
683 683
684 // Boilerplate for exceptions for stack overflows. Used from 684 // Boilerplate for exceptions for stack overflows. Used from
685 // Top::StackOverflow(). 685 // Top::StackOverflow().
686 const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); 686 const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []);
OLDNEW
« no previous file with comments | « src/ic.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698