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

Side by Side Diff: src/runtime.js

Issue 57052: * String type inference using compiler framework. (Closed)
Patch Set: Changes relative to head of bleeding edge (don't do diff with earlier versions) Created 11 years, 8 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/rewriter.cc ('k') | src/variables.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 // 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 if (IS_STRING(a)) { 156 if (IS_STRING(a)) {
157 return %StringAdd(a, %ToString(b)); 157 return %StringAdd(a, %ToString(b));
158 } else if (IS_STRING(b)) { 158 } else if (IS_STRING(b)) {
159 return %StringAdd(%ToString(a), b); 159 return %StringAdd(%ToString(a), b);
160 } else { 160 } else {
161 return %NumberAdd(%ToNumber(a), %ToNumber(b)); 161 return %NumberAdd(%ToNumber(a), %ToNumber(b));
162 } 162 }
163 } 163 }
164 164
165 165
166 // Left operand (this) is already a string.
167 function STRING_ADD_LEFT(x) {
168 x = %ToString(%ToPrimitive(x, NO_HINT));
169 return %StringAdd(this, x);
170 }
171
172
173 // Right operand (x) is already a string.
174 function STRING_ADD_RIGHT(x) {
175 var a = %ToString(%ToPrimitive(this, NO_HINT));
176 return %StringAdd(a, x);
177 }
178
179
166 // ECMA-262, section 11.6.2, page 50. 180 // ECMA-262, section 11.6.2, page 50.
167 function SUB(x) { 181 function SUB(x) {
168 return %NumberSub(%ToNumber(this), %ToNumber(x)); 182 return %NumberSub(%ToNumber(this), %ToNumber(x));
169 } 183 }
170 184
171 185
172 // ECMA-262, section 11.5.1, page 48. 186 // ECMA-262, section 11.5.1, page 48.
173 function MUL(x) { 187 function MUL(x) {
174 return %NumberMul(%ToNumber(this), %ToNumber(x)); 188 return %NumberMul(%ToNumber(this), %ToNumber(x));
175 } 189 }
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 // ECMA-262, section 11.8.7, page 54. 282 // ECMA-262, section 11.8.7, page 54.
269 function IN(x) { 283 function IN(x) {
270 if (x == null || (!IS_OBJECT(x) && !IS_FUNCTION(x))) { 284 if (x == null || (!IS_OBJECT(x) && !IS_FUNCTION(x))) {
271 throw %MakeTypeError('invalid_in_operator_use', [this, x]); 285 throw %MakeTypeError('invalid_in_operator_use', [this, x]);
272 } 286 }
273 return %_IsNonNegativeSmi(this) ? %HasElement(x, this) : %HasProperty(x, %ToSt ring(this)); 287 return %_IsNonNegativeSmi(this) ? %HasElement(x, this) : %HasProperty(x, %ToSt ring(this));
274 } 288 }
275 289
276 290
277 // ECMA-262, section 11.8.6, page 54. To make the implementation more 291 // ECMA-262, section 11.8.6, page 54. To make the implementation more
278 // efficient, the return value should be zero if the 'this' is an 292 // efficient, the return value should be zero if the 'this' is an
279 // instance of F, and non-zero if not. This makes it possible to avoid 293 // instance of F, and non-zero if not. This makes it possible to avoid
280 // an expensive ToBoolean conversion in the generated code. 294 // an expensive ToBoolean conversion in the generated code.
281 function INSTANCE_OF(F) { 295 function INSTANCE_OF(F) {
282 var V = this; 296 var V = this;
283 if (!IS_FUNCTION(F)) { 297 if (!IS_FUNCTION(F)) {
284 throw %MakeTypeError('instanceof_function_expected', [V]); 298 throw %MakeTypeError('instanceof_function_expected', [V]);
285 } 299 }
286 300
287 // If V is not an object, return false. 301 // If V is not an object, return false.
288 if (IS_NULL(V) || (!IS_OBJECT(V) && !IS_FUNCTION(V))) { 302 if (IS_NULL(V) || (!IS_OBJECT(V) && !IS_FUNCTION(V))) {
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 throw %MakeTypeError('cannot_convert_to_primitive', []); 532 throw %MakeTypeError('cannot_convert_to_primitive', []);
519 } 533 }
520 534
521 535
522 // NOTE: Setting the prototype for Array must take place as early as 536 // NOTE: Setting the prototype for Array must take place as early as
523 // possible due to code generation for array literals. When 537 // possible due to code generation for array literals. When
524 // generating code for a array literal a boilerplate array is created 538 // generating code for a array literal a boilerplate array is created
525 // that is cloned when running the code. It is essiential that the 539 // that is cloned when running the code. It is essiential that the
526 // boilerplate gets the right prototype. 540 // boilerplate gets the right prototype.
527 %FunctionSetPrototype($Array, new $Array(0)); 541 %FunctionSetPrototype($Array, new $Array(0));
OLDNEW
« no previous file with comments | « src/rewriter.cc ('k') | src/variables.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698