OLD | NEW |
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 "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #include "code-stubs.h" | 7 #include "code-stubs.h" |
8 #include "hydrogen.h" | 8 #include "hydrogen.h" |
9 #include "lithium.h" | 9 #include "lithium.h" |
10 | 10 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 int param_count = descriptor_->register_param_count_; | 120 int param_count = descriptor_->register_param_count_; |
121 HEnvironment* start_environment = graph()->start_environment(); | 121 HEnvironment* start_environment = graph()->start_environment(); |
122 HBasicBlock* next_block = CreateBasicBlock(start_environment); | 122 HBasicBlock* next_block = CreateBasicBlock(start_environment); |
123 Goto(next_block); | 123 Goto(next_block); |
124 next_block->SetJoinId(BailoutId::StubEntry()); | 124 next_block->SetJoinId(BailoutId::StubEntry()); |
125 set_current_block(next_block); | 125 set_current_block(next_block); |
126 | 126 |
127 bool runtime_stack_params = descriptor_->stack_parameter_count_.is_valid(); | 127 bool runtime_stack_params = descriptor_->stack_parameter_count_.is_valid(); |
128 HInstruction* stack_parameter_count = NULL; | 128 HInstruction* stack_parameter_count = NULL; |
129 for (int i = 0; i < param_count; ++i) { | 129 for (int i = 0; i < param_count; ++i) { |
130 Representation r = descriptor_->IsParameterCountRegister(i) | 130 Representation r = descriptor_->register_param_representations_ == NULL |
131 ? Representation::Integer32() | 131 ? Representation::Tagged() |
132 : Representation::Tagged(); | 132 : descriptor_->register_param_representations_[i]; |
133 HParameter* param = Add<HParameter>(i, HParameter::REGISTER_PARAMETER, r); | 133 HParameter* param = Add<HParameter>(i, HParameter::REGISTER_PARAMETER, r); |
134 start_environment->Bind(i, param); | 134 start_environment->Bind(i, param); |
135 parameters_[i] = param; | 135 parameters_[i] = param; |
136 if (descriptor_->IsParameterCountRegister(i)) { | 136 if (descriptor_->IsParameterCountRegister(i)) { |
137 param->set_type(HType::Smi()); | 137 param->set_type(HType::Smi()); |
138 stack_parameter_count = param; | 138 stack_parameter_count = param; |
139 arguments_length_ = stack_parameter_count; | 139 arguments_length_ = stack_parameter_count; |
140 } | 140 } |
141 } | 141 } |
142 | 142 |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 Handle<Code> NumberToStringStub::GenerateCode() { | 323 Handle<Code> NumberToStringStub::GenerateCode() { |
324 return DoGenerateCode(this); | 324 return DoGenerateCode(this); |
325 } | 325 } |
326 | 326 |
327 | 327 |
328 template <> | 328 template <> |
329 HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() { | 329 HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() { |
330 Factory* factory = isolate()->factory(); | 330 Factory* factory = isolate()->factory(); |
331 HValue* undefined = graph()->GetConstantUndefined(); | 331 HValue* undefined = graph()->GetConstantUndefined(); |
332 AllocationSiteMode alloc_site_mode = casted_stub()->allocation_site_mode(); | 332 AllocationSiteMode alloc_site_mode = casted_stub()->allocation_site_mode(); |
333 FastCloneShallowArrayStub::Mode mode = casted_stub()->mode(); | 333 |
334 int length = casted_stub()->length(); | 334 // This stub is very performance sensitive, the generated code must be tuned |
| 335 // so that it doesn't build and eager frame. |
| 336 info()->MarkMustNotHaveEagerFrame(); |
335 | 337 |
336 HInstruction* allocation_site = Add<HLoadKeyed>(GetParameter(0), | 338 HInstruction* allocation_site = Add<HLoadKeyed>(GetParameter(0), |
337 GetParameter(1), | 339 GetParameter(1), |
338 static_cast<HValue*>(NULL), | 340 static_cast<HValue*>(NULL), |
339 FAST_ELEMENTS); | 341 FAST_ELEMENTS); |
340 IfBuilder checker(this); | 342 IfBuilder checker(this); |
341 checker.IfNot<HCompareObjectEqAndBranch, HValue*>(allocation_site, | 343 checker.IfNot<HCompareObjectEqAndBranch, HValue*>(allocation_site, |
342 undefined); | 344 undefined); |
343 checker.Then(); | 345 checker.Then(); |
344 | 346 |
345 HObjectAccess access = HObjectAccess::ForAllocationSiteOffset( | 347 HObjectAccess access = HObjectAccess::ForAllocationSiteOffset( |
346 AllocationSite::kTransitionInfoOffset); | 348 AllocationSite::kTransitionInfoOffset); |
347 HInstruction* boilerplate = Add<HLoadNamedField>( | 349 HInstruction* boilerplate = Add<HLoadNamedField>( |
348 allocation_site, static_cast<HValue*>(NULL), access); | 350 allocation_site, static_cast<HValue*>(NULL), access); |
349 HValue* push_value; | 351 HValue* elements = AddLoadElements(boilerplate); |
350 if (mode == FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS) { | 352 HValue* capacity = AddLoadFixedArrayLength(elements); |
351 HValue* elements = AddLoadElements(boilerplate); | 353 IfBuilder zero_capacity(this); |
| 354 zero_capacity.If<HCompareNumericAndBranch>(capacity, graph()->GetConstant0(), |
| 355 Token::EQ); |
| 356 zero_capacity.Then(); |
| 357 Push(BuildCloneShallowArrayEmpty(boilerplate, |
| 358 allocation_site, |
| 359 alloc_site_mode)); |
| 360 zero_capacity.Else(); |
| 361 IfBuilder if_fixed_cow(this); |
| 362 if_fixed_cow.If<HCompareMap>(elements, factory->fixed_cow_array_map()); |
| 363 if_fixed_cow.Then(); |
| 364 Push(BuildCloneShallowArrayCow(boilerplate, |
| 365 allocation_site, |
| 366 alloc_site_mode, |
| 367 FAST_ELEMENTS)); |
| 368 if_fixed_cow.Else(); |
| 369 IfBuilder if_fixed(this); |
| 370 if_fixed.If<HCompareMap>(elements, factory->fixed_array_map()); |
| 371 if_fixed.Then(); |
| 372 Push(BuildCloneShallowArrayNonEmpty(boilerplate, |
| 373 allocation_site, |
| 374 alloc_site_mode, |
| 375 FAST_ELEMENTS)); |
352 | 376 |
353 IfBuilder if_fixed_cow(this); | 377 if_fixed.Else(); |
354 if_fixed_cow.If<HCompareMap>(elements, factory->fixed_cow_array_map()); | 378 Push(BuildCloneShallowArrayNonEmpty(boilerplate, |
355 if_fixed_cow.Then(); | 379 allocation_site, |
356 push_value = BuildCloneShallowArray(boilerplate, | 380 alloc_site_mode, |
357 allocation_site, | 381 FAST_DOUBLE_ELEMENTS)); |
358 alloc_site_mode, | 382 if_fixed.End(); |
359 FAST_ELEMENTS, | 383 if_fixed_cow.End(); |
360 0/*copy-on-write*/); | 384 zero_capacity.End(); |
361 environment()->Push(push_value); | |
362 if_fixed_cow.Else(); | |
363 | |
364 IfBuilder if_fixed(this); | |
365 if_fixed.If<HCompareMap>(elements, factory->fixed_array_map()); | |
366 if_fixed.Then(); | |
367 push_value = BuildCloneShallowArray(boilerplate, | |
368 allocation_site, | |
369 alloc_site_mode, | |
370 FAST_ELEMENTS, | |
371 length); | |
372 environment()->Push(push_value); | |
373 if_fixed.Else(); | |
374 push_value = BuildCloneShallowArray(boilerplate, | |
375 allocation_site, | |
376 alloc_site_mode, | |
377 FAST_DOUBLE_ELEMENTS, | |
378 length); | |
379 environment()->Push(push_value); | |
380 } else { | |
381 ElementsKind elements_kind = casted_stub()->ComputeElementsKind(); | |
382 push_value = BuildCloneShallowArray(boilerplate, | |
383 allocation_site, | |
384 alloc_site_mode, | |
385 elements_kind, | |
386 length); | |
387 environment()->Push(push_value); | |
388 } | |
389 | 385 |
390 checker.ElseDeopt("Uninitialized boilerplate literals"); | 386 checker.ElseDeopt("Uninitialized boilerplate literals"); |
391 checker.End(); | 387 checker.End(); |
392 | 388 |
393 return environment()->Pop(); | 389 return environment()->Pop(); |
394 } | 390 } |
395 | 391 |
396 | 392 |
397 Handle<Code> FastCloneShallowArrayStub::GenerateCode() { | 393 Handle<Code> FastCloneShallowArrayStub::GenerateCode() { |
398 return DoGenerateCode(this); | 394 return DoGenerateCode(this); |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 ElementsKind kind, | 633 ElementsKind kind, |
638 AllocationSiteOverrideMode override_mode, | 634 AllocationSiteOverrideMode override_mode, |
639 ArgumentClass argument_class) { | 635 ArgumentClass argument_class) { |
640 HValue* constructor = GetParameter(ArrayConstructorStubBase::kConstructor); | 636 HValue* constructor = GetParameter(ArrayConstructorStubBase::kConstructor); |
641 HValue* alloc_site = GetParameter(ArrayConstructorStubBase::kAllocationSite); | 637 HValue* alloc_site = GetParameter(ArrayConstructorStubBase::kAllocationSite); |
642 JSArrayBuilder array_builder(this, kind, alloc_site, constructor, | 638 JSArrayBuilder array_builder(this, kind, alloc_site, constructor, |
643 override_mode); | 639 override_mode); |
644 HValue* result = NULL; | 640 HValue* result = NULL; |
645 switch (argument_class) { | 641 switch (argument_class) { |
646 case NONE: | 642 case NONE: |
| 643 // This stub is very performance sensitive, the generated code must be |
| 644 // tuned so that it doesn't build and eager frame. |
| 645 info()->MarkMustNotHaveEagerFrame(); |
647 result = array_builder.AllocateEmptyArray(); | 646 result = array_builder.AllocateEmptyArray(); |
648 break; | 647 break; |
649 case SINGLE: | 648 case SINGLE: |
650 result = BuildArraySingleArgumentConstructor(&array_builder); | 649 result = BuildArraySingleArgumentConstructor(&array_builder); |
651 break; | 650 break; |
652 case MULTIPLE: | 651 case MULTIPLE: |
653 result = BuildArrayNArgumentsConstructor(&array_builder, kind); | 652 result = BuildArrayNArgumentsConstructor(&array_builder, kind); |
654 break; | 653 break; |
655 } | 654 } |
656 | 655 |
657 return result; | 656 return result; |
658 } | 657 } |
659 | 658 |
660 | 659 |
661 HValue* CodeStubGraphBuilderBase::BuildInternalArrayConstructor( | 660 HValue* CodeStubGraphBuilderBase::BuildInternalArrayConstructor( |
662 ElementsKind kind, ArgumentClass argument_class) { | 661 ElementsKind kind, ArgumentClass argument_class) { |
663 HValue* constructor = GetParameter( | 662 HValue* constructor = GetParameter( |
664 InternalArrayConstructorStubBase::kConstructor); | 663 InternalArrayConstructorStubBase::kConstructor); |
665 JSArrayBuilder array_builder(this, kind, constructor); | 664 JSArrayBuilder array_builder(this, kind, constructor); |
666 | 665 |
667 HValue* result = NULL; | 666 HValue* result = NULL; |
668 switch (argument_class) { | 667 switch (argument_class) { |
669 case NONE: | 668 case NONE: |
| 669 // This stub is very performance sensitive, the generated code must be |
| 670 // tuned so that it doesn't build and eager frame. |
| 671 info()->MarkMustNotHaveEagerFrame(); |
670 result = array_builder.AllocateEmptyArray(); | 672 result = array_builder.AllocateEmptyArray(); |
671 break; | 673 break; |
672 case SINGLE: | 674 case SINGLE: |
673 result = BuildArraySingleArgumentConstructor(&array_builder); | 675 result = BuildArraySingleArgumentConstructor(&array_builder); |
674 break; | 676 break; |
675 case MULTIPLE: | 677 case MULTIPLE: |
676 result = BuildArrayNArgumentsConstructor(&array_builder, kind); | 678 result = BuildArrayNArgumentsConstructor(&array_builder, kind); |
677 break; | 679 break; |
678 } | 680 } |
679 return result; | 681 return result; |
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1484 return BuildRegExpConstructResult(length, index, input); | 1486 return BuildRegExpConstructResult(length, index, input); |
1485 } | 1487 } |
1486 | 1488 |
1487 | 1489 |
1488 Handle<Code> RegExpConstructResultStub::GenerateCode() { | 1490 Handle<Code> RegExpConstructResultStub::GenerateCode() { |
1489 return DoGenerateCode(this); | 1491 return DoGenerateCode(this); |
1490 } | 1492 } |
1491 | 1493 |
1492 | 1494 |
1493 } } // namespace v8::internal | 1495 } } // namespace v8::internal |
OLD | NEW |