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

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: Created 8 years, 6 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/hydrogen.h ('k') | src/hydrogen-instructions.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 7945 matching lines...) Expand 10 before | Expand all | Expand 10 after
7956 ASSERT(current_block() != NULL); 7956 ASSERT(current_block() != NULL);
7957 ASSERT(current_block()->HasPredecessor()); 7957 ASSERT(current_block()->HasPredecessor());
7958 EqualityKind kind = 7958 EqualityKind kind =
7959 expr->op() == Token::EQ_STRICT ? kStrictEquality : kNonStrictEquality; 7959 expr->op() == Token::EQ_STRICT ? kStrictEquality : kNonStrictEquality;
7960 HIsNilAndBranch* instr = new(zone()) HIsNilAndBranch(value, kind, nil); 7960 HIsNilAndBranch* instr = new(zone()) HIsNilAndBranch(value, kind, nil);
7961 instr->set_position(expr->position()); 7961 instr->set_position(expr->position());
7962 return ast_context()->ReturnControl(instr, expr->id()); 7962 return ast_context()->ReturnControl(instr, expr->id());
7963 } 7963 }
7964 7964
7965 7965
7966 HInstruction* HGraphBuilder::BuildThisFunction() {
7967 // If we share optimized code between different closures, the
7968 // this-function is not a constant, except inside an inlined body.
7969 if (function_state()->outer() != NULL) {
7970 return new(zone()) HConstant(
7971 function_state()->compilation_info()->closure(),
7972 Representation::Tagged());
7973 } else {
7974 return new(zone()) HThisFunction;
7975 }
7976 }
7977
7978
7966 void HGraphBuilder::VisitThisFunction(ThisFunction* expr) { 7979 void HGraphBuilder::VisitThisFunction(ThisFunction* expr) {
7967 ASSERT(!HasStackOverflow()); 7980 ASSERT(!HasStackOverflow());
7968 ASSERT(current_block() != NULL); 7981 ASSERT(current_block() != NULL);
7969 ASSERT(current_block()->HasPredecessor()); 7982 ASSERT(current_block()->HasPredecessor());
7970 HThisFunction* self = new(zone()) HThisFunction( 7983 HInstruction* instr = BuildThisFunction();
7971 function_state()->compilation_info()->closure()); 7984 return ast_context()->ReturnInstruction(instr, expr->id());
7972 return ast_context()->ReturnInstruction(self, expr->id());
7973 } 7985 }
7974 7986
7975 7987
7976 void HGraphBuilder::VisitDeclarations(ZoneList<Declaration*>* declarations) { 7988 void HGraphBuilder::VisitDeclarations(ZoneList<Declaration*>* declarations) {
7977 ASSERT(globals_.is_empty()); 7989 ASSERT(globals_.is_empty());
7978 AstVisitor::VisitDeclarations(declarations); 7990 AstVisitor::VisitDeclarations(declarations);
7979 if (!globals_.is_empty()) { 7991 if (!globals_.is_empty()) {
7980 Handle<FixedArray> array = 7992 Handle<FixedArray> array =
7981 isolate()->factory()->NewFixedArray(globals_.length(), TENURED); 7993 isolate()->factory()->NewFixedArray(globals_.length(), TENURED);
7982 for (int i = 0; i < globals_.length(); ++i) array->set(i, *globals_.at(i)); 7994 for (int i = 0; i < globals_.length(); ++i) array->set(i, *globals_.at(i));
(...skipping 1194 matching lines...) Expand 10 before | Expand all | Expand 10 after
9177 } 9189 }
9178 } 9190 }
9179 9191
9180 #ifdef DEBUG 9192 #ifdef DEBUG
9181 if (graph_ != NULL) graph_->Verify(false); // No full verify. 9193 if (graph_ != NULL) graph_->Verify(false); // No full verify.
9182 if (allocator_ != NULL) allocator_->Verify(); 9194 if (allocator_ != NULL) allocator_->Verify();
9183 #endif 9195 #endif
9184 } 9196 }
9185 9197
9186 } } // namespace v8::internal 9198 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698