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 7528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7539 ASSERT(new_code_map->get(i + 1)->IsCode()); | 7539 ASSERT(new_code_map->get(i + 1)->IsCode()); |
7540 ASSERT(Code::cast(new_code_map->get(i + 1))->kind() == | 7540 ASSERT(Code::cast(new_code_map->get(i + 1))->kind() == |
7541 Code::OPTIMIZED_FUNCTION); | 7541 Code::OPTIMIZED_FUNCTION); |
7542 ASSERT(new_code_map->get(i + 2)->IsFixedArray()); | 7542 ASSERT(new_code_map->get(i + 2)->IsFixedArray()); |
7543 } | 7543 } |
7544 #endif | 7544 #endif |
7545 shared->set_optimized_code_map(*new_code_map); | 7545 shared->set_optimized_code_map(*new_code_map); |
7546 } | 7546 } |
7547 | 7547 |
7548 | 7548 |
| 7549 void SharedFunctionInfo::InstallFromOptimizedCodeMap(JSFunction* function, |
| 7550 int index) { |
| 7551 ASSERT(index > 0); |
| 7552 ASSERT(optimized_code_map()->IsFixedArray()); |
| 7553 FixedArray* code_map = FixedArray::cast(optimized_code_map()); |
| 7554 if (!bound()) { |
| 7555 FixedArray* cached_literals = FixedArray::cast(code_map->get(index + 1)); |
| 7556 ASSERT(cached_literals != NULL); |
| 7557 function->set_literals(cached_literals); |
| 7558 } |
| 7559 Code* code = Code::cast(code_map->get(index)); |
| 7560 ASSERT(code != NULL); |
| 7561 ASSERT(function->context()->global_context() == code_map->get(index - 1)); |
| 7562 function->ReplaceCode(code); |
| 7563 } |
| 7564 |
| 7565 |
7549 bool JSFunction::CompileLazy(Handle<JSFunction> function, | 7566 bool JSFunction::CompileLazy(Handle<JSFunction> function, |
7550 ClearExceptionFlag flag) { | 7567 ClearExceptionFlag flag) { |
7551 bool result = true; | 7568 bool result = true; |
7552 if (function->shared()->is_compiled()) { | 7569 if (function->shared()->is_compiled()) { |
7553 function->ReplaceCode(function->shared()->code()); | 7570 function->ReplaceCode(function->shared()->code()); |
7554 function->shared()->set_code_age(0); | 7571 function->shared()->set_code_age(0); |
7555 } else { | 7572 } else { |
7556 ASSERT(function->shared()->allows_lazy_compilation()); | 7573 ASSERT(function->shared()->allows_lazy_compilation()); |
7557 CompilationInfoWithZone info(function); | 7574 CompilationInfoWithZone info(function); |
7558 result = CompileLazyHelper(&info, flag); | 7575 result = CompileLazyHelper(&info, flag); |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8090 | 8107 |
8091 // Give the correct expected_nof_properties to initial maps created later. | 8108 // Give the correct expected_nof_properties to initial maps created later. |
8092 ASSERT(expected_nof_properties() >= slack); | 8109 ASSERT(expected_nof_properties() >= slack); |
8093 set_expected_nof_properties(expected_nof_properties() - slack); | 8110 set_expected_nof_properties(expected_nof_properties() - slack); |
8094 } | 8111 } |
8095 } | 8112 } |
8096 | 8113 |
8097 | 8114 |
8098 int SharedFunctionInfo::SearchOptimizedCodeMap(Context* global_context) { | 8115 int SharedFunctionInfo::SearchOptimizedCodeMap(Context* global_context) { |
8099 ASSERT(global_context->IsGlobalContext()); | 8116 ASSERT(global_context->IsGlobalContext()); |
| 8117 if (!FLAG_cache_optimized_code) return -1; |
8100 Object* value = optimized_code_map(); | 8118 Object* value = optimized_code_map(); |
8101 if (!value->IsSmi()) { | 8119 if (!value->IsSmi()) { |
8102 FixedArray* optimized_code_map = FixedArray::cast(value); | 8120 FixedArray* optimized_code_map = FixedArray::cast(value); |
8103 int length = optimized_code_map->length(); | 8121 int length = optimized_code_map->length(); |
8104 for (int i = 0; i < length; i += 3) { | 8122 for (int i = 0; i < length; i += 3) { |
8105 if (optimized_code_map->get(i) == global_context) { | 8123 if (optimized_code_map->get(i) == global_context) { |
8106 return i + 1; | 8124 return i + 1; |
8107 } | 8125 } |
8108 } | 8126 } |
8109 } | 8127 } |
(...skipping 5170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13280 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 13298 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
13281 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 13299 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
13282 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 13300 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
13283 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 13301 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
13284 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 13302 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
13285 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 13303 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
13286 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 13304 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
13287 } | 13305 } |
13288 | 13306 |
13289 } } // namespace v8::internal | 13307 } } // namespace v8::internal |
OLD | NEW |