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 5395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5406 ASSERT(!GetHeap()->InNewSpace(value)); | 5406 ASSERT(!GetHeap()->InNewSpace(value)); |
5407 Address entry = value->entry(); | 5407 Address entry = value->entry(); |
5408 WRITE_INTPTR_FIELD(this, kCodeEntryOffset, reinterpret_cast<intptr_t>(entry)); | 5408 WRITE_INTPTR_FIELD(this, kCodeEntryOffset, reinterpret_cast<intptr_t>(entry)); |
5409 } | 5409 } |
5410 | 5410 |
5411 | 5411 |
5412 void JSFunction::ReplaceCode(Code* code) { | 5412 void JSFunction::ReplaceCode(Code* code) { |
5413 bool was_optimized = IsOptimized(); | 5413 bool was_optimized = IsOptimized(); |
5414 bool is_optimized = code->kind() == Code::OPTIMIZED_FUNCTION; | 5414 bool is_optimized = code->kind() == Code::OPTIMIZED_FUNCTION; |
5415 | 5415 |
| 5416 if (was_optimized && is_optimized) { |
| 5417 shared()->EvictFromOptimizedCodeMap(this->code(), |
| 5418 "Replacing with another optimized code"); |
| 5419 } |
| 5420 |
5416 set_code(code); | 5421 set_code(code); |
5417 | 5422 |
5418 // Add/remove the function from the list of optimized functions for this | 5423 // Add/remove the function from the list of optimized functions for this |
5419 // context based on the state change. | 5424 // context based on the state change. |
5420 if (!was_optimized && is_optimized) { | 5425 if (!was_optimized && is_optimized) { |
5421 context()->native_context()->AddOptimizedFunction(this); | 5426 context()->native_context()->AddOptimizedFunction(this); |
5422 } | 5427 } |
5423 if (was_optimized && !is_optimized) { | 5428 if (was_optimized && !is_optimized) { |
5424 // TODO(titzer): linear in the number of optimized functions; fix! | 5429 // TODO(titzer): linear in the number of optimized functions; fix! |
5425 context()->native_context()->RemoveOptimizedFunction(this); | 5430 context()->native_context()->RemoveOptimizedFunction(this); |
(...skipping 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6730 #undef READ_UINT32_FIELD | 6735 #undef READ_UINT32_FIELD |
6731 #undef WRITE_UINT32_FIELD | 6736 #undef WRITE_UINT32_FIELD |
6732 #undef READ_SHORT_FIELD | 6737 #undef READ_SHORT_FIELD |
6733 #undef WRITE_SHORT_FIELD | 6738 #undef WRITE_SHORT_FIELD |
6734 #undef READ_BYTE_FIELD | 6739 #undef READ_BYTE_FIELD |
6735 #undef WRITE_BYTE_FIELD | 6740 #undef WRITE_BYTE_FIELD |
6736 | 6741 |
6737 } } // namespace v8::internal | 6742 } } // namespace v8::internal |
6738 | 6743 |
6739 #endif // V8_OBJECTS_INL_H_ | 6744 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |