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

Unified Diff: test/cctest/test-heap.cc

Issue 1138173002: Reland "Use function wrapper argument to expose internal arrays to native scripts." (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: addressed nit 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/v8natives.js ('k') | test/mjsunit/debug-stepout-scope-part1.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-heap.cc
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index d8c89aec1b4b242a9702c3a018681bdb9b2569bc..5730cde1bb24e309c4422f84696e843d5a4912a4 100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -5430,3 +5430,56 @@ TEST(PreprocessStackTrace) {
CHECK(!element->IsCode());
}
}
+
+
+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) {
+ 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();
+}
+
+
+TEST(BootstrappingExports) {
+ FLAG_expose_natives_as = "natives";
+ CcTest::InitializeVM();
+ v8::Isolate* isolate = CcTest::isolate();
+
+ if (Snapshot::HaveASnapshotToStartFrom(CcTest::i_isolate())) return;
+
+ 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);
+ 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(shared_has_been_collected);
+ CHECK(builtin_exports_has_been_collected);
+}
« no previous file with comments | « src/v8natives.js ('k') | test/mjsunit/debug-stepout-scope-part1.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698