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

Side by Side Diff: src/runtime.js

Issue 1336273002: [builtins] Remove STRING_ADD_LEFT and STRING_ADD_RIGHT builtins. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 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/objects.h ('k') | src/runtime/runtime.h » ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 // This files contains runtime support implemented in JavaScript. 5 // This files contains runtime support implemented in JavaScript.
6 6
7 // CAUTION: Some of the functions specified in this file are called 7 // CAUTION: Some of the functions specified in this file are called
8 // directly from compiled code. These are the functions with names in 8 // directly from compiled code. These are the functions with names in
9 // ALL CAPS. The compiled code passes the first argument in 'this'. 9 // ALL CAPS. The compiled code passes the first argument in 'this'.
10 10
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 143
144 // Strong mode COMPARE throws if an implicit conversion would be performed 144 // Strong mode COMPARE throws if an implicit conversion would be performed
145 function COMPARE_STRONG(x, ncr) { 145 function COMPARE_STRONG(x, ncr) {
146 if (IS_STRING(this) && IS_STRING(x)) return %_StringCompare(this, x); 146 if (IS_STRING(this) && IS_STRING(x)) return %_StringCompare(this, x);
147 if (IS_NUMBER(this) && IS_NUMBER(x)) return %NumberCompare(this, x, ncr); 147 if (IS_NUMBER(this) && IS_NUMBER(x)) return %NumberCompare(this, x, ncr);
148 148
149 throw %make_type_error(kStrongImplicitConversion); 149 throw %make_type_error(kStrongImplicitConversion);
150 } 150 }
151 151
152 152
153
154 /* -----------------------------------
155 - - - A r i t h m e t i c - - -
156 -----------------------------------
157 */
158
159 // Left operand (this) is already a string.
160 function STRING_ADD_LEFT(y) {
161 if (!IS_STRING(y)) {
162 if (IS_STRING_WRAPPER(y) && %_IsStringWrapperSafeForDefaultValueOf(y)) {
163 y = %_ValueOf(y);
164 } else {
165 y = IS_NUMBER(y)
166 ? %_NumberToString(y)
167 : %to_string_fun(%to_primitive(y, NO_HINT));
168 }
169 }
170 return %_StringAdd(this, y);
171 }
172
173
174 // Right operand (y) is already a string.
175 function STRING_ADD_RIGHT(y) {
176 var x = this;
177 if (!IS_STRING(x)) {
178 if (IS_STRING_WRAPPER(x) && %_IsStringWrapperSafeForDefaultValueOf(x)) {
179 x = %_ValueOf(x);
180 } else {
181 x = IS_NUMBER(x)
182 ? %_NumberToString(x)
183 : %to_string_fun(%to_primitive(x, NO_HINT));
184 }
185 }
186 return %_StringAdd(x, y);
187 }
188
189
190 /* ----------------------------- 153 /* -----------------------------
191 - - - H e l p e r s - - - 154 - - - H e l p e r s - - -
192 ----------------------------- 155 -----------------------------
193 */ 156 */
194 157
195 function APPLY_PREPARE(args) { 158 function APPLY_PREPARE(args) {
196 var length; 159 var length;
197 160
198 // First check that the receiver is callable. 161 // First check that the receiver is callable.
199 if (!IS_CALLABLE(this)) { 162 if (!IS_CALLABLE(this)) {
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 $toString = ToString; 494 $toString = ToString;
532 495
533 %InstallToContext([ 496 %InstallToContext([
534 "apply_prepare_builtin", APPLY_PREPARE, 497 "apply_prepare_builtin", APPLY_PREPARE,
535 "compare_builtin", COMPARE, 498 "compare_builtin", COMPARE,
536 "compare_strong_builtin", COMPARE_STRONG, 499 "compare_strong_builtin", COMPARE_STRONG,
537 "concat_iterable_to_array_builtin", CONCAT_ITERABLE_TO_ARRAY, 500 "concat_iterable_to_array_builtin", CONCAT_ITERABLE_TO_ARRAY,
538 "equals_builtin", EQUALS, 501 "equals_builtin", EQUALS,
539 "reflect_apply_prepare_builtin", REFLECT_APPLY_PREPARE, 502 "reflect_apply_prepare_builtin", REFLECT_APPLY_PREPARE,
540 "reflect_construct_prepare_builtin", REFLECT_CONSTRUCT_PREPARE, 503 "reflect_construct_prepare_builtin", REFLECT_CONSTRUCT_PREPARE,
541 "string_add_left_builtin", STRING_ADD_LEFT,
542 "string_add_right_builtin", STRING_ADD_RIGHT,
543 ]); 504 ]);
544 505
545 %InstallToContext([ 506 %InstallToContext([
546 "concat_iterable_to_array", ConcatIterableToArray, 507 "concat_iterable_to_array", ConcatIterableToArray,
547 "non_number_to_number", NonNumberToNumber, 508 "non_number_to_number", NonNumberToNumber,
548 "non_string_to_string", NonStringToString, 509 "non_string_to_string", NonStringToString,
549 "to_integer_fun", ToInteger, 510 "to_integer_fun", ToInteger,
550 "to_length_fun", ToLength, 511 "to_length_fun", ToLength,
551 "to_number_fun", ToNumber, 512 "to_number_fun", ToNumber,
552 "to_primitive", ToPrimitive, 513 "to_primitive", ToPrimitive,
553 "to_string_fun", ToString, 514 "to_string_fun", ToString,
554 ]); 515 ]);
555 516
556 utils.Export(function(to) { 517 utils.Export(function(to) {
557 to.ToBoolean = ToBoolean; 518 to.ToBoolean = ToBoolean;
558 to.ToLength = ToLength; 519 to.ToLength = ToLength;
559 to.ToNumber = ToNumber; 520 to.ToNumber = ToNumber;
560 to.ToPrimitive = ToPrimitive; 521 to.ToPrimitive = ToPrimitive;
561 to.ToString = ToString; 522 to.ToString = ToString;
562 }); 523 });
563 524
564 }) 525 })
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698