| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 | 50 |
| 51 var kReplacementMarkers = [ "%0", "%1", "%2", "%3" ]; | 51 var kReplacementMarkers = [ "%0", "%1", "%2", "%3" ]; |
| 52 | 52 |
| 53 function FormatString(format, message) { | 53 function FormatString(format, message) { |
| 54 var args = %MessageGetArguments(message); | 54 var args = %MessageGetArguments(message); |
| 55 var result = ""; | 55 var result = ""; |
| 56 var arg_num = 0; | 56 var arg_num = 0; |
| 57 for (var i = 0; i < format.length; i++) { | 57 for (var i = 0; i < format.length; i++) { |
| 58 var str = format[i]; | 58 var str = format[i]; |
| 59 for (arg_num = 0; arg_num < kReplacementMarkers.length; arg_num++) { | 59 for (arg_num = 0; arg_num < kReplacementMarkers.length; arg_num++) { |
| 60 if (format[i] !== kReplacementMarkers[arg_num]) continue; | 60 if (str == kReplacementMarkers[arg_num]) { |
| 61 try { | 61 try { |
| 62 str = ToDetailString(args[arg_num]); | 62 str = ToDetailString(args[arg_num]); |
| 63 } catch (e) { | 63 } catch (e) { |
| 64 str = "#<error>"; | 64 str = "#<error>"; |
| 65 } |
| 66 break; |
| 65 } | 67 } |
| 66 } | 68 } |
| 67 result += str; | 69 result += str; |
| 68 } | 70 } |
| 69 return result; | 71 return result; |
| 70 } | 72 } |
| 71 | 73 |
| 72 | 74 |
| 73 // To check if something is a native error we need to check the | 75 // To check if something is a native error we need to check the |
| 74 // concrete native error types. It is not enough to check "obj | 76 // concrete native error types. It is not enough to check "obj |
| (...skipping 18 matching lines...) Expand all Loading... |
| 93 function ToStringCheckErrorObject(obj) { | 95 function ToStringCheckErrorObject(obj) { |
| 94 if (IsNativeErrorObject(obj)) { | 96 if (IsNativeErrorObject(obj)) { |
| 95 return %_CallFunction(obj, errorToString); | 97 return %_CallFunction(obj, errorToString); |
| 96 } else { | 98 } else { |
| 97 return ToString(obj); | 99 return ToString(obj); |
| 98 } | 100 } |
| 99 } | 101 } |
| 100 | 102 |
| 101 | 103 |
| 102 function ToDetailString(obj) { | 104 function ToDetailString(obj) { |
| 103 if (obj != null && IS_OBJECT(obj) && obj.toString === $Object.prototype.toStri
ng) { | 105 if (obj != null && IS_OBJECT(obj) && |
| 106 obj.toString === $Object.prototype.toString) { |
| 104 var constructor = obj.constructor; | 107 var constructor = obj.constructor; |
| 105 if (!constructor) return ToStringCheckErrorObject(obj); | 108 if (!constructor) return ToStringCheckErrorObject(obj); |
| 106 var constructorName = constructor.name; | 109 var constructorName = constructor.name; |
| 107 if (!constructorName || !IS_STRING(constructorName)) { | 110 if (!constructorName || !IS_STRING(constructorName)) { |
| 108 return ToStringCheckErrorObject(obj); | 111 return ToStringCheckErrorObject(obj); |
| 109 } | 112 } |
| 110 return "#<" + constructorName + ">"; | 113 return "#<" + constructorName + ">"; |
| 111 } else { | 114 } else { |
| 112 return ToStringCheckErrorObject(obj); | 115 return ToStringCheckErrorObject(obj); |
| 113 } | 116 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 handler_returned_undefined: ["Proxy handler ", "%0", " returned undefine
d for '", "%1", "' trap"], | 203 handler_returned_undefined: ["Proxy handler ", "%0", " returned undefine
d for '", "%1", "' trap"], |
| 201 proxy_prop_not_configurable: ["Trap ", "%1", " of proxy handler ", "%0",
" returned non-configurable descriptor for property ", "%2"], | 204 proxy_prop_not_configurable: ["Trap ", "%1", " of proxy handler ", "%0",
" returned non-configurable descriptor for property ", "%2"], |
| 202 proxy_non_object_prop_names: ["Trap ", "%1", " returned non-object ", "%0
"], | 205 proxy_non_object_prop_names: ["Trap ", "%1", " returned non-object ", "%0
"], |
| 203 proxy_repeated_prop_name: ["Trap ", "%1", " returned repeated property
name ", "%2"], | 206 proxy_repeated_prop_name: ["Trap ", "%1", " returned repeated property
name ", "%2"], |
| 204 invalid_weakmap_key: ["Invalid value used as weak map key"], | 207 invalid_weakmap_key: ["Invalid value used as weak map key"], |
| 205 // RangeError | 208 // RangeError |
| 206 invalid_array_length: ["Invalid array length"], | 209 invalid_array_length: ["Invalid array length"], |
| 207 stack_overflow: ["Maximum call stack size exceeded"], | 210 stack_overflow: ["Maximum call stack size exceeded"], |
| 208 // SyntaxError | 211 // SyntaxError |
| 209 unable_to_parse: ["Parse error"], | 212 unable_to_parse: ["Parse error"], |
| 210 duplicate_regexp_flag: ["Duplicate RegExp flag ", "%0"], | 213 invalid_regexp_flags: ["Invalid flags supplied to RegExp construct
or '", "%0", "'"], |
| 211 invalid_regexp: ["Invalid RegExp pattern /", "%0", "/"], | 214 invalid_regexp: ["Invalid RegExp pattern /", "%0", "/"], |
| 212 illegal_break: ["Illegal break statement"], | 215 illegal_break: ["Illegal break statement"], |
| 213 illegal_continue: ["Illegal continue statement"], | 216 illegal_continue: ["Illegal continue statement"], |
| 214 illegal_return: ["Illegal return statement"], | 217 illegal_return: ["Illegal return statement"], |
| 215 error_loading_debugger: ["Error loading debugger"], | 218 error_loading_debugger: ["Error loading debugger"], |
| 216 no_input_to_regexp: ["No input to ", "%0"], | 219 no_input_to_regexp: ["No input to ", "%0"], |
| 217 invalid_json: ["String '", "%0", "' is not valid JSON"], | 220 invalid_json: ["String '", "%0", "' is not valid JSON"], |
| 218 circular_structure: ["Converting circular structure to JSON"], | 221 circular_structure: ["Converting circular structure to JSON"], |
| 219 obj_ctor_property_non_object: ["Object.", "%0", " called on non-object"], | 222 obj_ctor_property_non_object: ["Object.", "%0", " called on non-object"], |
| 220 called_on_null_or_undefined: ["%0", " called on null or undefined"], | 223 called_on_null_or_undefined: ["%0", " called on null or undefined"], |
| (...skipping 19 matching lines...) Expand all Loading... |
| 240 strict_lhs_prefix: ["Prefix increment/decrement may not have ev
al or arguments operand in strict mode"], | 243 strict_lhs_prefix: ["Prefix increment/decrement may not have ev
al or arguments operand in strict mode"], |
| 241 strict_reserved_word: ["Use of future reserved word in strict mode
"], | 244 strict_reserved_word: ["Use of future reserved word in strict mode
"], |
| 242 strict_delete: ["Delete of an unqualified identifier in str
ict mode."], | 245 strict_delete: ["Delete of an unqualified identifier in str
ict mode."], |
| 243 strict_delete_property: ["Cannot delete property '", "%0", "' of ",
"%1"], | 246 strict_delete_property: ["Cannot delete property '", "%0", "' of ",
"%1"], |
| 244 strict_const: ["Use of const in strict mode."], | 247 strict_const: ["Use of const in strict mode."], |
| 245 strict_function: ["In strict mode code, functions can only be
declared at top level or immediately within another function." ], | 248 strict_function: ["In strict mode code, functions can only be
declared at top level or immediately within another function." ], |
| 246 strict_read_only_property: ["Cannot assign to read only property '", "%
0", "' of ", "%1"], | 249 strict_read_only_property: ["Cannot assign to read only property '", "%
0", "' of ", "%1"], |
| 247 strict_cannot_assign: ["Cannot assign to read only '", "%0", "' in
strict mode"], | 250 strict_cannot_assign: ["Cannot assign to read only '", "%0", "' in
strict mode"], |
| 248 strict_poison_pill: ["'caller', 'callee', and 'arguments' proper
ties may not be accessed on strict mode functions or the arguments objects for c
alls to them"], | 251 strict_poison_pill: ["'caller', 'callee', and 'arguments' proper
ties may not be accessed on strict mode functions or the arguments objects for c
alls to them"], |
| 249 strict_caller: ["Illegal access to a strict mode caller fun
ction."], | 252 strict_caller: ["Illegal access to a strict mode caller fun
ction."], |
| 253 unprotected_let: ["Illegal let declaration in unprotected sta
tement context."], |
| 250 }; | 254 }; |
| 251 } | 255 } |
| 252 var message_type = %MessageGetType(message); | 256 var message_type = %MessageGetType(message); |
| 253 var format = kMessages[message_type]; | 257 var format = kMessages[message_type]; |
| 254 if (!format) return "<unknown message " + message_type + ">"; | 258 if (!format) return "<unknown message " + message_type + ">"; |
| 255 return FormatString(format, message); | 259 return FormatString(format, message); |
| 256 } | 260 } |
| 257 | 261 |
| 258 | 262 |
| 259 function GetLineNumber(message) { | 263 function GetLineNumber(message) { |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 */ | 556 */ |
| 553 function SourceLocation(script, position, line, column, start, end) { | 557 function SourceLocation(script, position, line, column, start, end) { |
| 554 this.script = script; | 558 this.script = script; |
| 555 this.position = position; | 559 this.position = position; |
| 556 this.line = line; | 560 this.line = line; |
| 557 this.column = column; | 561 this.column = column; |
| 558 this.start = start; | 562 this.start = start; |
| 559 this.end = end; | 563 this.end = end; |
| 560 } | 564 } |
| 561 | 565 |
| 566 SourceLocation.prototype.__proto__ = null; |
| 562 | 567 |
| 563 const kLineLengthLimit = 78; | 568 const kLineLengthLimit = 78; |
| 564 | 569 |
| 565 /** | 570 /** |
| 566 * Restrict source location start and end positions to make the source slice | 571 * Restrict source location start and end positions to make the source slice |
| 567 * no more that a certain number of characters wide. | 572 * no more that a certain number of characters wide. |
| 568 * @param {number} opt_limit The with limit of the source text with a default | 573 * @param {number} opt_limit The with limit of the source text with a default |
| 569 * of 78 | 574 * of 78 |
| 570 * @param {number} opt_before The number of characters to prefer before the | 575 * @param {number} opt_before The number of characters to prefer before the |
| 571 * position with a default value of 10 less that the limit | 576 * position with a default value of 10 less that the limit |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 * @constructor | 646 * @constructor |
| 642 */ | 647 */ |
| 643 function SourceSlice(script, from_line, to_line, from_position, to_position) { | 648 function SourceSlice(script, from_line, to_line, from_position, to_position) { |
| 644 this.script = script; | 649 this.script = script; |
| 645 this.from_line = from_line; | 650 this.from_line = from_line; |
| 646 this.to_line = to_line; | 651 this.to_line = to_line; |
| 647 this.from_position = from_position; | 652 this.from_position = from_position; |
| 648 this.to_position = to_position; | 653 this.to_position = to_position; |
| 649 } | 654 } |
| 650 | 655 |
| 656 SourceSlice.prototype.__proto__ = null; |
| 651 | 657 |
| 652 /** | 658 /** |
| 653 * Get the source text for a SourceSlice | 659 * Get the source text for a SourceSlice |
| 654 * @return {String} Source text for this slice. The last line will include | 660 * @return {String} Source text for this slice. The last line will include |
| 655 * the line terminating characters (if any) | 661 * the line terminating characters (if any) |
| 656 */ | 662 */ |
| 657 SourceSlice.prototype.sourceText = function () { | 663 SourceSlice.prototype.sourceText = function () { |
| 658 return %_CallFunction(this.script.source, | 664 return %_CallFunction(this.script.source, |
| 659 this.from_position, | 665 this.from_position, |
| 660 this.to_position, | 666 this.to_position, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 desc = ToPropertyDescriptor(desc); | 714 desc = ToPropertyDescriptor(desc); |
| 709 DefineOwnProperty(obj, name, desc, true); | 715 DefineOwnProperty(obj, name, desc, true); |
| 710 } | 716 } |
| 711 | 717 |
| 712 function CallSite(receiver, fun, pos) { | 718 function CallSite(receiver, fun, pos) { |
| 713 this.receiver = receiver; | 719 this.receiver = receiver; |
| 714 this.fun = fun; | 720 this.fun = fun; |
| 715 this.pos = pos; | 721 this.pos = pos; |
| 716 } | 722 } |
| 717 | 723 |
| 724 CallSite.prototype.__proto__ = null; |
| 725 |
| 718 CallSite.prototype.getThis = function () { | 726 CallSite.prototype.getThis = function () { |
| 719 return this.receiver; | 727 return this.receiver; |
| 720 }; | 728 }; |
| 721 | 729 |
| 722 CallSite.prototype.getTypeName = function () { | 730 CallSite.prototype.getTypeName = function () { |
| 723 var constructor = this.receiver.constructor; | 731 var constructor = this.receiver.constructor; |
| 724 if (!constructor) | 732 if (!constructor) { |
| 725 return %_CallFunction(this.receiver, ObjectToString); | 733 return %_CallFunction(this.receiver, ObjectToString); |
| 734 } |
| 726 var constructorName = constructor.name; | 735 var constructorName = constructor.name; |
| 727 if (!constructorName) | 736 if (!constructorName) { |
| 728 return %_CallFunction(this.receiver, ObjectToString); | 737 return %_CallFunction(this.receiver, ObjectToString); |
| 738 } |
| 729 return constructorName; | 739 return constructorName; |
| 730 }; | 740 }; |
| 731 | 741 |
| 732 CallSite.prototype.isToplevel = function () { | 742 CallSite.prototype.isToplevel = function () { |
| 733 if (this.receiver == null) | 743 if (this.receiver == null) { |
| 734 return true; | 744 return true; |
| 745 } |
| 735 return IS_GLOBAL(this.receiver); | 746 return IS_GLOBAL(this.receiver); |
| 736 }; | 747 }; |
| 737 | 748 |
| 738 CallSite.prototype.isEval = function () { | 749 CallSite.prototype.isEval = function () { |
| 739 var script = %FunctionGetScript(this.fun); | 750 var script = %FunctionGetScript(this.fun); |
| 740 return script && script.compilation_type == COMPILATION_TYPE_EVAL; | 751 return script && script.compilation_type == COMPILATION_TYPE_EVAL; |
| 741 }; | 752 }; |
| 742 | 753 |
| 743 CallSite.prototype.getEvalOrigin = function () { | 754 CallSite.prototype.getEvalOrigin = function () { |
| 744 var script = %FunctionGetScript(this.fun); | 755 var script = %FunctionGetScript(this.fun); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 757 CallSite.prototype.getFunctionName = function () { | 768 CallSite.prototype.getFunctionName = function () { |
| 758 // See if the function knows its own name | 769 // See if the function knows its own name |
| 759 var name = this.fun.name; | 770 var name = this.fun.name; |
| 760 if (name) { | 771 if (name) { |
| 761 return name; | 772 return name; |
| 762 } else { | 773 } else { |
| 763 return %FunctionGetInferredName(this.fun); | 774 return %FunctionGetInferredName(this.fun); |
| 764 } | 775 } |
| 765 // Maybe this is an evaluation? | 776 // Maybe this is an evaluation? |
| 766 var script = %FunctionGetScript(this.fun); | 777 var script = %FunctionGetScript(this.fun); |
| 767 if (script && script.compilation_type == COMPILATION_TYPE_EVAL) | 778 if (script && script.compilation_type == COMPILATION_TYPE_EVAL) { |
| 768 return "eval"; | 779 return "eval"; |
| 780 } |
| 769 return null; | 781 return null; |
| 770 }; | 782 }; |
| 771 | 783 |
| 772 CallSite.prototype.getMethodName = function () { | 784 CallSite.prototype.getMethodName = function () { |
| 773 // See if we can find a unique property on the receiver that holds | 785 // See if we can find a unique property on the receiver that holds |
| 774 // this function. | 786 // this function. |
| 775 var ownName = this.fun.name; | 787 var ownName = this.fun.name; |
| 776 if (ownName && this.receiver && | 788 if (ownName && this.receiver && |
| 777 (%_CallFunction(this.receiver, ownName, ObjectLookupGetter) === this.fun |
| | 789 (%_CallFunction(this.receiver, ownName, ObjectLookupGetter) === this.fun |
| |
| 778 %_CallFunction(this.receiver, ownName, ObjectLookupSetter) === this.fun |
| | 790 %_CallFunction(this.receiver, ownName, ObjectLookupSetter) === this.fun |
| |
| 779 this.receiver[ownName] === this.fun)) { | 791 this.receiver[ownName] === this.fun)) { |
| 780 // To handle DontEnum properties we guess that the method has | 792 // To handle DontEnum properties we guess that the method has |
| 781 // the same name as the function. | 793 // the same name as the function. |
| 782 return ownName; | 794 return ownName; |
| 783 } | 795 } |
| 784 var name = null; | 796 var name = null; |
| 785 for (var prop in this.receiver) { | 797 for (var prop in this.receiver) { |
| 786 if (this.receiver.__lookupGetter__(prop) === this.fun || | 798 if (this.receiver.__lookupGetter__(prop) === this.fun || |
| 787 this.receiver.__lookupSetter__(prop) === this.fun || | 799 this.receiver.__lookupSetter__(prop) === this.fun || |
| 788 (!this.receiver.__lookupGetter__(prop) && this.receiver[prop] === this.f
un)) { | 800 (!this.receiver.__lookupGetter__(prop) && this.receiver[prop] === this.f
un)) { |
| 789 // If we find more than one match bail out to avoid confusion. | 801 // If we find more than one match bail out to avoid confusion. |
| 790 if (name) | 802 if (name) { |
| 791 return null; | 803 return null; |
| 804 } |
| 792 name = prop; | 805 name = prop; |
| 793 } | 806 } |
| 794 } | 807 } |
| 795 if (name) | 808 if (name) { |
| 796 return name; | 809 return name; |
| 810 } |
| 797 return null; | 811 return null; |
| 798 }; | 812 }; |
| 799 | 813 |
| 800 CallSite.prototype.getFileName = function () { | 814 CallSite.prototype.getFileName = function () { |
| 801 var script = %FunctionGetScript(this.fun); | 815 var script = %FunctionGetScript(this.fun); |
| 802 return script ? script.name : null; | 816 return script ? script.name : null; |
| 803 }; | 817 }; |
| 804 | 818 |
| 805 CallSite.prototype.getLineNumber = function () { | 819 CallSite.prototype.getLineNumber = function () { |
| 806 if (this.pos == -1) | 820 if (this.pos == -1) { |
| 807 return null; | 821 return null; |
| 822 } |
| 808 var script = %FunctionGetScript(this.fun); | 823 var script = %FunctionGetScript(this.fun); |
| 809 var location = null; | 824 var location = null; |
| 810 if (script) { | 825 if (script) { |
| 811 location = script.locationFromPosition(this.pos, true); | 826 location = script.locationFromPosition(this.pos, true); |
| 812 } | 827 } |
| 813 return location ? location.line + 1 : null; | 828 return location ? location.line + 1 : null; |
| 814 }; | 829 }; |
| 815 | 830 |
| 816 CallSite.prototype.getColumnNumber = function () { | 831 CallSite.prototype.getColumnNumber = function () { |
| 817 if (this.pos == -1) | 832 if (this.pos == -1) { |
| 818 return null; | 833 return null; |
| 834 } |
| 819 var script = %FunctionGetScript(this.fun); | 835 var script = %FunctionGetScript(this.fun); |
| 820 var location = null; | 836 var location = null; |
| 821 if (script) { | 837 if (script) { |
| 822 location = script.locationFromPosition(this.pos, true); | 838 location = script.locationFromPosition(this.pos, true); |
| 823 } | 839 } |
| 824 return location ? location.column + 1: null; | 840 return location ? location.column + 1: null; |
| 825 }; | 841 }; |
| 826 | 842 |
| 827 CallSite.prototype.isNative = function () { | 843 CallSite.prototype.isNative = function () { |
| 828 var script = %FunctionGetScript(this.fun); | 844 var script = %FunctionGetScript(this.fun); |
| 829 return script ? (script.type == TYPE_NATIVE) : false; | 845 return script ? (script.type == TYPE_NATIVE) : false; |
| 830 }; | 846 }; |
| 831 | 847 |
| 832 CallSite.prototype.getPosition = function () { | 848 CallSite.prototype.getPosition = function () { |
| 833 return this.pos; | 849 return this.pos; |
| 834 }; | 850 }; |
| 835 | 851 |
| 836 CallSite.prototype.isConstructor = function () { | 852 CallSite.prototype.isConstructor = function () { |
| 837 var constructor = this.receiver ? this.receiver.constructor : null; | 853 var constructor = this.receiver ? this.receiver.constructor : null; |
| 838 if (!constructor) | 854 if (!constructor) { |
| 839 return false; | 855 return false; |
| 856 } |
| 840 return this.fun === constructor; | 857 return this.fun === constructor; |
| 841 }; | 858 }; |
| 842 | 859 |
| 843 function FormatEvalOrigin(script) { | 860 function FormatEvalOrigin(script) { |
| 844 var sourceURL = script.nameOrSourceURL(); | 861 var sourceURL = script.nameOrSourceURL(); |
| 845 if (sourceURL) | 862 if (sourceURL) { |
| 846 return sourceURL; | 863 return sourceURL; |
| 864 } |
| 847 | 865 |
| 848 var eval_origin = "eval at "; | 866 var eval_origin = "eval at "; |
| 849 if (script.eval_from_function_name) { | 867 if (script.eval_from_function_name) { |
| 850 eval_origin += script.eval_from_function_name; | 868 eval_origin += script.eval_from_function_name; |
| 851 } else { | 869 } else { |
| 852 eval_origin += "<anonymous>"; | 870 eval_origin += "<anonymous>"; |
| 853 } | 871 } |
| 854 | 872 |
| 855 var eval_from_script = script.eval_from_script; | 873 var eval_from_script = script.eval_from_script; |
| 856 if (eval_from_script) { | 874 if (eval_from_script) { |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1034 captureStackTrace(this, f); | 1052 captureStackTrace(this, f); |
| 1035 } else { | 1053 } else { |
| 1036 return new f(m); | 1054 return new f(m); |
| 1037 } | 1055 } |
| 1038 }); | 1056 }); |
| 1039 } | 1057 } |
| 1040 | 1058 |
| 1041 function captureStackTrace(obj, cons_opt) { | 1059 function captureStackTrace(obj, cons_opt) { |
| 1042 var stackTraceLimit = $Error.stackTraceLimit; | 1060 var stackTraceLimit = $Error.stackTraceLimit; |
| 1043 if (!stackTraceLimit || !IS_NUMBER(stackTraceLimit)) return; | 1061 if (!stackTraceLimit || !IS_NUMBER(stackTraceLimit)) return; |
| 1044 if (stackTraceLimit < 0 || stackTraceLimit > 10000) | 1062 if (stackTraceLimit < 0 || stackTraceLimit > 10000) { |
| 1045 stackTraceLimit = 10000; | 1063 stackTraceLimit = 10000; |
| 1064 } |
| 1046 var raw_stack = %CollectStackTrace(cons_opt | 1065 var raw_stack = %CollectStackTrace(cons_opt |
| 1047 ? cons_opt | 1066 ? cons_opt |
| 1048 : captureStackTrace, stackTraceLimit); | 1067 : captureStackTrace, stackTraceLimit); |
| 1049 DefineOneShotAccessor(obj, 'stack', function (obj) { | 1068 DefineOneShotAccessor(obj, 'stack', function (obj) { |
| 1050 return FormatRawStackTrace(obj, raw_stack); | 1069 return FormatRawStackTrace(obj, raw_stack); |
| 1051 }); | 1070 }); |
| 1052 }; | 1071 }; |
| 1053 | 1072 |
| 1054 $Math.__proto__ = global.Object.prototype; | 1073 $Math.__proto__ = global.Object.prototype; |
| 1055 | 1074 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1109 } | 1128 } |
| 1110 // This helper function is needed because access to properties on | 1129 // This helper function is needed because access to properties on |
| 1111 // the builtins object do not work inside of a catch clause. | 1130 // the builtins object do not work inside of a catch clause. |
| 1112 function isCyclicErrorMarker(o) { return o === cyclic_error_marker; } | 1131 function isCyclicErrorMarker(o) { return o === cyclic_error_marker; } |
| 1113 | 1132 |
| 1114 try { | 1133 try { |
| 1115 return %_CallFunction(this, errorToStringDetectCycle); | 1134 return %_CallFunction(this, errorToStringDetectCycle); |
| 1116 } catch(e) { | 1135 } catch(e) { |
| 1117 // If this error message was encountered already return the empty | 1136 // If this error message was encountered already return the empty |
| 1118 // string for it instead of recursively formatting it. | 1137 // string for it instead of recursively formatting it. |
| 1119 if (isCyclicErrorMarker(e)) return ''; | 1138 if (isCyclicErrorMarker(e)) { |
| 1120 else throw e; | 1139 return ''; |
| 1140 } |
| 1141 throw e; |
| 1121 } | 1142 } |
| 1122 } | 1143 } |
| 1123 | 1144 |
| 1124 | 1145 |
| 1125 InstallFunctions($Error.prototype, DONT_ENUM, ['toString', errorToString]); | 1146 InstallFunctions($Error.prototype, DONT_ENUM, ['toString', errorToString]); |
| 1126 | 1147 |
| 1127 // Boilerplate for exceptions for stack overflows. Used from | 1148 // Boilerplate for exceptions for stack overflows. Used from |
| 1128 // Isolate::StackOverflow(). | 1149 // Isolate::StackOverflow(). |
| 1129 const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); | 1150 const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); |
| OLD | NEW |