Index: test/cctest/test-heap.cc |
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc |
index 2e5f180c91a07618968c58bf6f1a352cc8fb8aa7..ab2391a875e88da54c1a2bddc8e82f54f0ed9187 100644 |
--- a/test/cctest/test-heap.cc |
+++ b/test/cctest/test-heap.cc |
@@ -5410,11 +5410,19 @@ |
} |
-static bool utils_has_been_collected = false; |
- |
-static void UtilsHasBeenCollected( |
+static bool shared_has_been_collected = false; |
+static bool builtin_exports_has_been_collected = false; |
+ |
+static void SharedHasBeenCollected( |
const v8::WeakCallbackInfo<v8::Persistent<v8::Object>>& data) { |
- utils_has_been_collected = true; |
+ shared_has_been_collected = true; |
+ data.GetParameter()->Reset(); |
+} |
+ |
+ |
+static void BuiltinExportsHasBeenCollected( |
+ const v8::WeakCallbackInfo<v8::Persistent<v8::Object>>& data) { |
+ builtin_exports_has_been_collected = true; |
data.GetParameter()->Reset(); |
} |
@@ -5426,50 +5434,30 @@ |
if (Snapshot::HaveASnapshotToStartFrom(CcTest::i_isolate())) return; |
- utils_has_been_collected = false; |
- |
- v8::Persistent<v8::Object> utils; |
+ shared_has_been_collected = false; |
+ builtin_exports_has_been_collected = false; |
+ |
+ v8::Persistent<v8::Object> shared; |
+ v8::Persistent<v8::Object> builtin_exports; |
{ |
v8::HandleScope scope(isolate); |
v8::Handle<v8::Object> natives = |
CcTest::global()->Get(v8_str("natives"))->ToObject(isolate); |
- utils.Reset(isolate, natives->Get(v8_str("utils"))->ToObject(isolate)); |
- natives->Delete(v8_str("utils")); |
- } |
- |
- utils.SetWeak(&utils, UtilsHasBeenCollected, |
- v8::WeakCallbackType::kParameter); |
+ shared.Reset(isolate, natives->Get(v8_str("shared"))->ToObject(isolate)); |
+ natives->Delete(v8_str("shared")); |
+ builtin_exports.Reset( |
+ isolate, natives->Get(v8_str("builtin_exports"))->ToObject(isolate)); |
+ natives->Delete(v8_str("builtin_exports")); |
+ } |
+ |
+ shared.SetWeak(&shared, SharedHasBeenCollected, |
+ v8::WeakCallbackType::kParameter); |
+ builtin_exports.SetWeak(&builtin_exports, BuiltinExportsHasBeenCollected, |
+ v8::WeakCallbackType::kParameter); |
CcTest::heap()->CollectAllAvailableGarbage("fire weak callbacks"); |
- CHECK(utils_has_been_collected); |
-} |
- |
- |
-TEST(Regress1878) { |
- FLAG_allow_natives_syntax = true; |
- CcTest::InitializeVM(); |
- v8::Isolate* isolate = CcTest::isolate(); |
- v8::HandleScope scope(isolate); |
- v8::Local<v8::Function> constructor = |
- v8::Utils::ToLocal(CcTest::i_isolate()->internal_array_function()); |
- CcTest::global()->Set(v8_str("InternalArray"), constructor); |
- |
- v8::TryCatch try_catch; |
- |
- CompileRun( |
- "var a = Array();" |
- "for (var i = 0; i < 1000; i++) {" |
- " var ai = new InternalArray(10000);" |
- " if (%HaveSameMap(ai, a)) throw Error();" |
- " if (!%HasFastObjectElements(ai)) throw Error();" |
- "}" |
- "for (var i = 0; i < 1000; i++) {" |
- " var ai = new InternalArray(10000);" |
- " if (%HaveSameMap(ai, a)) throw Error();" |
- " if (!%HasFastObjectElements(ai)) throw Error();" |
- "}"); |
- |
- CHECK(!try_catch.HasCaught()); |
-} |
+ CHECK(shared_has_been_collected); |
+ CHECK(builtin_exports_has_been_collected); |
+} |