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

Side by Side Diff: src/hydrogen.cc

Issue 31943002: Allow constants to be deleted by reinserting them into the graph as needed. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-dce.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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 627
628 #endif 628 #endif
629 629
630 630
631 HConstant* HGraph::GetConstant(SetOncePointer<HConstant>* pointer, 631 HConstant* HGraph::GetConstant(SetOncePointer<HConstant>* pointer,
632 int32_t value) { 632 int32_t value) {
633 if (!pointer->is_set()) { 633 if (!pointer->is_set()) {
634 // Can't pass GetInvalidContext() to HConstant::New, because that will 634 // Can't pass GetInvalidContext() to HConstant::New, because that will
635 // recursively call GetConstant 635 // recursively call GetConstant
636 HConstant* constant = HConstant::New(zone(), NULL, value); 636 HConstant* constant = HConstant::New(zone(), NULL, value);
637 constant->InsertAfter(GetConstantUndefined()); 637 constant->InsertAfter(entry_block()->first());
638 pointer->set(constant); 638 pointer->set(constant);
639 return constant;
639 } 640 }
640 return pointer->get(); 641 return ReinsertConstantIfNecessary(pointer->get());
641 } 642 }
642 643
643 644
645 HConstant* HGraph::ReinsertConstantIfNecessary(HConstant* constant) {
646 if (!constant->IsLinked()) {
647 // The constant was removed from the graph. Reinsert.
648 constant->ClearFlag(HValue::kIsDead);
649 constant->InsertAfter(entry_block()->first());
650 }
651 return constant;
652 }
653
654
644 HConstant* HGraph::GetConstant0() { 655 HConstant* HGraph::GetConstant0() {
645 return GetConstant(&constant_0_, 0); 656 return GetConstant(&constant_0_, 0);
646 } 657 }
647 658
648 659
649 HConstant* HGraph::GetConstant1() { 660 HConstant* HGraph::GetConstant1() {
650 return GetConstant(&constant_1_, 1); 661 return GetConstant(&constant_1_, 1);
651 } 662 }
652 663
653 664
654 HConstant* HGraph::GetConstantMinus1() { 665 HConstant* HGraph::GetConstantMinus1() {
655 return GetConstant(&constant_minus1_, -1); 666 return GetConstant(&constant_minus1_, -1);
656 } 667 }
657 668
658 669
659 #define DEFINE_GET_CONSTANT(Name, name, htype, boolean_value) \ 670 #define DEFINE_GET_CONSTANT(Name, name, htype, boolean_value) \
660 HConstant* HGraph::GetConstant##Name() { \ 671 HConstant* HGraph::GetConstant##Name() { \
661 if (!constant_##name##_.is_set()) { \ 672 if (!constant_##name##_.is_set()) { \
662 HConstant* constant = new(zone()) HConstant( \ 673 HConstant* constant = new(zone()) HConstant( \
663 Unique<Object>::CreateImmovable(isolate()->factory()->name##_value()), \ 674 Unique<Object>::CreateImmovable(isolate()->factory()->name##_value()), \
664 Representation::Tagged(), \ 675 Representation::Tagged(), \
665 htype, \ 676 htype, \
666 false, \ 677 false, \
667 true, \ 678 true, \
668 false, \ 679 false, \
669 boolean_value); \ 680 boolean_value); \
670 constant->InsertAfter(GetConstantUndefined()); \ 681 constant->InsertAfter(entry_block()->first()); \
671 constant_##name##_.set(constant); \ 682 constant_##name##_.set(constant); \
672 } \ 683 } \
673 return constant_##name##_.get(); \ 684 return ReinsertConstantIfNecessary(constant_##name##_.get()); \
674 } 685 }
675 686
676 687
688 DEFINE_GET_CONSTANT(Undefined, undefined, HType::Tagged(), false)
677 DEFINE_GET_CONSTANT(True, true, HType::Boolean(), true) 689 DEFINE_GET_CONSTANT(True, true, HType::Boolean(), true)
678 DEFINE_GET_CONSTANT(False, false, HType::Boolean(), false) 690 DEFINE_GET_CONSTANT(False, false, HType::Boolean(), false)
679 DEFINE_GET_CONSTANT(Hole, the_hole, HType::Tagged(), false) 691 DEFINE_GET_CONSTANT(Hole, the_hole, HType::Tagged(), false)
680 DEFINE_GET_CONSTANT(Null, null, HType::Tagged(), false) 692 DEFINE_GET_CONSTANT(Null, null, HType::Tagged(), false)
681 693
682 694
683 #undef DEFINE_GET_CONSTANT 695 #undef DEFINE_GET_CONSTANT
684 696
685 697
686 HConstant* HGraph::GetInvalidContext() { 698 HConstant* HGraph::GetInvalidContext() {
(...skipping 2512 matching lines...) Expand 10 before | Expand all | Expand 10 after
3199 } 3211 }
3200 return call; 3212 return call;
3201 } 3213 }
3202 3214
3203 3215
3204 void HOptimizedGraphBuilder::SetUpScope(Scope* scope) { 3216 void HOptimizedGraphBuilder::SetUpScope(Scope* scope) {
3205 // First special is HContext. 3217 // First special is HContext.
3206 HInstruction* context = Add<HContext>(); 3218 HInstruction* context = Add<HContext>();
3207 environment()->BindContext(context); 3219 environment()->BindContext(context);
3208 3220
3209 HConstant* undefined_constant = HConstant::cast(Add<HConstant>(
3210 isolate()->factory()->undefined_value()));
3211 graph()->set_undefined_constant(undefined_constant);
3212
3213 // Create an arguments object containing the initial parameters. Set the 3221 // Create an arguments object containing the initial parameters. Set the
3214 // initial values of parameters including "this" having parameter index 0. 3222 // initial values of parameters including "this" having parameter index 0.
3215 ASSERT_EQ(scope->num_parameters() + 1, environment()->parameter_count()); 3223 ASSERT_EQ(scope->num_parameters() + 1, environment()->parameter_count());
3216 HArgumentsObject* arguments_object = 3224 HArgumentsObject* arguments_object =
3217 New<HArgumentsObject>(environment()->parameter_count()); 3225 New<HArgumentsObject>(environment()->parameter_count());
3218 for (int i = 0; i < environment()->parameter_count(); ++i) { 3226 for (int i = 0; i < environment()->parameter_count(); ++i) {
3219 HInstruction* parameter = Add<HParameter>(i); 3227 HInstruction* parameter = Add<HParameter>(i);
3220 arguments_object->AddArgument(parameter, zone()); 3228 arguments_object->AddArgument(parameter, zone());
3221 environment()->Bind(i, parameter); 3229 environment()->Bind(i, parameter);
3222 } 3230 }
3223 AddInstruction(arguments_object); 3231 AddInstruction(arguments_object);
3224 graph()->SetArgumentsObject(arguments_object); 3232 graph()->SetArgumentsObject(arguments_object);
3225 3233
3234 HConstant* undefined_constant = graph()->GetConstantUndefined();
3226 // Initialize specials and locals to undefined. 3235 // Initialize specials and locals to undefined.
3227 for (int i = environment()->parameter_count() + 1; 3236 for (int i = environment()->parameter_count() + 1;
3228 i < environment()->length(); 3237 i < environment()->length();
3229 ++i) { 3238 ++i) {
3230 environment()->Bind(i, undefined_constant); 3239 environment()->Bind(i, undefined_constant);
3231 } 3240 }
3232 3241
3233 // Handle the arguments and arguments shadow variables specially (they do 3242 // Handle the arguments and arguments shadow variables specially (they do
3234 // not have declarations). 3243 // not have declarations).
3235 if (scope->arguments() != NULL) { 3244 if (scope->arguments() != NULL) {
(...skipping 6605 matching lines...) Expand 10 before | Expand all | Expand 10 after
9841 if (ShouldProduceTraceOutput()) { 9850 if (ShouldProduceTraceOutput()) {
9842 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 9851 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
9843 } 9852 }
9844 9853
9845 #ifdef DEBUG 9854 #ifdef DEBUG
9846 graph_->Verify(false); // No full verify. 9855 graph_->Verify(false); // No full verify.
9847 #endif 9856 #endif
9848 } 9857 }
9849 9858
9850 } } // namespace v8::internal 9859 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-dce.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698