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

Side by Side Diff: src/js/messages.js

Issue 2174723002: Move CallSite.toString to C++ (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@callsite-port
Patch Set: Rebase Created 4 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/builtins/builtins-callsite.cc ('k') | no next file » | 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 (function(global, utils) { 7 (function(global, utils) {
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
11 // ------------------------------------------------------------------- 11 // -------------------------------------------------------------------
12 // Imports 12 // Imports
13 13
14 var ArrayJoin; 14 var ArrayJoin;
15 var Bool16x8ToString; 15 var Bool16x8ToString;
16 var Bool32x4ToString; 16 var Bool32x4ToString;
17 var Bool8x16ToString; 17 var Bool8x16ToString;
18 var CallSite = utils.ImportNow("CallSite"); 18 var CallSite = utils.ImportNow("CallSite");
19 var callSiteConstructorSymbol =
20 utils.ImportNow("call_site_constructor_symbol");
21 var callSiteReceiverSymbol =
22 utils.ImportNow("call_site_receiver_symbol");
23 var callSiteFunctionSymbol =
24 utils.ImportNow("call_site_function_symbol");
25 var callSitePositionSymbol =
26 utils.ImportNow("call_site_position_symbol");
27 var callSiteStrictSymbol =
28 utils.ImportNow("call_site_strict_symbol");
29 var callSiteWasmObjectSymbol =
30 utils.ImportNow("call_site_wasm_obj_symbol");
31 var callSiteWasmFunctionIndexSymbol =
32 utils.ImportNow("call_site_wasm_func_index_symbol");
33 var Float32x4ToString; 19 var Float32x4ToString;
34 var GlobalObject = global.Object; 20 var GlobalObject = global.Object;
35 var GlobalError = global.Error; 21 var GlobalError = global.Error;
36 var GlobalEvalError = global.EvalError; 22 var GlobalEvalError = global.EvalError;
37 var GlobalRangeError = global.RangeError; 23 var GlobalRangeError = global.RangeError;
38 var GlobalReferenceError = global.ReferenceError; 24 var GlobalReferenceError = global.ReferenceError;
39 var GlobalSyntaxError = global.SyntaxError; 25 var GlobalSyntaxError = global.SyntaxError;
40 var GlobalTypeError = global.TypeError; 26 var GlobalTypeError = global.TypeError;
41 var GlobalURIError = global.URIError; 27 var GlobalURIError = global.URIError;
42 var Int16x8ToString; 28 var Int16x8ToString;
43 var Int32x4ToString; 29 var Int32x4ToString;
44 var Int8x16ToString; 30 var Int8x16ToString;
45 var InternalArray = utils.InternalArray; 31 var InternalArray = utils.InternalArray;
46 var internalErrorSymbol = utils.ImportNow("internal_error_symbol"); 32 var internalErrorSymbol = utils.ImportNow("internal_error_symbol");
47 var ObjectHasOwnProperty; 33 var ObjectHasOwnProperty;
48 var ObjectToString = utils.ImportNow("object_to_string"); 34 var ObjectToString = utils.ImportNow("object_to_string");
49 var Script = utils.ImportNow("Script"); 35 var Script = utils.ImportNow("Script");
50 var stackTraceSymbol = utils.ImportNow("stack_trace_symbol"); 36 var stackTraceSymbol = utils.ImportNow("stack_trace_symbol");
51 var StringIndexOf;
52 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); 37 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
53 var Uint16x8ToString; 38 var Uint16x8ToString;
54 var Uint32x4ToString; 39 var Uint32x4ToString;
55 var Uint8x16ToString; 40 var Uint8x16ToString;
56 41
57 utils.Import(function(from) { 42 utils.Import(function(from) {
58 ArrayJoin = from.ArrayJoin; 43 ArrayJoin = from.ArrayJoin;
59 Bool16x8ToString = from.Bool16x8ToString; 44 Bool16x8ToString = from.Bool16x8ToString;
60 Bool32x4ToString = from.Bool32x4ToString; 45 Bool32x4ToString = from.Bool32x4ToString;
61 Bool8x16ToString = from.Bool8x16ToString; 46 Bool8x16ToString = from.Bool8x16ToString;
62 Float32x4ToString = from.Float32x4ToString; 47 Float32x4ToString = from.Float32x4ToString;
63 Int16x8ToString = from.Int16x8ToString; 48 Int16x8ToString = from.Int16x8ToString;
64 Int32x4ToString = from.Int32x4ToString; 49 Int32x4ToString = from.Int32x4ToString;
65 Int8x16ToString = from.Int8x16ToString; 50 Int8x16ToString = from.Int8x16ToString;
66 ObjectHasOwnProperty = from.ObjectHasOwnProperty; 51 ObjectHasOwnProperty = from.ObjectHasOwnProperty;
67 StringIndexOf = from.StringIndexOf;
68 Uint16x8ToString = from.Uint16x8ToString; 52 Uint16x8ToString = from.Uint16x8ToString;
69 Uint32x4ToString = from.Uint32x4ToString; 53 Uint32x4ToString = from.Uint32x4ToString;
70 Uint8x16ToString = from.Uint8x16ToString; 54 Uint8x16ToString = from.Uint8x16ToString;
71 }); 55 });
72 56
73 // ------------------------------------------------------------------- 57 // -------------------------------------------------------------------
74 58
75 59
76 60
77 function NoSideEffectsObjectToString() { 61 function NoSideEffectsObjectToString() {
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 ); 249 );
266 250
267 251
268 function GetStackTraceLine(recv, fun, pos, isGlobal) { 252 function GetStackTraceLine(recv, fun, pos, isGlobal) {
269 return new CallSite(recv, fun, pos, false).toString(); 253 return new CallSite(recv, fun, pos, false).toString();
270 } 254 }
271 255
272 // ---------------------------------------------------------------------------- 256 // ----------------------------------------------------------------------------
273 // Error implementation 257 // Error implementation
274 258
275 function CallSiteToString() {
276 if (HAS_PRIVATE(this, callSiteWasmObjectSymbol)) {
277 var funName = this.getFunctionName();
278 var funcIndex = GET_PRIVATE(this, callSiteWasmFunctionIndexSymbol);
279 var pos = this.getPosition();
280 if (IS_NULL(funName)) funName = "<WASM UNNAMED>";
281 return funName + " (<WASM>[" + funcIndex + "]+" + pos + ")";
282 }
283
284 var fileName;
285 var fileLocation = "";
286 if (this.isNative()) {
287 fileLocation = "native";
288 } else {
289 fileName = this.getScriptNameOrSourceURL();
290 if (!fileName && this.isEval()) {
291 fileLocation = this.getEvalOrigin();
292 fileLocation += ", "; // Expecting source position to follow.
293 }
294
295 if (fileName) {
296 fileLocation += fileName;
297 } else {
298 // Source code does not originate from a file and is not native, but we
299 // can still get the source position inside the source string, e.g. in
300 // an eval string.
301 fileLocation += "<anonymous>";
302 }
303 var lineNumber = this.getLineNumber();
304 if (lineNumber != null) {
305 fileLocation += ":" + lineNumber;
306 var columnNumber = this.getColumnNumber();
307 if (columnNumber) {
308 fileLocation += ":" + columnNumber;
309 }
310 }
311 }
312
313 var line = "";
314 var functionName = this.getFunctionName();
315 var addSuffix = true;
316 var isConstructor = this.isConstructor();
317 var isMethodCall = !(this.isToplevel() || isConstructor);
318 if (isMethodCall) {
319 var typeName = GetTypeName(GET_PRIVATE(this, callSiteReceiverSymbol), true);
320 var methodName = this.getMethodName();
321 if (functionName) {
322 if (typeName && %_Call(StringIndexOf, functionName, typeName) != 0) {
323 line += typeName + ".";
324 }
325 line += functionName;
326 if (methodName &&
327 (%_Call(StringIndexOf, functionName, "." + methodName) !=
328 functionName.length - methodName.length - 1)) {
329 line += " [as " + methodName + "]";
330 }
331 } else {
332 line += typeName + "." + (methodName || "<anonymous>");
333 }
334 } else if (isConstructor) {
335 line += "new " + (functionName || "<anonymous>");
336 } else if (functionName) {
337 line += functionName;
338 } else {
339 line += fileLocation;
340 addSuffix = false;
341 }
342 if (addSuffix) {
343 line += " (" + fileLocation + ")";
344 }
345 return line;
346 }
347
348 %AddNamedProperty(CallSite.prototype, "toString", CallSiteToString,
349 DONT_ENUM | DONT_DELETE | READ_ONLY);
350 %SetNativeFlag(CallSiteToString);
351
352 259
353 function FormatErrorString(error) { 260 function FormatErrorString(error) {
354 try { 261 try {
355 return %_Call(ErrorToString, error); 262 return %_Call(ErrorToString, error);
356 } catch (e) { 263 } catch (e) {
357 try { 264 try {
358 return "<error: " + e + ">"; 265 return "<error: " + e + ">";
359 } catch (ee) { 266 } catch (ee) {
360 return "<error>"; 267 return "<error>";
361 } 268 }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 utils.Export(function(to) { 391 utils.Export(function(to) {
485 to.ErrorToString = ErrorToString; 392 to.ErrorToString = ErrorToString;
486 to.MakeError = MakeError; 393 to.MakeError = MakeError;
487 to.MakeRangeError = MakeRangeError; 394 to.MakeRangeError = MakeRangeError;
488 to.MakeSyntaxError = MakeSyntaxError; 395 to.MakeSyntaxError = MakeSyntaxError;
489 to.MakeTypeError = MakeTypeError; 396 to.MakeTypeError = MakeTypeError;
490 to.MakeURIError = MakeURIError; 397 to.MakeURIError = MakeURIError;
491 }); 398 });
492 399
493 }); 400 });
OLDNEW
« no previous file with comments | « src/builtins/builtins-callsite.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698