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

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

Issue 1127983003: Use function wrapper argument to expose internal arrays to native scripts. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebased and fixed nits 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/v8natives.js ('k') | test/mjsunit/regress/regress-1878.js » ('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 5412 matching lines...) Expand 10 before | Expand all | Expand 10 after
5423 CHECK(pos->IsSmi()); 5423 CHECK(pos->IsSmi());
5424 5424
5425 Handle<JSArray> stack_trace_array = Handle<JSArray>::cast(stack_trace); 5425 Handle<JSArray> stack_trace_array = Handle<JSArray>::cast(stack_trace);
5426 int array_length = Smi::cast(stack_trace_array->length())->value(); 5426 int array_length = Smi::cast(stack_trace_array->length())->value();
5427 for (int i = 0; i < array_length; i++) { 5427 for (int i = 0; i < array_length; i++) {
5428 Handle<Object> element = 5428 Handle<Object> element =
5429 Object::GetElement(isolate, stack_trace, i).ToHandleChecked(); 5429 Object::GetElement(isolate, stack_trace, i).ToHandleChecked();
5430 CHECK(!element->IsCode()); 5430 CHECK(!element->IsCode());
5431 } 5431 }
5432 } 5432 }
5433
5434
5435 static bool shared_has_been_collected = false;
5436 static bool builtin_exports_has_been_collected = false;
5437
5438 static void SharedHasBeenCollected(
5439 const v8::WeakCallbackInfo<v8::Persistent<v8::Object>>& data) {
5440 shared_has_been_collected = true;
5441 data.GetParameter()->Reset();
5442 }
5443
5444
5445 static void BuiltinExportsHasBeenCollected(
5446 const v8::WeakCallbackInfo<v8::Persistent<v8::Object>>& data) {
5447 builtin_exports_has_been_collected = true;
5448 data.GetParameter()->Reset();
5449 }
5450
5451
5452 TEST(BootstrappingExports) {
5453 FLAG_expose_natives_as = "natives";
5454 CcTest::InitializeVM();
5455 v8::Isolate* isolate = CcTest::isolate();
5456
5457 if (Snapshot::HaveASnapshotToStartFrom(CcTest::i_isolate())) return;
5458
5459 shared_has_been_collected = false;
5460 builtin_exports_has_been_collected = false;
5461
5462 v8::Persistent<v8::Object> shared;
5463 v8::Persistent<v8::Object> builtin_exports;
5464
5465 {
5466 v8::HandleScope scope(isolate);
5467 v8::Handle<v8::Object> natives =
5468 CcTest::global()->Get(v8_str("natives"))->ToObject(isolate);
5469 shared.Reset(isolate, natives->Get(v8_str("shared"))->ToObject(isolate));
5470 natives->Delete(v8_str("shared"));
5471 builtin_exports.Reset(
5472 isolate, natives->Get(v8_str("builtin_exports"))->ToObject(isolate));
5473 natives->Delete(v8_str("builtin_exports"));
5474 }
5475
5476 shared.SetWeak(&shared, SharedHasBeenCollected,
5477 v8::WeakCallbackType::kParameter);
5478 builtin_exports.SetWeak(&builtin_exports, BuiltinExportsHasBeenCollected,
5479 v8::WeakCallbackType::kParameter);
5480
5481 CcTest::heap()->CollectAllAvailableGarbage("fire weak callbacks");
5482
5483 CHECK(shared_has_been_collected);
5484 CHECK(builtin_exports_has_been_collected);
5485 }
OLDNEW
« no previous file with comments | « src/v8natives.js ('k') | test/mjsunit/regress/regress-1878.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698