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

Side by Side Diff: src/messages.js

Issue 131363008: A64: Synchronize with r15922. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 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 | « src/mark-compact.cc ('k') | src/mips/assembler-mips.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 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 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 var code = raw_stack[i + 2]; 1071 var code = raw_stack[i + 2];
1072 var pc = raw_stack[i + 3]; 1072 var pc = raw_stack[i + 3];
1073 var pos = %FunctionGetPositionForOffset(code, pc); 1073 var pos = %FunctionGetPositionForOffset(code, pc);
1074 non_strict_frames--; 1074 non_strict_frames--;
1075 frames.push(new CallSite(recv, fun, pos, (non_strict_frames < 0))); 1075 frames.push(new CallSite(recv, fun, pos, (non_strict_frames < 0)));
1076 } 1076 }
1077 return frames; 1077 return frames;
1078 } 1078 }
1079 1079
1080 1080
1081 function FormatStackTrace(error_string, frames) { 1081 // Flag to prevent recursive call of Error.prepareStackTrace.
1082 var formatting_custom_stack_trace = false;
1083
1084
1085 function FormatStackTrace(obj, error_string, frames) {
1086 if (IS_FUNCTION($Error.prepareStackTrace) && !formatting_custom_stack_trace) {
1087 var array = [];
1088 %MoveArrayContents(frames, array);
1089 formatting_custom_stack_trace = true;
1090 var stack_trace = void 0;
1091 try {
1092 stack_trace = $Error.prepareStackTrace(obj, array);
1093 } catch (e) {
1094 throw e; // The custom formatting function threw. Rethrow.
1095 } finally {
1096 formatting_custom_stack_trace = false;
1097 }
1098 return stack_trace;
1099 }
1100
1082 var lines = new InternalArray(); 1101 var lines = new InternalArray();
1083 lines.push(error_string); 1102 lines.push(error_string);
1084 for (var i = 0; i < frames.length; i++) { 1103 for (var i = 0; i < frames.length; i++) {
1085 var frame = frames[i]; 1104 var frame = frames[i];
1086 var line; 1105 var line;
1087 try { 1106 try {
1088 line = frame.toString(); 1107 line = frame.toString();
1089 } catch (e) { 1108 } catch (e) {
1090 try { 1109 try {
1091 line = "<error: " + e + ">"; 1110 line = "<error: " + e + ">";
(...skipping 16 matching lines...) Expand all
1108 } 1127 }
1109 var constructorName = constructor.name; 1128 var constructorName = constructor.name;
1110 if (!constructorName) { 1129 if (!constructorName) {
1111 return requireConstructor ? null : 1130 return requireConstructor ? null :
1112 %_CallFunction(receiver, ObjectToString); 1131 %_CallFunction(receiver, ObjectToString);
1113 } 1132 }
1114 return constructorName; 1133 return constructorName;
1115 } 1134 }
1116 1135
1117 1136
1118 // Flag to prevent recursive call of Error.prepareStackTrace.
1119 var formatting_custom_stack_trace = false;
1120
1121
1122 function captureStackTrace(obj, cons_opt) { 1137 function captureStackTrace(obj, cons_opt) {
1123 var stackTraceLimit = $Error.stackTraceLimit; 1138 var stackTraceLimit = $Error.stackTraceLimit;
1124 if (!stackTraceLimit || !IS_NUMBER(stackTraceLimit)) return; 1139 if (!stackTraceLimit || !IS_NUMBER(stackTraceLimit)) return;
1125 if (stackTraceLimit < 0 || stackTraceLimit > 10000) { 1140 if (stackTraceLimit < 0 || stackTraceLimit > 10000) {
1126 stackTraceLimit = 10000; 1141 stackTraceLimit = 10000;
1127 } 1142 }
1128 var stack = %CollectStackTrace(obj, 1143 var stack = %CollectStackTrace(obj,
1129 cons_opt ? cons_opt : captureStackTrace, 1144 cons_opt ? cons_opt : captureStackTrace,
1130 stackTraceLimit); 1145 stackTraceLimit);
1131 1146
1132 // Don't be lazy if the error stack formatting is custom (observable). 1147 var error_string = FormatErrorString(obj);
1133 if (IS_FUNCTION($Error.prepareStackTrace) && !formatting_custom_stack_trace) { 1148 // The holder of this getter ('obj') may not be the receiver ('this').
1134 var array = []; 1149 // When this getter is called the first time, we use the context values to
1135 %MoveArrayContents(GetStackFrames(stack), array); 1150 // format a stack trace string and turn this accessor pair into a data
1136 formatting_custom_stack_trace = true; 1151 // property (on the holder).
1137 try { 1152 var getter = function() {
1138 obj.stack = $Error.prepareStackTrace(obj, array); 1153 // Stack is still a raw array awaiting to be formatted.
1139 } catch (e) { 1154 var result = FormatStackTrace(obj, error_string, GetStackFrames(stack));
1140 throw e; // The custom formatting function threw. Rethrow. 1155 // Turn this accessor into a data property.
1141 } finally { 1156 %DefineOrRedefineDataProperty(obj, 'stack', result, NONE);
1142 formatting_custom_stack_trace = false; 1157 // Release context values.
1158 stack = error_string = void 0;
1159 return result;
1160 };
1161
1162 // Set the 'stack' property on the receiver. If the receiver is the same as
1163 // holder of this setter, the accessor pair is turned into a data property.
1164 var setter = function(v) {
1165 // Set data property on the receiver (not necessarily holder).
1166 %DefineOrRedefineDataProperty(this, 'stack', v, NONE);
1167 if (this === obj) {
1168 // Release context values if holder is the same as the receiver.
1169 stack = error_string = void 0;
1143 } 1170 }
1144 return;
1145 }
1146
1147 var error_string = FormatErrorString(obj);
1148 // Note that 'obj' and 'this' maybe different when called on objects that
1149 // have the error object on its prototype chain. The getter replaces itself
1150 // with a data property as soon as the stack trace has been formatted.
1151 // The getter must not change the object layout as it may be called after GC.
1152 var getter = function() {
1153 if (IS_STRING(stack)) return stack;
1154 // Stack is still a raw array awaiting to be formatted.
1155 stack = FormatStackTrace(error_string, GetStackFrames(stack));
1156 // Release context value.
1157 error_string = void 0;
1158 return stack;
1159 };
1160 %MarkOneShotGetter(getter);
1161
1162 // The 'stack' property of the receiver is set as data property. If
1163 // the receiver is the same as holder, this accessor pair is replaced.
1164 var setter = function(v) {
1165 %DefineOrRedefineDataProperty(this, 'stack', v, NONE);
1166 }; 1171 };
1167 1172
1168 %DefineOrRedefineAccessorProperty(obj, 'stack', getter, setter, DONT_ENUM); 1173 %DefineOrRedefineAccessorProperty(obj, 'stack', getter, setter, DONT_ENUM);
1169 } 1174 }
1170 1175
1171 1176
1172 function SetUpError() { 1177 function SetUpError() {
1173 // Define special error type constructors. 1178 // Define special error type constructors.
1174 1179
1175 var DefineError = function(f) { 1180 var DefineError = function(f) {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1293 } 1298 }
1294 1299
1295 1300
1296 InstallFunctions($Error.prototype, DONT_ENUM, ['toString', ErrorToString]); 1301 InstallFunctions($Error.prototype, DONT_ENUM, ['toString', ErrorToString]);
1297 1302
1298 // Boilerplate for exceptions for stack overflows. Used from 1303 // Boilerplate for exceptions for stack overflows. Used from
1299 // Isolate::StackOverflow(). 1304 // Isolate::StackOverflow().
1300 function SetUpStackOverflowBoilerplate() { 1305 function SetUpStackOverflowBoilerplate() {
1301 var boilerplate = MakeRangeError('stack_overflow', []); 1306 var boilerplate = MakeRangeError('stack_overflow', []);
1302 1307
1303 // The raw stack trace is stored as hidden property of the copy of this
1304 // boilerplate error object. Note that the receiver 'this' may not be that
1305 // error object copy, but can be found on the prototype chain of 'this'.
1306 // When the stack trace is formatted, this accessor property is replaced by
1307 // a data property.
1308 var error_string = boilerplate.name + ": " + boilerplate.message; 1308 var error_string = boilerplate.name + ": " + boilerplate.message;
1309 1309
1310 // The getter must not change the object layout as it may be called after GC. 1310 // The raw stack trace is stored as a hidden property on the holder of this
1311 function getter() { 1311 // getter, which may not be the same as the receiver. Find the holder to
1312 // retrieve the raw stack trace and then turn this accessor pair into a
1313 // data property.
1314 var getter = function() {
1312 var holder = this; 1315 var holder = this;
1313 while (!IS_ERROR(holder)) { 1316 while (!IS_ERROR(holder)) {
1314 holder = %GetPrototype(holder); 1317 holder = %GetPrototype(holder);
1315 if (holder == null) return MakeSyntaxError('illegal_access', []); 1318 if (IS_NULL(holder)) return MakeSyntaxError('illegal_access', []);
1316 } 1319 }
1317 var stack = %GetOverflowedStackTrace(holder); 1320 var stack = %GetAndClearOverflowedStackTrace(holder);
1318 if (IS_STRING(stack)) return stack; 1321 // We may not have captured any stack trace.
1319 if (IS_ARRAY(stack)) { 1322 if (IS_UNDEFINED(stack)) return stack;
1320 var result = FormatStackTrace(error_string, GetStackFrames(stack));
1321 %SetOverflowedStackTrace(holder, result);
1322 return result;
1323 }
1324 return void 0;
1325 }
1326 %MarkOneShotGetter(getter);
1327 1323
1328 // The 'stack' property of the receiver is set as data property. If 1324 var result = FormatStackTrace(holder, error_string, GetStackFrames(stack));
1329 // the receiver is the same as holder, this accessor pair is replaced. 1325 // Replace this accessor with a data property.
1330 function setter(v) { 1326 %DefineOrRedefineDataProperty(holder, 'stack', result, NONE);
1327 return result;
1328 };
1329
1330 // Set the 'stack' property on the receiver. If the receiver is the same as
1331 // holder of this setter, the accessor pair is turned into a data property.
1332 var setter = function(v) {
1331 %DefineOrRedefineDataProperty(this, 'stack', v, NONE); 1333 %DefineOrRedefineDataProperty(this, 'stack', v, NONE);
1332 // Release the stack trace that is stored as hidden property, if exists. 1334 // Tentatively clear the hidden property. If the receiver is the same as
1333 %SetOverflowedStackTrace(this, void 0); 1335 // holder, we release the raw stack trace this way.
1334 } 1336 %GetAndClearOverflowedStackTrace(this);
1337 };
1335 1338
1336 %DefineOrRedefineAccessorProperty( 1339 %DefineOrRedefineAccessorProperty(
1337 boilerplate, 'stack', getter, setter, DONT_ENUM); 1340 boilerplate, 'stack', getter, setter, DONT_ENUM);
1338 1341
1339 return boilerplate; 1342 return boilerplate;
1340 } 1343 }
1341 1344
1342 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate(); 1345 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate();
OLDNEW
« no previous file with comments | « src/mark-compact.cc ('k') | src/mips/assembler-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698