OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 | 2 |
3 #include <stdlib.h> | 3 #include <stdlib.h> |
4 | 4 |
5 #include "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #include "compilation-cache.h" | 7 #include "compilation-cache.h" |
8 #include "execution.h" | 8 #include "execution.h" |
9 #include "factory.h" | 9 #include "factory.h" |
10 #include "macro-assembler.h" | 10 #include "macro-assembler.h" |
(...skipping 2407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2418 InitializeVM(); | 2418 InitializeVM(); |
2419 v8::HandleScope scope; | 2419 v8::HandleScope scope; |
2420 SourceResource* resource = new SourceResource(i::StrDup(source)); | 2420 SourceResource* resource = new SourceResource(i::StrDup(source)); |
2421 { | 2421 { |
2422 v8::HandleScope scope; | 2422 v8::HandleScope scope; |
2423 v8::Handle<v8::String> source_string = v8::String::NewExternal(resource); | 2423 v8::Handle<v8::String> source_string = v8::String::NewExternal(resource); |
2424 v8::Script::Compile(source_string)->Run(); | 2424 v8::Script::Compile(source_string)->Run(); |
2425 CHECK(!resource->IsDisposed()); | 2425 CHECK(!resource->IsDisposed()); |
2426 } | 2426 } |
2427 HEAP->CollectAllAvailableGarbage(); | 2427 HEAP->CollectAllAvailableGarbage(); |
2428 // External source is being retained by the stack trace. | |
2429 CHECK(!resource->IsDisposed()); | |
2430 | 2428 |
2431 CompileRun("error.stack;"); | |
2432 HEAP->CollectAllAvailableGarbage(); | |
2433 // External source has been released. | 2429 // External source has been released. |
2434 CHECK(resource->IsDisposed()); | 2430 CHECK(resource->IsDisposed()); |
2435 delete resource; | 2431 delete resource; |
2436 } | 2432 } |
2437 | 2433 |
2438 | 2434 |
2439 TEST(ReleaseStackTraceData) { | 2435 TEST(ReleaseStackTraceData) { |
2440 static const char* source1 = "var error = null; " | 2436 static const char* source1 = "var error = null; " |
2441 /* Normal Error */ "try { " | 2437 /* Normal Error */ "try { " |
2442 " throw new Error(); " | 2438 " throw new Error(); " |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2504 Handle<Object> call_function(call); | 2500 Handle<Object> call_function(call); |
2505 | 2501 |
2506 // Now we are ready to mess up the heap. | 2502 // Now we are ready to mess up the heap. |
2507 HEAP->CollectAllGarbage(Heap::kReduceMemoryFootprintMask); | 2503 HEAP->CollectAllGarbage(Heap::kReduceMemoryFootprintMask); |
2508 | 2504 |
2509 // Either heap verification caught the problem already or we go kaboom once | 2505 // Either heap verification caught the problem already or we go kaboom once |
2510 // the CallIC is executed the next time. | 2506 // the CallIC is executed the next time. |
2511 USE(global->SetProperty(*name, *call_function, NONE, kNonStrictMode)); | 2507 USE(global->SetProperty(*name, *call_function, NONE, kNonStrictMode)); |
2512 CompileRun("call();"); | 2508 CompileRun("call();"); |
2513 } | 2509 } |
OLD | NEW |