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

Side by Side Diff: src/hydrogen.cc

Issue 5990005: Optimize instanceof further... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 11 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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 4829 matching lines...) Expand 10 before | Expand all | Expand 10 after
4840 VISIT_FOR_VALUE(expr->left()); 4840 VISIT_FOR_VALUE(expr->left());
4841 VISIT_FOR_VALUE(expr->right()); 4841 VISIT_FOR_VALUE(expr->right());
4842 4842
4843 HValue* right = Pop(); 4843 HValue* right = Pop();
4844 HValue* left = Pop(); 4844 HValue* left = Pop();
4845 Token::Value op = expr->op(); 4845 Token::Value op = expr->op();
4846 4846
4847 TypeInfo info = oracle()->CompareType(expr, TypeFeedbackOracle::RESULT); 4847 TypeInfo info = oracle()->CompareType(expr, TypeFeedbackOracle::RESULT);
4848 HInstruction* instr = NULL; 4848 HInstruction* instr = NULL;
4849 if (op == Token::INSTANCEOF) { 4849 if (op == Token::INSTANCEOF) {
4850 instr = new HInstanceOf(left, right); 4850 // Check to see if the rhs of the instanceof is a global function not
4851 // residing in new space. If it is we assume that the function will stay the
4852 // same.
4853 Handle<JSFunction> target = Handle<JSFunction>::null();
4854 Variable* var = expr->right()->AsVariableProxy()->AsVariable();
4855 bool global_function = (var != NULL) && var->is_global() && !var->is_this();
4856 CompilationInfo* info = graph()->info();
4857 if (global_function &&
4858 info->has_global_object() &&
4859 !info->global_object()->IsAccessCheckNeeded()) {
4860 Handle<String> name = var->name();
4861 Handle<GlobalObject> global(info->global_object());
4862 LookupResult lookup;
4863 global->Lookup(*name, &lookup);
4864 if (lookup.IsProperty() &&
4865 lookup.type() == NORMAL &&
4866 lookup.GetValue()->IsJSFunction()) {
4867 Handle<JSFunction> candidate(JSFunction::cast(lookup.GetValue()));
4868 // If the function is in new space we assume it's more likely to
4869 // change and thus prefer the general IC code.
4870 if (!Heap::InNewSpace(*candidate)) {
4871 target = candidate;
4872 }
4873 }
4874 }
4875
4876 // If the target is not null we have found a known global function that is
4877 // assumed to stay the same for this instanceof.
4878 if (target.is_null()) {
4879 instr = new HInstanceOf(left, right);
4880 } else {
4881 AddInstruction(new HCheckFunction(right, target));
4882 instr = new HInstanceOfKnownGlobal(left, target);
4883 }
4851 } else if (op == Token::IN) { 4884 } else if (op == Token::IN) {
4852 BAILOUT("Unsupported comparison: in"); 4885 BAILOUT("Unsupported comparison: in");
4853 } else if (info.IsNonPrimitive()) { 4886 } else if (info.IsNonPrimitive()) {
4854 switch (op) { 4887 switch (op) {
4855 case Token::EQ: 4888 case Token::EQ:
4856 case Token::EQ_STRICT: { 4889 case Token::EQ_STRICT: {
4857 AddInstruction(HCheckInstanceType::NewIsJSObjectOrJSFunction(left)); 4890 AddInstruction(HCheckInstanceType::NewIsJSObjectOrJSFunction(left));
4858 AddInstruction(HCheckInstanceType::NewIsJSObjectOrJSFunction(right)); 4891 AddInstruction(HCheckInstanceType::NewIsJSObjectOrJSFunction(right));
4859 instr = new HCompareJSObjectEq(left, right); 4892 instr = new HCompareJSObjectEq(left, right);
4860 break; 4893 break;
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
5677 } 5710 }
5678 5711
5679 #ifdef DEBUG 5712 #ifdef DEBUG
5680 if (graph_ != NULL) graph_->Verify(); 5713 if (graph_ != NULL) graph_->Verify();
5681 if (chunk_ != NULL) chunk_->Verify(); 5714 if (chunk_ != NULL) chunk_->Verify();
5682 if (allocator_ != NULL) allocator_->Verify(); 5715 if (allocator_ != NULL) allocator_->Verify();
5683 #endif 5716 #endif
5684 } 5717 }
5685 5718
5686 } } // namespace v8::internal 5719 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/code-stubs.h ('k') | src/hydrogen-instructions.h » ('j') | src/ia32/code-stubs-ia32.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698