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

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

Issue 1601023005: Remove a bit more dead code after array spread desugaring (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix is_simple Created 4 years, 11 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 | no next file » | 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 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 constant_properties_ = constant_properties; 490 constant_properties_ = constant_properties;
491 fast_elements_ = 491 fast_elements_ =
492 (max_element_index <= 32) || ((2 * elements) >= max_element_index); 492 (max_element_index <= 32) || ((2 * elements) >= max_element_index);
493 has_elements_ = elements > 0; 493 has_elements_ = elements > 0;
494 set_is_simple(is_simple); 494 set_is_simple(is_simple);
495 set_depth(depth_acc); 495 set_depth(depth_acc);
496 } 496 }
497 497
498 498
499 void ArrayLiteral::BuildConstantElements(Isolate* isolate) { 499 void ArrayLiteral::BuildConstantElements(Isolate* isolate) {
500 DCHECK_LT(first_spread_index_, 0);
501
500 if (!constant_elements_.is_null()) return; 502 if (!constant_elements_.is_null()) return;
501 503
502 int constants_length = 504 int constants_length = values()->length();
503 first_spread_index_ >= 0 ? first_spread_index_ : values()->length();
504 505
505 // Allocate a fixed array to hold all the object literals. 506 // Allocate a fixed array to hold all the object literals.
506 Handle<JSArray> array = isolate->factory()->NewJSArray( 507 Handle<JSArray> array = isolate->factory()->NewJSArray(
507 FAST_HOLEY_SMI_ELEMENTS, constants_length, constants_length, 508 FAST_HOLEY_SMI_ELEMENTS, constants_length, constants_length,
508 Strength::WEAK, INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE); 509 Strength::WEAK, INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE);
509 510
510 // Fill in the literals. 511 // Fill in the literals.
511 bool is_simple = (first_spread_index_ < 0); 512 bool is_simple = true;
512 int depth_acc = 1; 513 int depth_acc = 1;
513 bool is_holey = false; 514 bool is_holey = false;
514 int array_index = 0; 515 int array_index = 0;
515 for (; array_index < constants_length; array_index++) { 516 for (; array_index < constants_length; array_index++) {
516 Expression* element = values()->at(array_index); 517 Expression* element = values()->at(array_index);
517 DCHECK(!element->IsSpread()); 518 DCHECK(!element->IsSpread());
518 MaterializedLiteral* m_literal = element->AsMaterializedLiteral(); 519 MaterializedLiteral* m_literal = element->AsMaterializedLiteral();
519 if (m_literal != NULL) { 520 if (m_literal != NULL) {
520 m_literal->BuildConstants(isolate); 521 m_literal->BuildConstants(isolate);
521 if (m_literal->depth() + 1 > depth_acc) { 522 if (m_literal->depth() + 1 > depth_acc) {
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 bool Literal::Match(void* literal1, void* literal2) { 839 bool Literal::Match(void* literal1, void* literal2) {
839 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); 840 const AstValue* x = static_cast<Literal*>(literal1)->raw_value();
840 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); 841 const AstValue* y = static_cast<Literal*>(literal2)->raw_value();
841 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || 842 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) ||
842 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); 843 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber());
843 } 844 }
844 845
845 846
846 } // namespace internal 847 } // namespace internal
847 } // namespace v8 848 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698