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 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID); | 427 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID); |
428 for (RelocIterator it(*code, mask); !it.done(); it.next()) { | 428 for (RelocIterator it(*code, mask); !it.done(); it.next()) { |
429 infos->Add(*it.rinfo(), zone()); | 429 infos->Add(*it.rinfo(), zone()); |
430 } | 430 } |
431 } | 431 } |
432 | 432 |
433 | 433 |
434 void TypeFeedbackOracle::CreateDictionary(Handle<Code> code, | 434 void TypeFeedbackOracle::CreateDictionary(Handle<Code> code, |
435 ZoneList<RelocInfo>* infos) { | 435 ZoneList<RelocInfo>* infos) { |
436 AllowHeapAllocation allocation_allowed; | 436 AllowHeapAllocation allocation_allowed; |
437 byte* old_start = code->instruction_start(); | 437 Code* old_code = *code; |
438 dictionary_ = | 438 dictionary_ = |
439 isolate()->factory()->NewUnseededNumberDictionary(infos->length()); | 439 isolate()->factory()->NewUnseededNumberDictionary(infos->length()); |
440 byte* new_start = code->instruction_start(); | 440 RelocateRelocInfos(infos, old_code, *code); |
441 RelocateRelocInfos(infos, old_start, new_start); | |
442 } | 441 } |
443 | 442 |
444 | 443 |
445 void TypeFeedbackOracle::RelocateRelocInfos(ZoneList<RelocInfo>* infos, | 444 void TypeFeedbackOracle::RelocateRelocInfos(ZoneList<RelocInfo>* infos, |
446 byte* old_start, | 445 Code* old_code, |
447 byte* new_start) { | 446 Code* new_code) { |
448 for (int i = 0; i < infos->length(); i++) { | 447 for (int i = 0; i < infos->length(); i++) { |
449 RelocInfo* info = &(*infos)[i]; | 448 RelocInfo* info = &(*infos)[i]; |
450 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())); |
451 } | 452 } |
452 } | 453 } |
453 | 454 |
454 | 455 |
455 void TypeFeedbackOracle::ProcessRelocInfos(ZoneList<RelocInfo>* infos) { | 456 void TypeFeedbackOracle::ProcessRelocInfos(ZoneList<RelocInfo>* infos) { |
456 for (int i = 0; i < infos->length(); i++) { | 457 for (int i = 0; i < infos->length(); i++) { |
457 RelocInfo reloc_entry = (*infos)[i]; | 458 RelocInfo reloc_entry = (*infos)[i]; |
458 Address target_address = reloc_entry.target_address(); | 459 Address target_address = reloc_entry.target_address(); |
459 TypeFeedbackId ast_id = | 460 TypeFeedbackId ast_id = |
460 TypeFeedbackId(static_cast<unsigned>((*infos)[i].data())); | 461 TypeFeedbackId(static_cast<unsigned>((*infos)[i].data())); |
(...skipping 25 matching lines...) Expand all Loading... |
486 #ifdef DEBUG | 487 #ifdef DEBUG |
487 Object* result = NULL; | 488 Object* result = NULL; |
488 // Dictionary has been allocated with sufficient size for all elements. | 489 // Dictionary has been allocated with sufficient size for all elements. |
489 ASSERT(maybe_result->ToObject(&result)); | 490 ASSERT(maybe_result->ToObject(&result)); |
490 ASSERT(*dictionary_ == result); | 491 ASSERT(*dictionary_ == result); |
491 #endif | 492 #endif |
492 } | 493 } |
493 | 494 |
494 | 495 |
495 } } // namespace v8::internal | 496 } } // namespace v8::internal |
OLD | NEW |