| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 73 |
| 74 static uint32_t IdToKey(TypeFeedbackId ast_id) { | 74 static uint32_t IdToKey(TypeFeedbackId ast_id) { |
| 75 return static_cast<uint32_t>(ast_id.ToInt()); | 75 return static_cast<uint32_t>(ast_id.ToInt()); |
| 76 } | 76 } |
| 77 | 77 |
| 78 | 78 |
| 79 Handle<Object> TypeFeedbackOracle::GetInfo(TypeFeedbackId ast_id) { | 79 Handle<Object> TypeFeedbackOracle::GetInfo(TypeFeedbackId ast_id) { |
| 80 int entry = dictionary_->FindEntry(IdToKey(ast_id)); | 80 int entry = dictionary_->FindEntry(IdToKey(ast_id)); |
| 81 if (entry != UnseededNumberDictionary::kNotFound) { | 81 if (entry != UnseededNumberDictionary::kNotFound) { |
| 82 Object* value = dictionary_->ValueAt(entry); | 82 Object* value = dictionary_->ValueAt(entry); |
| 83 if (value->IsJSGlobalPropertyCell()) { | 83 if (value->IsCell()) { |
| 84 JSGlobalPropertyCell* cell = JSGlobalPropertyCell::cast(value); | 84 Cell* cell = Cell::cast(value); |
| 85 return Handle<Object>(cell->value(), isolate_); | 85 return Handle<Object>(cell->value(), isolate_); |
| 86 } else { | 86 } else { |
| 87 return Handle<Object>(value, isolate_); | 87 return Handle<Object>(value, isolate_); |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 return Handle<Object>::cast(isolate_->factory()->undefined_value()); | 90 return Handle<Object>::cast(isolate_->factory()->undefined_value()); |
| 91 } | 91 } |
| 92 | 92 |
| 93 | 93 |
| 94 Handle<JSGlobalPropertyCell> TypeFeedbackOracle::GetInfoCell( | 94 Handle<Cell> TypeFeedbackOracle::GetInfoCell( |
| 95 TypeFeedbackId ast_id) { | 95 TypeFeedbackId ast_id) { |
| 96 int entry = dictionary_->FindEntry(IdToKey(ast_id)); | 96 int entry = dictionary_->FindEntry(IdToKey(ast_id)); |
| 97 if (entry != UnseededNumberDictionary::kNotFound) { | 97 if (entry != UnseededNumberDictionary::kNotFound) { |
| 98 JSGlobalPropertyCell* cell = JSGlobalPropertyCell::cast( | 98 Cell* cell = Cell::cast(dictionary_->ValueAt(entry)); |
| 99 dictionary_->ValueAt(entry)); | 99 return Handle<Cell>(cell, isolate_); |
| 100 return Handle<JSGlobalPropertyCell>(cell, isolate_); | |
| 101 } | 100 } |
| 102 return Handle<JSGlobalPropertyCell>::null(); | 101 return Handle<Cell>::null(); |
| 103 } | 102 } |
| 104 | 103 |
| 105 | 104 |
| 106 bool TypeFeedbackOracle::LoadIsUninitialized(Property* expr) { | 105 bool TypeFeedbackOracle::LoadIsUninitialized(Property* expr) { |
| 107 Handle<Object> map_or_code = GetInfo(expr->PropertyFeedbackId()); | 106 Handle<Object> map_or_code = GetInfo(expr->PropertyFeedbackId()); |
| 108 if (map_or_code->IsMap()) return false; | 107 if (map_or_code->IsMap()) return false; |
| 109 if (map_or_code->IsCode()) { | 108 if (map_or_code->IsCode()) { |
| 110 Handle<Code> code = Handle<Code>::cast(map_or_code); | 109 Handle<Code> code = Handle<Code>::cast(map_or_code); |
| 111 return code->is_inline_cache_stub() && code->ic_state() == UNINITIALIZED; | 110 return code->is_inline_cache_stub() && code->ic_state() == UNINITIALIZED; |
| 112 } | 111 } |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 if (info->IsSmi()) { | 327 if (info->IsSmi()) { |
| 329 ASSERT(static_cast<ElementsKind>(Smi::cast(*info)->value()) <= | 328 ASSERT(static_cast<ElementsKind>(Smi::cast(*info)->value()) <= |
| 330 LAST_FAST_ELEMENTS_KIND); | 329 LAST_FAST_ELEMENTS_KIND); |
| 331 return Handle<JSFunction>(isolate_->global_context()->array_function()); | 330 return Handle<JSFunction>(isolate_->global_context()->array_function()); |
| 332 } else { | 331 } else { |
| 333 return Handle<JSFunction>::cast(info); | 332 return Handle<JSFunction>::cast(info); |
| 334 } | 333 } |
| 335 } | 334 } |
| 336 | 335 |
| 337 | 336 |
| 338 Handle<JSGlobalPropertyCell> TypeFeedbackOracle::GetCallNewAllocationInfoCell( | 337 Handle<Cell> TypeFeedbackOracle::GetCallNewAllocationInfoCell(CallNew* expr) { |
| 339 CallNew* expr) { | |
| 340 return GetInfoCell(expr->CallNewFeedbackId()); | 338 return GetInfoCell(expr->CallNewFeedbackId()); |
| 341 } | 339 } |
| 342 | 340 |
| 343 | 341 |
| 344 Handle<Map> TypeFeedbackOracle::GetObjectLiteralStoreMap( | 342 Handle<Map> TypeFeedbackOracle::GetObjectLiteralStoreMap( |
| 345 ObjectLiteral::Property* prop) { | 343 ObjectLiteral::Property* prop) { |
| 346 ASSERT(ObjectLiteralStoreIsMonomorphic(prop)); | 344 ASSERT(ObjectLiteralStoreIsMonomorphic(prop)); |
| 347 return Handle<Map>::cast(GetInfo(prop->key()->LiteralFeedbackId())); | 345 return Handle<Map>::cast(GetInfo(prop->key()->LiteralFeedbackId())); |
| 348 } | 346 } |
| 349 | 347 |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 } | 750 } |
| 753 | 751 |
| 754 | 752 |
| 755 void TypeFeedbackOracle::ProcessTypeFeedbackCells(Handle<Code> code) { | 753 void TypeFeedbackOracle::ProcessTypeFeedbackCells(Handle<Code> code) { |
| 756 Object* raw_info = code->type_feedback_info(); | 754 Object* raw_info = code->type_feedback_info(); |
| 757 if (!raw_info->IsTypeFeedbackInfo()) return; | 755 if (!raw_info->IsTypeFeedbackInfo()) return; |
| 758 Handle<TypeFeedbackCells> cache( | 756 Handle<TypeFeedbackCells> cache( |
| 759 TypeFeedbackInfo::cast(raw_info)->type_feedback_cells()); | 757 TypeFeedbackInfo::cast(raw_info)->type_feedback_cells()); |
| 760 for (int i = 0; i < cache->CellCount(); i++) { | 758 for (int i = 0; i < cache->CellCount(); i++) { |
| 761 TypeFeedbackId ast_id = cache->AstId(i); | 759 TypeFeedbackId ast_id = cache->AstId(i); |
| 762 JSGlobalPropertyCell* cell = cache->Cell(i); | 760 Cell* cell = cache->GetCell(i); |
| 763 Object* value = cell->value(); | 761 Object* value = cell->value(); |
| 764 if (value->IsSmi() || | 762 if (value->IsSmi() || |
| 765 (value->IsJSFunction() && | 763 (value->IsJSFunction() && |
| 766 !CanRetainOtherContext(JSFunction::cast(value), | 764 !CanRetainOtherContext(JSFunction::cast(value), |
| 767 *native_context_))) { | 765 *native_context_))) { |
| 768 SetInfo(ast_id, cell); | 766 SetInfo(ast_id, cell); |
| 769 } | 767 } |
| 770 } | 768 } |
| 771 } | 769 } |
| 772 | 770 |
| 773 | 771 |
| 774 void TypeFeedbackOracle::SetInfo(TypeFeedbackId ast_id, Object* target) { | 772 void TypeFeedbackOracle::SetInfo(TypeFeedbackId ast_id, Object* target) { |
| 775 ASSERT(dictionary_->FindEntry(IdToKey(ast_id)) == | 773 ASSERT(dictionary_->FindEntry(IdToKey(ast_id)) == |
| 776 UnseededNumberDictionary::kNotFound); | 774 UnseededNumberDictionary::kNotFound); |
| 777 MaybeObject* maybe_result = dictionary_->AtNumberPut(IdToKey(ast_id), target); | 775 MaybeObject* maybe_result = dictionary_->AtNumberPut(IdToKey(ast_id), target); |
| 778 USE(maybe_result); | 776 USE(maybe_result); |
| 779 #ifdef DEBUG | 777 #ifdef DEBUG |
| 780 Object* result = NULL; | 778 Object* result = NULL; |
| 781 // Dictionary has been allocated with sufficient size for all elements. | 779 // Dictionary has been allocated with sufficient size for all elements. |
| 782 ASSERT(maybe_result->ToObject(&result)); | 780 ASSERT(maybe_result->ToObject(&result)); |
| 783 ASSERT(*dictionary_ == result); | 781 ASSERT(*dictionary_ == result); |
| 784 #endif | 782 #endif |
| 785 } | 783 } |
| 786 | 784 |
| 787 } } // namespace v8::internal | 785 } } // namespace v8::internal |
| OLD | NEW |