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 14846017: Becuase of cross-context calls, hydrogen-based Array constructor needs to ensure (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Enable optimize_constructed_arrays Created 7 years, 7 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.h ('k') | src/flag-definitions.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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 HInstruction* array_function = BuildGetArrayFunction(context());
546 ArrayContextChecker(this,
547 GetParameter(ArrayConstructorStubBase::kConstructor),
548 array_function);
527 // Get the right map 549 // Get the right map
528 // Should be a constant 550 // Should be a constant
529 JSArrayBuilder array_builder( 551 JSArrayBuilder array_builder(
530 this, 552 this,
531 casted_stub()->elements_kind(), 553 casted_stub()->elements_kind(),
532 GetParameter(ArrayConstructorStubBase::kPropertyCell), 554 GetParameter(ArrayConstructorStubBase::kPropertyCell),
533 casted_stub()->mode()); 555 casted_stub()->mode());
534 return array_builder.AllocateEmptyArray(); 556 return array_builder.AllocateEmptyArray();
535 } 557 }
536 558
537 559
538 Handle<Code> ArrayNoArgumentConstructorStub::GenerateCode() { 560 Handle<Code> ArrayNoArgumentConstructorStub::GenerateCode() {
539 return DoGenerateCode(this); 561 return DoGenerateCode(this);
540 } 562 }
541 563
542 564
543 template <> 565 template <>
544 HValue* CodeStubGraphBuilder<ArraySingleArgumentConstructorStub>:: 566 HValue* CodeStubGraphBuilder<ArraySingleArgumentConstructorStub>::
545 BuildCodeStub() { 567 BuildCodeStub() {
568 HInstruction* array_function = BuildGetArrayFunction(context());
569 ArrayContextChecker(this,
570 GetParameter(ArrayConstructorStubBase::kConstructor),
571 array_function);
546 // Smi check and range check on the input arg. 572 // Smi check and range check on the input arg.
547 HValue* constant_one = graph()->GetConstant1(); 573 HValue* constant_one = graph()->GetConstant1();
548 HValue* constant_zero = graph()->GetConstant0(); 574 HValue* constant_zero = graph()->GetConstant0();
549 575
550 HInstruction* elements = AddInstruction( 576 HInstruction* elements = AddInstruction(
551 new(zone()) HArgumentsElements(false)); 577 new(zone()) HArgumentsElements(false));
552 HInstruction* argument = AddInstruction( 578 HInstruction* argument = AddInstruction(
553 new(zone()) HAccessArgumentsAt(elements, constant_one, constant_zero)); 579 new(zone()) HAccessArgumentsAt(elements, constant_one, constant_zero));
554 580
555 HConstant* max_alloc_length = 581 HConstant* max_alloc_length =
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 } 615 }
590 616
591 617
592 Handle<Code> ArraySingleArgumentConstructorStub::GenerateCode() { 618 Handle<Code> ArraySingleArgumentConstructorStub::GenerateCode() {
593 return DoGenerateCode(this); 619 return DoGenerateCode(this);
594 } 620 }
595 621
596 622
597 template <> 623 template <>
598 HValue* CodeStubGraphBuilder<ArrayNArgumentsConstructorStub>::BuildCodeStub() { 624 HValue* CodeStubGraphBuilder<ArrayNArgumentsConstructorStub>::BuildCodeStub() {
625 HInstruction* array_function = BuildGetArrayFunction(context());
626 ArrayContextChecker(this,
627 GetParameter(ArrayConstructorStubBase::kConstructor),
628 array_function);
599 ElementsKind kind = casted_stub()->elements_kind(); 629 ElementsKind kind = casted_stub()->elements_kind();
600 HValue* length = GetArgumentsLength(); 630 HValue* length = GetArgumentsLength();
601 631
602 JSArrayBuilder array_builder( 632 JSArrayBuilder array_builder(
603 this, 633 this,
604 kind, 634 kind,
605 GetParameter(ArrayConstructorStubBase::kPropertyCell), 635 GetParameter(ArrayConstructorStubBase::kPropertyCell),
606 casted_stub()->mode()); 636 casted_stub()->mode());
607 637
608 // We need to fill with the hole if it's a smi array in the multi-argument 638 // 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
663 ? graph()->GetConstantSmi1() 693 ? graph()->GetConstantSmi1()
664 : graph()->GetConstantUndefined(); 694 : graph()->GetConstantUndefined();
665 } 695 }
666 696
667 697
668 Handle<Code> CompareNilICStub::GenerateCode() { 698 Handle<Code> CompareNilICStub::GenerateCode() {
669 return DoGenerateCode(this); 699 return DoGenerateCode(this);
670 } 700 }
671 701
672 } } // namespace v8::internal 702 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/code-stubs.h ('k') | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698