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

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: 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
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 5387 matching lines...) Expand 10 before | Expand all | Expand 10 after
5398 CHECK(pos->IsSmi()); 5398 CHECK(pos->IsSmi());
5399 5399
5400 Handle<JSArray> stack_trace_array = Handle<JSArray>::cast(stack_trace); 5400 Handle<JSArray> stack_trace_array = Handle<JSArray>::cast(stack_trace);
5401 int array_length = Smi::cast(stack_trace_array->length())->value(); 5401 int array_length = Smi::cast(stack_trace_array->length())->value();
5402 for (int i = 0; i < array_length; i++) { 5402 for (int i = 0; i < array_length; i++) {
5403 Handle<Object> element = 5403 Handle<Object> element =
5404 Object::GetElement(isolate, stack_trace, i).ToHandleChecked(); 5404 Object::GetElement(isolate, stack_trace, i).ToHandleChecked();
5405 CHECK(!element->IsCode()); 5405 CHECK(!element->IsCode());
5406 } 5406 }
5407 } 5407 }
5408
5409
5410 static bool shared_has_been_collected = false;
5411 static bool builtin_exports_has_been_collected = false;
5412
5413 static void SharedHasBeenCollected(
5414 const v8::WeakCallbackInfo<v8::Persistent<v8::Object>>& data) {
5415 shared_has_been_collected = true;
5416 data.GetParameter()->Reset();
5417 }
5418
5419
5420 static void BuiltinExportsHasBeenCollected(
5421 const v8::WeakCallbackInfo<v8::Persistent<v8::Object>>& data) {
5422 builtin_exports_has_been_collected = true;
5423 data.GetParameter()->Reset();
5424 }
5425
5426
5427 TEST(BootstrappingExports) {
5428 FLAG_expose_natives_as = "natives";
5429 CcTest::InitializeVM();
5430 v8::Isolate* isolate = CcTest::isolate();
5431
5432 if (Snapshot::HaveASnapshotToStartFrom(CcTest::i_isolate())) return;
5433
5434 shared_has_been_collected = false;
5435 builtin_exports_has_been_collected = false;
5436
5437 v8::Persistent<v8::Object> shared;
5438 v8::Persistent<v8::Object> builtin_exports;
5439
5440 {
5441 v8::HandleScope scope(isolate);
5442 v8::Handle<v8::Object> natives =
5443 CcTest::global()->Get(v8_str("natives"))->ToObject(isolate);
5444 shared.Reset(isolate, natives->Get(v8_str("shared"))->ToObject(isolate));
5445 natives->Delete(v8_str("shared"));
5446 builtin_exports.Reset(
5447 isolate, natives->Get(v8_str("builtin_exports"))->ToObject(isolate));
5448 natives->Delete(v8_str("builtin_exports"));
5449 }
5450
5451 shared.SetWeak(&shared, SharedHasBeenCollected,
5452 v8::WeakCallbackType::kParameter);
5453 builtin_exports.SetWeak(&builtin_exports, BuiltinExportsHasBeenCollected,
5454 v8::WeakCallbackType::kParameter);
5455
5456 CcTest::heap()->CollectAllAvailableGarbage("fire weak callbacks");
5457
5458 CHECK(shared_has_been_collected);
5459 CHECK(builtin_exports_has_been_collected);
5460 }
OLDNEW
« src/objects.h ('K') | « 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