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 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1508 { v8::HandleScope scope(CcTest::isolate()); | 1508 { v8::HandleScope scope(CcTest::isolate()); |
1509 CompileRun("%OptimizeFunctionOnNextCall(foo); foo();"); | 1509 CompileRun("%OptimizeFunctionOnNextCall(foo); foo();"); |
1510 } | 1510 } |
1511 | 1511 |
1512 // Simulate one final GC to make sure the candidate queue is sane. | 1512 // Simulate one final GC to make sure the candidate queue is sane. |
1513 heap->CollectAllGarbage(); | 1513 heap->CollectAllGarbage(); |
1514 CHECK(function->shared()->is_compiled() || !function->IsOptimized()); | 1514 CHECK(function->shared()->is_compiled() || !function->IsOptimized()); |
1515 CHECK(function->is_compiled() || !function->IsOptimized()); | 1515 CHECK(function->is_compiled() || !function->IsOptimized()); |
1516 } | 1516 } |
1517 | 1517 |
| 1518 TEST(TestUseOfIncrementalBarrierOnCompileLazy) { |
| 1519 // Turn off always_opt because it interferes with running the built-in for |
| 1520 // the last call to g(). |
| 1521 i::FLAG_always_opt = false; |
| 1522 i::FLAG_allow_natives_syntax = true; |
| 1523 CcTest::InitializeVM(); |
| 1524 Isolate* isolate = CcTest::i_isolate(); |
| 1525 Factory* factory = isolate->factory(); |
| 1526 Heap* heap = isolate->heap(); |
| 1527 v8::HandleScope scope(CcTest::isolate()); |
| 1528 |
| 1529 CompileRun( |
| 1530 "function make_closure(x) {" |
| 1531 " return function() { return x + 3 };" |
| 1532 "}" |
| 1533 "var f = make_closure(5); f();" |
| 1534 "var g = make_closure(5);"); |
| 1535 |
| 1536 // Check f is compiled. |
| 1537 Handle<String> f_name = factory->InternalizeUtf8String("f"); |
| 1538 Handle<Object> f_value = |
| 1539 Object::GetProperty(isolate->global_object(), f_name).ToHandleChecked(); |
| 1540 Handle<JSFunction> f_function = Handle<JSFunction>::cast(f_value); |
| 1541 CHECK(f_function->is_compiled()); |
| 1542 |
| 1543 // Check g is not compiled. |
| 1544 Handle<String> g_name = factory->InternalizeUtf8String("g"); |
| 1545 Handle<Object> g_value = |
| 1546 Object::GetProperty(isolate->global_object(), g_name).ToHandleChecked(); |
| 1547 Handle<JSFunction> g_function = Handle<JSFunction>::cast(g_value); |
| 1548 // TODO(mvstanton): change to check that g is *not* compiled when optimized |
| 1549 // cache |
| 1550 // map lookup moves to the compile lazy builtin. |
| 1551 CHECK(g_function->is_compiled()); |
| 1552 |
| 1553 SimulateIncrementalMarking(heap); |
| 1554 CompileRun("%OptimizeFunctionOnNextCall(f); f();"); |
| 1555 |
| 1556 // g should now have available an optimized function, unmarked by gc. The |
| 1557 // CompileLazy built-in will discover it and install it in the closure, and |
| 1558 // the incremental write barrier should be used. |
| 1559 CompileRun("g();"); |
| 1560 CHECK(g_function->is_compiled()); |
| 1561 } |
1518 | 1562 |
1519 TEST(CompilationCacheCachingBehavior) { | 1563 TEST(CompilationCacheCachingBehavior) { |
1520 // If we do not flush code, or have the compilation cache turned off, this | 1564 // If we do not flush code, or have the compilation cache turned off, this |
1521 // test is invalid. | 1565 // test is invalid. |
1522 if (!FLAG_flush_code || !FLAG_compilation_cache) { | 1566 if (!FLAG_flush_code || !FLAG_compilation_cache) { |
1523 return; | 1567 return; |
1524 } | 1568 } |
1525 CcTest::InitializeVM(); | 1569 CcTest::InitializeVM(); |
1526 Isolate* isolate = CcTest::i_isolate(); | 1570 Isolate* isolate = CcTest::i_isolate(); |
1527 Factory* factory = isolate->factory(); | 1571 Factory* factory = isolate->factory(); |
(...skipping 4919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6447 isolate->IncrementJsCallsFromApiCounter(); | 6491 isolate->IncrementJsCallsFromApiCounter(); |
6448 isolate->IncrementJsCallsFromApiCounter(); | 6492 isolate->IncrementJsCallsFromApiCounter(); |
6449 isolate->IncrementJsCallsFromApiCounter(); | 6493 isolate->IncrementJsCallsFromApiCounter(); |
6450 calls_per_ms = memory_reducer->SampleAndGetJsCallsPerMs(4); | 6494 calls_per_ms = memory_reducer->SampleAndGetJsCallsPerMs(4); |
6451 CheckDoubleEquals(2, calls_per_ms); | 6495 CheckDoubleEquals(2, calls_per_ms); |
6452 } | 6496 } |
6453 | 6497 |
6454 | 6498 |
6455 } // namespace internal | 6499 } // namespace internal |
6456 } // namespace v8 | 6500 } // namespace v8 |
OLD | NEW |