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 2480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2491 if (code->IsNull()) return *target; | 2491 if (code->IsNull()) return *target; |
2492 RUNTIME_ASSERT(code->IsJSFunction()); | 2492 RUNTIME_ASSERT(code->IsJSFunction()); |
2493 Handle<JSFunction> source = Handle<JSFunction>::cast(code); | 2493 Handle<JSFunction> source = Handle<JSFunction>::cast(code); |
2494 Handle<SharedFunctionInfo> target_shared(target->shared()); | 2494 Handle<SharedFunctionInfo> target_shared(target->shared()); |
2495 Handle<SharedFunctionInfo> source_shared(source->shared()); | 2495 Handle<SharedFunctionInfo> source_shared(source->shared()); |
2496 | 2496 |
2497 if (!JSFunction::EnsureCompiled(source, KEEP_EXCEPTION)) { | 2497 if (!JSFunction::EnsureCompiled(source, KEEP_EXCEPTION)) { |
2498 return Failure::Exception(); | 2498 return Failure::Exception(); |
2499 } | 2499 } |
2500 | 2500 |
| 2501 // Mark both, the source and the target, as un-flushable because the |
| 2502 // shared unoptimized code makes them impossible to enqueue in a list. |
| 2503 ASSERT(target_shared->code()->gc_metadata() == NULL); |
| 2504 ASSERT(source_shared->code()->gc_metadata() == NULL); |
| 2505 target_shared->set_dont_flush(true); |
| 2506 source_shared->set_dont_flush(true); |
| 2507 |
2501 // Set the code, scope info, formal parameter count, and the length | 2508 // Set the code, scope info, formal parameter count, and the length |
2502 // of the target shared function info. Set the source code of the | 2509 // of the target shared function info. Set the source code of the |
2503 // target function to undefined. SetCode is only used for built-in | 2510 // target function to undefined. SetCode is only used for built-in |
2504 // constructors like String, Array, and Object, and some web code | 2511 // constructors like String, Array, and Object, and some web code |
2505 // doesn't like seeing source code for constructors. | 2512 // doesn't like seeing source code for constructors. |
2506 target_shared->ReplaceCode(source_shared->code()); | 2513 target_shared->ReplaceCode(source_shared->code()); |
2507 target_shared->set_scope_info(source_shared->scope_info()); | 2514 target_shared->set_scope_info(source_shared->scope_info()); |
2508 target_shared->set_length(source_shared->length()); | 2515 target_shared->set_length(source_shared->length()); |
2509 target_shared->set_formal_parameter_count( | 2516 target_shared->set_formal_parameter_count( |
2510 source_shared->formal_parameter_count()); | 2517 source_shared->formal_parameter_count()); |
(...skipping 10986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13497 // Handle last resort GC and make sure to allow future allocations | 13504 // Handle last resort GC and make sure to allow future allocations |
13498 // to grow the heap without causing GCs (if possible). | 13505 // to grow the heap without causing GCs (if possible). |
13499 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13506 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13500 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13507 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
13501 "Runtime::PerformGC"); | 13508 "Runtime::PerformGC"); |
13502 } | 13509 } |
13503 } | 13510 } |
13504 | 13511 |
13505 | 13512 |
13506 } } // namespace v8::internal | 13513 } } // namespace v8::internal |
OLD | NEW |