OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 byte* new_start) { | 489 byte* new_start) { |
490 for (int i = 0; i < infos->length(); i++) { | 490 for (int i = 0; i < infos->length(); i++) { |
491 RelocInfo* info = &(*infos)[i]; | 491 RelocInfo* info = &(*infos)[i]; |
492 info->set_pc(new_start + (info->pc() - old_start)); | 492 info->set_pc(new_start + (info->pc() - old_start)); |
493 } | 493 } |
494 } | 494 } |
495 | 495 |
496 | 496 |
497 void TypeFeedbackOracle::ProcessRelocInfos(ZoneList<RelocInfo>* infos) { | 497 void TypeFeedbackOracle::ProcessRelocInfos(ZoneList<RelocInfo>* infos) { |
498 for (int i = 0; i < infos->length(); i++) { | 498 for (int i = 0; i < infos->length(); i++) { |
499 Address target_address = (*infos)[i].target_address(); | 499 RelocInfo reloc_entry = (*infos)[i]; |
| 500 Address target_address = reloc_entry.target_address(); |
500 unsigned ast_id = static_cast<unsigned>((*infos)[i].data()); | 501 unsigned ast_id = static_cast<unsigned>((*infos)[i].data()); |
501 ProcessTargetAt(target_address, ast_id); | 502 Code* target = Code::GetCodeFromTargetAddress(target_address); |
| 503 switch (target->kind()) { |
| 504 case Code::LOAD_IC: |
| 505 case Code::STORE_IC: |
| 506 case Code::CALL_IC: |
| 507 case Code::KEYED_CALL_IC: |
| 508 if (target->ic_state() == MONOMORPHIC) { |
| 509 if (target->kind() == Code::CALL_IC && |
| 510 target->check_type() != RECEIVER_MAP_CHECK) { |
| 511 SetInfo(ast_id, Smi::FromInt(target->check_type())); |
| 512 } else { |
| 513 Object* map = target->FindFirstMap(); |
| 514 SetInfo(ast_id, map == NULL ? static_cast<Object*>(target) : map); |
| 515 } |
| 516 } else if (target->ic_state() == MEGAMORPHIC) { |
| 517 SetInfo(ast_id, target); |
| 518 } |
| 519 break; |
| 520 |
| 521 case Code::KEYED_LOAD_IC: |
| 522 case Code::KEYED_STORE_IC: |
| 523 if (target->ic_state() == MONOMORPHIC || |
| 524 target->ic_state() == MEGAMORPHIC) { |
| 525 SetInfo(ast_id, target); |
| 526 } |
| 527 break; |
| 528 |
| 529 case Code::UNARY_OP_IC: |
| 530 case Code::BINARY_OP_IC: |
| 531 case Code::COMPARE_IC: |
| 532 case Code::TO_BOOLEAN_IC: |
| 533 SetInfo(ast_id, target); |
| 534 break; |
| 535 |
| 536 case Code::STUB: |
| 537 if (target->major_key() == CodeStub::CallFunction && |
| 538 target->has_function_cache()) { |
| 539 Object* value = CallFunctionStub::GetCachedValue(reloc_entry.pc()); |
| 540 if (value->IsJSFunction()) { |
| 541 SetInfo(ast_id, value); |
| 542 } |
| 543 } |
| 544 break; |
| 545 |
| 546 default: |
| 547 break; |
| 548 } |
502 } | 549 } |
503 } | 550 } |
504 | 551 |
505 | |
506 void TypeFeedbackOracle::ProcessTargetAt(Address target_address, | |
507 unsigned ast_id) { | |
508 Code* target = Code::GetCodeFromTargetAddress(target_address); | |
509 switch (target->kind()) { | |
510 case Code::LOAD_IC: | |
511 case Code::STORE_IC: | |
512 case Code::CALL_IC: | |
513 case Code::KEYED_CALL_IC: | |
514 if (target->ic_state() == MONOMORPHIC) { | |
515 if (target->kind() == Code::CALL_IC && | |
516 target->check_type() != RECEIVER_MAP_CHECK) { | |
517 SetInfo(ast_id, Smi::FromInt(target->check_type())); | |
518 } else { | |
519 Object* map = target->FindFirstMap(); | |
520 SetInfo(ast_id, map == NULL ? static_cast<Object*>(target) : map); | |
521 } | |
522 } else if (target->ic_state() == MEGAMORPHIC) { | |
523 SetInfo(ast_id, target); | |
524 } | |
525 break; | |
526 | |
527 case Code::KEYED_LOAD_IC: | |
528 case Code::KEYED_STORE_IC: | |
529 if (target->ic_state() == MONOMORPHIC || | |
530 target->ic_state() == MEGAMORPHIC) { | |
531 SetInfo(ast_id, target); | |
532 } | |
533 break; | |
534 | |
535 case Code::UNARY_OP_IC: | |
536 case Code::BINARY_OP_IC: | |
537 case Code::COMPARE_IC: | |
538 case Code::TO_BOOLEAN_IC: | |
539 SetInfo(ast_id, target); | |
540 break; | |
541 | |
542 case Code::STUB: | |
543 if (target->major_key() == CodeStub::CallFunction && | |
544 target->has_function_cache()) { | |
545 Object* value = CallFunctionStub::GetCachedValue(target_address); | |
546 if (value->IsJSFunction()) { | |
547 SetInfo(ast_id, value); | |
548 } | |
549 } | |
550 break; | |
551 | |
552 default: | |
553 break; | |
554 } | |
555 } | |
556 | |
557 | 552 |
558 void TypeFeedbackOracle::SetInfo(unsigned ast_id, Object* target) { | 553 void TypeFeedbackOracle::SetInfo(unsigned ast_id, Object* target) { |
559 ASSERT(dictionary_->FindEntry(ast_id) == NumberDictionary::kNotFound); | 554 ASSERT(dictionary_->FindEntry(ast_id) == NumberDictionary::kNotFound); |
560 MaybeObject* maybe_result = dictionary_->AtNumberPut(ast_id, target); | 555 MaybeObject* maybe_result = dictionary_->AtNumberPut(ast_id, target); |
561 USE(maybe_result); | 556 USE(maybe_result); |
562 #ifdef DEBUG | 557 #ifdef DEBUG |
563 Object* result = NULL; | 558 Object* result = NULL; |
564 // Dictionary has been allocated with sufficient size for all elements. | 559 // Dictionary has been allocated with sufficient size for all elements. |
565 ASSERT(maybe_result->ToObject(&result)); | 560 ASSERT(maybe_result->ToObject(&result)); |
566 ASSERT(*dictionary_ == result); | 561 ASSERT(*dictionary_ == result); |
567 #endif | 562 #endif |
568 } | 563 } |
569 | 564 |
570 } } // namespace v8::internal | 565 } } // namespace v8::internal |
OLD | NEW |