OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // ------------------------------------------------------------------- | 5 // ------------------------------------------------------------------- |
6 | 6 |
7 var kMessages = { | 7 var kMessages = { |
8 // Error | 8 // Error |
9 cyclic_proto: ["Cyclic __proto__ value"], | 9 cyclic_proto: ["Cyclic __proto__ value"], |
10 code_gen_from_strings: ["%0"], | 10 code_gen_from_strings: ["%0"], |
(...skipping 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1116 | 1116 |
1117 var stack_trace_symbol; // Set during bootstrapping. | 1117 var stack_trace_symbol; // Set during bootstrapping. |
1118 var formatted_stack_trace_symbol = NEW_PRIVATE_OWN("formatted stack trace"); | 1118 var formatted_stack_trace_symbol = NEW_PRIVATE_OWN("formatted stack trace"); |
1119 | 1119 |
1120 | 1120 |
1121 // Format the stack trace if not yet done, and return it. | 1121 // Format the stack trace if not yet done, and return it. |
1122 // Cache the formatted stack trace on the holder. | 1122 // Cache the formatted stack trace on the holder. |
1123 var StackTraceGetter = function() { | 1123 var StackTraceGetter = function() { |
1124 var formatted_stack_trace = UNDEFINED; | 1124 var formatted_stack_trace = UNDEFINED; |
1125 var holder = this; | 1125 var holder = this; |
1126 while (holder && IS_UNDEFINED(formatted_stack_trace)) { | 1126 while (holder) { |
1127 formatted_stack_trace = GET_PRIVATE(holder, formatted_stack_trace_symbol); | 1127 var formatted_stack_trace = |
1128 holder = %GetPrototype(holder); | 1128 GET_PRIVATE(holder, formatted_stack_trace_symbol); |
arv (Not doing code reviews)
2014/09/24 14:15:17
wrong indent
| |
1129 if (IS_UNDEFINED(formatted_stack_trace)) { | |
1130 // No formatted stack trace available. | |
1131 var stack_trace = GET_PRIVATE(holder, stack_trace_symbol); | |
1132 if (IS_UNDEFINED(stack_trace)) { | |
1133 // Neither formatted nor structured stack trace available. | |
1134 // Look further up the prototype chain. | |
1135 holder = %GetPrototype(holder); | |
1136 continue; | |
1137 } | |
1138 formatted_stack_trace = FormatStackTrace(holder, stack_trace); | |
1139 SET_PRIVATE(holder, stack_trace_symbol, UNDEFINED); | |
1140 SET_PRIVATE(holder, formatted_stack_trace_symbol, formatted_stack_trace); | |
1141 } | |
1142 return formatted_stack_trace; | |
1129 } | 1143 } |
1130 if (IS_UNDEFINED(formatted_stack_trace)) { | 1144 return UNDEFINED; |
1131 holder = this; | |
1132 while (!HAS_DEFINED_PRIVATE(holder, stack_trace_symbol)) { | |
1133 holder = %GetPrototype(holder); | |
1134 if (!holder) return UNDEFINED; | |
1135 } | |
1136 var stack_trace = GET_PRIVATE(holder, stack_trace_symbol); | |
1137 if (IS_UNDEFINED(stack_trace)) return UNDEFINED; | |
1138 formatted_stack_trace = FormatStackTrace(holder, stack_trace); | |
1139 SET_PRIVATE(holder, stack_trace_symbol, UNDEFINED); | |
1140 SET_PRIVATE(holder, formatted_stack_trace_symbol, formatted_stack_trace); | |
1141 } | |
1142 return formatted_stack_trace; | |
1143 }; | 1145 }; |
1144 | 1146 |
1145 | 1147 |
1146 // If the receiver equals the holder, set the formatted stack trace that the | 1148 // If the receiver equals the holder, set the formatted stack trace that the |
1147 // getter returns. | 1149 // getter returns. |
1148 var StackTraceSetter = function(v) { | 1150 var StackTraceSetter = function(v) { |
1149 if (HAS_PRIVATE(this, stack_trace_symbol)) { | 1151 if (HAS_PRIVATE(this, stack_trace_symbol)) { |
1150 SET_PRIVATE(this, stack_trace_symbol, UNDEFINED); | 1152 SET_PRIVATE(this, stack_trace_symbol, UNDEFINED); |
1151 SET_PRIVATE(this, formatted_stack_trace_symbol, v); | 1153 SET_PRIVATE(this, formatted_stack_trace_symbol, v); |
1152 } | 1154 } |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1296 function SetUpStackOverflowBoilerplate() { | 1298 function SetUpStackOverflowBoilerplate() { |
1297 var boilerplate = MakeRangeError('stack_overflow', []); | 1299 var boilerplate = MakeRangeError('stack_overflow', []); |
1298 | 1300 |
1299 %DefineAccessorPropertyUnchecked( | 1301 %DefineAccessorPropertyUnchecked( |
1300 boilerplate, 'stack', StackTraceGetter, StackTraceSetter, DONT_ENUM); | 1302 boilerplate, 'stack', StackTraceGetter, StackTraceSetter, DONT_ENUM); |
1301 | 1303 |
1302 return boilerplate; | 1304 return boilerplate; |
1303 } | 1305 } |
1304 | 1306 |
1305 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate(); | 1307 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate(); |
OLD | NEW |