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

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

Issue 1150293002: Do not leak message object beyond try-catch. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix memory leak by setting flag Created 5 years, 7 months 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
« no previous file with comments | « src/x87/full-codegen-x87.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 5540 matching lines...) Expand 10 before | Expand all | Expand 10 after
5551 size_t counter2 = 2000; 5551 size_t counter2 = 2000;
5552 tracer->SampleNewSpaceAllocation(time2, counter2); 5552 tracer->SampleNewSpaceAllocation(time2, counter2);
5553 size_t bytes = tracer->NewSpaceAllocatedBytesInLast(1000); 5553 size_t bytes = tracer->NewSpaceAllocatedBytesInLast(1000);
5554 CHECK_EQ(10000, bytes); 5554 CHECK_EQ(10000, bytes);
5555 int time3 = 1000; 5555 int time3 = 1000;
5556 size_t counter3 = 30000; 5556 size_t counter3 = 30000;
5557 tracer->SampleNewSpaceAllocation(time3, counter3); 5557 tracer->SampleNewSpaceAllocation(time3, counter3);
5558 bytes = tracer->NewSpaceAllocatedBytesInLast(100); 5558 bytes = tracer->NewSpaceAllocatedBytesInLast(100);
5559 CHECK_EQ((counter3 - counter1) * 100 / (time3 - time1), bytes); 5559 CHECK_EQ((counter3 - counter1) * 100 / (time3 - time1), bytes);
5560 } 5560 }
5561
5562
5563 static void CheckLeak(const v8::FunctionCallbackInfo<v8::Value>& args) {
5564 Isolate* isolate = CcTest::i_isolate();
5565 Object* message =
5566 *reinterpret_cast<Object**>(isolate->pending_message_obj_address());
5567 CHECK(message->IsTheHole());
5568 }
5569
5570
5571 TEST(MessageObjectLeak) {
5572 CcTest::InitializeVM();
5573 v8::Isolate* isolate = CcTest::isolate();
5574 v8::HandleScope scope(isolate);
5575 v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate);
5576 global->Set(v8::String::NewFromUtf8(isolate, "check"),
5577 v8::FunctionTemplate::New(isolate, CheckLeak));
5578 v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global);
5579 v8::Context::Scope cscope(context);
5580
5581 const char* test =
5582 "try {"
5583 " throw 'message 1';"
5584 "} catch (e) {"
5585 "}"
5586 "check();"
5587 "L: try {"
5588 " throw 'message 2';"
5589 "} finally {"
5590 " break L;"
5591 "}"
5592 "check();";
5593 CompileRun(test);
5594
5595 const char* flag = "--turbo-filter=*";
5596 FlagList::SetFlagsFromString(flag, StrLength(flag));
5597 FLAG_always_opt = true;
5598 FLAG_turbo_exceptions = true;
5599
5600 CompileRun(test);
5601 }
OLDNEW
« no previous file with comments | « src/x87/full-codegen-x87.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698