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

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

Issue 149133004: A64: Synchronize with r17807. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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/code-stubs.cc ('k') | src/codegen.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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 isolate()->GetHTracer()->TraceCompilation(&info_); 143 isolate()->GetHTracer()->TraceCompilation(&info_);
144 } 144 }
145 145
146 int param_count = descriptor_->register_param_count_; 146 int param_count = descriptor_->register_param_count_;
147 HEnvironment* start_environment = graph()->start_environment(); 147 HEnvironment* start_environment = graph()->start_environment();
148 HBasicBlock* next_block = CreateBasicBlock(start_environment); 148 HBasicBlock* next_block = CreateBasicBlock(start_environment);
149 Goto(next_block); 149 Goto(next_block);
150 next_block->SetJoinId(BailoutId::StubEntry()); 150 next_block->SetJoinId(BailoutId::StubEntry());
151 set_current_block(next_block); 151 set_current_block(next_block);
152 152
153 bool runtime_stack_params = descriptor_->stack_parameter_count_.is_valid();
154 HInstruction* stack_parameter_count = NULL;
153 for (int i = 0; i < param_count; ++i) { 155 for (int i = 0; i < param_count; ++i) {
154 HParameter* param = 156 Representation r = descriptor_->IsParameterCountRegister(i)
155 Add<HParameter>(i, HParameter::REGISTER_PARAMETER); 157 ? Representation::Integer32()
158 : Representation::Tagged();
159 HParameter* param = Add<HParameter>(i, HParameter::REGISTER_PARAMETER, r);
156 start_environment->Bind(i, param); 160 start_environment->Bind(i, param);
157 parameters_[i] = param; 161 parameters_[i] = param;
162 if (descriptor_->IsParameterCountRegister(i)) {
163 param->set_type(HType::Smi());
164 stack_parameter_count = param;
165 arguments_length_ = stack_parameter_count;
166 }
158 } 167 }
159 168
160 HInstruction* stack_parameter_count; 169 ASSERT(!runtime_stack_params || arguments_length_ != NULL);
161 if (descriptor_->stack_parameter_count_.is_valid()) { 170 if (!runtime_stack_params) {
162 ASSERT(descriptor_->environment_length() == (param_count + 1));
163 stack_parameter_count = New<HParameter>(param_count,
164 HParameter::REGISTER_PARAMETER,
165 Representation::Integer32());
166 stack_parameter_count->set_type(HType::Smi());
167 // It's essential to bind this value to the environment in case of deopt.
168 AddInstruction(stack_parameter_count);
169 start_environment->Bind(param_count, stack_parameter_count);
170 arguments_length_ = stack_parameter_count;
171 } else {
172 ASSERT(descriptor_->environment_length() == param_count);
173 stack_parameter_count = graph()->GetConstantMinus1(); 171 stack_parameter_count = graph()->GetConstantMinus1();
174 arguments_length_ = graph()->GetConstant0(); 172 arguments_length_ = graph()->GetConstant0();
175 } 173 }
176 174
177 context_ = Add<HContext>(); 175 context_ = Add<HContext>();
178 start_environment->BindContext(context_); 176 start_environment->BindContext(context_);
179 177
180 Add<HSimulate>(BailoutId::StubEntry()); 178 Add<HSimulate>(BailoutId::StubEntry());
181 179
182 NoObservableSideEffectsScope no_effects(this); 180 NoObservableSideEffectsScope no_effects(this);
183 181
184 HValue* return_value = BuildCodeStub(); 182 HValue* return_value = BuildCodeStub();
185 183
186 // We might have extra expressions to pop from the stack in addition to the 184 // We might have extra expressions to pop from the stack in addition to the
187 // arguments above. 185 // arguments above.
188 HInstruction* stack_pop_count = stack_parameter_count; 186 HInstruction* stack_pop_count = stack_parameter_count;
189 if (descriptor_->function_mode_ == JS_FUNCTION_STUB_MODE) { 187 if (descriptor_->function_mode_ == JS_FUNCTION_STUB_MODE) {
190 if (!stack_parameter_count->IsConstant() && 188 if (!stack_parameter_count->IsConstant() &&
191 descriptor_->hint_stack_parameter_count_ < 0) { 189 descriptor_->hint_stack_parameter_count_ < 0) {
192 HInstruction* amount = graph()->GetConstant1(); 190 HInstruction* constant_one = graph()->GetConstant1();
193 stack_pop_count = Add<HAdd>(stack_parameter_count, amount); 191 stack_pop_count = Add<HAdd>(stack_parameter_count, constant_one);
194 stack_pop_count->ChangeRepresentation(Representation::Integer32());
195 stack_pop_count->ClearFlag(HValue::kCanOverflow); 192 stack_pop_count->ClearFlag(HValue::kCanOverflow);
193 // TODO(mvstanton): verify that stack_parameter_count+1 really fits in a
194 // smi.
196 } else { 195 } else {
197 int count = descriptor_->hint_stack_parameter_count_; 196 int count = descriptor_->hint_stack_parameter_count_;
198 stack_pop_count = Add<HConstant>(count); 197 stack_pop_count = Add<HConstant>(count);
199 } 198 }
200 } 199 }
201 200
202 if (current_block() != NULL) { 201 if (current_block() != NULL) {
203 HReturn* hreturn_instruction = New<HReturn>(return_value, 202 HReturn* hreturn_instruction = New<HReturn>(return_value,
204 stack_pop_count); 203 stack_pop_count);
205 FinishCurrentBlock(hreturn_instruction); 204 FinishCurrentBlock(hreturn_instruction);
206 } 205 }
207 return true; 206 return true;
208 } 207 }
209 208
210 209
211 template <class Stub> 210 template <class Stub>
212 class CodeStubGraphBuilder: public CodeStubGraphBuilderBase { 211 class CodeStubGraphBuilder: public CodeStubGraphBuilderBase {
213 public: 212 public:
214 explicit CodeStubGraphBuilder(Isolate* isolate, Stub* stub) 213 CodeStubGraphBuilder(Isolate* isolate, Stub* stub)
215 : CodeStubGraphBuilderBase(isolate, stub) {} 214 : CodeStubGraphBuilderBase(isolate, stub) {}
216 215
217 protected: 216 protected:
218 virtual HValue* BuildCodeStub() { 217 virtual HValue* BuildCodeStub() {
219 if (casted_stub()->IsUninitialized()) { 218 if (casted_stub()->IsUninitialized()) {
220 return BuildCodeUninitializedStub(); 219 return BuildCodeUninitializedStub();
221 } else { 220 } else {
222 return BuildCodeInitializedStub(); 221 return BuildCodeInitializedStub();
223 } 222 }
224 } 223 }
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 HObjectAccess::ForBackingStoreOffset(casted_stub()->offset(), rep); 587 HObjectAccess::ForBackingStoreOffset(casted_stub()->offset(), rep);
589 return AddLoadNamedField(GetParameter(0), access); 588 return AddLoadNamedField(GetParameter(0), access);
590 } 589 }
591 590
592 591
593 Handle<Code> KeyedLoadFieldStub::GenerateCode(Isolate* isolate) { 592 Handle<Code> KeyedLoadFieldStub::GenerateCode(Isolate* isolate) {
594 return DoGenerateCode(isolate, this); 593 return DoGenerateCode(isolate, this);
595 } 594 }
596 595
597 596
597 template<>
598 HValue* CodeStubGraphBuilder<KeyedArrayCallStub>::BuildCodeStub() {
599 int argc = casted_stub()->argc() + 1;
600 info()->set_parameter_count(argc);
601
602 HValue* receiver = Add<HParameter>(1);
603
604 // Load the expected initial array map from the context.
605 JSArrayBuilder array_builder(this, casted_stub()->elements_kind());
606 HValue* map = array_builder.EmitMapCode();
607
608 HValue* checked_receiver = Add<HCheckMapValue>(receiver, map);
609
610 HValue* function = BuildUncheckedMonomorphicElementAccess(
611 checked_receiver, GetParameter(0),
612 NULL, true, casted_stub()->elements_kind(),
613 false, NEVER_RETURN_HOLE, STANDARD_STORE);
614 return Add<HCallFunction>(function, argc, TAIL_CALL);
615 }
616
617
618 Handle<Code> KeyedArrayCallStub::GenerateCode(Isolate* isolate) {
619 return DoGenerateCode(isolate, this);
620 }
621
622
598 template <> 623 template <>
599 HValue* CodeStubGraphBuilder<KeyedStoreFastElementStub>::BuildCodeStub() { 624 HValue* CodeStubGraphBuilder<KeyedStoreFastElementStub>::BuildCodeStub() {
600 BuildUncheckedMonomorphicElementAccess( 625 BuildUncheckedMonomorphicElementAccess(
601 GetParameter(0), GetParameter(1), GetParameter(2), 626 GetParameter(0), GetParameter(1), GetParameter(2),
602 casted_stub()->is_js_array(), casted_stub()->elements_kind(), 627 casted_stub()->is_js_array(), casted_stub()->elements_kind(),
603 true, NEVER_RETURN_HOLE, casted_stub()->store_mode()); 628 true, NEVER_RETURN_HOLE, casted_stub()->store_mode());
604 629
605 return GetParameter(2); 630 return GetParameter(2);
606 } 631 }
607 632
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 HValue* CodeStubGraphBuilderBase::BuildArraySingleArgumentConstructor( 713 HValue* CodeStubGraphBuilderBase::BuildArraySingleArgumentConstructor(
689 JSArrayBuilder* array_builder) { 714 JSArrayBuilder* array_builder) {
690 // Smi check and range check on the input arg. 715 // Smi check and range check on the input arg.
691 HValue* constant_one = graph()->GetConstant1(); 716 HValue* constant_one = graph()->GetConstant1();
692 HValue* constant_zero = graph()->GetConstant0(); 717 HValue* constant_zero = graph()->GetConstant0();
693 718
694 HInstruction* elements = Add<HArgumentsElements>(false); 719 HInstruction* elements = Add<HArgumentsElements>(false);
695 HInstruction* argument = Add<HAccessArgumentsAt>( 720 HInstruction* argument = Add<HAccessArgumentsAt>(
696 elements, constant_one, constant_zero); 721 elements, constant_one, constant_zero);
697 722
698 HConstant* max_alloc_length = 723 return BuildAllocateArrayFromLength(array_builder, argument);
699 Add<HConstant>(JSObject::kInitialMaxFastElementArray);
700 const int initial_capacity = JSArray::kPreallocatedArrayElements;
701 HConstant* initial_capacity_node = Add<HConstant>(initial_capacity);
702
703 HInstruction* checked_arg = Add<HBoundsCheck>(argument, max_alloc_length);
704 IfBuilder if_builder(this);
705 if_builder.If<HCompareNumericAndBranch>(checked_arg, constant_zero,
706 Token::EQ);
707 if_builder.Then();
708 Push(initial_capacity_node); // capacity
709 Push(constant_zero); // length
710 if_builder.Else();
711 Push(checked_arg); // capacity
712 Push(checked_arg); // length
713 if_builder.End();
714
715 // Figure out total size
716 HValue* length = Pop();
717 HValue* capacity = Pop();
718 return array_builder->AllocateArray(capacity, length, true);
719 } 724 }
720 725
721 726
722 HValue* CodeStubGraphBuilderBase::BuildArrayNArgumentsConstructor( 727 HValue* CodeStubGraphBuilderBase::BuildArrayNArgumentsConstructor(
723 JSArrayBuilder* array_builder, ElementsKind kind) { 728 JSArrayBuilder* array_builder, ElementsKind kind) {
724 // We need to fill with the hole if it's a smi array in the multi-argument 729 // We need to fill with the hole if it's a smi array in the multi-argument
725 // case because we might have to bail out while copying arguments into 730 // case because we might have to bail out while copying arguments into
726 // the array because they aren't compatible with a smi array. 731 // the array because they aren't compatible with a smi array.
727 // If it's a double array, no problem, and if it's fast then no 732 // If it's a double array, no problem, and if it's fast then no
728 // problem either because doubles are boxed. 733 // problem either because doubles are boxed.
734 //
735 // TODO(mvstanton): consider an instruction to memset fill the array
736 // with zero in this case instead.
729 HValue* length = GetArgumentsLength(); 737 HValue* length = GetArgumentsLength();
730 bool fill_with_hole = IsFastSmiElementsKind(kind); 738 JSArrayBuilder::FillMode fill_mode = IsFastSmiElementsKind(kind)
739 ? JSArrayBuilder::FILL_WITH_HOLE
740 : JSArrayBuilder::DONT_FILL_WITH_HOLE;
731 HValue* new_object = array_builder->AllocateArray(length, 741 HValue* new_object = array_builder->AllocateArray(length,
732 length, 742 length,
733 fill_with_hole); 743 fill_mode);
734 HValue* elements = array_builder->GetElementsLocation(); 744 HValue* elements = array_builder->GetElementsLocation();
735 ASSERT(elements != NULL); 745 ASSERT(elements != NULL);
736 746
737 // Now populate the elements correctly. 747 // Now populate the elements correctly.
738 LoopBuilder builder(this, 748 LoopBuilder builder(this,
739 context(), 749 context(),
740 LoopBuilder::kPostIncrement); 750 LoopBuilder::kPostIncrement);
741 HValue* start = graph()->GetConstant0(); 751 HValue* start = graph()->GetConstant0();
742 HValue* key = builder.BeginBody(start, length, Token::LT); 752 HValue* key = builder.BeginBody(start, length, Token::LT);
743 HInstruction* argument_elements = Add<HArgumentsElements>(false); 753 HInstruction* argument_elements = Add<HArgumentsElements>(false);
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
1286 1296
1287 return js_function; 1297 return js_function;
1288 } 1298 }
1289 1299
1290 1300
1291 Handle<Code> FastNewClosureStub::GenerateCode(Isolate* isolate) { 1301 Handle<Code> FastNewClosureStub::GenerateCode(Isolate* isolate) {
1292 return DoGenerateCode(isolate, this); 1302 return DoGenerateCode(isolate, this);
1293 } 1303 }
1294 1304
1295 1305
1306 template<>
1307 HValue* CodeStubGraphBuilder<KeyedLoadDictionaryElementStub>::BuildCodeStub() {
1308 HValue* receiver = GetParameter(0);
1309 HValue* key = GetParameter(1);
1310
1311 Add<HCheckSmi>(key);
1312
1313 return BuildUncheckedDictionaryElementLoad(receiver, key);
1314 }
1315
1316
1317 Handle<Code> KeyedLoadDictionaryElementStub::GenerateCode(Isolate* isolate) {
1318 return DoGenerateCode(isolate, this);
1319 }
1320
1321
1296 } } // namespace v8::internal 1322 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/code-stubs.cc ('k') | src/codegen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698