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

Side by Side Diff: src/ia32/fast-codegen-ia32.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 | « src/arm/fast-codegen-arm.cc ('k') | src/runtime.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 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 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 __ push(Immediate(expr->flags())); 649 __ push(Immediate(expr->flags()));
650 __ CallRuntime(Runtime::kMaterializeRegExpLiteral, 4); 650 __ CallRuntime(Runtime::kMaterializeRegExpLiteral, 4);
651 // Label done: 651 // Label done:
652 __ bind(&done); 652 __ bind(&done);
653 Move(expr->context(), eax); 653 Move(expr->context(), eax);
654 } 654 }
655 655
656 656
657 void FastCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { 657 void FastCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
658 Comment cmnt(masm_, "[ ObjectLiteral"); 658 Comment cmnt(masm_, "[ ObjectLiteral");
659 Label exists;
660 // Registers will be used as follows:
661 // edi = JS function.
662 // ebx = literals array.
663 // eax = boilerplate
664
665 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); 659 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
666 __ mov(ebx, FieldOperand(edi, JSFunction::kLiteralsOffset)); 660 __ push(FieldOperand(edi, JSFunction::kLiteralsOffset));
667 int literal_offset =
668 FixedArray::kHeaderSize + expr->literal_index() * kPointerSize;
669 __ mov(eax, FieldOperand(ebx, literal_offset));
670 __ cmp(eax, Factory::undefined_value());
671 __ j(not_equal, &exists);
672 // Create boilerplate if it does not exist.
673 // Literal array (0).
674 __ push(ebx);
675 // Literal index (1).
676 __ push(Immediate(Smi::FromInt(expr->literal_index()))); 661 __ push(Immediate(Smi::FromInt(expr->literal_index())));
677 // Constant properties (2).
678 __ push(Immediate(expr->constant_properties())); 662 __ push(Immediate(expr->constant_properties()));
679 __ CallRuntime(Runtime::kCreateObjectLiteralBoilerplate, 3); 663 if (expr->depth() > 1) {
680 __ bind(&exists); 664 __ CallRuntime(Runtime::kCreateObjectLiteral, 3);
681 // eax contains boilerplate.
682 // Clone boilerplate.
683 __ push(eax);
684 if (expr->depth() == 1) {
685 __ CallRuntime(Runtime::kCloneShallowLiteralBoilerplate, 1);
686 } else { 665 } else {
687 __ CallRuntime(Runtime::kCloneLiteralBoilerplate, 1); 666 __ CallRuntime(Runtime::kCreateObjectLiteralShallow, 3);
688 } 667 }
689 668
690 // If result_saved == true: The result is saved on top of the 669 // If result_saved == true: The result is saved on top of the
691 // stack and in eax. 670 // stack and in eax.
692 // If result_saved == false: The result not on the stack, just in eax. 671 // If result_saved == false: The result not on the stack, just in eax.
693 bool result_saved = false; 672 bool result_saved = false;
694 673
695 for (int i = 0; i < expr->properties()->length(); i++) { 674 for (int i = 0; i < expr->properties()->length(); i++) {
696 ObjectLiteral::Property* property = expr->properties()->at(i); 675 ObjectLiteral::Property* property = expr->properties()->at(i);
697 if (property->IsCompileTimeValue()) continue; 676 if (property->IsCompileTimeValue()) continue;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 __ add(Operand(esp), Immediate(kPointerSize)); 752 __ add(Operand(esp), Immediate(kPointerSize));
774 __ jmp(true_label_); 753 __ jmp(true_label_);
775 break; 754 break;
776 } 755 }
777 } 756 }
778 } 757 }
779 758
780 759
781 void FastCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { 760 void FastCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
782 Comment cmnt(masm_, "[ ArrayLiteral"); 761 Comment cmnt(masm_, "[ ArrayLiteral");
783 Label make_clone;
784
785 // Fetch the function's literals array.
786 __ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); 762 __ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
787 __ mov(ebx, FieldOperand(ebx, JSFunction::kLiteralsOffset)); 763 __ push(FieldOperand(ebx, JSFunction::kLiteralsOffset));
788 // Check if the literal's boilerplate has been instantiated.
789 int offset =
790 FixedArray::kHeaderSize + (expr->literal_index() * kPointerSize);
791 __ mov(eax, FieldOperand(ebx, offset));
792 __ cmp(eax, Factory::undefined_value());
793 __ j(not_equal, &make_clone);
794
795 // Instantiate the boilerplate.
796 __ push(ebx);
797 __ push(Immediate(Smi::FromInt(expr->literal_index()))); 764 __ push(Immediate(Smi::FromInt(expr->literal_index())));
798 __ push(Immediate(expr->literals())); 765 __ push(Immediate(expr->literals()));
799 __ CallRuntime(Runtime::kCreateArrayLiteralBoilerplate, 3);
800
801 __ bind(&make_clone);
802 // Clone the boilerplate.
803 __ push(eax);
804 if (expr->depth() > 1) { 766 if (expr->depth() > 1) {
805 __ CallRuntime(Runtime::kCloneLiteralBoilerplate, 1); 767 __ CallRuntime(Runtime::kCreateArrayLiteral, 3);
806 } else { 768 } else {
807 __ CallRuntime(Runtime::kCloneShallowLiteralBoilerplate, 1); 769 __ CallRuntime(Runtime::kCreateArrayLiteralShallow, 3);
808 } 770 }
809 771
810 bool result_saved = false; // Is the result saved to the stack? 772 bool result_saved = false; // Is the result saved to the stack?
811 773
812 // Emit code to evaluate all the non-constant subexpressions and to store 774 // Emit code to evaluate all the non-constant subexpressions and to store
813 // them into the newly cloned array. 775 // them into the newly cloned array.
814 ZoneList<Expression*>* subexprs = expr->values(); 776 ZoneList<Expression*>* subexprs = expr->values();
815 for (int i = 0, len = subexprs->length(); i < len; i++) { 777 for (int i = 0, len = subexprs->length(); i < len; i++) {
816 Expression* subexpr = subexprs->at(i); 778 Expression* subexpr = subexprs->at(i);
817 // If the subexpression is a literal or a simple materialized literal it 779 // If the subexpression is a literal or a simple materialized literal it
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after
1680 1642
1681 void FastCodeGenerator::VisitThisFunction(ThisFunction* expr) { 1643 void FastCodeGenerator::VisitThisFunction(ThisFunction* expr) {
1682 __ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); 1644 __ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
1683 Move(expr->context(), eax); 1645 Move(expr->context(), eax);
1684 } 1646 }
1685 1647
1686 #undef __ 1648 #undef __
1687 1649
1688 1650
1689 } } // namespace v8::internal 1651 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/fast-codegen-arm.cc ('k') | src/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698