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 2236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2247 | 2247 |
2248 // Since we don't store the source we should never optimize this. | 2248 // Since we don't store the source we should never optimize this. |
2249 target_shared->code()->set_optimizable(false); | 2249 target_shared->code()->set_optimizable(false); |
2250 | 2250 |
2251 // Clear the optimization hints related to the compiled code as these | 2251 // Clear the optimization hints related to the compiled code as these |
2252 // are no longer valid when the code is overwritten. | 2252 // are no longer valid when the code is overwritten. |
2253 target_shared->ClearThisPropertyAssignmentsInfo(); | 2253 target_shared->ClearThisPropertyAssignmentsInfo(); |
2254 | 2254 |
2255 // Set the code of the target function. | 2255 // Set the code of the target function. |
2256 target->ReplaceCode(source_shared->code()); | 2256 target->ReplaceCode(source_shared->code()); |
| 2257 ASSERT(target->next_function_link()->IsUndefined()); |
2257 | 2258 |
2258 // Make sure we get a fresh copy of the literal vector to avoid cross | 2259 // Make sure we get a fresh copy of the literal vector to avoid cross |
2259 // context contamination. | 2260 // context contamination. |
2260 Handle<Context> context(source->context()); | 2261 Handle<Context> context(source->context()); |
2261 int number_of_literals = source->NumberOfLiterals(); | 2262 int number_of_literals = source->NumberOfLiterals(); |
2262 Handle<FixedArray> literals = | 2263 Handle<FixedArray> literals = |
2263 isolate->factory()->NewFixedArray(number_of_literals, TENURED); | 2264 isolate->factory()->NewFixedArray(number_of_literals, TENURED); |
2264 if (number_of_literals > 0) { | 2265 if (number_of_literals > 0) { |
2265 literals->set(JSFunction::kLiteralNativeContextIndex, | 2266 literals->set(JSFunction::kLiteralNativeContextIndex, |
2266 context->native_context()); | 2267 context->native_context()); |
2267 } | 2268 } |
2268 target->set_context(*context); | 2269 target->set_context(*context); |
2269 target->set_literals(*literals); | 2270 target->set_literals(*literals); |
2270 target->set_next_function_link(isolate->heap()->undefined_value()); | |
2271 | 2271 |
2272 if (isolate->logger()->is_logging_code_events() || | 2272 if (isolate->logger()->is_logging_code_events() || |
2273 CpuProfiler::is_profiling(isolate)) { | 2273 CpuProfiler::is_profiling(isolate)) { |
2274 isolate->logger()->LogExistingFunction( | 2274 isolate->logger()->LogExistingFunction( |
2275 source_shared, Handle<Code>(source_shared->code())); | 2275 source_shared, Handle<Code>(source_shared->code())); |
2276 } | 2276 } |
2277 | 2277 |
2278 return *target; | 2278 return *target; |
2279 } | 2279 } |
2280 | 2280 |
(...skipping 10998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13279 // Handle last resort GC and make sure to allow future allocations | 13279 // Handle last resort GC and make sure to allow future allocations |
13280 // to grow the heap without causing GCs (if possible). | 13280 // to grow the heap without causing GCs (if possible). |
13281 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13281 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13282 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13282 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
13283 "Runtime::PerformGC"); | 13283 "Runtime::PerformGC"); |
13284 } | 13284 } |
13285 } | 13285 } |
13286 | 13286 |
13287 | 13287 |
13288 } } // namespace v8::internal | 13288 } } // namespace v8::internal |
OLD | NEW |