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 4446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4457 "g(); %OptimizeFunctionOnNextCall(g); g();"); | 4457 "g(); %OptimizeFunctionOnNextCall(g); g();"); |
4458 | 4458 |
4459 Handle<JSFunction> g = | 4459 Handle<JSFunction> g = |
4460 v8::Utils::OpenHandle( | 4460 v8::Utils::OpenHandle( |
4461 *v8::Handle<v8::Function>::Cast( | 4461 *v8::Handle<v8::Function>::Cast( |
4462 CcTest::global()->Get(v8_str("g")))); | 4462 CcTest::global()->Get(v8_str("g")))); |
4463 code = inner_scope.CloseAndEscape(handle(g->code(), isolate)); | 4463 code = inner_scope.CloseAndEscape(handle(g->code(), isolate)); |
4464 if (!code->is_optimized_code()) return; | 4464 if (!code->is_optimized_code()) return; |
4465 } | 4465 } |
4466 | 4466 |
4467 Handle<FixedArray> lit = isolate->factory()->empty_fixed_array(); | 4467 Handle<TypeFeedbackVector> vector = handle(shared->feedback_vector()); |
| 4468 Handle<LiteralsArray> lit = |
| 4469 LiteralsArray::New(isolate, vector, shared->num_literals(), TENURED); |
4468 Handle<Context> context(isolate->context()); | 4470 Handle<Context> context(isolate->context()); |
4469 | 4471 |
4470 // Add the new code several times to the optimized code map and also set an | 4472 // Add the new code several times to the optimized code map and also set an |
4471 // allocation timeout so that expanding the code map will trigger a GC. | 4473 // allocation timeout so that expanding the code map will trigger a GC. |
4472 heap->set_allocation_timeout(5); | 4474 heap->set_allocation_timeout(5); |
4473 FLAG_gc_interval = 1000; | 4475 FLAG_gc_interval = 1000; |
4474 for (int i = 0; i < 10; ++i) { | 4476 for (int i = 0; i < 10; ++i) { |
4475 BailoutId id = BailoutId(i); | 4477 BailoutId id = BailoutId(i); |
4476 SharedFunctionInfo::AddToOptimizedCodeMap(shared, context, code, lit, id); | 4478 SharedFunctionInfo::AddToOptimizedCodeMap(shared, context, code, lit, id); |
4477 } | 4479 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4513 "g(); %OptimizeFunctionOnNextCall(g); g();"); | 4515 "g(); %OptimizeFunctionOnNextCall(g); g();"); |
4514 | 4516 |
4515 Handle<JSFunction> g = | 4517 Handle<JSFunction> g = |
4516 v8::Utils::OpenHandle( | 4518 v8::Utils::OpenHandle( |
4517 *v8::Handle<v8::Function>::Cast( | 4519 *v8::Handle<v8::Function>::Cast( |
4518 CcTest::global()->Get(v8_str("g")))); | 4520 CcTest::global()->Get(v8_str("g")))); |
4519 code = inner_scope.CloseAndEscape(handle(g->code(), isolate)); | 4521 code = inner_scope.CloseAndEscape(handle(g->code(), isolate)); |
4520 if (!code->is_optimized_code()) return; | 4522 if (!code->is_optimized_code()) return; |
4521 } | 4523 } |
4522 | 4524 |
4523 Handle<FixedArray> lit = isolate->factory()->empty_fixed_array(); | 4525 Handle<TypeFeedbackVector> vector = handle(shared->feedback_vector()); |
| 4526 Handle<LiteralsArray> lit = |
| 4527 LiteralsArray::New(isolate, vector, shared->num_literals(), TENURED); |
4524 Handle<Context> context(isolate->context()); | 4528 Handle<Context> context(isolate->context()); |
4525 | 4529 |
4526 // Add the code several times to the optimized code map. | 4530 // Add the code several times to the optimized code map. |
4527 for (int i = 0; i < 3; ++i) { | 4531 for (int i = 0; i < 3; ++i) { |
4528 HandleScope inner_scope(isolate); | 4532 HandleScope inner_scope(isolate); |
4529 BailoutId id = BailoutId(i); | 4533 BailoutId id = BailoutId(i); |
4530 SharedFunctionInfo::AddToOptimizedCodeMap(shared, context, code, lit, id); | 4534 SharedFunctionInfo::AddToOptimizedCodeMap(shared, context, code, lit, id); |
4531 } | 4535 } |
4532 shared->optimized_code_map()->Print(); | 4536 shared->optimized_code_map()->Print(); |
4533 | 4537 |
4534 // Add the code with a literals array to be evacuated. | 4538 // Add the code with a literals array to be evacuated. |
4535 Page* evac_page; | 4539 Page* evac_page; |
4536 { | 4540 { |
4537 HandleScope inner_scope(isolate); | 4541 HandleScope inner_scope(isolate); |
4538 AlwaysAllocateScope always_allocate(isolate); | 4542 AlwaysAllocateScope always_allocate(isolate); |
4539 // Make sure literal is placed on an old-space evacuation candidate. | 4543 // Make sure literal is placed on an old-space evacuation candidate. |
4540 SimulateFullSpace(heap->old_space()); | 4544 SimulateFullSpace(heap->old_space()); |
4541 Handle<FixedArray> lit = isolate->factory()->NewFixedArray(23, TENURED); | 4545 |
| 4546 // Make sure there the number of literals is > 0. |
| 4547 Handle<LiteralsArray> lit = |
| 4548 LiteralsArray::New(isolate, vector, 23, TENURED); |
| 4549 |
4542 evac_page = Page::FromAddress(lit->address()); | 4550 evac_page = Page::FromAddress(lit->address()); |
4543 BailoutId id = BailoutId(100); | 4551 BailoutId id = BailoutId(100); |
4544 SharedFunctionInfo::AddToOptimizedCodeMap(shared, context, code, lit, id); | 4552 SharedFunctionInfo::AddToOptimizedCodeMap(shared, context, code, lit, id); |
4545 } | 4553 } |
4546 | 4554 |
4547 // Heap is ready, force {lit_page} to become an evacuation candidate and | 4555 // Heap is ready, force {lit_page} to become an evacuation candidate and |
4548 // simulate incremental marking to enqueue optimized code map. | 4556 // simulate incremental marking to enqueue optimized code map. |
4549 FLAG_manual_evacuation_candidates_selection = true; | 4557 FLAG_manual_evacuation_candidates_selection = true; |
4550 evac_page->SetFlag(MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING); | 4558 evac_page->SetFlag(MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING); |
4551 SimulateIncrementalMarking(heap); | 4559 SimulateIncrementalMarking(heap); |
(...skipping 1852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6404 // The CollectGarbage call above starts sweeper threads. | 6412 // The CollectGarbage call above starts sweeper threads. |
6405 // The crash will happen if the following two functions | 6413 // The crash will happen if the following two functions |
6406 // are called before sweeping finishes. | 6414 // are called before sweeping finishes. |
6407 heap->StartIncrementalMarking(); | 6415 heap->StartIncrementalMarking(); |
6408 heap->FinalizeIncrementalMarkingIfComplete("test"); | 6416 heap->FinalizeIncrementalMarkingIfComplete("test"); |
6409 } | 6417 } |
6410 | 6418 |
6411 | 6419 |
6412 } // namespace internal | 6420 } // namespace internal |
6413 } // namespace v8 | 6421 } // namespace v8 |
OLD | NEW |