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

Side by Side Diff: src/messages.js

Issue 1297803003: Revert of Remove property loads from js builtins objects from runtime. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « src/isolate.cc ('k') | src/v8natives.js » ('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 // 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 $errorToString; 7 var $errorToString;
8 var $getStackTraceLine;
8 var $internalErrorSymbol; 9 var $internalErrorSymbol;
10 var $messageGetPositionInLine;
11 var $messageGetLineNumber;
12 var $messageGetSourceLine;
13 var $stackOverflowBoilerplate;
9 var $stackTraceSymbol; 14 var $stackTraceSymbol;
10 var MakeError; 15 var MakeError;
11 var MakeEvalError; 16 var MakeEvalError;
12 var MakeRangeError; 17 var MakeRangeError;
13 var MakeReferenceError; 18 var MakeReferenceError;
14 var MakeSyntaxError; 19 var MakeSyntaxError;
15 var MakeTypeError; 20 var MakeTypeError;
16 var MakeURIError; 21 var MakeURIError;
17 22
18 (function(global, utils) { 23 (function(global, utils) {
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 function GetLineNumber(message) { 206 function GetLineNumber(message) {
202 var start_position = %MessageGetStartPosition(message); 207 var start_position = %MessageGetStartPosition(message);
203 if (start_position == -1) return kNoLineNumberInfo; 208 if (start_position == -1) return kNoLineNumberInfo;
204 var script = %MessageGetScript(message); 209 var script = %MessageGetScript(message);
205 var location = script.locationFromPosition(start_position, true); 210 var location = script.locationFromPosition(start_position, true);
206 if (location == null) return kNoLineNumberInfo; 211 if (location == null) return kNoLineNumberInfo;
207 return location.line + 1; 212 return location.line + 1;
208 } 213 }
209 214
210 215
211 //Returns the offset of the given position within the containing line.
212 function GetColumnNumber(message) {
213 var script = %MessageGetScript(message);
214 var start_position = %MessageGetStartPosition(message);
215 var location = script.locationFromPosition(start_position, true);
216 if (location == null) return -1;
217 return location.column;
218 }
219
220
221 // Returns the source code line containing the given source 216 // Returns the source code line containing the given source
222 // position, or the empty string if the position is invalid. 217 // position, or the empty string if the position is invalid.
223 function GetSourceLine(message) { 218 function GetSourceLine(message) {
224 var script = %MessageGetScript(message); 219 var script = %MessageGetScript(message);
225 var start_position = %MessageGetStartPosition(message); 220 var start_position = %MessageGetStartPosition(message);
226 var location = script.locationFromPosition(start_position, true); 221 var location = script.locationFromPosition(start_position, true);
227 if (location == null) return ""; 222 if (location == null) return "";
228 return location.sourceText(); 223 return location.sourceText();
229 } 224 }
230 225
231
232 /** 226 /**
233 * Find a line number given a specific source position. 227 * Find a line number given a specific source position.
234 * @param {number} position The source position. 228 * @param {number} position The source position.
235 * @return {number} 0 if input too small, -1 if input too large, 229 * @return {number} 0 if input too small, -1 if input too large,
236 else the line number. 230 else the line number.
237 */ 231 */
238 function ScriptLineFromPosition(position) { 232 function ScriptLineFromPosition(position) {
239 var lower = 0; 233 var lower = 0;
240 var upper = this.lineCount() - 1; 234 var upper = this.lineCount() - 1;
241 var line_ends = this.line_ends; 235 var line_ends = this.line_ends;
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 this.to_position, 549 this.to_position,
556 StringSubstring); 550 StringSubstring);
557 } 551 }
558 552
559 utils.SetUpLockedPrototype(SourceSlice, 553 utils.SetUpLockedPrototype(SourceSlice,
560 ["script", "from_line", "to_line", "from_position", "to_position"], 554 ["script", "from_line", "to_line", "from_position", "to_position"],
561 ["sourceText", SourceSliceSourceText] 555 ["sourceText", SourceSliceSourceText]
562 ); 556 );
563 557
564 558
559 // Returns the offset of the given position within the containing
560 // line.
561 function GetPositionInLine(message) {
562 var script = %MessageGetScript(message);
563 var start_position = %MessageGetStartPosition(message);
564 var location = script.locationFromPosition(start_position, true);
565 if (location == null) return -1;
566 return location.column;
567 }
568
569
565 function GetStackTraceLine(recv, fun, pos, isGlobal) { 570 function GetStackTraceLine(recv, fun, pos, isGlobal) {
566 return new CallSite(recv, fun, pos, false).toString(); 571 return new CallSite(recv, fun, pos, false).toString();
567 } 572 }
568 573
569 // ---------------------------------------------------------------------------- 574 // ----------------------------------------------------------------------------
570 // Error implementation 575 // Error implementation
571 576
572 var CallSiteReceiverKey = NEW_PRIVATE("CallSite#receiver"); 577 var CallSiteReceiverKey = NEW_PRIVATE("CallSite#receiver");
573 var CallSiteFunctionKey = NEW_PRIVATE("CallSite#function"); 578 var CallSiteFunctionKey = NEW_PRIVATE("CallSite#function");
574 var CallSitePositionKey = NEW_PRIVATE("CallSite#position"); 579 var CallSitePositionKey = NEW_PRIVATE("CallSite#position");
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 throw MakeTypeError(kCalledOnNonObject, "Error.prototype.toString"); 998 throw MakeTypeError(kCalledOnNonObject, "Error.prototype.toString");
994 } 999 }
995 1000
996 return %ErrorToStringRT(this); 1001 return %ErrorToStringRT(this);
997 } 1002 }
998 1003
999 utils.InstallFunctions(GlobalError.prototype, DONT_ENUM, 1004 utils.InstallFunctions(GlobalError.prototype, DONT_ENUM,
1000 ['toString', ErrorToString]); 1005 ['toString', ErrorToString]);
1001 1006
1002 $errorToString = ErrorToString; 1007 $errorToString = ErrorToString;
1008 $messageGetPositionInLine = GetPositionInLine;
1009 $messageGetLineNumber = GetLineNumber;
1010 $messageGetSourceLine = GetSourceLine;
1003 1011
1004 MakeError = function(type, arg0, arg1, arg2) { 1012 MakeError = function(type, arg0, arg1, arg2) {
1005 return MakeGenericError(GlobalError, type, arg0, arg1, arg2); 1013 return MakeGenericError(GlobalError, type, arg0, arg1, arg2);
1006 } 1014 }
1007 1015
1008 MakeRangeError = function(type, arg0, arg1, arg2) { 1016 MakeRangeError = function(type, arg0, arg1, arg2) {
1009 return MakeGenericError(GlobalRangeError, type, arg0, arg1, arg2); 1017 return MakeGenericError(GlobalRangeError, type, arg0, arg1, arg2);
1010 } 1018 }
1011 1019
1012 MakeSyntaxError = function(type, arg0, arg1, arg2) { 1020 MakeSyntaxError = function(type, arg0, arg1, arg2) {
1013 return MakeGenericError(GlobalSyntaxError, type, arg0, arg1, arg2); 1021 return MakeGenericError(GlobalSyntaxError, type, arg0, arg1, arg2);
1014 } 1022 }
1015 1023
1016 MakeTypeError = function(type, arg0, arg1, arg2) { 1024 MakeTypeError = function(type, arg0, arg1, arg2) {
1017 return MakeGenericError(GlobalTypeError, type, arg0, arg1, arg2); 1025 return MakeGenericError(GlobalTypeError, type, arg0, arg1, arg2);
1018 } 1026 }
1019 1027
1020 MakeURIError = function() { 1028 MakeURIError = function() {
1021 return MakeGenericError(GlobalURIError, kURIMalformed); 1029 return MakeGenericError(GlobalURIError, kURIMalformed);
1022 } 1030 }
1023 1031
1024 // Boilerplate for exceptions for stack overflows. Used from 1032 // Boilerplate for exceptions for stack overflows. Used from
1025 // Isolate::StackOverflow(). 1033 // Isolate::StackOverflow().
1026 var StackOverflowBoilerplate = MakeRangeError(kStackOverflow); 1034 $stackOverflowBoilerplate = MakeRangeError(kStackOverflow);
1027 %DefineAccessorPropertyUnchecked(StackOverflowBoilerplate, 'stack', 1035 %DefineAccessorPropertyUnchecked($stackOverflowBoilerplate, 'stack',
1028 StackTraceGetter, StackTraceSetter, 1036 StackTraceGetter, StackTraceSetter,
1029 DONT_ENUM); 1037 DONT_ENUM);
1030 1038
1031 // Define actual captureStackTrace function after everything has been set up. 1039 // Define actual captureStackTrace function after everything has been set up.
1032 captureStackTrace = function captureStackTrace(obj, cons_opt) { 1040 captureStackTrace = function captureStackTrace(obj, cons_opt) {
1033 // Define accessors first, as this may fail and throw. 1041 // Define accessors first, as this may fail and throw.
1034 ObjectDefineProperty(obj, 'stack', { get: StackTraceGetter, 1042 ObjectDefineProperty(obj, 'stack', { get: StackTraceGetter,
1035 set: StackTraceSetter, 1043 set: StackTraceSetter,
1036 configurable: true }); 1044 configurable: true });
1037 %CollectStackTrace(obj, cons_opt ? cons_opt : captureStackTrace); 1045 %CollectStackTrace(obj, cons_opt ? cons_opt : captureStackTrace);
1038 }; 1046 };
1039 1047
1040 GlobalError.captureStackTrace = captureStackTrace; 1048 GlobalError.captureStackTrace = captureStackTrace;
1041 1049
1042 utils.ExportToRuntime(function(to) { 1050 utils.ExportToRuntime(function(to) {
1043 to.Error = GlobalError; 1051 to.Error = GlobalError;
1044 to.EvalError = GlobalEvalError; 1052 to.EvalError = GlobalEvalError;
1045 to.RangeError = GlobalRangeError; 1053 to.RangeError = GlobalRangeError;
1046 to.ReferenceError = GlobalReferenceError; 1054 to.ReferenceError = GlobalReferenceError;
1047 to.SyntaxError = GlobalSyntaxError; 1055 to.SyntaxError = GlobalSyntaxError;
1048 to.TypeError = GlobalTypeError; 1056 to.TypeError = GlobalTypeError;
1049 to.URIError = GlobalURIError; 1057 to.URIError = GlobalURIError;
1050 to.GetStackTraceLine = GetStackTraceLine; 1058 to.GetStackTraceLine = GetStackTraceLine;
1051 to.NoSideEffectToString = NoSideEffectToString; 1059 to.NoSideEffectToString = NoSideEffectToString;
1052 to.ToDetailString = ToDetailString; 1060 to.ToDetailString = ToDetailString;
1053 to.MakeError = MakeGenericError; 1061 to.MakeError = MakeGenericError;
1054 to.MessageGetLineNumber = GetLineNumber;
1055 to.MessageGetColumnNumber = GetColumnNumber;
1056 to.MessageGetSourceLine = GetSourceLine;
1057 to.StackOverflowBoilerplate = StackOverflowBoilerplate;
1058 }); 1062 });
1059 1063
1060 }); 1064 });
OLDNEW
« no previous file with comments | « src/isolate.cc ('k') | src/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698