Chromium Code Reviews| 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 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 750 } | 750 } |
| 751 | 751 |
| 752 | 752 |
| 753 function GetStackTraceLine(recv, fun, pos, isGlobal) { | 753 function GetStackTraceLine(recv, fun, pos, isGlobal) { |
| 754 return new CallSite(recv, fun, pos, false).toString(); | 754 return new CallSite(recv, fun, pos, false).toString(); |
| 755 } | 755 } |
| 756 | 756 |
| 757 // ---------------------------------------------------------------------------- | 757 // ---------------------------------------------------------------------------- |
| 758 // Error implementation | 758 // Error implementation |
| 759 | 759 |
| 760 var CallSiteReceiverKey = NEW_PRIVATE("CallSite#receiver"); | 760 var CallSiteReceiverKey = NEW_PRIVATE_OWN("CallSite#receiver"); |
| 761 var CallSiteFunctionKey = NEW_PRIVATE("CallSite#function"); | 761 var CallSiteFunctionKey = NEW_PRIVATE_OWN("CallSite#function"); |
| 762 var CallSitePositionKey = NEW_PRIVATE("CallSite#position"); | 762 var CallSitePositionKey = NEW_PRIVATE_OWN("CallSite#position"); |
| 763 var CallSiteStrictModeKey = NEW_PRIVATE("CallSite#strict_mode"); | 763 var CallSiteStrictModeKey = NEW_PRIVATE_OWN("CallSite#strict_mode"); |
| 764 | 764 |
| 765 function CallSite(receiver, fun, pos, strict_mode) { | 765 function CallSite(receiver, fun, pos, strict_mode) { |
| 766 SET_PRIVATE(this, CallSiteReceiverKey, receiver); | 766 SET_PRIVATE(this, CallSiteReceiverKey, receiver); |
| 767 SET_PRIVATE(this, CallSiteFunctionKey, fun); | 767 SET_PRIVATE(this, CallSiteFunctionKey, fun); |
| 768 SET_PRIVATE(this, CallSitePositionKey, pos); | 768 SET_PRIVATE(this, CallSitePositionKey, pos); |
| 769 SET_PRIVATE(this, CallSiteStrictModeKey, strict_mode); | 769 SET_PRIVATE(this, CallSiteStrictModeKey, strict_mode); |
| 770 } | 770 } |
| 771 | 771 |
| 772 function CallSiteGetThis() { | 772 function CallSiteGetThis() { |
| 773 return GET_PRIVATE(this, CallSiteStrictModeKey) | 773 return GET_PRIVATE(this, CallSiteStrictModeKey) |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1108 var constructorName = constructor.name; | 1108 var constructorName = constructor.name; |
| 1109 if (!constructorName) { | 1109 if (!constructorName) { |
| 1110 return requireConstructor ? null : | 1110 return requireConstructor ? null : |
| 1111 %_CallFunction(receiver, ObjectToString); | 1111 %_CallFunction(receiver, ObjectToString); |
| 1112 } | 1112 } |
| 1113 return constructorName; | 1113 return constructorName; |
| 1114 } | 1114 } |
| 1115 | 1115 |
| 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("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 = GET_PRIVATE(this, formatted_stack_trace_symbol); | 1124 var formatted_stack_trace = UNDEFINED; |
| 1125 var holder = this; | |
| 1126 while (holder && IS_UNDEFINED(formatted_stack_trace)) { | |
| 1127 formatted_stack_trace = GET_PRIVATE(holder, formatted_stack_trace_symbol); | |
| 1128 holder = %GetPrototype(holder); | |
|
arv (Not doing code reviews)
2014/09/23 18:31:20
Why are we using own private symbols here? It is c
Dmitry Lomov (no reviews)
2014/09/24 06:07:40
I just wanted to remove all non-own symbols from V
| |
| 1129 } | |
| 1125 if (IS_UNDEFINED(formatted_stack_trace)) { | 1130 if (IS_UNDEFINED(formatted_stack_trace)) { |
| 1126 var holder = this; | 1131 holder = this; |
| 1127 while (!HAS_PRIVATE(holder, stack_trace_symbol)) { | 1132 while (!HAS_DEFINED_PRIVATE(holder, stack_trace_symbol)) { |
| 1128 holder = %GetPrototype(holder); | 1133 holder = %GetPrototype(holder); |
| 1129 if (!holder) return UNDEFINED; | 1134 if (!holder) return UNDEFINED; |
| 1130 } | 1135 } |
| 1131 var stack_trace = GET_PRIVATE(holder, stack_trace_symbol); | 1136 var stack_trace = GET_PRIVATE(holder, stack_trace_symbol); |
| 1132 if (IS_UNDEFINED(stack_trace)) return UNDEFINED; | 1137 if (IS_UNDEFINED(stack_trace)) return UNDEFINED; |
| 1133 formatted_stack_trace = FormatStackTrace(holder, stack_trace); | 1138 formatted_stack_trace = FormatStackTrace(holder, stack_trace); |
| 1134 SET_PRIVATE(holder, stack_trace_symbol, UNDEFINED); | 1139 SET_PRIVATE(holder, stack_trace_symbol, UNDEFINED); |
| 1135 SET_PRIVATE(holder, formatted_stack_trace_symbol, formatted_stack_trace); | 1140 SET_PRIVATE(holder, formatted_stack_trace_symbol, formatted_stack_trace); |
| 1136 } | 1141 } |
| 1137 return formatted_stack_trace; | 1142 return formatted_stack_trace; |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1291 function SetUpStackOverflowBoilerplate() { | 1296 function SetUpStackOverflowBoilerplate() { |
| 1292 var boilerplate = MakeRangeError('stack_overflow', []); | 1297 var boilerplate = MakeRangeError('stack_overflow', []); |
| 1293 | 1298 |
| 1294 %DefineAccessorPropertyUnchecked( | 1299 %DefineAccessorPropertyUnchecked( |
| 1295 boilerplate, 'stack', StackTraceGetter, StackTraceSetter, DONT_ENUM); | 1300 boilerplate, 'stack', StackTraceGetter, StackTraceSetter, DONT_ENUM); |
| 1296 | 1301 |
| 1297 return boilerplate; | 1302 return boilerplate; |
| 1298 } | 1303 } |
| 1299 | 1304 |
| 1300 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate(); | 1305 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate(); |
| OLD | NEW |