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

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

Issue 1143993003: Use shared container to manage imports/exports. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fixed test for no-snap 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/weak-collection.js ('k') | test/mjsunit/debug-script.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 5392 matching lines...) Expand 10 before | Expand all | Expand 10 after
5403 Handle<JSArray> stack_trace_array = Handle<JSArray>::cast(stack_trace); 5403 Handle<JSArray> stack_trace_array = Handle<JSArray>::cast(stack_trace);
5404 int array_length = Smi::cast(stack_trace_array->length())->value(); 5404 int array_length = Smi::cast(stack_trace_array->length())->value();
5405 for (int i = 0; i < array_length; i++) { 5405 for (int i = 0; i < array_length; i++) {
5406 Handle<Object> element = 5406 Handle<Object> element =
5407 Object::GetElement(isolate, stack_trace, i).ToHandleChecked(); 5407 Object::GetElement(isolate, stack_trace, i).ToHandleChecked();
5408 CHECK(!element->IsCode()); 5408 CHECK(!element->IsCode());
5409 } 5409 }
5410 } 5410 }
5411 5411
5412 5412
5413 static bool shared_has_been_collected = false; 5413 static bool utils_has_been_collected = false;
5414 static bool builtin_exports_has_been_collected = false;
5415 5414
5416 static void SharedHasBeenCollected( 5415 static void UtilsHasBeenCollected(
5417 const v8::WeakCallbackInfo<v8::Persistent<v8::Object>>& data) { 5416 const v8::WeakCallbackInfo<v8::Persistent<v8::Object>>& data) {
5418 shared_has_been_collected = true; 5417 utils_has_been_collected = true;
5419 data.GetParameter()->Reset(); 5418 data.GetParameter()->Reset();
5420 } 5419 }
5421 5420
5422
5423 static void BuiltinExportsHasBeenCollected(
5424 const v8::WeakCallbackInfo<v8::Persistent<v8::Object>>& data) {
5425 builtin_exports_has_been_collected = true;
5426 data.GetParameter()->Reset();
5427 }
5428
5429 5421
5430 TEST(BootstrappingExports) { 5422 TEST(BootstrappingExports) {
5431 FLAG_expose_natives_as = "natives"; 5423 FLAG_expose_natives_as = "natives";
5432 CcTest::InitializeVM(); 5424 CcTest::InitializeVM();
5433 v8::Isolate* isolate = CcTest::isolate(); 5425 v8::Isolate* isolate = CcTest::isolate();
5434 5426
5435 if (Snapshot::HaveASnapshotToStartFrom(CcTest::i_isolate())) return; 5427 if (Snapshot::HaveASnapshotToStartFrom(CcTest::i_isolate())) return;
5436 5428
5437 shared_has_been_collected = false; 5429 utils_has_been_collected = false;
5438 builtin_exports_has_been_collected = false;
5439 5430
5440 v8::Persistent<v8::Object> shared; 5431 v8::Persistent<v8::Object> utils;
5441 v8::Persistent<v8::Object> builtin_exports;
5442 5432
5443 { 5433 {
5444 v8::HandleScope scope(isolate); 5434 v8::HandleScope scope(isolate);
5445 v8::Handle<v8::Object> natives = 5435 v8::Handle<v8::Object> natives =
5446 CcTest::global()->Get(v8_str("natives"))->ToObject(isolate); 5436 CcTest::global()->Get(v8_str("natives"))->ToObject(isolate);
5447 shared.Reset(isolate, natives->Get(v8_str("shared"))->ToObject(isolate)); 5437 utils.Reset(isolate, natives->Get(v8_str("utils"))->ToObject(isolate));
5448 natives->Delete(v8_str("shared")); 5438 natives->Delete(v8_str("utils"));
5449 builtin_exports.Reset(
5450 isolate, natives->Get(v8_str("builtin_exports"))->ToObject(isolate));
5451 natives->Delete(v8_str("builtin_exports"));
5452 } 5439 }
5453 5440
5454 shared.SetWeak(&shared, SharedHasBeenCollected, 5441 utils.SetWeak(&utils, UtilsHasBeenCollected,
5455 v8::WeakCallbackType::kParameter); 5442 v8::WeakCallbackType::kParameter);
5456 builtin_exports.SetWeak(&builtin_exports, BuiltinExportsHasBeenCollected,
5457 v8::WeakCallbackType::kParameter);
5458 5443
5459 CcTest::heap()->CollectAllAvailableGarbage("fire weak callbacks"); 5444 CcTest::heap()->CollectAllAvailableGarbage("fire weak callbacks");
5460 5445
5461 CHECK(shared_has_been_collected); 5446 CHECK(utils_has_been_collected);
5462 CHECK(builtin_exports_has_been_collected);
5463 } 5447 }
5448
5449
5450 TEST(Regress1878) {
5451 FLAG_allow_natives_syntax = true;
5452 CcTest::InitializeVM();
5453 v8::Isolate* isolate = CcTest::isolate();
5454 v8::HandleScope scope(isolate);
5455 v8::Local<v8::Function> constructor =
5456 v8::Utils::ToLocal(CcTest::i_isolate()->internal_array_function());
5457 CcTest::global()->Set(v8_str("InternalArray"), constructor);
5458
5459 v8::TryCatch try_catch;
5460
5461 CompileRun(
5462 "var a = Array();"
5463 "for (var i = 0; i < 1000; i++) {"
5464 " var ai = new InternalArray(10000);"
5465 " if (%HaveSameMap(ai, a)) throw Error();"
5466 " if (!%HasFastObjectElements(ai)) throw Error();"
5467 "}"
5468 "for (var i = 0; i < 1000; i++) {"
5469 " var ai = new InternalArray(10000);"
5470 " if (%HaveSameMap(ai, a)) throw Error();"
5471 " if (!%HasFastObjectElements(ai)) throw Error();"
5472 "}");
5473
5474 CHECK(!try_catch.HasCaught());
5475 }
OLDNEW
« no previous file with comments | « src/weak-collection.js ('k') | test/mjsunit/debug-script.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698