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

Side by Side Diff: src/messages.js

Issue 11377158: Fire 'stack' getter of error objects after GC. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments. Created 8 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
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 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 1078
1079 function captureStackTrace(obj, cons_opt) { 1079 function captureStackTrace(obj, cons_opt) {
1080 var stackTraceLimit = $Error.stackTraceLimit; 1080 var stackTraceLimit = $Error.stackTraceLimit;
1081 if (!stackTraceLimit || !IS_NUMBER(stackTraceLimit)) return; 1081 if (!stackTraceLimit || !IS_NUMBER(stackTraceLimit)) return;
1082 if (stackTraceLimit < 0 || stackTraceLimit > 10000) { 1082 if (stackTraceLimit < 0 || stackTraceLimit > 10000) {
1083 stackTraceLimit = 10000; 1083 stackTraceLimit = 10000;
1084 } 1084 }
1085 var raw_stack = %CollectStackTrace(obj, 1085 var raw_stack = %CollectStackTrace(obj,
1086 cons_opt ? cons_opt : captureStackTrace, 1086 cons_opt ? cons_opt : captureStackTrace,
1087 stackTraceLimit); 1087 stackTraceLimit);
1088
1089 // Don't be lazy if the error stack formatting is custom (observable).
1090 if (IS_FUNCTION($Error.prepareStackTrace)) {
1091 obj.stack = FormatRawStackTrace(obj, raw_stack);
1092 return;
1093 }
1094
1088 // Note that 'obj' and 'this' maybe different when called on objects that 1095 // Note that 'obj' and 'this' maybe different when called on objects that
1089 // have the error object on its prototype chain. The getter replaces itself 1096 // have the error object on its prototype chain. The getter replaces itself
1090 // with a data property as soon as the stack trace has been formatted. 1097 // with a data property as soon as the stack trace has been formatted.
1091 var getter = function() { 1098 var getter = function() {
1092 var value = FormatRawStackTrace(obj, raw_stack); 1099 var value = FormatRawStackTrace(obj, raw_stack);
1093 %DefineOrRedefineDataProperty(obj, 'stack', value, NONE); 1100 %DefineOrRedefineDataProperty(obj, 'stack', value, NONE);
1094 return value; 1101 return value;
1095 }; 1102 };
1096 // The 'stack' property of the receiver is set as data property. If 1103 // The 'stack' property of the receiver is set as data property. If
1097 // the receiver is the same as holder, this accessor pair is replaced. 1104 // the receiver is the same as holder, this accessor pair is replaced.
1098 var setter = function(v) { 1105 var setter = function(v) {
1099 %DefineOrRedefineDataProperty(this, 'stack', v, NONE); 1106 %DefineOrRedefineDataProperty(this, 'stack', v, NONE);
1100 }; 1107 };
1101 1108
1109 %SetNativeFlag(getter);
1102 %DefineOrRedefineAccessorProperty(obj, 'stack', getter, setter, DONT_ENUM); 1110 %DefineOrRedefineAccessorProperty(obj, 'stack', getter, setter, DONT_ENUM);
1103 } 1111 }
1104 1112
1105 1113
1106 function SetUpError() { 1114 function SetUpError() {
1107 // Define special error type constructors. 1115 // Define special error type constructors.
1108 1116
1109 var DefineError = function(f) { 1117 var DefineError = function(f) {
1110 // Store the error function in both the global object 1118 // Store the error function in both the global object
1111 // and the runtime object. The function is fetched 1119 // and the runtime object. The function is fetched
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 %DefineOrRedefineDataProperty(holder, 'stack', result, NONE); 1259 %DefineOrRedefineDataProperty(holder, 'stack', result, NONE);
1252 return result; 1260 return result;
1253 } 1261 }
1254 1262
1255 // The 'stack' property of the receiver is set as data property. If 1263 // The 'stack' property of the receiver is set as data property. If
1256 // the receiver is the same as holder, this accessor pair is replaced. 1264 // the receiver is the same as holder, this accessor pair is replaced.
1257 function setter(v) { 1265 function setter(v) {
1258 %DefineOrRedefineDataProperty(this, 'stack', v, NONE); 1266 %DefineOrRedefineDataProperty(this, 'stack', v, NONE);
1259 } 1267 }
1260 1268
1269 %SetNativeFlag(getter);
1270
1261 %DefineOrRedefineAccessorProperty( 1271 %DefineOrRedefineAccessorProperty(
1262 boilerplate, 'stack', getter, setter, DONT_ENUM); 1272 boilerplate, 'stack', getter, setter, DONT_ENUM);
1263 1273
1264 return boilerplate; 1274 return boilerplate;
1265 } 1275 }
1266 1276
1267 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate(); 1277 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate();
OLDNEW
« src/heap.cc ('K') | « src/mark-compact.cc ('k') | test/cctest/test-decls.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698