| 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 25 matching lines...) Expand all Loading... |
| 36 #include "type-info.h" | 36 #include "type-info.h" |
| 37 | 37 |
| 38 #include "ic-inl.h" | 38 #include "ic-inl.h" |
| 39 #include "objects-inl.h" | 39 #include "objects-inl.h" |
| 40 | 40 |
| 41 namespace v8 { | 41 namespace v8 { |
| 42 namespace internal { | 42 namespace internal { |
| 43 | 43 |
| 44 | 44 |
| 45 TypeFeedbackOracle::TypeFeedbackOracle(Handle<Code> code, | 45 TypeFeedbackOracle::TypeFeedbackOracle(Handle<Code> code, |
| 46 Handle<FixedArray> feedback_vector, |
| 46 Handle<Context> native_context, | 47 Handle<Context> native_context, |
| 47 Zone* zone) | 48 Zone* zone) |
| 48 : native_context_(native_context), | 49 : native_context_(native_context), |
| 49 zone_(zone) { | 50 zone_(zone), |
| 50 Object* raw_info = code->type_feedback_info(); | 51 feedback_vector_(feedback_vector) { |
| 51 if (raw_info->IsTypeFeedbackInfo()) { | |
| 52 feedback_vector_ = Handle<FixedArray>(TypeFeedbackInfo::cast(raw_info)-> | |
| 53 feedback_vector()); | |
| 54 } | |
| 55 | |
| 56 BuildDictionary(code); | 52 BuildDictionary(code); |
| 57 ASSERT(dictionary_->IsDictionary()); | 53 ASSERT(dictionary_->IsDictionary()); |
| 58 } | 54 } |
| 59 | 55 |
| 60 | 56 |
| 61 static uint32_t IdToKey(TypeFeedbackId ast_id) { | 57 static uint32_t IdToKey(TypeFeedbackId ast_id) { |
| 62 return static_cast<uint32_t>(ast_id.ToInt()); | 58 return static_cast<uint32_t>(ast_id.ToInt()); |
| 63 } | 59 } |
| 64 | 60 |
| 65 | 61 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 121 |
| 126 | 122 |
| 127 bool TypeFeedbackOracle::CallNewIsMonomorphic(int slot) { | 123 bool TypeFeedbackOracle::CallNewIsMonomorphic(int slot) { |
| 128 Handle<Object> info = GetInfo(slot); | 124 Handle<Object> info = GetInfo(slot); |
| 129 return info->IsAllocationSite() || info->IsJSFunction(); | 125 return info->IsAllocationSite() || info->IsJSFunction(); |
| 130 } | 126 } |
| 131 | 127 |
| 132 | 128 |
| 133 byte TypeFeedbackOracle::ForInType(int feedback_vector_slot) { | 129 byte TypeFeedbackOracle::ForInType(int feedback_vector_slot) { |
| 134 Handle<Object> value = GetInfo(feedback_vector_slot); | 130 Handle<Object> value = GetInfo(feedback_vector_slot); |
| 135 return value->IsSmi() && | 131 return value.is_identical_to( |
| 136 Smi::cast(*value)->value() == TypeFeedbackInfo::kForInFastCaseMarker | 132 TypeFeedbackInfo::UninitializedSentinel(isolate())) |
| 137 ? ForInStatement::FAST_FOR_IN : ForInStatement::SLOW_FOR_IN; | 133 ? ForInStatement::FAST_FOR_IN : ForInStatement::SLOW_FOR_IN; |
| 138 } | 134 } |
| 139 | 135 |
| 140 | 136 |
| 141 KeyedAccessStoreMode TypeFeedbackOracle::GetStoreMode( | 137 KeyedAccessStoreMode TypeFeedbackOracle::GetStoreMode( |
| 142 TypeFeedbackId ast_id) { | 138 TypeFeedbackId ast_id) { |
| 143 Handle<Object> maybe_code = GetInfo(ast_id); | 139 Handle<Object> maybe_code = GetInfo(ast_id); |
| 144 if (maybe_code->IsCode()) { | 140 if (maybe_code->IsCode()) { |
| 145 Handle<Code> code = Handle<Code>::cast(maybe_code); | 141 Handle<Code> code = Handle<Code>::cast(maybe_code); |
| 146 if (code->kind() == Code::KEYED_STORE_IC) { | 142 if (code->kind() == Code::KEYED_STORE_IC) { |
| 147 return KeyedStoreIC::GetKeyedAccessStoreMode(code->extra_ic_state()); | 143 return KeyedStoreIC::GetKeyedAccessStoreMode(code->extra_ic_state()); |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID); | 427 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID); |
| 432 for (RelocIterator it(*code, mask); !it.done(); it.next()) { | 428 for (RelocIterator it(*code, mask); !it.done(); it.next()) { |
| 433 infos->Add(*it.rinfo(), zone()); | 429 infos->Add(*it.rinfo(), zone()); |
| 434 } | 430 } |
| 435 } | 431 } |
| 436 | 432 |
| 437 | 433 |
| 438 void TypeFeedbackOracle::CreateDictionary(Handle<Code> code, | 434 void TypeFeedbackOracle::CreateDictionary(Handle<Code> code, |
| 439 ZoneList<RelocInfo>* infos) { | 435 ZoneList<RelocInfo>* infos) { |
| 440 AllowHeapAllocation allocation_allowed; | 436 AllowHeapAllocation allocation_allowed; |
| 441 byte* old_start = code->instruction_start(); | 437 Code* old_code = *code; |
| 442 dictionary_ = | 438 dictionary_ = |
| 443 isolate()->factory()->NewUnseededNumberDictionary(infos->length()); | 439 isolate()->factory()->NewUnseededNumberDictionary(infos->length()); |
| 444 byte* new_start = code->instruction_start(); | 440 RelocateRelocInfos(infos, old_code, *code); |
| 445 RelocateRelocInfos(infos, old_start, new_start); | |
| 446 } | 441 } |
| 447 | 442 |
| 448 | 443 |
| 449 void TypeFeedbackOracle::RelocateRelocInfos(ZoneList<RelocInfo>* infos, | 444 void TypeFeedbackOracle::RelocateRelocInfos(ZoneList<RelocInfo>* infos, |
| 450 byte* old_start, | 445 Code* old_code, |
| 451 byte* new_start) { | 446 Code* new_code) { |
| 452 for (int i = 0; i < infos->length(); i++) { | 447 for (int i = 0; i < infos->length(); i++) { |
| 453 RelocInfo* info = &(*infos)[i]; | 448 RelocInfo* info = &(*infos)[i]; |
| 454 info->set_pc(new_start + (info->pc() - old_start)); | 449 info->set_host(new_code); |
| 450 info->set_pc(new_code->instruction_start() + |
| 451 (info->pc() - old_code->instruction_start())); |
| 455 } | 452 } |
| 456 } | 453 } |
| 457 | 454 |
| 458 | 455 |
| 459 void TypeFeedbackOracle::ProcessRelocInfos(ZoneList<RelocInfo>* infos) { | 456 void TypeFeedbackOracle::ProcessRelocInfos(ZoneList<RelocInfo>* infos) { |
| 460 for (int i = 0; i < infos->length(); i++) { | 457 for (int i = 0; i < infos->length(); i++) { |
| 461 RelocInfo reloc_entry = (*infos)[i]; | 458 RelocInfo reloc_entry = (*infos)[i]; |
| 462 Address target_address = reloc_entry.target_address(); | 459 Address target_address = reloc_entry.target_address(); |
| 463 TypeFeedbackId ast_id = | 460 TypeFeedbackId ast_id = |
| 464 TypeFeedbackId(static_cast<unsigned>((*infos)[i].data())); | 461 TypeFeedbackId(static_cast<unsigned>((*infos)[i].data())); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 490 #ifdef DEBUG | 487 #ifdef DEBUG |
| 491 Object* result = NULL; | 488 Object* result = NULL; |
| 492 // Dictionary has been allocated with sufficient size for all elements. | 489 // Dictionary has been allocated with sufficient size for all elements. |
| 493 ASSERT(maybe_result->ToObject(&result)); | 490 ASSERT(maybe_result->ToObject(&result)); |
| 494 ASSERT(*dictionary_ == result); | 491 ASSERT(*dictionary_ == result); |
| 495 #endif | 492 #endif |
| 496 } | 493 } |
| 497 | 494 |
| 498 | 495 |
| 499 } } // namespace v8::internal | 496 } } // namespace v8::internal |
| OLD | NEW |