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

Side by Side Diff: src/messages.js

Issue 6269021: Fix another message object leak. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } 75 }
76 76
77 77
78 var kMessages = 0; 78 var kMessages = 0;
79 79
80 80
81 function FormatString(format, args) { 81 function FormatString(format, args) {
82 var result = format; 82 var result = format;
83 for (var i = 0; i < args.length; i++) { 83 for (var i = 0; i < args.length; i++) {
84 var str; 84 var str;
85 try { str = ToDetailString(args[i]); } 85 try {
86 catch (e) { str = "#<error>"; } 86 str = ToDetailString(args[i]);
87 } catch (e) {
88 str = "#<error>";
89 }
87 result = ArrayJoin.call(StringSplit.call(result, "%" + i), str); 90 result = ArrayJoin.call(StringSplit.call(result, "%" + i), str);
88 } 91 }
89 return result; 92 return result;
90 } 93 }
91 94
92 95
93 // To check if something is a native error we need to check the 96 // To check if something is a native error we need to check the
94 // concrete native error types. It is not enough to check "obj 97 // concrete native error types. It is not enough to check "obj
95 // instanceof $Error" because user code can replace 98 // instanceof $Error" because user code can replace
96 // NativeError.prototype.__proto__. User code cannot replace 99 // NativeError.prototype.__proto__. User code cannot replace
(...skipping 20 matching lines...) Expand all
117 return ToString(obj); 120 return ToString(obj);
118 } 121 }
119 } 122 }
120 123
121 124
122 function ToDetailString(obj) { 125 function ToDetailString(obj) {
123 if (obj != null && IS_OBJECT(obj) && obj.toString === $Object.prototype.toStri ng) { 126 if (obj != null && IS_OBJECT(obj) && obj.toString === $Object.prototype.toStri ng) {
124 var constructor = obj.constructor; 127 var constructor = obj.constructor;
125 if (!constructor) return ToStringCheckErrorObject(obj); 128 if (!constructor) return ToStringCheckErrorObject(obj);
126 var constructorName = constructor.name; 129 var constructorName = constructor.name;
127 if (!constructorName) return ToStringCheckErrorObject(obj); 130 if (!constructorName || !IS_STRING(constructorName)) {
131 return ToStringCheckErrorObject(obj);
132 }
128 return "#<" + GetInstanceName(constructorName) + ">"; 133 return "#<" + GetInstanceName(constructorName) + ">";
129 } else { 134 } else {
130 return ToStringCheckErrorObject(obj); 135 return ToStringCheckErrorObject(obj);
131 } 136 }
132 } 137 }
133 138
134 139
135 function MakeGenericError(constructor, type, args) { 140 function MakeGenericError(constructor, type, args) {
136 if (IS_UNDEFINED(args)) { 141 if (IS_UNDEFINED(args)) {
137 args = []; 142 args = [];
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 else throw e; 1078 else throw e;
1074 } 1079 }
1075 } 1080 }
1076 1081
1077 %FunctionSetName(errorToString, 'toString'); 1082 %FunctionSetName(errorToString, 'toString');
1078 %SetProperty($Error.prototype, 'toString', errorToString, DONT_ENUM); 1083 %SetProperty($Error.prototype, 'toString', errorToString, DONT_ENUM);
1079 1084
1080 // Boilerplate for exceptions for stack overflows. Used from 1085 // Boilerplate for exceptions for stack overflows. Used from
1081 // Top::StackOverflow(). 1086 // Top::StackOverflow().
1082 const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); 1087 const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []);
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698