| OLD | NEW |
| 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 STANDARD_STORE); | 179 STANDARD_STORE); |
| 180 return code->is_keyed_store_stub() && standard_store && | 180 return code->is_keyed_store_stub() && standard_store && |
| 181 code->ic_state() == POLYMORPHIC; | 181 code->ic_state() == POLYMORPHIC; |
| 182 } | 182 } |
| 183 return false; | 183 return false; |
| 184 } | 184 } |
| 185 | 185 |
| 186 | 186 |
| 187 bool TypeFeedbackOracle::CallIsMonomorphic(Call* expr) { | 187 bool TypeFeedbackOracle::CallIsMonomorphic(Call* expr) { |
| 188 Handle<Object> value = GetInfo(expr->CallFeedbackId()); | 188 Handle<Object> value = GetInfo(expr->CallFeedbackId()); |
| 189 return value->IsMap() || value->IsSmi() || value->IsJSFunction(); | 189 return value->IsMap() || value->IsAllocationSite() || value->IsJSFunction() || |
| 190 value->IsSmi(); |
| 190 } | 191 } |
| 191 | 192 |
| 192 | 193 |
| 193 bool TypeFeedbackOracle::CallNewIsMonomorphic(CallNew* expr) { | 194 bool TypeFeedbackOracle::CallNewIsMonomorphic(CallNew* expr) { |
| 194 Handle<Object> info = GetInfo(expr->CallNewFeedbackId()); | 195 Handle<Object> info = GetInfo(expr->CallNewFeedbackId()); |
| 195 return info->IsSmi() || info->IsJSFunction(); | 196 return info->IsAllocationSite() || info->IsJSFunction(); |
| 196 } | 197 } |
| 197 | 198 |
| 198 | 199 |
| 199 bool TypeFeedbackOracle::ObjectLiteralStoreIsMonomorphic( | 200 bool TypeFeedbackOracle::ObjectLiteralStoreIsMonomorphic( |
| 200 ObjectLiteral::Property* prop) { | 201 ObjectLiteral::Property* prop) { |
| 201 Handle<Object> map_or_code = GetInfo(prop->key()->LiteralFeedbackId()); | 202 Handle<Object> map_or_code = GetInfo(prop->key()->LiteralFeedbackId()); |
| 202 return map_or_code->IsMap(); | 203 return map_or_code->IsMap(); |
| 203 } | 204 } |
| 204 | 205 |
| 205 | 206 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 Handle<Object> value = GetInfo(expr->CallFeedbackId()); | 296 Handle<Object> value = GetInfo(expr->CallFeedbackId()); |
| 296 if (!value->IsSmi()) return RECEIVER_MAP_CHECK; | 297 if (!value->IsSmi()) return RECEIVER_MAP_CHECK; |
| 297 CheckType check = static_cast<CheckType>(Smi::cast(*value)->value()); | 298 CheckType check = static_cast<CheckType>(Smi::cast(*value)->value()); |
| 298 ASSERT(check != RECEIVER_MAP_CHECK); | 299 ASSERT(check != RECEIVER_MAP_CHECK); |
| 299 return check; | 300 return check; |
| 300 } | 301 } |
| 301 | 302 |
| 302 | 303 |
| 303 Handle<JSFunction> TypeFeedbackOracle::GetCallTarget(Call* expr) { | 304 Handle<JSFunction> TypeFeedbackOracle::GetCallTarget(Call* expr) { |
| 304 Handle<Object> info = GetInfo(expr->CallFeedbackId()); | 305 Handle<Object> info = GetInfo(expr->CallFeedbackId()); |
| 305 if (info->IsSmi()) { | 306 if (info->IsAllocationSite()) { |
| 306 ASSERT(static_cast<ElementsKind>(Smi::cast(*info)->value()) <= | |
| 307 LAST_FAST_ELEMENTS_KIND); | |
| 308 return Handle<JSFunction>(isolate_->global_context()->array_function()); | 307 return Handle<JSFunction>(isolate_->global_context()->array_function()); |
| 309 } else { | 308 } else { |
| 310 return Handle<JSFunction>::cast(info); | 309 return Handle<JSFunction>::cast(info); |
| 311 } | 310 } |
| 312 } | 311 } |
| 313 | 312 |
| 314 | 313 |
| 315 Handle<JSFunction> TypeFeedbackOracle::GetCallNewTarget(CallNew* expr) { | 314 Handle<JSFunction> TypeFeedbackOracle::GetCallNewTarget(CallNew* expr) { |
| 316 Handle<Object> info = GetInfo(expr->CallNewFeedbackId()); | 315 Handle<Object> info = GetInfo(expr->CallNewFeedbackId()); |
| 317 if (info->IsSmi()) { | 316 if (info->IsAllocationSite()) { |
| 318 ASSERT(static_cast<ElementsKind>(Smi::cast(*info)->value()) <= | |
| 319 LAST_FAST_ELEMENTS_KIND); | |
| 320 return Handle<JSFunction>(isolate_->global_context()->array_function()); | 317 return Handle<JSFunction>(isolate_->global_context()->array_function()); |
| 321 } else { | 318 } else { |
| 322 return Handle<JSFunction>::cast(info); | 319 return Handle<JSFunction>::cast(info); |
| 323 } | 320 } |
| 324 } | 321 } |
| 325 | 322 |
| 326 | 323 |
| 327 Handle<Cell> TypeFeedbackOracle::GetCallNewAllocationInfoCell(CallNew* expr) { | 324 Handle<Cell> TypeFeedbackOracle::GetCallNewAllocationInfoCell(CallNew* expr) { |
| 328 return GetInfoCell(expr->CallNewFeedbackId()); | 325 return GetInfoCell(expr->CallNewFeedbackId()); |
| 329 } | 326 } |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 void TypeFeedbackOracle::ProcessTypeFeedbackCells(Handle<Code> code) { | 658 void TypeFeedbackOracle::ProcessTypeFeedbackCells(Handle<Code> code) { |
| 662 Object* raw_info = code->type_feedback_info(); | 659 Object* raw_info = code->type_feedback_info(); |
| 663 if (!raw_info->IsTypeFeedbackInfo()) return; | 660 if (!raw_info->IsTypeFeedbackInfo()) return; |
| 664 Handle<TypeFeedbackCells> cache( | 661 Handle<TypeFeedbackCells> cache( |
| 665 TypeFeedbackInfo::cast(raw_info)->type_feedback_cells()); | 662 TypeFeedbackInfo::cast(raw_info)->type_feedback_cells()); |
| 666 for (int i = 0; i < cache->CellCount(); i++) { | 663 for (int i = 0; i < cache->CellCount(); i++) { |
| 667 TypeFeedbackId ast_id = cache->AstId(i); | 664 TypeFeedbackId ast_id = cache->AstId(i); |
| 668 Cell* cell = cache->GetCell(i); | 665 Cell* cell = cache->GetCell(i); |
| 669 Object* value = cell->value(); | 666 Object* value = cell->value(); |
| 670 if (value->IsSmi() || | 667 if (value->IsSmi() || |
| 668 value->IsAllocationSite() || |
| 671 (value->IsJSFunction() && | 669 (value->IsJSFunction() && |
| 672 !CanRetainOtherContext(JSFunction::cast(value), | 670 !CanRetainOtherContext(JSFunction::cast(value), |
| 673 *native_context_))) { | 671 *native_context_))) { |
| 674 SetInfo(ast_id, cell); | 672 SetInfo(ast_id, cell); |
| 675 } | 673 } |
| 676 } | 674 } |
| 677 } | 675 } |
| 678 | 676 |
| 679 | 677 |
| 680 void TypeFeedbackOracle::SetInfo(TypeFeedbackId ast_id, Object* target) { | 678 void TypeFeedbackOracle::SetInfo(TypeFeedbackId ast_id, Object* target) { |
| 681 ASSERT(dictionary_->FindEntry(IdToKey(ast_id)) == | 679 ASSERT(dictionary_->FindEntry(IdToKey(ast_id)) == |
| 682 UnseededNumberDictionary::kNotFound); | 680 UnseededNumberDictionary::kNotFound); |
| 683 MaybeObject* maybe_result = dictionary_->AtNumberPut(IdToKey(ast_id), target); | 681 MaybeObject* maybe_result = dictionary_->AtNumberPut(IdToKey(ast_id), target); |
| 684 USE(maybe_result); | 682 USE(maybe_result); |
| 685 #ifdef DEBUG | 683 #ifdef DEBUG |
| 686 Object* result = NULL; | 684 Object* result = NULL; |
| 687 // Dictionary has been allocated with sufficient size for all elements. | 685 // Dictionary has been allocated with sufficient size for all elements. |
| 688 ASSERT(maybe_result->ToObject(&result)); | 686 ASSERT(maybe_result->ToObject(&result)); |
| 689 ASSERT(*dictionary_ == result); | 687 ASSERT(*dictionary_ == result); |
| 690 #endif | 688 #endif |
| 691 } | 689 } |
| 692 | 690 |
| 693 } } // namespace v8::internal | 691 } } // namespace v8::internal |
| OLD | NEW |