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 7774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7785 FixedArray* code_map = FixedArray::cast(optimized_code_map()); | 7785 FixedArray* code_map = FixedArray::cast(optimized_code_map()); |
7786 if (!bound()) { | 7786 if (!bound()) { |
7787 FixedArray* cached_literals = FixedArray::cast(code_map->get(index + 1)); | 7787 FixedArray* cached_literals = FixedArray::cast(code_map->get(index + 1)); |
7788 ASSERT(cached_literals != NULL); | 7788 ASSERT(cached_literals != NULL); |
7789 function->set_literals(cached_literals); | 7789 function->set_literals(cached_literals); |
7790 } | 7790 } |
7791 Code* code = Code::cast(code_map->get(index)); | 7791 Code* code = Code::cast(code_map->get(index)); |
7792 ASSERT(code != NULL); | 7792 ASSERT(code != NULL); |
7793 ASSERT(function->context()->native_context() == code_map->get(index - 1)); | 7793 ASSERT(function->context()->native_context() == code_map->get(index - 1)); |
7794 function->ReplaceCode(code); | 7794 function->ReplaceCode(code); |
| 7795 code->MakeYoung(); |
7795 } | 7796 } |
7796 | 7797 |
7797 | 7798 |
7798 bool JSFunction::CompileLazy(Handle<JSFunction> function, | 7799 bool JSFunction::CompileLazy(Handle<JSFunction> function, |
7799 ClearExceptionFlag flag) { | 7800 ClearExceptionFlag flag) { |
7800 bool result = true; | 7801 bool result = true; |
7801 if (function->shared()->is_compiled()) { | 7802 if (function->shared()->is_compiled()) { |
7802 function->ReplaceCode(function->shared()->code()); | 7803 function->ReplaceCode(function->shared()->code()); |
7803 function->shared()->set_code_age(0); | 7804 function->shared()->set_code_age(0); |
7804 } else { | 7805 } else { |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8381 | 8382 |
8382 void ObjectVisitor::VisitCodeTarget(RelocInfo* rinfo) { | 8383 void ObjectVisitor::VisitCodeTarget(RelocInfo* rinfo) { |
8383 ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode())); | 8384 ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode())); |
8384 Object* target = Code::GetCodeFromTargetAddress(rinfo->target_address()); | 8385 Object* target = Code::GetCodeFromTargetAddress(rinfo->target_address()); |
8385 Object* old_target = target; | 8386 Object* old_target = target; |
8386 VisitPointer(&target); | 8387 VisitPointer(&target); |
8387 CHECK_EQ(target, old_target); // VisitPointer doesn't change Code* *target. | 8388 CHECK_EQ(target, old_target); // VisitPointer doesn't change Code* *target. |
8388 } | 8389 } |
8389 | 8390 |
8390 | 8391 |
| 8392 void ObjectVisitor::VisitCodeAgeSequence(RelocInfo* rinfo) { |
| 8393 ASSERT(RelocInfo::IsCodeAgeSequence(rinfo->rmode())); |
| 8394 Object* stub = rinfo->code_age_stub(); |
| 8395 if (stub) { |
| 8396 VisitPointer(&stub); |
| 8397 } |
| 8398 } |
| 8399 |
| 8400 |
8391 void ObjectVisitor::VisitCodeEntry(Address entry_address) { | 8401 void ObjectVisitor::VisitCodeEntry(Address entry_address) { |
8392 Object* code = Code::GetObjectFromEntryAddress(entry_address); | 8402 Object* code = Code::GetObjectFromEntryAddress(entry_address); |
8393 Object* old_code = code; | 8403 Object* old_code = code; |
8394 VisitPointer(&code); | 8404 VisitPointer(&code); |
8395 if (code != old_code) { | 8405 if (code != old_code) { |
8396 Memory::Address_at(entry_address) = reinterpret_cast<Code*>(code)->entry(); | 8406 Memory::Address_at(entry_address) = reinterpret_cast<Code*>(code)->entry(); |
8397 } | 8407 } |
8398 } | 8408 } |
8399 | 8409 |
8400 | 8410 |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8593 } | 8603 } |
8594 } | 8604 } |
8595 | 8605 |
8596 | 8606 |
8597 bool Code::allowed_in_shared_map_code_cache() { | 8607 bool Code::allowed_in_shared_map_code_cache() { |
8598 return is_keyed_load_stub() || is_keyed_store_stub() || | 8608 return is_keyed_load_stub() || is_keyed_store_stub() || |
8599 (is_compare_ic_stub() && compare_state() == CompareIC::KNOWN_OBJECTS); | 8609 (is_compare_ic_stub() && compare_state() == CompareIC::KNOWN_OBJECTS); |
8600 } | 8610 } |
8601 | 8611 |
8602 | 8612 |
| 8613 void Code::MakeCodeAgeSequenceYoung(byte* sequence) { |
| 8614 PatchPlatformCodeAge(sequence, kNoAge, NO_MARKING_PARITY); |
| 8615 } |
| 8616 |
| 8617 |
| 8618 void Code::MakeYoung() { |
| 8619 byte* sequence = FindCodeAgeSequence(); |
| 8620 if (sequence != NULL) { |
| 8621 PatchPlatformCodeAge(sequence, kNoAge, NO_MARKING_PARITY); |
| 8622 } |
| 8623 } |
| 8624 |
| 8625 |
| 8626 void Code::MakeOlder(MarkingParity current_parity) { |
| 8627 byte* sequence = FindCodeAgeSequence(); |
| 8628 if (sequence != NULL) { |
| 8629 Age age; |
| 8630 MarkingParity code_parity; |
| 8631 GetCodeAgeAndParity(sequence, &age, &code_parity); |
| 8632 if (age != kLastCodeAge && code_parity != current_parity) { |
| 8633 PatchPlatformCodeAge(sequence, static_cast<Age>(age + 1), |
| 8634 current_parity); |
| 8635 } |
| 8636 } |
| 8637 } |
| 8638 |
| 8639 |
| 8640 bool Code::IsOld() { |
| 8641 byte* sequence = FindCodeAgeSequence(); |
| 8642 if (sequence == NULL) return false; |
| 8643 Age age; |
| 8644 MarkingParity parity; |
| 8645 GetCodeAgeAndParity(sequence, &age, &parity); |
| 8646 return age >= kSexagenarianCodeAge; |
| 8647 } |
| 8648 |
| 8649 |
| 8650 byte* Code::FindCodeAgeSequence() { |
| 8651 if (kind() != FUNCTION && kind() != OPTIMIZED_FUNCTION) return NULL; |
| 8652 if (strlen(FLAG_stop_at) == 0 && |
| 8653 !ProfileEntryHookStub::HasEntryHook() && |
| 8654 (kind() == FUNCTION && !has_debug_break_slots())) { |
| 8655 return FindPlatformCodeAgeSequence(); |
| 8656 } |
| 8657 return NULL; |
| 8658 } |
| 8659 |
| 8660 |
| 8661 void Code::GetCodeAgeAndParity(Code* code, Age* age, |
| 8662 MarkingParity* parity) { |
| 8663 Isolate* isolate = Isolate::Current(); |
| 8664 Builtins* builtins = isolate->builtins(); |
| 8665 Code* stub = NULL; |
| 8666 #define HANDLE_CODE_AGE(AGE) \ |
| 8667 stub = *builtins->Make##AGE##CodeYoungAgainEvenMarking(); \ |
| 8668 if (code == stub) { \ |
| 8669 *age = k##AGE##CodeAge; \ |
| 8670 *parity = EVEN_MARKING_PARITY; \ |
| 8671 return; \ |
| 8672 } \ |
| 8673 stub = *builtins->Make##AGE##CodeYoungAgainOddMarking(); \ |
| 8674 if (code == stub) { \ |
| 8675 *age = k##AGE##CodeAge; \ |
| 8676 *parity = ODD_MARKING_PARITY; \ |
| 8677 return; \ |
| 8678 } |
| 8679 CODE_AGE_LIST(HANDLE_CODE_AGE) |
| 8680 #undef HANDLE_CODE_AGE |
| 8681 UNREACHABLE(); |
| 8682 } |
| 8683 |
| 8684 |
| 8685 Code* Code::GetCodeAgeStub(Age age, MarkingParity parity) { |
| 8686 Isolate* isolate = Isolate::Current(); |
| 8687 Builtins* builtins = isolate->builtins(); |
| 8688 switch (age) { |
| 8689 #define HANDLE_CODE_AGE(AGE) \ |
| 8690 case k##AGE##CodeAge: { \ |
| 8691 Code* stub = parity == EVEN_MARKING_PARITY \ |
| 8692 ? *builtins->Make##AGE##CodeYoungAgainEvenMarking() \ |
| 8693 : *builtins->Make##AGE##CodeYoungAgainOddMarking(); \ |
| 8694 return stub; \ |
| 8695 } |
| 8696 CODE_AGE_LIST(HANDLE_CODE_AGE) |
| 8697 #undef HANDLE_CODE_AGE |
| 8698 default: |
| 8699 UNREACHABLE(); |
| 8700 break; |
| 8701 } |
| 8702 return NULL; |
| 8703 } |
| 8704 |
| 8705 |
8603 #ifdef ENABLE_DISASSEMBLER | 8706 #ifdef ENABLE_DISASSEMBLER |
8604 | 8707 |
8605 void DeoptimizationInputData::DeoptimizationInputDataPrint(FILE* out) { | 8708 void DeoptimizationInputData::DeoptimizationInputDataPrint(FILE* out) { |
8606 disasm::NameConverter converter; | 8709 disasm::NameConverter converter; |
8607 int deopt_count = DeoptCount(); | 8710 int deopt_count = DeoptCount(); |
8608 PrintF(out, "Deoptimization Input Data (deopt points = %d)\n", deopt_count); | 8711 PrintF(out, "Deoptimization Input Data (deopt points = %d)\n", deopt_count); |
8609 if (0 == deopt_count) return; | 8712 if (0 == deopt_count) return; |
8610 | 8713 |
8611 PrintF(out, "%6s %6s %6s %6s %12s\n", "index", "ast id", "argc", "pc", | 8714 PrintF(out, "%6s %6s %6s %6s %12s\n", "index", "ast id", "argc", "pc", |
8612 FLAG_print_code_verbose ? "commands" : ""); | 8715 FLAG_print_code_verbose ? "commands" : ""); |
(...skipping 5015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13628 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 13731 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
13629 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 13732 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
13630 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 13733 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
13631 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 13734 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
13632 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 13735 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
13633 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 13736 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
13634 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 13737 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
13635 } | 13738 } |
13636 | 13739 |
13637 } } // namespace v8::internal | 13740 } } // namespace v8::internal |
OLD | NEW |