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 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1510 CompileRun("%OptimizeFunctionOnNextCall(foo); foo();"); | 1510 CompileRun("%OptimizeFunctionOnNextCall(foo); foo();"); |
1511 } | 1511 } |
1512 | 1512 |
1513 // Simulate one final GC to make sure the candidate queue is sane. | 1513 // Simulate one final GC to make sure the candidate queue is sane. |
1514 heap->CollectAllGarbage(); | 1514 heap->CollectAllGarbage(); |
1515 CHECK(function->shared()->is_compiled() || !function->IsOptimized()); | 1515 CHECK(function->shared()->is_compiled() || !function->IsOptimized()); |
1516 CHECK(function->is_compiled() || !function->IsOptimized()); | 1516 CHECK(function->is_compiled() || !function->IsOptimized()); |
1517 } | 1517 } |
1518 | 1518 |
1519 TEST(TestUseOfIncrementalBarrierOnCompileLazy) { | 1519 TEST(TestUseOfIncrementalBarrierOnCompileLazy) { |
1520 // This test requires us to run the CompileLazy builtin, which won't be run | |
1521 // when the interpreter is used. | |
1522 if (i::FLAG_ignition) return; | |
Michael Starzinger
2016/04/08 12:44:02
This should actually only happen because of eager
Michael Starzinger
2016/04/08 12:53:05
Actually, as discussed offline: This should even w
mvstanton
2016/04/11 13:36:14
Yes, it still fails with --turbo and --ignition. I
mvstanton
2016/04/11 13:36:14
Acknowledged.
| |
1520 // Turn off always_opt because it interferes with running the built-in for | 1523 // Turn off always_opt because it interferes with running the built-in for |
1521 // the last call to g(). | 1524 // the last call to g(). |
1522 i::FLAG_always_opt = false; | 1525 i::FLAG_always_opt = false; |
1523 i::FLAG_allow_natives_syntax = true; | 1526 i::FLAG_allow_natives_syntax = true; |
1524 CcTest::InitializeVM(); | 1527 CcTest::InitializeVM(); |
1525 Isolate* isolate = CcTest::i_isolate(); | 1528 Isolate* isolate = CcTest::i_isolate(); |
1526 Factory* factory = isolate->factory(); | 1529 Factory* factory = isolate->factory(); |
1527 Heap* heap = isolate->heap(); | 1530 Heap* heap = isolate->heap(); |
1528 v8::HandleScope scope(CcTest::isolate()); | 1531 v8::HandleScope scope(CcTest::isolate()); |
1529 | 1532 |
1530 CompileRun( | 1533 CompileRun( |
1531 "function make_closure(x) {" | 1534 "function make_closure(x) {" |
1532 " return function() { return x + 3 };" | 1535 " return function() { return x + 3 };" |
1533 "}" | 1536 "}" |
1534 "var f = make_closure(5); f();" | 1537 "var f = make_closure(5); f();" |
1535 "var g = make_closure(5);"); | 1538 "var g = make_closure(5);"); |
1536 | 1539 |
1537 // Check f is compiled. | 1540 // Check f is compiled. |
1538 Handle<String> f_name = factory->InternalizeUtf8String("f"); | 1541 Handle<String> f_name = factory->InternalizeUtf8String("f"); |
1539 Handle<Object> f_value = | 1542 Handle<Object> f_value = |
1540 Object::GetProperty(isolate->global_object(), f_name).ToHandleChecked(); | 1543 Object::GetProperty(isolate->global_object(), f_name).ToHandleChecked(); |
1541 Handle<JSFunction> f_function = Handle<JSFunction>::cast(f_value); | 1544 Handle<JSFunction> f_function = Handle<JSFunction>::cast(f_value); |
1542 CHECK(f_function->is_compiled()); | 1545 CHECK(f_function->is_compiled()); |
1543 | 1546 |
1544 // Check g is not compiled. | 1547 // Check g is not compiled. |
1545 Handle<String> g_name = factory->InternalizeUtf8String("g"); | 1548 Handle<String> g_name = factory->InternalizeUtf8String("g"); |
1546 Handle<Object> g_value = | 1549 Handle<Object> g_value = |
1547 Object::GetProperty(isolate->global_object(), g_name).ToHandleChecked(); | 1550 Object::GetProperty(isolate->global_object(), g_name).ToHandleChecked(); |
1548 Handle<JSFunction> g_function = Handle<JSFunction>::cast(g_value); | 1551 Handle<JSFunction> g_function = Handle<JSFunction>::cast(g_value); |
1549 // TODO(mvstanton): change to check that g is *not* compiled when optimized | 1552 CHECK(!g_function->is_compiled()); |
1550 // cache | |
1551 // map lookup moves to the compile lazy builtin. | |
1552 CHECK(g_function->is_compiled()); | |
1553 | 1553 |
1554 SimulateIncrementalMarking(heap); | 1554 SimulateIncrementalMarking(heap); |
1555 CompileRun("%OptimizeFunctionOnNextCall(f); f();"); | 1555 CompileRun("%OptimizeFunctionOnNextCall(f); f();"); |
1556 | 1556 |
1557 // g should now have available an optimized function, unmarked by gc. The | 1557 // g should now have available an optimized function, unmarked by gc. The |
1558 // CompileLazy built-in will discover it and install it in the closure, and | 1558 // CompileLazy built-in will discover it and install it in the closure, and |
1559 // the incremental write barrier should be used. | 1559 // the incremental write barrier should be used. |
1560 CompileRun("g();"); | 1560 CompileRun("g();"); |
1561 CHECK(g_function->is_compiled()); | 1561 CHECK(g_function->is_compiled()); |
1562 } | 1562 } |
(...skipping 5038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6601 heap->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>(arrays[j], N - 1); | 6601 heap->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>(arrays[j], N - 1); |
6602 } | 6602 } |
6603 } | 6603 } |
6604 // Force allocation from the free list. | 6604 // Force allocation from the free list. |
6605 heap->set_force_oom(true); | 6605 heap->set_force_oom(true); |
6606 heap->CollectGarbage(OLD_SPACE); | 6606 heap->CollectGarbage(OLD_SPACE); |
6607 } | 6607 } |
6608 | 6608 |
6609 } // namespace internal | 6609 } // namespace internal |
6610 } // namespace v8 | 6610 } // namespace v8 |
OLD | NEW |