| 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 4412 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4423     BailoutId id = BailoutId(i); | 4423     BailoutId id = BailoutId(i); | 
| 4424     SharedFunctionInfo::AddToOptimizedCodeMap(shared, context, code, lit, id); | 4424     SharedFunctionInfo::AddToOptimizedCodeMap(shared, context, code, lit, id); | 
| 4425   } | 4425   } | 
| 4426 | 4426 | 
| 4427   // Trigger a GC to flush out the bug. | 4427   // Trigger a GC to flush out the bug. | 
| 4428   heap->CollectGarbage(i::OLD_SPACE, "fire in the hole"); | 4428   heap->CollectGarbage(i::OLD_SPACE, "fire in the hole"); | 
| 4429   boomer->Print(); | 4429   boomer->Print(); | 
| 4430 } | 4430 } | 
| 4431 | 4431 | 
| 4432 | 4432 | 
|  | 4433 TEST(Regress513496) { | 
|  | 4434   i::FLAG_flush_optimized_code_cache = false; | 
|  | 4435   i::FLAG_allow_natives_syntax = true; | 
|  | 4436   CcTest::InitializeVM(); | 
|  | 4437   Isolate* isolate = CcTest::i_isolate(); | 
|  | 4438   Heap* heap = isolate->heap(); | 
|  | 4439   HandleScope scope(isolate); | 
|  | 4440 | 
|  | 4441   // Perfrom one initial GC to enable code flushing. | 
|  | 4442   CcTest::heap()->CollectAllGarbage(); | 
|  | 4443 | 
|  | 4444   // Prepare an optimized closure with containing an inlined function. Then age | 
|  | 4445   // the inlined unoptimized code to trigger code flushing but make sure the | 
|  | 4446   // outer optimized code is kept in the optimized code map. | 
|  | 4447   Handle<SharedFunctionInfo> shared; | 
|  | 4448   { | 
|  | 4449     HandleScope inner_scope(isolate); | 
|  | 4450     CompileRun( | 
|  | 4451         "function g(x) { return x + 1 }" | 
|  | 4452         "function mkClosure() {" | 
|  | 4453         "  return function(x) { return g(x); };" | 
|  | 4454         "}" | 
|  | 4455         "var f = mkClosure();" | 
|  | 4456         "f(1); f(2);" | 
|  | 4457         "%OptimizeFunctionOnNextCall(f); f(3);"); | 
|  | 4458 | 
|  | 4459     Handle<JSFunction> g = Handle<JSFunction>::cast(v8::Utils::OpenHandle( | 
|  | 4460         *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("g"))))); | 
|  | 4461     CHECK(g->shared()->is_compiled()); | 
|  | 4462     const int kAgingThreshold = 6; | 
|  | 4463     for (int i = 0; i < kAgingThreshold; i++) { | 
|  | 4464       g->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2)); | 
|  | 4465     } | 
|  | 4466 | 
|  | 4467     Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle( | 
|  | 4468         *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f"))))); | 
|  | 4469     CHECK(f->is_compiled()); | 
|  | 4470     shared = inner_scope.CloseAndEscape(handle(f->shared(), isolate)); | 
|  | 4471     CompileRun("f = null"); | 
|  | 4472   } | 
|  | 4473 | 
|  | 4474   // Lookup the optimized code and keep it alive. | 
|  | 4475   CodeAndLiterals result = shared->SearchOptimizedCodeMap( | 
|  | 4476       isolate->context()->native_context(), BailoutId::None()); | 
|  | 4477   Handle<Code> optimized_code(result.code, isolate); | 
|  | 4478 | 
|  | 4479   // Finish a full GC cycle so that the unoptimized code of 'g' is flushed even | 
|  | 4480   // though the optimized code for 'f' is reachable via the optimized code map. | 
|  | 4481   heap->CollectAllGarbage(); | 
|  | 4482 | 
|  | 4483   // Make a new closure that will get code installed from the code map. | 
|  | 4484   // Unoptimized code is missing and the deoptimizer will go ballistic. | 
|  | 4485   CompileRun("var h = mkClosure(); h('bozo');"); | 
|  | 4486 } | 
|  | 4487 | 
|  | 4488 | 
| 4433 TEST(LargeObjectSlotRecording) { | 4489 TEST(LargeObjectSlotRecording) { | 
| 4434   FLAG_manual_evacuation_candidates_selection = true; | 4490   FLAG_manual_evacuation_candidates_selection = true; | 
| 4435   CcTest::InitializeVM(); | 4491   CcTest::InitializeVM(); | 
| 4436   Isolate* isolate = CcTest::i_isolate(); | 4492   Isolate* isolate = CcTest::i_isolate(); | 
| 4437   Heap* heap = isolate->heap(); | 4493   Heap* heap = isolate->heap(); | 
| 4438   HandleScope scope(isolate); | 4494   HandleScope scope(isolate); | 
| 4439 | 4495 | 
| 4440   // Create an object on an evacuation candidate. | 4496   // Create an object on an evacuation candidate. | 
| 4441   SimulateFullSpace(heap->old_space()); | 4497   SimulateFullSpace(heap->old_space()); | 
| 4442   Handle<FixedArray> lit = isolate->factory()->NewFixedArray(4, TENURED); | 4498   Handle<FixedArray> lit = isolate->factory()->NewFixedArray(4, TENURED); | 
| (...skipping 1841 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 6284   isolate->IncrementJsCallsFromApiCounter(); | 6340   isolate->IncrementJsCallsFromApiCounter(); | 
| 6285   isolate->IncrementJsCallsFromApiCounter(); | 6341   isolate->IncrementJsCallsFromApiCounter(); | 
| 6286   isolate->IncrementJsCallsFromApiCounter(); | 6342   isolate->IncrementJsCallsFromApiCounter(); | 
| 6287   calls_per_ms = memory_reducer->SampleAndGetJsCallsPerMs(4); | 6343   calls_per_ms = memory_reducer->SampleAndGetJsCallsPerMs(4); | 
| 6288   CheckDoubleEquals(2, calls_per_ms); | 6344   CheckDoubleEquals(2, calls_per_ms); | 
| 6289 } | 6345 } | 
| 6290 | 6346 | 
| 6291 | 6347 | 
| 6292 }  // namespace internal | 6348 }  // namespace internal | 
| 6293 }  // namespace v8 | 6349 }  // namespace v8 | 
| OLD | NEW | 
|---|