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

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

Issue 1540953004: [runtime] Rewrite Function.prototype.toString in C++. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix typos. Created 5 years 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
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 callSiteReceiverSymbol = 18 var callSiteReceiverSymbol =
19 utils.ImportNow("call_site_receiver_symbol"); 19 utils.ImportNow("call_site_receiver_symbol");
20 var callSiteFunctionSymbol = 20 var callSiteFunctionSymbol =
21 utils.ImportNow("call_site_function_symbol"); 21 utils.ImportNow("call_site_function_symbol");
22 var callSitePositionSymbol = 22 var callSitePositionSymbol =
23 utils.ImportNow("call_site_position_symbol"); 23 utils.ImportNow("call_site_position_symbol");
24 var callSiteStrictSymbol = 24 var callSiteStrictSymbol =
25 utils.ImportNow("call_site_strict_symbol"); 25 utils.ImportNow("call_site_strict_symbol");
26 var FLAG_harmony_tostring; 26 var FLAG_harmony_tostring;
27 var Float32x4ToString; 27 var Float32x4ToString;
28 var formattedStackTraceSymbol = 28 var formattedStackTraceSymbol =
29 utils.ImportNow("formatted_stack_trace_symbol"); 29 utils.ImportNow("formatted_stack_trace_symbol");
30 var FunctionSourceString
31 var GlobalObject = global.Object; 30 var GlobalObject = global.Object;
32 var Int16x8ToString; 31 var Int16x8ToString;
33 var Int32x4ToString; 32 var Int32x4ToString;
34 var Int8x16ToString; 33 var Int8x16ToString;
35 var InternalArray = utils.InternalArray; 34 var InternalArray = utils.InternalArray;
36 var internalErrorSymbol = utils.ImportNow("internal_error_symbol"); 35 var internalErrorSymbol = utils.ImportNow("internal_error_symbol");
37 var ObjectDefineProperty; 36 var ObjectDefineProperty;
38 var ObjectToString = utils.ImportNow("object_to_string"); 37 var ObjectToString = utils.ImportNow("object_to_string");
39 var Script = utils.ImportNow("Script"); 38 var Script = utils.ImportNow("Script");
40 var stackTraceSymbol = utils.ImportNow("stack_trace_symbol"); 39 var stackTraceSymbol = utils.ImportNow("stack_trace_symbol");
41 var StringCharAt; 40 var StringCharAt;
42 var StringIndexOf; 41 var StringIndexOf;
43 var StringSubstring; 42 var StringSubstring;
44 var SymbolToString; 43 var SymbolToString;
45 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); 44 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
46 var Uint16x8ToString; 45 var Uint16x8ToString;
47 var Uint32x4ToString; 46 var Uint32x4ToString;
48 var Uint8x16ToString; 47 var Uint8x16ToString;
49 48
50 utils.Import(function(from) { 49 utils.Import(function(from) {
51 ArrayJoin = from.ArrayJoin; 50 ArrayJoin = from.ArrayJoin;
52 Bool16x8ToString = from.Bool16x8ToString; 51 Bool16x8ToString = from.Bool16x8ToString;
53 Bool32x4ToString = from.Bool32x4ToString; 52 Bool32x4ToString = from.Bool32x4ToString;
54 Bool8x16ToString = from.Bool8x16ToString; 53 Bool8x16ToString = from.Bool8x16ToString;
55 Float32x4ToString = from.Float32x4ToString; 54 Float32x4ToString = from.Float32x4ToString;
56 FunctionSourceString = from.FunctionSourceString;
57 Int16x8ToString = from.Int16x8ToString; 55 Int16x8ToString = from.Int16x8ToString;
58 Int32x4ToString = from.Int32x4ToString; 56 Int32x4ToString = from.Int32x4ToString;
59 Int8x16ToString = from.Int8x16ToString; 57 Int8x16ToString = from.Int8x16ToString;
60 ObjectDefineProperty = from.ObjectDefineProperty; 58 ObjectDefineProperty = from.ObjectDefineProperty;
61 StringCharAt = from.StringCharAt; 59 StringCharAt = from.StringCharAt;
62 StringIndexOf = from.StringIndexOf; 60 StringIndexOf = from.StringIndexOf;
63 StringSubstring = from.StringSubstring; 61 StringSubstring = from.StringSubstring;
64 SymbolToString = from.SymbolToString; 62 SymbolToString = from.SymbolToString;
65 Uint16x8ToString = from.Uint16x8ToString; 63 Uint16x8ToString = from.Uint16x8ToString;
66 Uint32x4ToString = from.Uint32x4ToString; 64 Uint32x4ToString = from.Uint32x4ToString;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 return `${name}: ${message}`; 111 return `${name}: ${message}`;
114 } 112 }
115 113
116 function NoSideEffectsToString(obj) { 114 function NoSideEffectsToString(obj) {
117 if (IS_STRING(obj)) return obj; 115 if (IS_STRING(obj)) return obj;
118 if (IS_NUMBER(obj)) return %_NumberToString(obj); 116 if (IS_NUMBER(obj)) return %_NumberToString(obj);
119 if (IS_BOOLEAN(obj)) return obj ? 'true' : 'false'; 117 if (IS_BOOLEAN(obj)) return obj ? 'true' : 'false';
120 if (IS_UNDEFINED(obj)) return 'undefined'; 118 if (IS_UNDEFINED(obj)) return 'undefined';
121 if (IS_NULL(obj)) return 'null'; 119 if (IS_NULL(obj)) return 'null';
122 if (IS_FUNCTION(obj)) { 120 if (IS_FUNCTION(obj)) {
123 var str = %_Call(FunctionSourceString, obj, obj); 121 var str = %FunctionToString(obj);
124 if (str.length > 128) { 122 if (str.length > 128) {
125 str = %_SubString(str, 0, 111) + "...<omitted>..." + 123 str = %_SubString(str, 0, 111) + "...<omitted>..." +
126 %_SubString(str, str.length - 2, str.length); 124 %_SubString(str, str.length - 2, str.length);
127 } 125 }
128 return str; 126 return str;
129 } 127 }
130 if (IS_SYMBOL(obj)) return %_Call(SymbolToString, obj); 128 if (IS_SYMBOL(obj)) return %_Call(SymbolToString, obj);
131 if (IS_SIMD_VALUE(obj)) { 129 if (IS_SIMD_VALUE(obj)) {
132 switch (typeof(obj)) { 130 switch (typeof(obj)) {
133 case 'float32x4': return %_Call(Float32x4ToString, obj); 131 case 'float32x4': return %_Call(Float32x4ToString, obj);
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 utils.Export(function(to) { 1004 utils.Export(function(to) {
1007 to.ErrorToString = ErrorToString; 1005 to.ErrorToString = ErrorToString;
1008 to.MakeError = MakeError; 1006 to.MakeError = MakeError;
1009 to.MakeRangeError = MakeRangeError; 1007 to.MakeRangeError = MakeRangeError;
1010 to.MakeSyntaxError = MakeSyntaxError; 1008 to.MakeSyntaxError = MakeSyntaxError;
1011 to.MakeTypeError = MakeTypeError; 1009 to.MakeTypeError = MakeTypeError;
1012 to.MakeURIError = MakeURIError; 1010 to.MakeURIError = MakeURIError;
1013 }); 1011 });
1014 1012
1015 }); 1013 });
OLDNEW
« src/debug/mirrors.js ('K') | « src/ia32/builtins-ia32.cc ('k') | src/js/prologue.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698