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

Side by Side Diff: src/hydrogen.cc

Issue 792233008: ES6 computed property names (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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/full-codegen.cc ('k') | src/ia32/full-codegen-ia32.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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/hydrogen.h" 5 #include "src/hydrogen.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "src/v8.h" 9 #include "src/v8.h"
10 10
(...skipping 5534 matching lines...) Expand 10 before | Expand all | Expand 10 after
5545 } 5545 }
5546 } 5546 }
5547 return true; 5547 return true;
5548 } 5548 }
5549 5549
5550 5550
5551 void HOptimizedGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) { 5551 void HOptimizedGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) {
5552 DCHECK(!HasStackOverflow()); 5552 DCHECK(!HasStackOverflow());
5553 DCHECK(current_block() != NULL); 5553 DCHECK(current_block() != NULL);
5554 DCHECK(current_block()->HasPredecessor()); 5554 DCHECK(current_block()->HasPredecessor());
5555
5556 for (int i = 0; i < expr->properties()->length(); i++) {
5557 if (expr->properties()->at(i)->is_computed_name()) {
5558 return Bailout(kComputedPropertyName);
5559 }
5560 }
5561
5555 expr->BuildConstantProperties(isolate()); 5562 expr->BuildConstantProperties(isolate());
5556 Handle<JSFunction> closure = function_state()->compilation_info()->closure(); 5563 Handle<JSFunction> closure = function_state()->compilation_info()->closure();
5557 HInstruction* literal; 5564 HInstruction* literal;
5558 5565
5559 // Check whether to use fast or slow deep-copying for boilerplate. 5566 // Check whether to use fast or slow deep-copying for boilerplate.
5560 int max_properties = kMaxFastLiteralProperties; 5567 int max_properties = kMaxFastLiteralProperties;
5561 Handle<Object> literals_cell(closure->literals()->get(expr->literal_index()), 5568 Handle<Object> literals_cell(closure->literals()->get(expr->literal_index()),
5562 isolate()); 5569 isolate());
5563 Handle<AllocationSite> site; 5570 Handle<AllocationSite> site;
5564 Handle<JSObject> boilerplate; 5571 Handle<JSObject> boilerplate;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
5600 } 5607 }
5601 5608
5602 // The object is expected in the bailout environment during computation 5609 // The object is expected in the bailout environment during computation
5603 // of the property values and is the value of the entire expression. 5610 // of the property values and is the value of the entire expression.
5604 Push(literal); 5611 Push(literal);
5605 5612
5606 expr->CalculateEmitStore(zone()); 5613 expr->CalculateEmitStore(zone());
5607 5614
5608 for (int i = 0; i < expr->properties()->length(); i++) { 5615 for (int i = 0; i < expr->properties()->length(); i++) {
5609 ObjectLiteral::Property* property = expr->properties()->at(i); 5616 ObjectLiteral::Property* property = expr->properties()->at(i);
5617 DCHECK(!property->is_computed_name());
5610 if (property->IsCompileTimeValue()) continue; 5618 if (property->IsCompileTimeValue()) continue;
5611 5619
5612 Literal* key = property->key(); 5620 Literal* key = property->key()->AsLiteral();
5613 Expression* value = property->value(); 5621 Expression* value = property->value();
5614 5622
5615 switch (property->kind()) { 5623 switch (property->kind()) {
5616 case ObjectLiteral::Property::MATERIALIZED_LITERAL: 5624 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
5617 DCHECK(!CompileTimeValue::IsCompileTimeValue(value)); 5625 DCHECK(!CompileTimeValue::IsCompileTimeValue(value));
5618 // Fall through. 5626 // Fall through.
5619 case ObjectLiteral::Property::COMPUTED: 5627 case ObjectLiteral::Property::COMPUTED:
5620 // It is safe to use [[Put]] here because the boilerplate already 5628 // It is safe to use [[Put]] here because the boilerplate already
5621 // contains computed properties with an uninitialized value. 5629 // contains computed properties with an uninitialized value.
5622 if (key->value()->IsInternalizedString()) { 5630 if (key->value()->IsInternalizedString()) {
5623 if (property->emit_store()) { 5631 if (property->emit_store()) {
5624 CHECK_ALIVE(VisitForValue(value)); 5632 CHECK_ALIVE(VisitForValue(value));
5625 HValue* value = Pop(); 5633 HValue* value = Pop();
5626 5634
5627 // Add [[HomeObject]] to function literals. 5635 // Add [[HomeObject]] to function literals.
5628 if (FunctionLiteral::NeedsHomeObject(property->value())) { 5636 if (FunctionLiteral::NeedsHomeObject(property->value())) {
5629 Handle<Symbol> sym = isolate()->factory()->home_object_symbol(); 5637 Handle<Symbol> sym = isolate()->factory()->home_object_symbol();
5630 HInstruction* store_home = BuildKeyedGeneric( 5638 HInstruction* store_home = BuildKeyedGeneric(
5631 STORE, NULL, value, Add<HConstant>(sym), literal); 5639 STORE, NULL, value, Add<HConstant>(sym), literal);
5632 AddInstruction(store_home); 5640 AddInstruction(store_home);
5633 DCHECK(store_home->HasObservableSideEffects()); 5641 DCHECK(store_home->HasObservableSideEffects());
5634 Add<HSimulate>(property->value()->id(), REMOVABLE_SIMULATE); 5642 Add<HSimulate>(property->value()->id(), REMOVABLE_SIMULATE);
5635 } 5643 }
5636 5644
5637 Handle<Map> map = property->GetReceiverType(); 5645 Handle<Map> map = property->GetReceiverType();
5638 Handle<String> name = property->key()->AsPropertyName(); 5646 Handle<String> name = key->AsPropertyName();
5639 HInstruction* store; 5647 HInstruction* store;
5640 if (map.is_null()) { 5648 if (map.is_null()) {
5641 // If we don't know the monomorphic type, do a generic store. 5649 // If we don't know the monomorphic type, do a generic store.
5642 CHECK_ALIVE(store = BuildNamedGeneric( 5650 CHECK_ALIVE(store = BuildNamedGeneric(
5643 STORE, NULL, literal, name, value)); 5651 STORE, NULL, literal, name, value));
5644 } else { 5652 } else {
5645 PropertyAccessInfo info(this, STORE, ToType(map), name); 5653 PropertyAccessInfo info(this, STORE, ToType(map), name);
5646 if (info.CanAccessMonomorphic()) { 5654 if (info.CanAccessMonomorphic()) {
5647 HValue* checked_literal = Add<HCheckMaps>(literal, map); 5655 HValue* checked_literal = Add<HCheckMaps>(literal, map);
5648 DCHECK(!info.IsAccessor()); 5656 DCHECK(!info.IsAccessor());
(...skipping 7786 matching lines...) Expand 10 before | Expand all | Expand 10 after
13435 if (ShouldProduceTraceOutput()) { 13443 if (ShouldProduceTraceOutput()) {
13436 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 13444 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
13437 } 13445 }
13438 13446
13439 #ifdef DEBUG 13447 #ifdef DEBUG
13440 graph_->Verify(false); // No full verify. 13448 graph_->Verify(false); // No full verify.
13441 #endif 13449 #endif
13442 } 13450 }
13443 13451
13444 } } // namespace v8::internal 13452 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/full-codegen.cc ('k') | src/ia32/full-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698