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

Side by Side Diff: src/messages.js

Issue 46593010: Correctly load message from an Error object. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month 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 | test/mjsunit/regress/regress-crbug-306220.js » ('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 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 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 $Error.captureStackTrace = captureStackTrace; 1240 $Error.captureStackTrace = captureStackTrace;
1241 1241
1242 %SetProperty($Error.prototype, 'message', '', DONT_ENUM); 1242 %SetProperty($Error.prototype, 'message', '', DONT_ENUM);
1243 1243
1244 // Global list of error objects visited during ErrorToString. This is 1244 // Global list of error objects visited during ErrorToString. This is
1245 // used to detect cycles in error toString formatting. 1245 // used to detect cycles in error toString formatting.
1246 var visited_errors = new InternalArray(); 1246 var visited_errors = new InternalArray();
1247 var cyclic_error_marker = new $Object(); 1247 var cyclic_error_marker = new $Object();
1248 1248
1249 function GetPropertyWithoutInvokingMonkeyGetters(error, name) { 1249 function GetPropertyWithoutInvokingMonkeyGetters(error, name) {
1250 var current = error;
1250 // Climb the prototype chain until we find the holder. 1251 // Climb the prototype chain until we find the holder.
1251 while (error && !%HasLocalProperty(error, name)) { 1252 while (current && !%HasLocalProperty(current, name)) {
1252 error = %GetPrototype(error); 1253 current = %GetPrototype(current);
1253 } 1254 }
1254 if (IS_NULL(error)) return UNDEFINED; 1255 if (IS_NULL(current)) return UNDEFINED;
1255 if (!IS_OBJECT(error)) return error[name]; 1256 if (!IS_OBJECT(current)) return error[name];
1256 // If the property is an accessor on one of the predefined errors that can be 1257 // If the property is an accessor on one of the predefined errors that can be
1257 // generated statically by the compiler, don't touch it. This is to address 1258 // generated statically by the compiler, don't touch it. This is to address
1258 // http://code.google.com/p/chromium/issues/detail?id=69187 1259 // http://code.google.com/p/chromium/issues/detail?id=69187
1259 var desc = %GetOwnProperty(error, name); 1260 var desc = %GetOwnProperty(current, name);
1260 if (desc && desc[IS_ACCESSOR_INDEX]) { 1261 if (desc && desc[IS_ACCESSOR_INDEX]) {
1261 var isName = name === "name"; 1262 var isName = name === "name";
1262 if (error === $ReferenceError.prototype) 1263 if (current === $ReferenceError.prototype)
1263 return isName ? "ReferenceError" : UNDEFINED; 1264 return isName ? "ReferenceError" : UNDEFINED;
1264 if (error === $SyntaxError.prototype) 1265 if (current === $SyntaxError.prototype)
1265 return isName ? "SyntaxError" : UNDEFINED; 1266 return isName ? "SyntaxError" : UNDEFINED;
1266 if (error === $TypeError.prototype) 1267 if (current === $TypeError.prototype)
1267 return isName ? "TypeError" : UNDEFINED; 1268 return isName ? "TypeError" : UNDEFINED;
1268 } 1269 }
1269 // Otherwise, read normally. 1270 // Otherwise, read normally.
1270 return error[name]; 1271 return error[name];
1271 } 1272 }
1272 1273
1273 function ErrorToStringDetectCycle(error) { 1274 function ErrorToStringDetectCycle(error) {
1274 if (!%PushIfAbsent(visited_errors, error)) throw cyclic_error_marker; 1275 if (!%PushIfAbsent(visited_errors, error)) throw cyclic_error_marker;
1275 try { 1276 try {
1276 var name = GetPropertyWithoutInvokingMonkeyGetters(error, "name"); 1277 var name = GetPropertyWithoutInvokingMonkeyGetters(error, "name");
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1341 %GetAndClearOverflowedStackTrace(this); 1342 %GetAndClearOverflowedStackTrace(this);
1342 }; 1343 };
1343 1344
1344 %DefineOrRedefineAccessorProperty( 1345 %DefineOrRedefineAccessorProperty(
1345 boilerplate, 'stack', getter, setter, DONT_ENUM); 1346 boilerplate, 'stack', getter, setter, DONT_ENUM);
1346 1347
1347 return boilerplate; 1348 return boilerplate;
1348 } 1349 }
1349 1350
1350 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate(); 1351 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate();
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-crbug-306220.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698