Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 the assumption used for optimization is | |
|
Mads Ager (chromium)
2011/01/04 17:25:58
Simplify to: If it is we assume that the function
Søren Thygesen Gjesse
2011/01/05 09:28:00
Done.
| |
| 4852 // that the function most likely will stay the 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 Handle<JSGlobalPropertyCell> cell = Handle<JSGlobalPropertyCell>::null(); | |
|
Mads Ager (chromium)
2011/01/04 17:25:58
Do you need the cell declaration out here? Can't y
Søren Thygesen Gjesse
2011/01/05 09:28:00
Don't need the cell at all, can just use lookup.Ge
| |
| 4863 LookupResult lookup; | |
| 4864 global->Lookup(*name, &lookup); | |
| 4865 if (lookup.IsProperty() && lookup.type() == NORMAL) { | |
| 4866 cell = Handle<JSGlobalPropertyCell>(global->GetPropertyCell(&lookup)); | |
| 4867 if (cell->value()->IsJSFunction()) { | |
| 4868 Handle<JSFunction> candidate(JSFunction::cast(cell->value())); | |
| 4869 // If the function is in new space we assume it's more likely to | |
| 4870 // change and thus prefer the general IC code. | |
| 4871 if (!Heap::InNewSpace(*candidate)) { | |
| 4872 target = candidate; | |
| 4873 } | |
| 4874 } | |
| 4875 } | |
| 4876 } | |
| 4877 | |
| 4878 // If the traget is not null we have found a known global function that is | |
|
Mads Ager (chromium)
2011/01/04 17:25:58
traget -> target
Søren Thygesen Gjesse
2011/01/05 09:28:00
Done.
| |
| 4879 // assumed to stay the same for this instanceof. | |
| 4880 if (target.is_null()) { | |
| 4881 instr = new HInstanceOf(left, right); | |
| 4882 } else { | |
| 4883 AddInstruction(new HCheckFunction(right, target)); | |
| 4884 instr = new HInstanceOfKnownGlobal(left, target); | |
| 4885 } | |
| 4851 } else if (op == Token::IN) { | 4886 } else if (op == Token::IN) { |
| 4852 BAILOUT("Unsupported comparison: in"); | 4887 BAILOUT("Unsupported comparison: in"); |
| 4853 } else if (info.IsNonPrimitive()) { | 4888 } else if (info.IsNonPrimitive()) { |
| 4854 switch (op) { | 4889 switch (op) { |
| 4855 case Token::EQ: | 4890 case Token::EQ: |
| 4856 case Token::EQ_STRICT: { | 4891 case Token::EQ_STRICT: { |
| 4857 AddInstruction(HCheckInstanceType::NewIsJSObjectOrJSFunction(left)); | 4892 AddInstruction(HCheckInstanceType::NewIsJSObjectOrJSFunction(left)); |
| 4858 AddInstruction(HCheckInstanceType::NewIsJSObjectOrJSFunction(right)); | 4893 AddInstruction(HCheckInstanceType::NewIsJSObjectOrJSFunction(right)); |
| 4859 instr = new HCompareJSObjectEq(left, right); | 4894 instr = new HCompareJSObjectEq(left, right); |
| 4860 break; | 4895 break; |
| (...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5677 } | 5712 } |
| 5678 | 5713 |
| 5679 #ifdef DEBUG | 5714 #ifdef DEBUG |
| 5680 if (graph_ != NULL) graph_->Verify(); | 5715 if (graph_ != NULL) graph_->Verify(); |
| 5681 if (chunk_ != NULL) chunk_->Verify(); | 5716 if (chunk_ != NULL) chunk_->Verify(); |
| 5682 if (allocator_ != NULL) allocator_->Verify(); | 5717 if (allocator_ != NULL) allocator_->Verify(); |
| 5683 #endif | 5718 #endif |
| 5684 } | 5719 } |
| 5685 | 5720 |
| 5686 } } // namespace v8::internal | 5721 } } // namespace v8::internal |
| OLD | NEW |