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

Side by Side Diff: src/code-stubs-hydrogen.cc

Issue 34523004: More Hydrogen templatization. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Improper usage of New<> replaced with NewUncasted<> 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 | « no previous file | src/hydrogen.h » ('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 // 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 // It's essential to bind this value to the environment in case of deopt. 167 // It's essential to bind this value to the environment in case of deopt.
168 AddInstruction(stack_parameter_count); 168 AddInstruction(stack_parameter_count);
169 start_environment->Bind(param_count, stack_parameter_count); 169 start_environment->Bind(param_count, stack_parameter_count);
170 arguments_length_ = stack_parameter_count; 170 arguments_length_ = stack_parameter_count;
171 } else { 171 } else {
172 ASSERT(descriptor_->environment_length() == param_count); 172 ASSERT(descriptor_->environment_length() == param_count);
173 stack_parameter_count = graph()->GetConstantMinus1(); 173 stack_parameter_count = graph()->GetConstantMinus1();
174 arguments_length_ = graph()->GetConstant0(); 174 arguments_length_ = graph()->GetConstant0();
175 } 175 }
176 176
177 context_ = New<HContext>(); 177 context_ = Add<HContext>();
178 AddInstruction(context_);
179 start_environment->BindContext(context_); 178 start_environment->BindContext(context_);
180 179
181 Add<HSimulate>(BailoutId::StubEntry()); 180 Add<HSimulate>(BailoutId::StubEntry());
182 181
183 NoObservableSideEffectsScope no_effects(this); 182 NoObservableSideEffectsScope no_effects(this);
184 183
185 HValue* return_value = BuildCodeStub(); 184 HValue* return_value = BuildCodeStub();
186 185
187 // We might have extra expressions to pop from the stack in addition to the 186 // We might have extra expressions to pop from the stack in addition to the
188 // arguments above. 187 // arguments above.
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 return DoGenerateCode(isolate, this); 559 return DoGenerateCode(isolate, this);
561 } 560 }
562 561
563 562
564 template<> 563 template<>
565 HValue* CodeStubGraphBuilder<LoadFieldStub>::BuildCodeStub() { 564 HValue* CodeStubGraphBuilder<LoadFieldStub>::BuildCodeStub() {
566 Representation rep = casted_stub()->representation(); 565 Representation rep = casted_stub()->representation();
567 HObjectAccess access = casted_stub()->is_inobject() ? 566 HObjectAccess access = casted_stub()->is_inobject() ?
568 HObjectAccess::ForJSObjectOffset(casted_stub()->offset(), rep) : 567 HObjectAccess::ForJSObjectOffset(casted_stub()->offset(), rep) :
569 HObjectAccess::ForBackingStoreOffset(casted_stub()->offset(), rep); 568 HObjectAccess::ForBackingStoreOffset(casted_stub()->offset(), rep);
570 return AddInstruction(BuildLoadNamedField(GetParameter(0), access)); 569 return AddLoadNamedField(GetParameter(0), access);
571 } 570 }
572 571
573 572
574 Handle<Code> LoadFieldStub::GenerateCode(Isolate* isolate) { 573 Handle<Code> LoadFieldStub::GenerateCode(Isolate* isolate) {
575 return DoGenerateCode(isolate, this); 574 return DoGenerateCode(isolate, this);
576 } 575 }
577 576
578 577
579 template<> 578 template<>
580 HValue* CodeStubGraphBuilder<KeyedLoadFieldStub>::BuildCodeStub() { 579 HValue* CodeStubGraphBuilder<KeyedLoadFieldStub>::BuildCodeStub() {
581 Representation rep = casted_stub()->representation(); 580 Representation rep = casted_stub()->representation();
582 HObjectAccess access = casted_stub()->is_inobject() ? 581 HObjectAccess access = casted_stub()->is_inobject() ?
583 HObjectAccess::ForJSObjectOffset(casted_stub()->offset(), rep) : 582 HObjectAccess::ForJSObjectOffset(casted_stub()->offset(), rep) :
584 HObjectAccess::ForBackingStoreOffset(casted_stub()->offset(), rep); 583 HObjectAccess::ForBackingStoreOffset(casted_stub()->offset(), rep);
585 return AddInstruction(BuildLoadNamedField(GetParameter(0), access)); 584 return AddLoadNamedField(GetParameter(0), access);
586 } 585 }
587 586
588 587
589 Handle<Code> KeyedLoadFieldStub::GenerateCode(Isolate* isolate) { 588 Handle<Code> KeyedLoadFieldStub::GenerateCode(Isolate* isolate) {
590 return DoGenerateCode(isolate, this); 589 return DoGenerateCode(isolate, this);
591 } 590 }
592 591
593 592
594 template <> 593 template <>
595 HValue* CodeStubGraphBuilder<KeyedStoreFastElementStub>::BuildCodeStub() { 594 HValue* CodeStubGraphBuilder<KeyedStoreFastElementStub>::BuildCodeStub() {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 } 680 }
682 681
683 682
684 HValue* CodeStubGraphBuilderBase::BuildArraySingleArgumentConstructor( 683 HValue* CodeStubGraphBuilderBase::BuildArraySingleArgumentConstructor(
685 JSArrayBuilder* array_builder) { 684 JSArrayBuilder* array_builder) {
686 // Smi check and range check on the input arg. 685 // Smi check and range check on the input arg.
687 HValue* constant_one = graph()->GetConstant1(); 686 HValue* constant_one = graph()->GetConstant1();
688 HValue* constant_zero = graph()->GetConstant0(); 687 HValue* constant_zero = graph()->GetConstant0();
689 688
690 HInstruction* elements = Add<HArgumentsElements>(false); 689 HInstruction* elements = Add<HArgumentsElements>(false);
691 HInstruction* argument = AddInstruction( 690 HInstruction* argument = Add<HAccessArgumentsAt>(
692 new(zone()) HAccessArgumentsAt(elements, constant_one, constant_zero)); 691 elements, constant_one, constant_zero);
693 692
694 HConstant* max_alloc_length = 693 HConstant* max_alloc_length =
695 Add<HConstant>(JSObject::kInitialMaxFastElementArray); 694 Add<HConstant>(JSObject::kInitialMaxFastElementArray);
696 const int initial_capacity = JSArray::kPreallocatedArrayElements; 695 const int initial_capacity = JSArray::kPreallocatedArrayElements;
697 HConstant* initial_capacity_node = New<HConstant>(initial_capacity); 696 HConstant* initial_capacity_node = Add<HConstant>(initial_capacity);
698 AddInstruction(initial_capacity_node);
699 697
700 HInstruction* checked_arg = Add<HBoundsCheck>(argument, max_alloc_length); 698 HInstruction* checked_arg = Add<HBoundsCheck>(argument, max_alloc_length);
701 IfBuilder if_builder(this); 699 IfBuilder if_builder(this);
702 if_builder.If<HCompareNumericAndBranch>(checked_arg, constant_zero, 700 if_builder.If<HCompareNumericAndBranch>(checked_arg, constant_zero,
703 Token::EQ); 701 Token::EQ);
704 if_builder.Then(); 702 if_builder.Then();
705 Push(initial_capacity_node); // capacity 703 Push(initial_capacity_node); // capacity
706 Push(constant_zero); // length 704 Push(constant_zero); // length
707 if_builder.Else(); 705 if_builder.Else();
708 Push(checked_arg); // capacity 706 Push(checked_arg); // capacity
(...skipping 22 matching lines...) Expand all
731 HValue* elements = array_builder->GetElementsLocation(); 729 HValue* elements = array_builder->GetElementsLocation();
732 ASSERT(elements != NULL); 730 ASSERT(elements != NULL);
733 731
734 // Now populate the elements correctly. 732 // Now populate the elements correctly.
735 LoopBuilder builder(this, 733 LoopBuilder builder(this,
736 context(), 734 context(),
737 LoopBuilder::kPostIncrement); 735 LoopBuilder::kPostIncrement);
738 HValue* start = graph()->GetConstant0(); 736 HValue* start = graph()->GetConstant0();
739 HValue* key = builder.BeginBody(start, length, Token::LT); 737 HValue* key = builder.BeginBody(start, length, Token::LT);
740 HInstruction* argument_elements = Add<HArgumentsElements>(false); 738 HInstruction* argument_elements = Add<HArgumentsElements>(false);
741 HInstruction* argument = AddInstruction(new(zone()) HAccessArgumentsAt( 739 HInstruction* argument = Add<HAccessArgumentsAt>(
742 argument_elements, length, key)); 740 argument_elements, length, key);
743 741
744 Add<HStoreKeyed>(elements, key, argument, kind); 742 Add<HStoreKeyed>(elements, key, argument, kind);
745 builder.EndBody(); 743 builder.EndBody();
746 return new_object; 744 return new_object;
747 } 745 }
748 746
749 747
750 template <> 748 template <>
751 HValue* CodeStubGraphBuilder<ArrayNoArgumentConstructorStub>::BuildCodeStub() { 749 HValue* CodeStubGraphBuilder<ArrayNoArgumentConstructorStub>::BuildCodeStub() {
752 ElementsKind kind = casted_stub()->elements_kind(); 750 ElementsKind kind = casted_stub()->elements_kind();
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 restore_check.If<HCompareNumericAndBranch>(key, second_entry_index, 1159 restore_check.If<HCompareNumericAndBranch>(key, second_entry_index,
1162 Token::EQ); 1160 Token::EQ);
1163 restore_check.Then(); 1161 restore_check.Then();
1164 { 1162 {
1165 // Store the unoptimized code 1163 // Store the unoptimized code
1166 BuildInstallCode(js_function, shared_info); 1164 BuildInstallCode(js_function, shared_info);
1167 loop_builder.Break(); 1165 loop_builder.Break();
1168 } 1166 }
1169 restore_check.Else(); 1167 restore_check.Else();
1170 { 1168 {
1171 HValue* keyed_minus = AddInstruction(HSub::New(zone(), context(), key, 1169 HValue* keyed_minus = AddUncasted<HSub>(
1172 shared_function_entry_length)); 1170 key, shared_function_entry_length);
1173 HInstruction* keyed_lookup = Add<HLoadKeyed>(optimized_map, 1171 HInstruction* keyed_lookup = Add<HLoadKeyed>(optimized_map,
1174 keyed_minus, static_cast<HValue*>(NULL), FAST_ELEMENTS); 1172 keyed_minus, static_cast<HValue*>(NULL), FAST_ELEMENTS);
1175 IfBuilder done_check(this); 1173 IfBuilder done_check(this);
1176 done_check.If<HCompareObjectEqAndBranch>(native_context, 1174 done_check.If<HCompareObjectEqAndBranch>(native_context,
1177 keyed_lookup); 1175 keyed_lookup);
1178 done_check.Then(); 1176 done_check.Then();
1179 { 1177 {
1180 // Hit: fetch the optimized code. 1178 // Hit: fetch the optimized code.
1181 HValue* keyed_plus = AddInstruction(HAdd::New(zone(), context(), 1179 HValue* keyed_plus = AddUncasted<HAdd>(
1182 keyed_minus, graph()->GetConstant1())); 1180 keyed_minus, graph()->GetConstant1());
1183 HValue* code_object = Add<HLoadKeyed>(optimized_map, 1181 HValue* code_object = Add<HLoadKeyed>(optimized_map,
1184 keyed_plus, static_cast<HValue*>(NULL), FAST_ELEMENTS); 1182 keyed_plus, static_cast<HValue*>(NULL), FAST_ELEMENTS);
1185 BuildInstallOptimizedCode(js_function, native_context, code_object); 1183 BuildInstallOptimizedCode(js_function, native_context, code_object);
1186 1184
1187 // Fall out of the loop 1185 // Fall out of the loop
1188 loop_builder.Break(); 1186 loop_builder.Break();
1189 } 1187 }
1190 done_check.Else(); 1188 done_check.Else();
1191 done_check.End(); 1189 done_check.End();
1192 } 1190 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 return js_function; 1252 return js_function;
1255 } 1253 }
1256 1254
1257 1255
1258 Handle<Code> FastNewClosureStub::GenerateCode(Isolate* isolate) { 1256 Handle<Code> FastNewClosureStub::GenerateCode(Isolate* isolate) {
1259 return DoGenerateCode(isolate, this); 1257 return DoGenerateCode(isolate, this);
1260 } 1258 }
1261 1259
1262 1260
1263 } } // namespace v8::internal 1261 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/hydrogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698