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

Side by Side Diff: src/arm/fast-codegen-arm.cc

Issue 465148: Create literal boilerplate as part of cloning in the top-level compiler.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years 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/ia32/fast-codegen-ia32.cc » ('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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 __ mov(r1, Operand(expr->flags())); 650 __ mov(r1, Operand(expr->flags()));
651 __ stm(db_w, sp, r4.bit() | r3.bit() | r2.bit() | r1.bit()); 651 __ stm(db_w, sp, r4.bit() | r3.bit() | r2.bit() | r1.bit());
652 __ CallRuntime(Runtime::kMaterializeRegExpLiteral, 4); 652 __ CallRuntime(Runtime::kMaterializeRegExpLiteral, 4);
653 __ bind(&done); 653 __ bind(&done);
654 Move(expr->context(), r0); 654 Move(expr->context(), r0);
655 } 655 }
656 656
657 657
658 void FastCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { 658 void FastCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
659 Comment cmnt(masm_, "[ ObjectLiteral"); 659 Comment cmnt(masm_, "[ ObjectLiteral");
660 Label boilerplate_exists;
661 __ ldr(r2, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); 660 __ ldr(r2, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
662 // r2 = literal array (0).
663 __ ldr(r2, FieldMemOperand(r2, JSFunction::kLiteralsOffset)); 661 __ ldr(r2, FieldMemOperand(r2, JSFunction::kLiteralsOffset));
664 int literal_offset =
665 FixedArray::kHeaderSize + expr->literal_index() * kPointerSize;
666 __ ldr(r0, FieldMemOperand(r2, literal_offset));
667 // Check whether we need to materialize the object literal boilerplate.
668 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex);
669 __ cmp(r0, Operand(ip));
670 __ b(ne, &boilerplate_exists);
671 // Create boilerplate if it does not exist.
672 // r1 = literal index (1).
673 __ mov(r1, Operand(Smi::FromInt(expr->literal_index()))); 662 __ mov(r1, Operand(Smi::FromInt(expr->literal_index())));
674 // r0 = constant properties (2).
675 __ mov(r0, Operand(expr->constant_properties())); 663 __ mov(r0, Operand(expr->constant_properties()));
676 __ stm(db_w, sp, r2.bit() | r1.bit() | r0.bit()); 664 __ stm(db_w, sp, r2.bit() | r1.bit() | r0.bit());
677 __ CallRuntime(Runtime::kCreateObjectLiteralBoilerplate, 3);
678 __ bind(&boilerplate_exists);
679 // r0 contains boilerplate.
680 // Clone boilerplate.
681 __ push(r0);
682 if (expr->depth() > 1) { 665 if (expr->depth() > 1) {
683 __ CallRuntime(Runtime::kCloneLiteralBoilerplate, 1); 666 __ CallRuntime(Runtime::kCreateObjectLiteral, 3);
684 } else { 667 } else {
685 __ CallRuntime(Runtime::kCloneShallowLiteralBoilerplate, 1); 668 __ CallRuntime(Runtime::kCreateObjectLiteralShallow, 3);
686 } 669 }
687 670
688 // If result_saved == true: The result is saved on top of the 671 // If result_saved == true: The result is saved on top of the
689 // stack and in r0. 672 // stack and in r0.
690 // If result_saved == false: The result not on the stack, just in r0. 673 // If result_saved == false: The result not on the stack, just in r0.
691 bool result_saved = false; 674 bool result_saved = false;
692 675
693 for (int i = 0; i < expr->properties()->length(); i++) { 676 for (int i = 0; i < expr->properties()->length(); i++) {
694 ObjectLiteral::Property* property = expr->properties()->at(i); 677 ObjectLiteral::Property* property = expr->properties()->at(i);
695 if (property->IsCompileTimeValue()) continue; 678 if (property->IsCompileTimeValue()) continue;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 __ pop(); 759 __ pop();
777 __ jmp(true_label_); 760 __ jmp(true_label_);
778 break; 761 break;
779 } 762 }
780 } 763 }
781 } 764 }
782 765
783 766
784 void FastCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { 767 void FastCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
785 Comment cmnt(masm_, "[ ArrayLiteral"); 768 Comment cmnt(masm_, "[ ArrayLiteral");
786 Label make_clone;
787
788 // Fetch the function's literals array.
789 __ ldr(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); 769 __ ldr(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
790 __ ldr(r3, FieldMemOperand(r3, JSFunction::kLiteralsOffset)); 770 __ ldr(r3, FieldMemOperand(r3, JSFunction::kLiteralsOffset));
791 // Check if the literal's boilerplate has been instantiated.
792 int offset =
793 FixedArray::kHeaderSize + (expr->literal_index() * kPointerSize);
794 __ ldr(r0, FieldMemOperand(r3, offset));
795 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex);
796 __ cmp(r0, ip);
797 __ b(&make_clone, ne);
798
799 // Instantiate the boilerplate.
800 __ mov(r2, Operand(Smi::FromInt(expr->literal_index()))); 771 __ mov(r2, Operand(Smi::FromInt(expr->literal_index())));
801 __ mov(r1, Operand(expr->literals())); 772 __ mov(r1, Operand(expr->literals()));
802 __ stm(db_w, sp, r3.bit() | r2.bit() | r1.bit()); 773 __ stm(db_w, sp, r3.bit() | r2.bit() | r1.bit());
803 __ CallRuntime(Runtime::kCreateArrayLiteralBoilerplate, 3);
804
805 __ bind(&make_clone);
806 // Clone the boilerplate.
807 __ push(r0);
808 if (expr->depth() > 1) { 774 if (expr->depth() > 1) {
809 __ CallRuntime(Runtime::kCloneLiteralBoilerplate, 1); 775 __ CallRuntime(Runtime::kCreateArrayLiteral, 3);
810 } else { 776 } else {
811 __ CallRuntime(Runtime::kCloneShallowLiteralBoilerplate, 1); 777 __ CallRuntime(Runtime::kCreateArrayLiteralShallow, 3);
812 } 778 }
813 779
814 bool result_saved = false; // Is the result saved to the stack? 780 bool result_saved = false; // Is the result saved to the stack?
815 781
816 // Emit code to evaluate all the non-constant subexpressions and to store 782 // Emit code to evaluate all the non-constant subexpressions and to store
817 // them into the newly cloned array. 783 // them into the newly cloned array.
818 ZoneList<Expression*>* subexprs = expr->values(); 784 ZoneList<Expression*>* subexprs = expr->values();
819 for (int i = 0, len = subexprs->length(); i < len; i++) { 785 for (int i = 0, len = subexprs->length(); i < len; i++) {
820 Expression* subexpr = subexprs->at(i); 786 Expression* subexpr = subexprs->at(i);
821 // If the subexpression is a literal or a simple materialized literal it 787 // If the subexpression is a literal or a simple materialized literal it
(...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after
1699 void FastCodeGenerator::VisitThisFunction(ThisFunction* expr) { 1665 void FastCodeGenerator::VisitThisFunction(ThisFunction* expr) {
1700 __ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); 1666 __ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
1701 Move(expr->context(), r0); 1667 Move(expr->context(), r0);
1702 } 1668 }
1703 1669
1704 1670
1705 #undef __ 1671 #undef __
1706 1672
1707 1673
1708 } } // namespace v8::internal 1674 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/ia32/fast-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698