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

Side by Side Diff: src/ast/ast.cc

Issue 1768203002: Properly prepare boilerplate properties in the parser for the runtime (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: drop IsInternalized DCHECK Created 4 years, 9 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 | « no previous file | src/runtime/runtime-literals.cc » ('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 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 #include "src/ast/ast.h" 5 #include "src/ast/ast.h"
6 6
7 #include <cmath> // For isfinite. 7 #include <cmath> // For isfinite.
8 8
9 #include "src/ast/prettyprinter.h" 9 #include "src/ast/prettyprinter.h"
10 #include "src/ast/scopes.h" 10 #include "src/ast/scopes.h"
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 may_store_doubles_ = true; 458 may_store_doubles_ = true;
459 } 459 }
460 460
461 is_simple = is_simple && !value->IsUninitialized(); 461 is_simple = is_simple && !value->IsUninitialized();
462 462
463 // Keep track of the number of elements in the object literal and 463 // Keep track of the number of elements in the object literal and
464 // the largest element index. If the largest element index is 464 // the largest element index. If the largest element index is
465 // much larger than the number of elements, creating an object 465 // much larger than the number of elements, creating an object
466 // literal with fast elements will be a waste of space. 466 // literal with fast elements will be a waste of space.
467 uint32_t element_index = 0; 467 uint32_t element_index = 0;
468 if (key->IsString() 468 if (key->IsString() && String::cast(*key)->AsArrayIndex(&element_index)) {
469 && Handle<String>::cast(key)->AsArrayIndex(&element_index) 469 max_element_index = Max(element_index, max_element_index);
470 && element_index > max_element_index) {
471 max_element_index = element_index;
472 elements++; 470 elements++;
473 } else if (key->IsSmi()) { 471 key = isolate->factory()->NewNumberFromUint(element_index);
474 int key_value = Smi::cast(*key)->value(); 472 } else if (key->ToArrayIndex(&element_index)) {
475 if (key_value > 0 473 max_element_index = Max(element_index, max_element_index);
476 && static_cast<uint32_t>(key_value) > max_element_index) {
477 max_element_index = key_value;
478 }
479 elements++; 474 elements++;
475 } else if (key->IsNumber()) {
476 key = isolate->factory()->NumberToString(key);
480 } 477 }
481 478
482 // Add name, value pair to the fixed array. 479 // Add name, value pair to the fixed array.
483 constant_properties->set(position++, *key); 480 constant_properties->set(position++, *key);
484 constant_properties->set(position++, *value); 481 constant_properties->set(position++, *value);
485 } 482 }
486 483
487 constant_properties_ = constant_properties; 484 constant_properties_ = constant_properties;
488 fast_elements_ = 485 fast_elements_ =
489 (max_element_index <= 32) || ((2 * elements) >= max_element_index); 486 (max_element_index <= 32) || ((2 * elements) >= max_element_index);
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 bool Literal::Match(void* literal1, void* literal2) { 831 bool Literal::Match(void* literal1, void* literal2) {
835 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); 832 const AstValue* x = static_cast<Literal*>(literal1)->raw_value();
836 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); 833 const AstValue* y = static_cast<Literal*>(literal2)->raw_value();
837 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || 834 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) ||
838 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); 835 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber());
839 } 836 }
840 837
841 838
842 } // namespace internal 839 } // namespace internal
843 } // namespace v8 840 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/runtime/runtime-literals.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698