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

Side by Side Diff: src/hydrogen.cc

Issue 10103035: Share optimized code for closures. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: added x64 and ARM ports Created 8 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
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 7627 matching lines...) Expand 10 before | Expand all | Expand 10 after
7638 ASSERT(current_block() != NULL); 7638 ASSERT(current_block() != NULL);
7639 ASSERT(current_block()->HasPredecessor()); 7639 ASSERT(current_block()->HasPredecessor());
7640 EqualityKind kind = 7640 EqualityKind kind =
7641 expr->op() == Token::EQ_STRICT ? kStrictEquality : kNonStrictEquality; 7641 expr->op() == Token::EQ_STRICT ? kStrictEquality : kNonStrictEquality;
7642 HIsNilAndBranch* instr = new(zone()) HIsNilAndBranch(value, kind, nil); 7642 HIsNilAndBranch* instr = new(zone()) HIsNilAndBranch(value, kind, nil);
7643 instr->set_position(expr->position()); 7643 instr->set_position(expr->position());
7644 return ast_context()->ReturnControl(instr, expr->id()); 7644 return ast_context()->ReturnControl(instr, expr->id());
7645 } 7645 }
7646 7646
7647 7647
7648 HInstruction* HGraphBuilder::BuildThisFunction() {
7649 // If we share optimized code between different closures, the
7650 // this-function is not a constant, except inside an inlined body.
7651 if (function_state()->outer() != NULL) {
7652 return new(zone()) HConstant(
7653 function_state()->compilation_info()->closure(),
7654 Representation::Tagged());
7655 } else {
7656 return new(zone()) HThisFunction;
7657 }
7658 }
7659
7660
7648 void HGraphBuilder::VisitThisFunction(ThisFunction* expr) { 7661 void HGraphBuilder::VisitThisFunction(ThisFunction* expr) {
7649 ASSERT(!HasStackOverflow()); 7662 ASSERT(!HasStackOverflow());
7650 ASSERT(current_block() != NULL); 7663 ASSERT(current_block() != NULL);
7651 ASSERT(current_block()->HasPredecessor()); 7664 ASSERT(current_block()->HasPredecessor());
7652 HThisFunction* self = new(zone()) HThisFunction( 7665 HInstruction* instr = BuildThisFunction();
7653 function_state()->compilation_info()->closure()); 7666 return ast_context()->ReturnInstruction(instr, expr->id());
7654 return ast_context()->ReturnInstruction(self, expr->id());
7655 } 7667 }
7656 7668
7657 7669
7658 void HGraphBuilder::VisitDeclarations(ZoneList<Declaration*>* declarations) { 7670 void HGraphBuilder::VisitDeclarations(ZoneList<Declaration*>* declarations) {
7659 ASSERT(globals_.is_empty()); 7671 ASSERT(globals_.is_empty());
7660 AstVisitor::VisitDeclarations(declarations); 7672 AstVisitor::VisitDeclarations(declarations);
7661 if (!globals_.is_empty()) { 7673 if (!globals_.is_empty()) {
7662 Handle<FixedArray> array = 7674 Handle<FixedArray> array =
7663 isolate()->factory()->NewFixedArray(globals_.length(), TENURED); 7675 isolate()->factory()->NewFixedArray(globals_.length(), TENURED);
7664 for (int i = 0; i < globals_.length(); ++i) array->set(i, *globals_.at(i)); 7676 for (int i = 0; i < globals_.length(); ++i) array->set(i, *globals_.at(i));
(...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after
8860 } 8872 }
8861 } 8873 }
8862 8874
8863 #ifdef DEBUG 8875 #ifdef DEBUG
8864 if (graph_ != NULL) graph_->Verify(false); // No full verify. 8876 if (graph_ != NULL) graph_->Verify(false); // No full verify.
8865 if (allocator_ != NULL) allocator_->Verify(); 8877 if (allocator_ != NULL) allocator_->Verify();
8866 #endif 8878 #endif
8867 } 8879 }
8868 8880
8869 } } // namespace v8::internal 8881 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698