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 #ifdef DEBUG |
| 4505 TEST(Regress513507) { |
| 4506 i::FLAG_flush_optimized_code_cache = false; |
| 4507 i::FLAG_allow_natives_syntax = true; |
| 4508 i::FLAG_gc_global = true; |
| 4509 CcTest::InitializeVM(); |
| 4510 Isolate* isolate = CcTest::i_isolate(); |
| 4511 Heap* heap = isolate->heap(); |
| 4512 HandleScope scope(isolate); |
| 4513 |
| 4514 // Prepare function whose optimized code map we can use. |
| 4515 Handle<SharedFunctionInfo> shared; |
| 4516 { |
| 4517 HandleScope inner_scope(isolate); |
| 4518 CompileRun("function f() { return 1 }" |
| 4519 "f(); %OptimizeFunctionOnNextCall(f); f();"); |
| 4520 |
| 4521 Handle<JSFunction> f = |
| 4522 v8::Utils::OpenHandle( |
| 4523 *v8::Handle<v8::Function>::Cast( |
| 4524 CcTest::global()->Get(v8_str("f")))); |
| 4525 shared = inner_scope.CloseAndEscape(handle(f->shared(), isolate)); |
| 4526 CompileRun("f = null"); |
| 4527 } |
| 4528 |
| 4529 // Prepare optimized code that we can use. |
| 4530 Handle<Code> code; |
| 4531 { |
| 4532 HandleScope inner_scope(isolate); |
| 4533 CompileRun("function g() { return 2 }" |
| 4534 "g(); %OptimizeFunctionOnNextCall(g); g();"); |
| 4535 |
| 4536 Handle<JSFunction> g = |
| 4537 v8::Utils::OpenHandle( |
| 4538 *v8::Handle<v8::Function>::Cast( |
| 4539 CcTest::global()->Get(v8_str("g")))); |
| 4540 code = inner_scope.CloseAndEscape(handle(g->code(), isolate)); |
| 4541 if (!code->is_optimized_code()) return; |
| 4542 } |
| 4543 |
| 4544 Handle<FixedArray> lit = isolate->factory()->empty_fixed_array(); |
| 4545 Handle<Context> context(isolate->context()); |
| 4546 |
| 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 } |
| 4556 #endif // DEBUG |
| 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 |