OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 9013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9024 ASSERT(cached_literals != NULL); | 9024 ASSERT(cached_literals != NULL); |
9025 function->set_literals(cached_literals); | 9025 function->set_literals(cached_literals); |
9026 } | 9026 } |
9027 Code* code = Code::cast(code_map->get(index)); | 9027 Code* code = Code::cast(code_map->get(index)); |
9028 ASSERT(code != NULL); | 9028 ASSERT(code != NULL); |
9029 ASSERT(function->context()->native_context() == code_map->get(index - 1)); | 9029 ASSERT(function->context()->native_context() == code_map->get(index - 1)); |
9030 function->ReplaceCode(code); | 9030 function->ReplaceCode(code); |
9031 } | 9031 } |
9032 | 9032 |
9033 | 9033 |
9034 void SharedFunctionInfo::ClearOptimizedCodeMap(const char* reason) { | 9034 void SharedFunctionInfo::ClearOptimizedCodeMap(Code* optimized_code, |
| 9035 const char* reason) { |
9035 if (!optimized_code_map()->IsSmi()) { | 9036 if (!optimized_code_map()->IsSmi()) { |
9036 if (FLAG_trace_opt) { | 9037 if (optimized_code == NULL || true) { |
9037 PrintF("[clearing optimizing code map (%s) for ", reason); | 9038 if (FLAG_trace_opt) { |
9038 ShortPrint(); | 9039 PrintF("[clearing entire optimizing code map (%s) for ", reason); |
9039 PrintF("]\n"); | 9040 ShortPrint(); |
| 9041 PrintF("]\n"); |
| 9042 } |
| 9043 set_optimized_code_map(Smi::FromInt(0)); |
| 9044 } else { |
| 9045 int i; |
| 9046 bool removed_entry = false; |
| 9047 FixedArray* code_map = FixedArray::cast(optimized_code_map()); |
| 9048 for (i = 0; i < code_map->length(); i += kEntryLength) { |
| 9049 ASSERT(code_map->get(i)->IsNativeContext()); |
| 9050 if (Code::cast(code_map->get(i + 1)) == optimized_code) { |
| 9051 if (FLAG_trace_opt) { |
| 9052 PrintF("[clearing optimizing code map (%s) for ", reason); |
| 9053 ShortPrint(); |
| 9054 PrintF("]\n"); |
| 9055 } |
| 9056 removed_entry = true; |
| 9057 break; |
| 9058 } |
| 9059 } |
| 9060 while (i < (code_map->length() - kEntryLength)) { |
| 9061 code_map->set(i, code_map->get(i + 1 + kEntryLength)); |
| 9062 code_map->set(i + 1, code_map->get(i + 2 + kEntryLength)); |
| 9063 code_map->set(i + 2, code_map->get(i + 3 + kEntryLength)); |
| 9064 i += kEntryLength; |
| 9065 } |
| 9066 if (removed_entry) { |
| 9067 Heap* heap = GetHeap(); |
| 9068 int new_length = code_map->length() - kEntryLength; |
| 9069 if (new_length == 0) { |
| 9070 set_optimized_code_map(Smi::FromInt(0)); |
| 9071 return; |
| 9072 } |
| 9073 Address filler_start = reinterpret_cast<Address>( |
| 9074 code_map->GetFirstElementAddress() + new_length); |
| 9075 heap->CreateFillerObjectAt(filler_start, |
| 9076 kEntryLength * kPointerSize); |
| 9077 code_map->set_length(new_length); |
| 9078 } |
9040 } | 9079 } |
9041 set_optimized_code_map(Smi::FromInt(0)); | |
9042 } | 9080 } |
9043 } | 9081 } |
9044 | 9082 |
9045 | 9083 |
9046 bool JSFunction::CompileLazy(Handle<JSFunction> function, | 9084 bool JSFunction::CompileLazy(Handle<JSFunction> function, |
9047 ClearExceptionFlag flag) { | 9085 ClearExceptionFlag flag) { |
9048 bool result = true; | 9086 bool result = true; |
9049 if (function->shared()->is_compiled()) { | 9087 if (function->shared()->is_compiled()) { |
9050 function->ReplaceCode(function->shared()->code()); | 9088 function->ReplaceCode(function->shared()->code()); |
9051 function->shared()->set_code_age(0); | 9089 function->shared()->set_code_age(0); |
(...skipping 6302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15354 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 15392 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
15355 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 15393 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
15356 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 15394 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
15357 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 15395 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
15358 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 15396 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
15359 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 15397 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
15360 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 15398 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
15361 } | 15399 } |
15362 | 15400 |
15363 } } // namespace v8::internal | 15401 } } // namespace v8::internal |
OLD | NEW |