| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 ObjectLookupGetter) === this.fun || | 819 ObjectLookupGetter) === this.fun || |
| 820 %_CallFunction(this.receiver, | 820 %_CallFunction(this.receiver, |
| 821 ownName, | 821 ownName, |
| 822 ObjectLookupSetter) === this.fun || | 822 ObjectLookupSetter) === this.fun || |
| 823 %GetDataProperty(this.receiver, ownName) === this.fun)) { | 823 %GetDataProperty(this.receiver, ownName) === this.fun)) { |
| 824 // To handle DontEnum properties we guess that the method has | 824 // To handle DontEnum properties we guess that the method has |
| 825 // the same name as the function. | 825 // the same name as the function. |
| 826 return ownName; | 826 return ownName; |
| 827 } | 827 } |
| 828 var name = null; | 828 var name = null; |
| 829 for (var prop in this.receiver) { | 829 var property_names = %GetPropertyNamesNoSideEffect(this.receiver); |
| 830 for (var i = 0; i < property_names.length; i++) { |
| 831 var prop = property_names[i]; |
| 830 if (%_CallFunction(this.receiver, prop, ObjectLookupGetter) === this.fun || | 832 if (%_CallFunction(this.receiver, prop, ObjectLookupGetter) === this.fun || |
| 831 %_CallFunction(this.receiver, prop, ObjectLookupSetter) === this.fun || | 833 %_CallFunction(this.receiver, prop, ObjectLookupSetter) === this.fun || |
| 832 %GetDataProperty(this.receiver, prop) === this.fun) { | 834 %GetDataProperty(this.receiver, TO_STRING_INLINE(prop)) === this.fun) { |
| 833 // If we find more than one match bail out to avoid confusion. | 835 // If we find more than one match bail out to avoid confusion. |
| 834 if (name) { | 836 if (name) { |
| 835 return null; | 837 return null; |
| 836 } | 838 } |
| 837 name = prop; | 839 name = prop; |
| 838 } | 840 } |
| 839 } | 841 } |
| 840 if (name) { | 842 if (name) { |
| 841 return name; | 843 return name; |
| 842 } | 844 } |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1123 stack = FormatStackTrace(error_string, GetStackFrames(stack)); | 1125 stack = FormatStackTrace(error_string, GetStackFrames(stack)); |
| 1124 // Release context value. | 1126 // Release context value. |
| 1125 error_string = void 0; | 1127 error_string = void 0; |
| 1126 return stack; | 1128 return stack; |
| 1127 }; | 1129 }; |
| 1128 %MarkOneShotGetter(getter); | 1130 %MarkOneShotGetter(getter); |
| 1129 | 1131 |
| 1130 // The 'stack' property of the receiver is set as data property. If | 1132 // The 'stack' property of the receiver is set as data property. If |
| 1131 // the receiver is the same as holder, this accessor pair is replaced. | 1133 // the receiver is the same as holder, this accessor pair is replaced. |
| 1132 var setter = function(v) { | 1134 var setter = function(v) { |
| 1135 // If the receiver is the holder, release the raw stack trace. |
| 1136 if (this == obj) stack = void 0; |
| 1133 %DefineOrRedefineDataProperty(this, 'stack', v, NONE); | 1137 %DefineOrRedefineDataProperty(this, 'stack', v, NONE); |
| 1134 }; | 1138 }; |
| 1135 | 1139 |
| 1136 %DefineOrRedefineAccessorProperty(obj, 'stack', getter, setter, DONT_ENUM); | 1140 %DefineOrRedefineAccessorProperty(obj, 'stack', getter, setter, DONT_ENUM); |
| 1137 } | 1141 } |
| 1138 | 1142 |
| 1139 | 1143 |
| 1140 function SetUpError() { | 1144 function SetUpError() { |
| 1141 // Define special error type constructors. | 1145 // Define special error type constructors. |
| 1142 | 1146 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1275 // a data property. | 1279 // a data property. |
| 1276 var error_string = boilerplate.name + ": " + boilerplate.message; | 1280 var error_string = boilerplate.name + ": " + boilerplate.message; |
| 1277 | 1281 |
| 1278 // The getter must not change the object layout as it may be called after GC. | 1282 // The getter must not change the object layout as it may be called after GC. |
| 1279 function getter() { | 1283 function getter() { |
| 1280 var holder = this; | 1284 var holder = this; |
| 1281 while (!IS_ERROR(holder)) { | 1285 while (!IS_ERROR(holder)) { |
| 1282 holder = %GetPrototype(holder); | 1286 holder = %GetPrototype(holder); |
| 1283 if (holder == null) return MakeSyntaxError('illegal_access', []); | 1287 if (holder == null) return MakeSyntaxError('illegal_access', []); |
| 1284 } | 1288 } |
| 1285 var stack = %GetOverflowedStackTrace(holder); | 1289 var stack = %GetOverflowStackTrace(holder); |
| 1286 if (IS_STRING(stack)) return stack; | 1290 if (IS_STRING(stack)) return stack; |
| 1287 if (IS_ARRAY(stack)) { | 1291 if (IS_ARRAY(stack)) { |
| 1288 var result = FormatStackTrace(error_string, GetStackFrames(stack)); | 1292 var result = FormatStackTrace(error_string, GetStackFrames(stack)); |
| 1289 %SetOverflowedStackTrace(holder, result); | 1293 %SetOverflowStackTrace(holder, result); |
| 1290 return result; | 1294 return result; |
| 1291 } | 1295 } |
| 1292 return void 0; | 1296 return void 0; |
| 1293 } | 1297 } |
| 1294 %MarkOneShotGetter(getter); | 1298 %MarkOneShotGetter(getter); |
| 1295 | 1299 |
| 1296 // The 'stack' property of the receiver is set as data property. If | 1300 // The 'stack' property of the receiver is set as data property. If |
| 1297 // the receiver is the same as holder, this accessor pair is replaced. | 1301 // the receiver is the same as holder, this accessor pair is replaced. |
| 1298 function setter(v) { | 1302 function setter(v) { |
| 1303 // Attempt to release the overflow stack trace stored as hidden property. |
| 1304 if (IS_ERROR(this)) %SetOverflowStackTrace(this, void 0); |
| 1299 %DefineOrRedefineDataProperty(this, 'stack', v, NONE); | 1305 %DefineOrRedefineDataProperty(this, 'stack', v, NONE); |
| 1300 // Release the stack trace that is stored as hidden property, if exists. | |
| 1301 %SetOverflowedStackTrace(this, void 0); | |
| 1302 } | 1306 } |
| 1303 | 1307 |
| 1304 %DefineOrRedefineAccessorProperty( | 1308 %DefineOrRedefineAccessorProperty( |
| 1305 boilerplate, 'stack', getter, setter, DONT_ENUM); | 1309 boilerplate, 'stack', getter, setter, DONT_ENUM); |
| 1306 | 1310 |
| 1307 return boilerplate; | 1311 return boilerplate; |
| 1308 } | 1312 } |
| 1309 | 1313 |
| 1310 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate(); | 1314 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate(); |
| OLD | NEW |