OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 | 2 |
3 #include <stdlib.h> | 3 #include <stdlib.h> |
4 | 4 |
5 #include "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #include "compilation-cache.h" | 7 #include "compilation-cache.h" |
8 #include "execution.h" | 8 #include "execution.h" |
9 #include "factory.h" | 9 #include "factory.h" |
10 #include "macro-assembler.h" | 10 #include "macro-assembler.h" |
(...skipping 2490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2501 Handle<Object> call_function(call); | 2501 Handle<Object> call_function(call); |
2502 | 2502 |
2503 // Now we are ready to mess up the heap. | 2503 // Now we are ready to mess up the heap. |
2504 HEAP->CollectAllGarbage(Heap::kReduceMemoryFootprintMask); | 2504 HEAP->CollectAllGarbage(Heap::kReduceMemoryFootprintMask); |
2505 | 2505 |
2506 // Either heap verification caught the problem already or we go kaboom once | 2506 // Either heap verification caught the problem already or we go kaboom once |
2507 // the CallIC is executed the next time. | 2507 // the CallIC is executed the next time. |
2508 USE(global->SetProperty(*name, *call_function, NONE, kNonStrictMode)); | 2508 USE(global->SetProperty(*name, *call_function, NONE, kNonStrictMode)); |
2509 CompileRun("call();"); | 2509 CompileRun("call();"); |
2510 } | 2510 } |
| 2511 |
| 2512 |
| 2513 TEST(Regress159140) { |
| 2514 i::FLAG_allow_natives_syntax = true; |
| 2515 i::FLAG_flush_code_incrementally = true; |
| 2516 InitializeVM(); |
| 2517 v8::HandleScope scope; |
| 2518 |
| 2519 // Perform one initial GC to enable code flushing. |
| 2520 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
| 2521 |
| 2522 // Prepare several closures that are all eligible for code flushing |
| 2523 // because all reachable ones are not optimized. Make sure that the |
| 2524 // optimized code object is directly reachable through a handle so |
| 2525 // that it is marked black during incremental marking. |
| 2526 Handle<Code> code; |
| 2527 { |
| 2528 HandleScope inner_scope; |
| 2529 CompileRun("function h(x) {}" |
| 2530 "function mkClosure() {" |
| 2531 " return function(x) { return x + 1; };" |
| 2532 "}" |
| 2533 "var f = mkClosure();" |
| 2534 "var g = mkClosure();" |
| 2535 "f(1); f(2);" |
| 2536 "g(1); g(2);" |
| 2537 "h(1); h(2);" |
| 2538 "%OptimizeFunctionOnNextCall(f); f(3);" |
| 2539 "%OptimizeFunctionOnNextCall(h); h(3);"); |
| 2540 |
| 2541 Handle<JSFunction> f = |
| 2542 v8::Utils::OpenHandle( |
| 2543 *v8::Handle<v8::Function>::Cast( |
| 2544 v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); |
| 2545 CHECK(f->is_compiled()); |
| 2546 CompileRun("f = null;"); |
| 2547 |
| 2548 Handle<JSFunction> g = |
| 2549 v8::Utils::OpenHandle( |
| 2550 *v8::Handle<v8::Function>::Cast( |
| 2551 v8::Context::GetCurrent()->Global()->Get(v8_str("g")))); |
| 2552 CHECK(g->is_compiled()); |
| 2553 const int kAgingThreshold = 6; |
| 2554 for (int i = 0; i < kAgingThreshold; i++) { |
| 2555 g->code()->MakeOlder(static_cast<MarkingParity>(i % 2)); |
| 2556 } |
| 2557 |
| 2558 code = inner_scope.CloseAndEscape(Handle<Code>(f->code())); |
| 2559 } |
| 2560 |
| 2561 // Simulate incremental marking so that the functions are enqueued as |
| 2562 // code flushing candidates. Then optimize oneo function. Finally |
| 2563 // finish the GC to complete code flushing. |
| 2564 SimulateIncrementalMarking(); |
| 2565 CompileRun("%OptimizeFunctionOnNextCall(g); g(3);"); |
| 2566 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
| 2567 |
| 2568 // Unoptimized code is missing and the deoptimizer will go ballistic. |
| 2569 CompileRun("g('bozo');"); |
| 2570 } |
OLD | NEW |