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 7103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7114 prev.SetWeak<Value, Snorkel<Value> >(new Snorkel<Value>(&prev.As<Value>()), | 7114 prev.SetWeak<Value, Snorkel<Value> >(new Snorkel<Value>(&prev.As<Value>()), |
7115 &HandleWeakReference); | 7115 &HandleWeakReference); |
7116 } | 7116 } |
7117 whammy->objects_[whammy->cursor_].Reset(info.GetIsolate(), obj); | 7117 whammy->objects_[whammy->cursor_].Reset(info.GetIsolate(), obj); |
7118 whammy->cursor_ = (whammy->cursor_ + 1) % Whammy::kObjectCount; | 7118 whammy->cursor_ = (whammy->cursor_ + 1) % Whammy::kObjectCount; |
7119 info.GetReturnValue().Set(whammy->getScript()->Run()); | 7119 info.GetReturnValue().Set(whammy->getScript()->Run()); |
7120 } | 7120 } |
7121 | 7121 |
7122 | 7122 |
7123 THREADED_TEST(WeakReference) { | 7123 THREADED_TEST(WeakReference) { |
| 7124 i::FLAG_expose_gc = true; |
7124 v8::Isolate* isolate = CcTest::isolate(); | 7125 v8::Isolate* isolate = CcTest::isolate(); |
7125 v8::HandleScope handle_scope(isolate); | 7126 v8::HandleScope handle_scope(isolate); |
7126 v8::Handle<v8::ObjectTemplate> templ= v8::ObjectTemplate::New(isolate); | 7127 v8::Handle<v8::ObjectTemplate> templ= v8::ObjectTemplate::New(isolate); |
7127 Whammy* whammy = new Whammy(CcTest::isolate()); | 7128 Whammy* whammy = new Whammy(CcTest::isolate()); |
7128 templ->SetNamedPropertyHandler(WhammyPropertyGetter, | 7129 templ->SetNamedPropertyHandler(WhammyPropertyGetter, |
7129 0, 0, 0, 0, | 7130 0, 0, 0, 0, |
7130 v8::External::New(CcTest::isolate(), whammy)); | 7131 v8::External::New(CcTest::isolate(), whammy)); |
7131 const char* extension_list[] = { "v8/gc" }; | 7132 const char* extension_list[] = { "v8/gc" }; |
7132 v8::ExtensionConfiguration extensions(1, extension_list); | 7133 v8::ExtensionConfiguration extensions(1, extension_list); |
7133 v8::Handle<Context> context = | 7134 v8::Handle<Context> context = |
(...skipping 6338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13472 #ifdef DEBUG | 13473 #ifdef DEBUG |
13473 if (count != expected) CcTest::heap()->TracePathToGlobal(); | 13474 if (count != expected) CcTest::heap()->TracePathToGlobal(); |
13474 #endif | 13475 #endif |
13475 CHECK_EQ(expected, count); | 13476 CHECK_EQ(expected, count); |
13476 } | 13477 } |
13477 | 13478 |
13478 | 13479 |
13479 TEST(DontLeakGlobalObjects) { | 13480 TEST(DontLeakGlobalObjects) { |
13480 // Regression test for issues 1139850 and 1174891. | 13481 // Regression test for issues 1139850 and 1174891. |
13481 | 13482 |
| 13483 i::FLAG_expose_gc = true; |
13482 v8::V8::Initialize(); | 13484 v8::V8::Initialize(); |
13483 | 13485 |
13484 for (int i = 0; i < 5; i++) { | 13486 for (int i = 0; i < 5; i++) { |
13485 { v8::HandleScope scope(CcTest::isolate()); | 13487 { v8::HandleScope scope(CcTest::isolate()); |
13486 LocalContext context; | 13488 LocalContext context; |
13487 } | 13489 } |
13488 v8::V8::ContextDisposedNotification(); | 13490 v8::V8::ContextDisposedNotification(); |
13489 CheckSurvivingGlobalObjectsCount(0); | 13491 CheckSurvivingGlobalObjectsCount(0); |
13490 | 13492 |
13491 { v8::HandleScope scope(CcTest::isolate()); | 13493 { v8::HandleScope scope(CcTest::isolate()); |
(...skipping 8323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21815 context->Global()->Set(v8_str("P"), templ->NewInstance()); | 21817 context->Global()->Set(v8_str("P"), templ->NewInstance()); |
21816 CompileRun( | 21818 CompileRun( |
21817 "function C1() {" | 21819 "function C1() {" |
21818 " this.x = 23;" | 21820 " this.x = 23;" |
21819 "};" | 21821 "};" |
21820 "C1.prototype = P;" | 21822 "C1.prototype = P;" |
21821 "for (var i = 0; i < 4; i++ ) {" | 21823 "for (var i = 0; i < 4; i++ ) {" |
21822 " new C1();" | 21824 " new C1();" |
21823 "}"); | 21825 "}"); |
21824 } | 21826 } |
OLD | NEW |