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

Side by Side Diff: src/type-info.cc

Issue 9571001: Introduce basic type feedback for for-in statements to avoid deopts. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 9 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/type-info.h ('k') | src/x64/full-codegen-x64.cc » ('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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 return value->IsMap() || value->IsSmi() || value->IsJSFunction(); 147 return value->IsMap() || value->IsSmi() || value->IsJSFunction();
148 } 148 }
149 149
150 150
151 bool TypeFeedbackOracle::CallNewIsMonomorphic(CallNew* expr) { 151 bool TypeFeedbackOracle::CallNewIsMonomorphic(CallNew* expr) {
152 Handle<Object> value = GetInfo(expr->id()); 152 Handle<Object> value = GetInfo(expr->id());
153 return value->IsJSFunction(); 153 return value->IsJSFunction();
154 } 154 }
155 155
156 156
157 bool TypeFeedbackOracle::IsForInFastCase(ForInStatement* stmt) {
158 Handle<Object> value = GetInfo(stmt->PrepareId());
159 return value->IsSmi() &&
160 Smi::cast(*value)->value() == TypeFeedbackCells::kForInFastCaseMarker;
161 }
162
163
157 Handle<Map> TypeFeedbackOracle::LoadMonomorphicReceiverType(Property* expr) { 164 Handle<Map> TypeFeedbackOracle::LoadMonomorphicReceiverType(Property* expr) {
158 ASSERT(LoadIsMonomorphicNormal(expr)); 165 ASSERT(LoadIsMonomorphicNormal(expr));
159 Handle<Object> map_or_code = GetInfo(expr->id()); 166 Handle<Object> map_or_code = GetInfo(expr->id());
160 if (map_or_code->IsCode()) { 167 if (map_or_code->IsCode()) {
161 Handle<Code> code = Handle<Code>::cast(map_or_code); 168 Handle<Code> code = Handle<Code>::cast(map_or_code);
162 Map* first_map = code->FindFirstMap(); 169 Map* first_map = code->FindFirstMap();
163 ASSERT(first_map != NULL); 170 ASSERT(first_map != NULL);
164 return CanRetainOtherContext(first_map, *global_context_) 171 return CanRetainOtherContext(first_map, *global_context_)
165 ? Handle<Map>::null() 172 ? Handle<Map>::null()
166 : Handle<Map>(first_map); 173 : Handle<Map>(first_map);
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 659
653 660
654 void TypeFeedbackOracle::ProcessTypeFeedbackCells(Handle<Code> code) { 661 void TypeFeedbackOracle::ProcessTypeFeedbackCells(Handle<Code> code) {
655 Object* raw_info = code->type_feedback_info(); 662 Object* raw_info = code->type_feedback_info();
656 if (!raw_info->IsTypeFeedbackInfo()) return; 663 if (!raw_info->IsTypeFeedbackInfo()) return;
657 Handle<TypeFeedbackCells> cache( 664 Handle<TypeFeedbackCells> cache(
658 TypeFeedbackInfo::cast(raw_info)->type_feedback_cells()); 665 TypeFeedbackInfo::cast(raw_info)->type_feedback_cells());
659 for (int i = 0; i < cache->CellCount(); i++) { 666 for (int i = 0; i < cache->CellCount(); i++) {
660 unsigned ast_id = cache->AstId(i)->value(); 667 unsigned ast_id = cache->AstId(i)->value();
661 Object* value = cache->Cell(i)->value(); 668 Object* value = cache->Cell(i)->value();
662 if (value->IsJSFunction() && 669 if (value->IsSmi() ||
663 !CanRetainOtherContext(JSFunction::cast(value), 670 (value->IsJSFunction() &&
664 *global_context_)) { 671 !CanRetainOtherContext(JSFunction::cast(value),
672 *global_context_))) {
665 SetInfo(ast_id, value); 673 SetInfo(ast_id, value);
666 } 674 }
667 } 675 }
668 } 676 }
669 677
670 678
671 void TypeFeedbackOracle::SetInfo(unsigned ast_id, Object* target) { 679 void TypeFeedbackOracle::SetInfo(unsigned ast_id, Object* target) {
672 ASSERT(dictionary_->FindEntry(ast_id) == UnseededNumberDictionary::kNotFound); 680 ASSERT(dictionary_->FindEntry(ast_id) == UnseededNumberDictionary::kNotFound);
673 MaybeObject* maybe_result = dictionary_->AtNumberPut(ast_id, target); 681 MaybeObject* maybe_result = dictionary_->AtNumberPut(ast_id, target);
674 USE(maybe_result); 682 USE(maybe_result);
675 #ifdef DEBUG 683 #ifdef DEBUG
676 Object* result = NULL; 684 Object* result = NULL;
677 // Dictionary has been allocated with sufficient size for all elements. 685 // Dictionary has been allocated with sufficient size for all elements.
678 ASSERT(maybe_result->ToObject(&result)); 686 ASSERT(maybe_result->ToObject(&result));
679 ASSERT(*dictionary_ == result); 687 ASSERT(*dictionary_ == result);
680 #endif 688 #endif
681 } 689 }
682 690
683 } } // namespace v8::internal 691 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/type-info.h ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698