Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: test/cctest/test-heap.cc

Issue 11275186: Collect stack trace on stack overflow. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: . Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 2392 matching lines...) Expand 10 before | Expand all | Expand 10 after
2403 size_t length() const { return length_; } 2403 size_t length() const { return length_; }
2404 2404
2405 bool IsDisposed() { return data_ == NULL; } 2405 bool IsDisposed() { return data_ == NULL; }
2406 2406
2407 private: 2407 private:
2408 const char* data_; 2408 const char* data_;
2409 size_t length_; 2409 size_t length_;
2410 }; 2410 };
2411 2411
2412 2412
2413 TEST(ReleaseStackTraceData) { 2413 void ReleaseStackTraceDataTest(const char* source) {
2414 // Test that the data retained by the Error.stack accessor is released 2414 // Test that the data retained by the Error.stack accessor is released
2415 // after the first time the accessor is fired. We use external string 2415 // after the first time the accessor is fired. We use external string
2416 // to check whether the data is being released since the external string 2416 // to check whether the data is being released since the external string
2417 // resource's callback is fired when the external string is GC'ed. 2417 // resource's callback is fired when the external string is GC'ed.
2418 InitializeVM(); 2418 InitializeVM();
2419 v8::HandleScope scope; 2419 v8::HandleScope scope;
2420 static const char* source = "var error = 1; "
2421 "try { "
2422 " throw new Error(); "
2423 "} catch (e) { "
2424 " error = e; "
2425 "} ";
2426 SourceResource* resource = new SourceResource(i::StrDup(source)); 2420 SourceResource* resource = new SourceResource(i::StrDup(source));
2427 { 2421 {
2428 v8::HandleScope scope; 2422 v8::HandleScope scope;
2429 v8::Handle<v8::String> source_string = v8::String::NewExternal(resource); 2423 v8::Handle<v8::String> source_string = v8::String::NewExternal(resource);
2430 v8::Script::Compile(source_string)->Run(); 2424 v8::Script::Compile(source_string)->Run();
2431 CHECK(!resource->IsDisposed()); 2425 CHECK(!resource->IsDisposed());
2432 } 2426 }
2433 HEAP->CollectAllAvailableGarbage(); 2427 HEAP->CollectAllAvailableGarbage();
2434 // External source is being retained by the stack trace. 2428 // External source is being retained by the stack trace.
2435 CHECK(!resource->IsDisposed()); 2429 CHECK(!resource->IsDisposed());
2436 2430
2437 CompileRun("error.stack; error.stack;"); 2431 CompileRun("error.stack;");
2438 HEAP->CollectAllAvailableGarbage(); 2432 HEAP->CollectAllAvailableGarbage();
2439 // External source has been released. 2433 // External source has been released.
2440 CHECK(resource->IsDisposed()); 2434 CHECK(resource->IsDisposed());
2435 delete resource;
2436 }
2441 2437
2442 delete resource; 2438
2439 TEST(ReleaseStackTraceData) {
2440 static const char* source1 = "var error = null; "
2441 /* Normal Error */ "try { "
2442 " throw new Error(); "
2443 "} catch (e) { "
2444 " error = e; "
2445 "} ";
2446 static const char* source2 = "var error = null; "
2447 /* Stack overflow */ "try { "
2448 " (function f() { f(); })(); "
2449 "} catch (e) { "
2450 " error = e; "
2451 "} ";
2452 ReleaseStackTraceDataTest(source1);
2453 ReleaseStackTraceDataTest(source2);
2443 } 2454 }
2444 2455
2445 2456
2446 TEST(Regression144230) { 2457 TEST(Regression144230) {
2447 InitializeVM(); 2458 InitializeVM();
2448 v8::HandleScope scope; 2459 v8::HandleScope scope;
2449 2460
2450 // First make sure that the uninitialized CallIC stub is on a single page 2461 // First make sure that the uninitialized CallIC stub is on a single page
2451 // that will later be selected as an evacuation candidate. 2462 // that will later be selected as an evacuation candidate.
2452 { 2463 {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2493 Handle<Object> call_function(call); 2504 Handle<Object> call_function(call);
2494 2505
2495 // Now we are ready to mess up the heap. 2506 // Now we are ready to mess up the heap.
2496 HEAP->CollectAllGarbage(Heap::kReduceMemoryFootprintMask); 2507 HEAP->CollectAllGarbage(Heap::kReduceMemoryFootprintMask);
2497 2508
2498 // Either heap verification caught the problem already or we go kaboom once 2509 // Either heap verification caught the problem already or we go kaboom once
2499 // the CallIC is executed the next time. 2510 // the CallIC is executed the next time.
2500 USE(global->SetProperty(*name, *call_function, NONE, kNonStrictMode)); 2511 USE(global->SetProperty(*name, *call_function, NONE, kNonStrictMode));
2501 CompileRun("call();"); 2512 CompileRun("call();");
2502 } 2513 }
OLDNEW
« src/isolate.cc ('K') | « src/runtime.cc ('k') | test/mjsunit/stack-traces-overflow.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698