OLD | NEW |
---|---|
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 HValue* GetArgumentsLength() { | 75 HValue* GetArgumentsLength() { |
76 // This is initialized in BuildGraph() | 76 // This is initialized in BuildGraph() |
77 ASSERT(arguments_length_ != NULL); | 77 ASSERT(arguments_length_ != NULL); |
78 return arguments_length_; | 78 return arguments_length_; |
79 } | 79 } |
80 CompilationInfo* info() { return &info_; } | 80 CompilationInfo* info() { return &info_; } |
81 HydrogenCodeStub* stub() { return info_.code_stub(); } | 81 HydrogenCodeStub* stub() { return info_.code_stub(); } |
82 HContext* context() { return context_; } | 82 HContext* context() { return context_; } |
83 Isolate* isolate() { return info_.isolate(); } | 83 Isolate* isolate() { return info_.isolate(); } |
84 | 84 |
85 class ArrayContextChecker { | |
86 public: | |
87 ArrayContextChecker(HGraphBuilder* builder, HValue* constructor, | |
88 HValue* array_function) | |
89 : checker_(builder) { | |
90 checker_.If<HCompareObjectEqAndBranch, HValue*>(constructor, | |
91 array_function); | |
92 checker_.Then(); | |
93 } | |
94 | |
95 ~ArrayContextChecker() { | |
96 checker_.ElseDeopt(); | |
97 checker_.End(); | |
98 } | |
99 private: | |
100 IfBuilder checker_; | |
101 }; | |
102 | |
85 private: | 103 private: |
86 SmartArrayPointer<HParameter*> parameters_; | 104 SmartArrayPointer<HParameter*> parameters_; |
87 HValue* arguments_length_; | 105 HValue* arguments_length_; |
88 CompilationInfoWithZone info_; | 106 CompilationInfoWithZone info_; |
89 CodeStubInterfaceDescriptor* descriptor_; | 107 CodeStubInterfaceDescriptor* descriptor_; |
90 HContext* context_; | 108 HContext* context_; |
91 }; | 109 }; |
92 | 110 |
93 | 111 |
94 bool CodeStubGraphBuilderBase::BuildGraph() { | 112 bool CodeStubGraphBuilderBase::BuildGraph() { |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
517 return DoGenerateCode(this); | 535 return DoGenerateCode(this); |
518 } | 536 } |
519 | 537 |
520 | 538 |
521 template <> | 539 template <> |
522 HValue* CodeStubGraphBuilder<ArrayNoArgumentConstructorStub>::BuildCodeStub() { | 540 HValue* CodeStubGraphBuilder<ArrayNoArgumentConstructorStub>::BuildCodeStub() { |
523 // ----------- S t a t e ------------- | 541 // ----------- S t a t e ------------- |
524 // -- Parameter 1 : type info cell | 542 // -- Parameter 1 : type info cell |
525 // -- Parameter 0 : constructor | 543 // -- Parameter 0 : constructor |
526 // ----------------------------------- | 544 // ----------------------------------- |
545 HValue* array_result = GetParameter(0); | |
Toon Verwaest
2013/05/07 11:02:06
Remove
mvstanton
2013/05/07 12:40:50
Done.
| |
546 HInstruction* array_function = BuildGetArrayFunction(context()); | |
547 ArrayContextChecker(this, | |
548 GetParameter(ArrayConstructorStubBase::kConstructor), | |
549 array_function); | |
527 // Get the right map | 550 // Get the right map |
528 // Should be a constant | 551 // Should be a constant |
529 JSArrayBuilder array_builder( | 552 JSArrayBuilder array_builder( |
530 this, | 553 this, |
531 casted_stub()->elements_kind(), | 554 casted_stub()->elements_kind(), |
532 GetParameter(ArrayConstructorStubBase::kPropertyCell), | 555 GetParameter(ArrayConstructorStubBase::kPropertyCell), |
533 casted_stub()->mode()); | 556 casted_stub()->mode()); |
534 return array_builder.AllocateEmptyArray(); | 557 array_result = array_builder.AllocateEmptyArray(); |
Toon Verwaest
2013/05/07 11:02:06
Just return.
mvstanton
2013/05/07 12:40:50
Done.
| |
558 return array_result; | |
535 } | 559 } |
536 | 560 |
537 | 561 |
538 Handle<Code> ArrayNoArgumentConstructorStub::GenerateCode() { | 562 Handle<Code> ArrayNoArgumentConstructorStub::GenerateCode() { |
539 return DoGenerateCode(this); | 563 return DoGenerateCode(this); |
540 } | 564 } |
541 | 565 |
542 | 566 |
543 template <> | 567 template <> |
544 HValue* CodeStubGraphBuilder<ArraySingleArgumentConstructorStub>:: | 568 HValue* CodeStubGraphBuilder<ArraySingleArgumentConstructorStub>:: |
545 BuildCodeStub() { | 569 BuildCodeStub() { |
570 HInstruction* array_function = BuildGetArrayFunction(context()); | |
571 ArrayContextChecker(this, | |
572 GetParameter(ArrayConstructorStubBase::kConstructor), | |
573 array_function); | |
546 // Smi check and range check on the input arg. | 574 // Smi check and range check on the input arg. |
547 HValue* constant_one = graph()->GetConstant1(); | 575 HValue* constant_one = graph()->GetConstant1(); |
548 HValue* constant_zero = graph()->GetConstant0(); | 576 HValue* constant_zero = graph()->GetConstant0(); |
549 | 577 |
550 HInstruction* elements = AddInstruction( | 578 HInstruction* elements = AddInstruction( |
551 new(zone()) HArgumentsElements(false)); | 579 new(zone()) HArgumentsElements(false)); |
552 HInstruction* argument = AddInstruction( | 580 HInstruction* argument = AddInstruction( |
553 new(zone()) HAccessArgumentsAt(elements, constant_one, constant_zero)); | 581 new(zone()) HAccessArgumentsAt(elements, constant_one, constant_zero)); |
554 | 582 |
555 HConstant* max_alloc_length = | 583 HConstant* max_alloc_length = |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
589 } | 617 } |
590 | 618 |
591 | 619 |
592 Handle<Code> ArraySingleArgumentConstructorStub::GenerateCode() { | 620 Handle<Code> ArraySingleArgumentConstructorStub::GenerateCode() { |
593 return DoGenerateCode(this); | 621 return DoGenerateCode(this); |
594 } | 622 } |
595 | 623 |
596 | 624 |
597 template <> | 625 template <> |
598 HValue* CodeStubGraphBuilder<ArrayNArgumentsConstructorStub>::BuildCodeStub() { | 626 HValue* CodeStubGraphBuilder<ArrayNArgumentsConstructorStub>::BuildCodeStub() { |
627 HInstruction* array_function = BuildGetArrayFunction(context()); | |
628 ArrayContextChecker(this, | |
629 GetParameter(ArrayConstructorStubBase::kConstructor), | |
630 array_function); | |
599 ElementsKind kind = casted_stub()->elements_kind(); | 631 ElementsKind kind = casted_stub()->elements_kind(); |
600 HValue* length = GetArgumentsLength(); | 632 HValue* length = GetArgumentsLength(); |
601 | 633 |
602 JSArrayBuilder array_builder( | 634 JSArrayBuilder array_builder( |
603 this, | 635 this, |
604 kind, | 636 kind, |
605 GetParameter(ArrayConstructorStubBase::kPropertyCell), | 637 GetParameter(ArrayConstructorStubBase::kPropertyCell), |
606 casted_stub()->mode()); | 638 casted_stub()->mode()); |
607 | 639 |
608 // We need to fill with the hole if it's a smi array in the multi-argument | 640 // We need to fill with the hole if it's a smi array in the multi-argument |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
663 ? graph()->GetConstantSmi1() | 695 ? graph()->GetConstantSmi1() |
664 : graph()->GetConstantUndefined(); | 696 : graph()->GetConstantUndefined(); |
665 } | 697 } |
666 | 698 |
667 | 699 |
668 Handle<Code> CompareNilICStub::GenerateCode() { | 700 Handle<Code> CompareNilICStub::GenerateCode() { |
669 return DoGenerateCode(this); | 701 return DoGenerateCode(this); |
670 } | 702 } |
671 | 703 |
672 } } // namespace v8::internal | 704 } } // namespace v8::internal |
OLD | NEW |