Chromium Code Reviews| 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 7678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7689 ASSERT(function->context()->native_context() == code_map->get(index - 1)); | 7689 ASSERT(function->context()->native_context() == code_map->get(index - 1)); |
| 7690 function->ReplaceCode(code); | 7690 function->ReplaceCode(code); |
| 7691 } | 7691 } |
| 7692 | 7692 |
| 7693 | 7693 |
| 7694 bool JSFunction::CompileLazy(Handle<JSFunction> function, | 7694 bool JSFunction::CompileLazy(Handle<JSFunction> function, |
| 7695 ClearExceptionFlag flag) { | 7695 ClearExceptionFlag flag) { |
| 7696 bool result = true; | 7696 bool result = true; |
| 7697 if (function->shared()->is_compiled()) { | 7697 if (function->shared()->is_compiled()) { |
| 7698 function->ReplaceCode(function->shared()->code()); | 7698 function->ReplaceCode(function->shared()->code()); |
| 7699 function->shared()->set_code_age(0); | |
| 7700 } else { | 7699 } else { |
| 7701 ASSERT(function->shared()->allows_lazy_compilation()); | 7700 ASSERT(function->shared()->allows_lazy_compilation()); |
| 7702 CompilationInfoWithZone info(function); | 7701 CompilationInfoWithZone info(function); |
| 7703 result = CompileLazyHelper(&info, flag); | 7702 result = CompileLazyHelper(&info, flag); |
| 7704 ASSERT(!result || function->is_compiled()); | 7703 ASSERT(!result || function->is_compiled()); |
| 7705 } | 7704 } |
| 7706 return result; | 7705 return result; |
| 7707 } | 7706 } |
| 7708 | 7707 |
| 7709 | 7708 |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8277 | 8276 |
| 8278 void ObjectVisitor::VisitCodeTarget(RelocInfo* rinfo) { | 8277 void ObjectVisitor::VisitCodeTarget(RelocInfo* rinfo) { |
| 8279 ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode())); | 8278 ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode())); |
| 8280 Object* target = Code::GetCodeFromTargetAddress(rinfo->target_address()); | 8279 Object* target = Code::GetCodeFromTargetAddress(rinfo->target_address()); |
| 8281 Object* old_target = target; | 8280 Object* old_target = target; |
| 8282 VisitPointer(&target); | 8281 VisitPointer(&target); |
| 8283 CHECK_EQ(target, old_target); // VisitPointer doesn't change Code* *target. | 8282 CHECK_EQ(target, old_target); // VisitPointer doesn't change Code* *target. |
| 8284 } | 8283 } |
| 8285 | 8284 |
| 8286 | 8285 |
| 8286 void ObjectVisitor::VisitCodeAgeSequence(RelocInfo* rinfo) { | |
| 8287 ASSERT(RelocInfo::IsCodeAgeSequence(rinfo->rmode())); | |
| 8288 Object* stub = rinfo->code_age_stub(); | |
| 8289 if (stub) { | |
| 8290 VisitPointer(&stub); | |
| 8291 } | |
| 8292 } | |
| 8293 | |
| 8294 | |
| 8287 void ObjectVisitor::VisitCodeEntry(Address entry_address) { | 8295 void ObjectVisitor::VisitCodeEntry(Address entry_address) { |
| 8288 Object* code = Code::GetObjectFromEntryAddress(entry_address); | 8296 Object* code = Code::GetObjectFromEntryAddress(entry_address); |
| 8289 Object* old_code = code; | 8297 Object* old_code = code; |
| 8290 VisitPointer(&code); | 8298 VisitPointer(&code); |
| 8291 if (code != old_code) { | 8299 if (code != old_code) { |
| 8292 Memory::Address_at(entry_address) = reinterpret_cast<Code*>(code)->entry(); | 8300 Memory::Address_at(entry_address) = reinterpret_cast<Code*>(code)->entry(); |
| 8293 } | 8301 } |
| 8294 } | 8302 } |
| 8295 | 8303 |
| 8296 | 8304 |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8489 } | 8497 } |
| 8490 } | 8498 } |
| 8491 | 8499 |
| 8492 | 8500 |
| 8493 bool Code::allowed_in_shared_map_code_cache() { | 8501 bool Code::allowed_in_shared_map_code_cache() { |
| 8494 return is_keyed_load_stub() || is_keyed_store_stub() || | 8502 return is_keyed_load_stub() || is_keyed_store_stub() || |
| 8495 (is_compare_ic_stub() && compare_state() == CompareIC::KNOWN_OBJECTS); | 8503 (is_compare_ic_stub() && compare_state() == CompareIC::KNOWN_OBJECTS); |
| 8496 } | 8504 } |
| 8497 | 8505 |
| 8498 | 8506 |
| 8507 void Code::MakeCodeAgeSequenceYoung(byte* sequence) { | |
| 8508 PatchPlatformCodeAge(sequence, kNoAge, NO_MARKING_PARITY); | |
| 8509 } | |
| 8510 | |
| 8511 | |
| 8512 void Code::MakeYoung() { | |
| 8513 byte* sequence = FindCodeAgeSequence(); | |
| 8514 if (sequence != NULL) { | |
| 8515 PatchPlatformCodeAge(sequence, kNoAge, NO_MARKING_PARITY); | |
| 8516 } | |
| 8517 } | |
| 8518 | |
| 8519 | |
| 8520 void Code::MakeOlder() { | |
|
Michael Starzinger
2012/09/21 09:43:19
I think MakeOlder should only be called from the G
danno
2012/10/25 10:07:23
Done.
| |
| 8521 byte* sequence = FindCodeAgeSequence(); | |
| 8522 if (sequence != NULL) { | |
| 8523 Age age; | |
| 8524 MarkingParity code_parity; | |
| 8525 MarkingParity current_parity = GetHeap()->marking_parity(); | |
|
Michael Starzinger
2012/09/21 09:43:19
Can we remove the marking_parity getter in Heap?
danno
2012/10/25 10:07:23
Done.
| |
| 8526 GetCodeAgeAndParity(sequence, &age, &code_parity); | |
| 8527 if (age != kLastCodeAge && code_parity != current_parity) { | |
| 8528 PatchPlatformCodeAge(sequence, static_cast<Age>(age + 1), | |
| 8529 current_parity); | |
| 8530 } | |
| 8531 } | |
| 8532 } | |
| 8533 | |
| 8534 | |
| 8535 bool Code::IsOld() { | |
| 8536 byte* sequence = FindCodeAgeSequence(); | |
| 8537 if (sequence == NULL) return false; | |
| 8538 Age age; | |
| 8539 MarkingParity parity; | |
| 8540 GetCodeAgeAndParity(sequence, &age, &parity); | |
| 8541 return age >= kSexagenarianCodeAge; | |
| 8542 } | |
| 8543 | |
| 8544 | |
| 8545 byte* Code::FindCodeAgeSequence() { | |
| 8546 if (kind() != FUNCTION && kind() != OPTIMIZED_FUNCTION) return NULL; | |
| 8547 if (strlen(FLAG_stop_at) == 0 && | |
| 8548 !ProfileEntryHookStub::HasEntryHook() && | |
| 8549 (kind() == FUNCTION && !has_debug_break_slots())) { | |
| 8550 return FindPlatformCodeAgeSequence(); | |
| 8551 } | |
| 8552 return NULL; | |
| 8553 } | |
| 8554 | |
| 8555 | |
| 8556 void Code::GetCodeAgeAndParity(Code* code, Age* age, | |
| 8557 MarkingParity* parity) { | |
| 8558 Isolate* isolate = Isolate::Current(); | |
| 8559 Builtins* builtins = isolate->builtins(); | |
| 8560 Code* stub = NULL; | |
| 8561 #define HANDLE_CODE_AGE(AGE) \ | |
| 8562 stub = *builtins->Make##AGE##CodeYoungAgainEvenMarking(); \ | |
| 8563 if (code == stub) { \ | |
| 8564 *age = k##AGE##CodeAge; \ | |
| 8565 *parity = EVEN_MARKING_PARITY; \ | |
| 8566 return; \ | |
| 8567 } \ | |
| 8568 stub = *builtins->Make##AGE##CodeYoungAgainOddMarking(); \ | |
| 8569 if (code == stub) { \ | |
| 8570 *age = k##AGE##CodeAge; \ | |
| 8571 *parity = ODD_MARKING_PARITY; \ | |
| 8572 return; \ | |
| 8573 } | |
| 8574 CODE_AGE_LIST(HANDLE_CODE_AGE) | |
| 8575 #undef HANDLE_CODE_AGE | |
| 8576 UNREACHABLE(); | |
| 8577 } | |
| 8578 | |
| 8579 | |
| 8580 Code* Code::GetCodeAgeStub(Age age, MarkingParity parity) { | |
| 8581 Isolate* isolate = Isolate::Current(); | |
| 8582 Builtins* builtins = isolate->builtins(); | |
| 8583 switch (age) { | |
| 8584 #define HANDLE_CODE_AGE(AGE) \ | |
| 8585 case k##AGE##CodeAge: { \ | |
| 8586 Code* stub = parity == EVEN_MARKING_PARITY \ | |
| 8587 ? *builtins->Make##AGE##CodeYoungAgainEvenMarking() \ | |
| 8588 : *builtins->Make##AGE##CodeYoungAgainOddMarking(); \ | |
| 8589 return stub; \ | |
| 8590 } | |
| 8591 CODE_AGE_LIST(HANDLE_CODE_AGE) | |
| 8592 #undef HANDLE_CODE_AGE | |
| 8593 default: | |
| 8594 UNREACHABLE(); | |
| 8595 break; | |
| 8596 } | |
| 8597 return NULL; | |
| 8598 } | |
| 8599 | |
| 8600 | |
| 8499 #ifdef ENABLE_DISASSEMBLER | 8601 #ifdef ENABLE_DISASSEMBLER |
| 8500 | 8602 |
| 8501 void DeoptimizationInputData::DeoptimizationInputDataPrint(FILE* out) { | 8603 void DeoptimizationInputData::DeoptimizationInputDataPrint(FILE* out) { |
| 8502 disasm::NameConverter converter; | 8604 disasm::NameConverter converter; |
| 8503 int deopt_count = DeoptCount(); | 8605 int deopt_count = DeoptCount(); |
| 8504 PrintF(out, "Deoptimization Input Data (deopt points = %d)\n", deopt_count); | 8606 PrintF(out, "Deoptimization Input Data (deopt points = %d)\n", deopt_count); |
| 8505 if (0 == deopt_count) return; | 8607 if (0 == deopt_count) return; |
| 8506 | 8608 |
| 8507 PrintF(out, "%6s %6s %6s %6s %12s\n", "index", "ast id", "argc", "pc", | 8609 PrintF(out, "%6s %6s %6s %6s %12s\n", "index", "ast id", "argc", "pc", |
| 8508 FLAG_print_code_verbose ? "commands" : ""); | 8610 FLAG_print_code_verbose ? "commands" : ""); |
| (...skipping 4993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13502 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 13604 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
| 13503 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 13605 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
| 13504 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 13606 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
| 13505 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 13607 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
| 13506 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 13608 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
| 13507 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 13609 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
| 13508 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 13610 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
| 13509 } | 13611 } |
| 13510 | 13612 |
| 13511 } } // namespace v8::internal | 13613 } } // namespace v8::internal |
| OLD | NEW |