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 4483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4494 | 4494 |
4495 // Now enable the debugger which in turn will disable code flushing. | 4495 // Now enable the debugger which in turn will disable code flushing. |
4496 CHECK(isolate->debug()->Load()); | 4496 CHECK(isolate->debug()->Load()); |
4497 | 4497 |
4498 // This cycle will bust the heap and subsequent cycles will go ballistic. | 4498 // This cycle will bust the heap and subsequent cycles will go ballistic. |
4499 heap->CollectAllGarbage(); | 4499 heap->CollectAllGarbage(); |
4500 heap->CollectAllGarbage(); | 4500 heap->CollectAllGarbage(); |
4501 } | 4501 } |
4502 | 4502 |
4503 | 4503 |
4504 TEST(Regress513507) { | |
4505 i::FLAG_flush_optimized_code_cache = false; | |
4506 i::FLAG_allow_natives_syntax = true; | |
4507 i::FLAG_gc_global = true; | |
4508 CcTest::InitializeVM(); | |
4509 Isolate* isolate = CcTest::i_isolate(); | |
4510 Heap* heap = isolate->heap(); | |
4511 HandleScope scope(isolate); | |
4512 | |
4513 // Prepare function whose optimized code map we can use. | |
4514 Handle<SharedFunctionInfo> shared; | |
4515 { | |
4516 HandleScope inner_scope(isolate); | |
4517 CompileRun("function f() { return 1 }" | |
4518 "f(); %OptimizeFunctionOnNextCall(f); f();"); | |
4519 | |
4520 Handle<JSFunction> f = | |
4521 v8::Utils::OpenHandle( | |
4522 *v8::Handle<v8::Function>::Cast( | |
4523 CcTest::global()->Get(v8_str("f")))); | |
4524 shared = inner_scope.CloseAndEscape(handle(f->shared(), isolate)); | |
4525 CompileRun("f = null"); | |
4526 } | |
4527 | |
4528 // Prepare optimize code that we can use. | |
Hannes Payer (out of office)
2015/08/04 16:57:38
optimized
Michael Starzinger
2015/08/04 17:02:58
Done.
| |
4529 Handle<Code> code; | |
4530 { | |
4531 HandleScope inner_scope(isolate); | |
4532 CompileRun("function g() { return 2 }" | |
4533 "g(); %OptimizeFunctionOnNextCall(g); g();"); | |
4534 | |
4535 Handle<JSFunction> g = | |
4536 v8::Utils::OpenHandle( | |
4537 *v8::Handle<v8::Function>::Cast( | |
4538 CcTest::global()->Get(v8_str("g")))); | |
4539 code = inner_scope.CloseAndEscape(handle(g->code(), isolate)); | |
4540 if (!code->is_optimized_code()) return; | |
4541 } | |
4542 | |
4543 Handle<FixedArray> lit = isolate->factory()->empty_fixed_array(); | |
4544 Handle<Context> context(isolate->context()); | |
4545 | |
4546 #ifdef DEBUG | |
Hannes Payer (out of office)
2015/08/04 16:57:38
Let's move it up, because the test is otherwise no
Michael Starzinger
2015/08/04 17:02:58
Done.
| |
4547 // Add the new code several times to the optimized code map and also set an | |
4548 // allocation timeout so that expanding the code map will trigger a GC. | |
4549 heap->set_allocation_timeout(5); | |
4550 FLAG_gc_interval = 1000; | |
4551 for (int i = 0; i < 10; ++i) { | |
4552 BailoutId id = BailoutId(i); | |
4553 SharedFunctionInfo::AddToOptimizedCodeMap(shared, context, code, lit, id); | |
4554 } | |
4555 #endif | |
4556 } | |
4557 | |
4558 | |
4504 class DummyVisitor : public ObjectVisitor { | 4559 class DummyVisitor : public ObjectVisitor { |
4505 public: | 4560 public: |
4506 void VisitPointers(Object** start, Object** end) { } | 4561 void VisitPointers(Object** start, Object** end) { } |
4507 }; | 4562 }; |
4508 | 4563 |
4509 | 4564 |
4510 TEST(DeferredHandles) { | 4565 TEST(DeferredHandles) { |
4511 CcTest::InitializeVM(); | 4566 CcTest::InitializeVM(); |
4512 Isolate* isolate = CcTest::i_isolate(); | 4567 Isolate* isolate = CcTest::i_isolate(); |
4513 Heap* heap = isolate->heap(); | 4568 Heap* heap = isolate->heap(); |
(...skipping 1692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6206 array->address(), | 6261 array->address(), |
6207 array->address() + array->Size()); | 6262 array->address() + array->Size()); |
6208 CHECK(reinterpret_cast<void*>(buffer->Get(1)) == | 6263 CHECK(reinterpret_cast<void*>(buffer->Get(1)) == |
6209 HeapObject::RawField(heap->empty_fixed_array(), | 6264 HeapObject::RawField(heap->empty_fixed_array(), |
6210 FixedArrayBase::kLengthOffset)); | 6265 FixedArrayBase::kLengthOffset)); |
6211 CHECK(reinterpret_cast<void*>(buffer->Get(2)) == | 6266 CHECK(reinterpret_cast<void*>(buffer->Get(2)) == |
6212 HeapObject::RawField(heap->empty_fixed_array(), | 6267 HeapObject::RawField(heap->empty_fixed_array(), |
6213 FixedArrayBase::kLengthOffset)); | 6268 FixedArrayBase::kLengthOffset)); |
6214 delete buffer; | 6269 delete buffer; |
6215 } | 6270 } |
OLD | NEW |