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

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

Issue 1375613005: Version 4.8.2.1 (cherry-pick) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@4.8.2
Patch Set: Created 5 years, 2 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 | « test/cctest/cctest.h ('k') | test/cctest/test-heap.cc » ('j') | 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 6518 matching lines...) Expand 10 before | Expand all | Expand 10 after
6529 FlagAndPersistent object_a, object_b; 6529 FlagAndPersistent object_a, object_b;
6530 6530
6531 intptr_t big_heap_size; 6531 intptr_t big_heap_size;
6532 6532
6533 { 6533 {
6534 v8::HandleScope handle_scope(iso); 6534 v8::HandleScope handle_scope(iso);
6535 Local<Object> a(v8::Object::New(iso)); 6535 Local<Object> a(v8::Object::New(iso));
6536 Local<Object> b(v8::Object::New(iso)); 6536 Local<Object> b(v8::Object::New(iso));
6537 object_a.handle.Reset(iso, a); 6537 object_a.handle.Reset(iso, a);
6538 object_b.handle.Reset(iso, b); 6538 object_b.handle.Reset(iso, b);
6539 if (interlinked && 6539 if (interlinked) {
6540 !v8::internal::FLAG_scavenge_reclaim_unmodified_objects) {
6541 a->Set(v8_str("x"), b); 6540 a->Set(v8_str("x"), b);
6542 b->Set(v8_str("x"), a); 6541 b->Set(v8_str("x"), a);
6543 } 6542 }
6544 if (global_gc) { 6543 if (global_gc) {
6545 CcTest::heap()->CollectAllGarbage(); 6544 CcTest::heap()->CollectAllGarbage();
6546 } else { 6545 } else {
6547 CcTest::heap()->CollectGarbage(i::NEW_SPACE); 6546 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
6548 } 6547 }
6549 // We are relying on this creating a big flag array and reserving the space 6548 // We are relying on this creating a big flag array and reserving the space
6550 // up front. 6549 // up front.
6551 v8::Handle<Value> big_array = CompileRun("new Array(5000)"); 6550 v8::Handle<Value> big_array = CompileRun("new Array(50000)");
6552 if (!v8::internal::FLAG_scavenge_reclaim_unmodified_objects) 6551 a->Set(v8_str("y"), big_array);
6553 a->Set(v8_str("y"), big_array);
6554 big_heap_size = CcTest::heap()->SizeOfObjects(); 6552 big_heap_size = CcTest::heap()->SizeOfObjects();
6555 } 6553 }
6556 6554
6557 object_a.flag = false; 6555 object_a.flag = false;
6558 object_b.flag = false; 6556 object_b.flag = false;
6559 object_a.handle.SetWeak(&object_a, &SetFlag, 6557 object_a.handle.SetWeak(&object_a, &SetFlag,
6560 v8::WeakCallbackType::kParameter); 6558 v8::WeakCallbackType::kParameter);
6561 object_b.handle.SetWeak(&object_b, &SetFlag, 6559 object_b.handle.SetWeak(&object_b, &SetFlag,
6562 v8::WeakCallbackType::kParameter); 6560 v8::WeakCallbackType::kParameter);
6563 CHECK(!object_b.handle.IsIndependent()); 6561 CHECK(!object_b.handle.IsIndependent());
6564 object_a.handle.MarkIndependent(); 6562 object_a.handle.MarkIndependent();
6565 object_b.handle.MarkIndependent(); 6563 object_b.handle.MarkIndependent();
6566 CHECK(object_b.handle.IsIndependent()); 6564 CHECK(object_b.handle.IsIndependent());
6567 if (global_gc) { 6565 if (global_gc) {
6568 CcTest::heap()->CollectAllGarbage(); 6566 CcTest::heap()->CollectAllGarbage();
6569 } else { 6567 } else {
6570 CcTest::heap()->CollectGarbage(i::NEW_SPACE); 6568 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
6571 } 6569 }
6572 // A single GC should be enough to reclaim the memory, since we are using 6570 // A single GC should be enough to reclaim the memory, since we are using
6573 // phantom handles. 6571 // phantom handles.
6574 CHECK_LT(CcTest::heap()->SizeOfObjects(), big_heap_size - 20000); 6572 CHECK_LT(CcTest::heap()->SizeOfObjects(), big_heap_size - 200000);
6575 CHECK(object_a.flag); 6573 CHECK(object_a.flag);
6576 CHECK(object_b.flag); 6574 CHECK(object_b.flag);
6577 } 6575 }
6578 6576
6579 6577
6580 TEST(IndependentWeakHandle) { 6578 TEST(IndependentWeakHandle) {
6581 IndependentWeakHandle(false, false); 6579 IndependentWeakHandle(false, false);
6582 IndependentWeakHandle(false, true); 6580 IndependentWeakHandle(false, true);
6583 IndependentWeakHandle(true, false); 6581 IndependentWeakHandle(true, false);
6584 IndependentWeakHandle(true, true); 6582 IndependentWeakHandle(true, true);
(...skipping 15304 matching lines...) Expand 10 before | Expand all | Expand 10 after
21889 CompileRun("function boom() { throw new Error(\"boom\") }"); 21887 CompileRun("function boom() { throw new Error(\"boom\") }");
21890 21888
21891 v8::Local<v8::Object> global_object = env->Global(); 21889 v8::Local<v8::Object> global_object = env->Global();
21892 v8::Local<v8::Function> foo = 21890 v8::Local<v8::Function> foo =
21893 v8::Local<v8::Function>::Cast(global_object->Get(v8_str("boom"))); 21891 v8::Local<v8::Function>::Cast(global_object->Get(v8_str("boom")));
21894 21892
21895 foo->Call(global_object, 0, NULL); 21893 foo->Call(global_object, 0, NULL);
21896 21894
21897 CHECK_EQ(1, nb_uncaught_exception_callback_calls); 21895 CHECK_EQ(1, nb_uncaught_exception_callback_calls);
21898 } 21896 }
OLDNEW
« no previous file with comments | « test/cctest/cctest.h ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698