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

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
« no previous file with comments | « src/code-stubs.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 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 4844 matching lines...) Expand 10 before | Expand all | Expand 10 after
4855 VISIT_FOR_VALUE(expr->left()); 4855 VISIT_FOR_VALUE(expr->left());
4856 VISIT_FOR_VALUE(expr->right()); 4856 VISIT_FOR_VALUE(expr->right());
4857 4857
4858 HValue* right = Pop(); 4858 HValue* right = Pop();
4859 HValue* left = Pop(); 4859 HValue* left = Pop();
4860 Token::Value op = expr->op(); 4860 Token::Value op = expr->op();
4861 4861
4862 TypeInfo info = oracle()->CompareType(expr, TypeFeedbackOracle::RESULT); 4862 TypeInfo info = oracle()->CompareType(expr, TypeFeedbackOracle::RESULT);
4863 HInstruction* instr = NULL; 4863 HInstruction* instr = NULL;
4864 if (op == Token::INSTANCEOF) { 4864 if (op == Token::INSTANCEOF) {
4865 instr = new HInstanceOf(left, right); 4865 // Check to see if the rhs of the instanceof is a global function not
4866 // residing in new space. If it is we assume that the function will stay the
4867 // same.
4868 Handle<JSFunction> target = Handle<JSFunction>::null();
4869 Variable* var = expr->right()->AsVariableProxy()->AsVariable();
4870 bool global_function = (var != NULL) && var->is_global() && !var->is_this();
4871 CompilationInfo* info = graph()->info();
4872 if (global_function &&
4873 info->has_global_object() &&
4874 !info->global_object()->IsAccessCheckNeeded()) {
4875 Handle<String> name = var->name();
4876 Handle<GlobalObject> global(info->global_object());
4877 LookupResult lookup;
4878 global->Lookup(*name, &lookup);
4879 if (lookup.IsProperty() &&
4880 lookup.type() == NORMAL &&
4881 lookup.GetValue()->IsJSFunction()) {
4882 Handle<JSFunction> candidate(JSFunction::cast(lookup.GetValue()));
4883 // If the function is in new space we assume it's more likely to
4884 // change and thus prefer the general IC code.
4885 if (!Heap::InNewSpace(*candidate)) {
4886 target = candidate;
4887 }
4888 }
4889 }
4890
4891 // If the target is not null we have found a known global function that is
4892 // assumed to stay the same for this instanceof.
4893 if (target.is_null()) {
4894 instr = new HInstanceOf(left, right);
4895 } else {
4896 AddInstruction(new HCheckFunction(right, target));
4897 instr = new HInstanceOfKnownGlobal(left, target);
4898 }
4866 } else if (op == Token::IN) { 4899 } else if (op == Token::IN) {
4867 BAILOUT("Unsupported comparison: in"); 4900 BAILOUT("Unsupported comparison: in");
4868 } else if (info.IsNonPrimitive()) { 4901 } else if (info.IsNonPrimitive()) {
4869 switch (op) { 4902 switch (op) {
4870 case Token::EQ: 4903 case Token::EQ:
4871 case Token::EQ_STRICT: { 4904 case Token::EQ_STRICT: {
4872 AddInstruction(new HCheckNonSmi(left)); 4905 AddInstruction(new HCheckNonSmi(left));
4873 AddInstruction(HCheckInstanceType::NewIsJSObjectOrJSFunction(left)); 4906 AddInstruction(HCheckInstanceType::NewIsJSObjectOrJSFunction(left));
4874 AddInstruction(new HCheckNonSmi(right)); 4907 AddInstruction(new HCheckNonSmi(right));
4875 AddInstruction(HCheckInstanceType::NewIsJSObjectOrJSFunction(right)); 4908 AddInstruction(HCheckInstanceType::NewIsJSObjectOrJSFunction(right));
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after
5726 } 5759 }
5727 5760
5728 #ifdef DEBUG 5761 #ifdef DEBUG
5729 if (graph_ != NULL) graph_->Verify(); 5762 if (graph_ != NULL) graph_->Verify();
5730 if (chunk_ != NULL) chunk_->Verify(); 5763 if (chunk_ != NULL) chunk_->Verify();
5731 if (allocator_ != NULL) allocator_->Verify(); 5764 if (allocator_ != NULL) allocator_->Verify();
5732 #endif 5765 #endif
5733 } 5766 }
5734 5767
5735 } } // namespace v8::internal 5768 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/code-stubs.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698