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

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

Issue 2632503003: [runtime] Allocate space for computed property names (Closed)
Patch Set: Fix some variable names. Created 3 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
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/compile-time-value.h" 9 #include "src/ast/compile-time-value.h"
10 #include "src/ast/prettyprinter.h" 10 #include "src/ast/prettyprinter.h"
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 (max_element_index <= 32) || ((2 * elements) >= max_element_index)); 575 (max_element_index <= 32) || ((2 * elements) >= max_element_index));
576 bit_field_ = HasElementsField::update(bit_field_, elements > 0); 576 bit_field_ = HasElementsField::update(bit_field_, elements > 0);
577 577
578 set_is_simple(is_simple); 578 set_is_simple(is_simple);
579 set_depth(depth_acc); 579 set_depth(depth_acc);
580 } 580 }
581 581
582 void ObjectLiteral::BuildConstantProperties(Isolate* isolate) { 582 void ObjectLiteral::BuildConstantProperties(Isolate* isolate) {
583 if (!constant_properties_.is_null()) return; 583 if (!constant_properties_.is_null()) return;
584 584
585 // Allocate a fixed array to hold all the constant properties. 585 // Allocate a fixed array to hold all the constant properties and the number
586 Handle<FixedArray> constant_properties = 586 // of total properties.
587 isolate->factory()->NewFixedArray(boilerplate_properties_ * 2, TENURED); 587 Handle<FixedArray> constant_properties = isolate->factory()->NewFixedArray(
Toon Verwaest 2017/01/18 08:49:53 Handle<ConstantProperties> = isolate->factory()->N
Franzi 2017/01/18 14:23:10 Acknowledged.
588 boilerplate_properties_ * 2 + 1, TENURED);
588 589
589 int position = 0; 590 int position = 0;
590 for (int i = 0; i < properties()->length(); i++) { 591 for (int i = 0; i < properties()->length(); i++) {
591 ObjectLiteral::Property* property = properties()->at(i); 592 ObjectLiteral::Property* property = properties()->at(i);
592 if (!IsBoilerplateProperty(property)) { 593 if (!IsBoilerplateProperty(property)) {
593 continue; 594 continue;
594 } 595 }
595 596
596 if (static_cast<uint32_t>(position) == boilerplate_properties_ * 2) { 597 if (static_cast<uint32_t>(position) == boilerplate_properties_ * 2) {
597 DCHECK(property->is_computed_name()); 598 DCHECK(property->is_computed_name());
(...skipping 17 matching lines...) Expand all
615 key = isolate->factory()->NewNumberFromUint(element_index); 616 key = isolate->factory()->NewNumberFromUint(element_index);
616 } else if (key->IsNumber() && !key->ToArrayIndex(&element_index)) { 617 } else if (key->IsNumber() && !key->ToArrayIndex(&element_index)) {
617 key = isolate->factory()->NumberToString(key); 618 key = isolate->factory()->NumberToString(key);
618 } 619 }
619 620
620 // Add name, value pair to the fixed array. 621 // Add name, value pair to the fixed array.
621 constant_properties->set(position++, *key); 622 constant_properties->set(position++, *key);
622 constant_properties->set(position++, *value); 623 constant_properties->set(position++, *value);
623 } 624 }
624 625
626 Handle<Object> total_properties =
627 isolate->factory()->NewNumberFromInt(total_properties_);
gsathya 2017/01/17 18:31:39 total_properties_ can be calculated using the abov
Franzi 2017/01/17 19:08:45 The loop breaks on the first computed property, an
Toon Verwaest 2017/01/18 08:49:53 I think what he means is that DCHECK_EQ(total_prop
Franzi 2017/01/18 14:23:10 As discussed, it's not equal if __proto__ is prese
628 constant_properties->set(position, *total_properties);
629
625 constant_properties_ = constant_properties; 630 constant_properties_ = constant_properties;
626 } 631 }
627 632
628 bool ObjectLiteral::IsFastCloningSupported() const { 633 bool ObjectLiteral::IsFastCloningSupported() const {
629 // The FastCloneShallowObject builtin doesn't copy elements, and object 634 // The FastCloneShallowObject builtin doesn't copy elements, and object
630 // literals don't support copy-on-write (COW) elements for now. 635 // literals don't support copy-on-write (COW) elements for now.
631 // TODO(mvstanton): make object literals support COW elements. 636 // TODO(mvstanton): make object literals support COW elements.
632 return fast_elements() && has_shallow_properties() && 637 return fast_elements() && has_shallow_properties() &&
633 properties_count() <= ConstructorBuiltinsAssembler:: 638 properties_count() <= ConstructorBuiltinsAssembler::
634 kMaximumClonedShallowObjectProperties; 639 kMaximumClonedShallowObjectProperties;
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 // static 1042 // static
1038 bool Literal::Match(void* literal1, void* literal2) { 1043 bool Literal::Match(void* literal1, void* literal2) {
1039 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); 1044 const AstValue* x = static_cast<Literal*>(literal1)->raw_value();
1040 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); 1045 const AstValue* y = static_cast<Literal*>(literal2)->raw_value();
1041 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || 1046 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) ||
1042 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); 1047 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber());
1043 } 1048 }
1044 1049
1045 } // namespace internal 1050 } // namespace internal
1046 } // namespace v8 1051 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/ast.h ('k') | src/compiler/access-info.cc » ('j') | src/compiler/access-info.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698