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

Side by Side Diff: src/runtime.js

Issue 754863002: Optimize testing for an index's existence in packed Arrays (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased for landing Created 6 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
« no previous file with comments | « src/macros.py ('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' and 9 // ALL CAPS. The compiled code passes the first argument in 'this' and
10 // it does not push the function onto the stack. This means that you 10 // it does not push the function onto the stack. This means that you
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 function DELETE(key, strict) { 317 function DELETE(key, strict) {
318 return %DeleteProperty(%ToObject(this), %ToName(key), strict); 318 return %DeleteProperty(%ToObject(this), %ToName(key), strict);
319 } 319 }
320 320
321 321
322 // ECMA-262, section 11.8.7, page 54. 322 // ECMA-262, section 11.8.7, page 54.
323 function IN(x) { 323 function IN(x) {
324 if (!IS_SPEC_OBJECT(x)) { 324 if (!IS_SPEC_OBJECT(x)) {
325 throw %MakeTypeError('invalid_in_operator_use', [this, x]); 325 throw %MakeTypeError('invalid_in_operator_use', [this, x]);
326 } 326 }
327 return %_IsNonNegativeSmi(this) ? 327 if (%_IsNonNegativeSmi(this)) {
328 %HasElement(x, this) : %HasProperty(x, %ToName(this)); 328 if (IS_ARRAY(x) && %_HasFastPackedElements(x)) {
329 return this < x.length;
330 }
331 return %HasElement(x, this);
332 }
333 return %HasProperty(x, %ToName(this));
329 } 334 }
330 335
331 336
332 // ECMA-262, section 11.8.6, page 54. To make the implementation more 337 // ECMA-262, section 11.8.6, page 54. To make the implementation more
333 // efficient, the return value should be zero if the 'this' is an 338 // efficient, the return value should be zero if the 'this' is an
334 // instance of F, and non-zero if not. This makes it possible to avoid 339 // instance of F, and non-zero if not. This makes it possible to avoid
335 // an expensive ToBoolean conversion in the generated code. 340 // an expensive ToBoolean conversion in the generated code.
336 function INSTANCE_OF(F) { 341 function INSTANCE_OF(F) {
337 var V = this; 342 var V = this;
338 if (!IS_SPEC_FUNCTION(F)) { 343 if (!IS_SPEC_FUNCTION(F)) {
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 return i; 661 return i;
657 } 662 }
658 663
659 664
660 // NOTE: Setting the prototype for Array must take place as early as 665 // NOTE: Setting the prototype for Array must take place as early as
661 // possible due to code generation for array literals. When 666 // possible due to code generation for array literals. When
662 // generating code for a array literal a boilerplate array is created 667 // generating code for a array literal a boilerplate array is created
663 // that is cloned when running the code. It is essential that the 668 // that is cloned when running the code. It is essential that the
664 // boilerplate gets the right prototype. 669 // boilerplate gets the right prototype.
665 %FunctionSetPrototype($Array, new $Array(0)); 670 %FunctionSetPrototype($Array, new $Array(0));
OLDNEW
« no previous file with comments | « src/macros.py ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698