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 5409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5420 ASSERT(!GetHeap()->InNewSpace(value)); | 5420 ASSERT(!GetHeap()->InNewSpace(value)); |
5421 Address entry = value->entry(); | 5421 Address entry = value->entry(); |
5422 WRITE_INTPTR_FIELD(this, kCodeEntryOffset, reinterpret_cast<intptr_t>(entry)); | 5422 WRITE_INTPTR_FIELD(this, kCodeEntryOffset, reinterpret_cast<intptr_t>(entry)); |
5423 } | 5423 } |
5424 | 5424 |
5425 | 5425 |
5426 void JSFunction::ReplaceCode(Code* code) { | 5426 void JSFunction::ReplaceCode(Code* code) { |
5427 bool was_optimized = IsOptimized(); | 5427 bool was_optimized = IsOptimized(); |
5428 bool is_optimized = code->kind() == Code::OPTIMIZED_FUNCTION; | 5428 bool is_optimized = code->kind() == Code::OPTIMIZED_FUNCTION; |
5429 | 5429 |
5430 if (was_optimized && is_optimized) { | |
5431 shared()->EvictFromOptimizedCodeMap( | |
5432 this->code(), "Replacing with another optimized code"); | |
5433 } | |
5434 | |
5435 set_code(code); | 5430 set_code(code); |
5436 | 5431 |
5437 // Add/remove the function from the list of optimized functions for this | 5432 // Add/remove the function from the list of optimized functions for this |
5438 // context based on the state change. | 5433 // context based on the state change. |
5439 if (!was_optimized && is_optimized) { | 5434 if (!was_optimized && is_optimized) { |
5440 context()->native_context()->AddOptimizedFunction(this); | 5435 context()->native_context()->AddOptimizedFunction(this); |
5441 } | 5436 } |
5442 if (was_optimized && !is_optimized) { | 5437 if (was_optimized && !is_optimized) { |
5443 // TODO(titzer): linear in the number of optimized functions; fix! | 5438 // TODO(titzer): linear in the number of optimized functions; fix! |
5444 context()->native_context()->RemoveOptimizedFunction(this); | 5439 context()->native_context()->RemoveOptimizedFunction(this); |
| 5440 shared()->EvictFromOptimizedCodeMap(context()->native_context(), |
| 5441 "Removing optimized code"); |
5445 } | 5442 } |
5446 } | 5443 } |
5447 | 5444 |
5448 | 5445 |
5449 Context* JSFunction::context() { | 5446 Context* JSFunction::context() { |
5450 return Context::cast(READ_FIELD(this, kContextOffset)); | 5447 return Context::cast(READ_FIELD(this, kContextOffset)); |
5451 } | 5448 } |
5452 | 5449 |
5453 | 5450 |
5454 void JSFunction::set_context(Object* value) { | 5451 void JSFunction::set_context(Object* value) { |
(...skipping 1298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6753 #undef READ_UINT32_FIELD | 6750 #undef READ_UINT32_FIELD |
6754 #undef WRITE_UINT32_FIELD | 6751 #undef WRITE_UINT32_FIELD |
6755 #undef READ_SHORT_FIELD | 6752 #undef READ_SHORT_FIELD |
6756 #undef WRITE_SHORT_FIELD | 6753 #undef WRITE_SHORT_FIELD |
6757 #undef READ_BYTE_FIELD | 6754 #undef READ_BYTE_FIELD |
6758 #undef WRITE_BYTE_FIELD | 6755 #undef WRITE_BYTE_FIELD |
6759 | 6756 |
6760 } } // namespace v8::internal | 6757 } } // namespace v8::internal |
6761 | 6758 |
6762 #endif // V8_OBJECTS_INL_H_ | 6759 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |