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

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

Issue 764003003: Reland parts of 'Use weak cells in map checks in polymorphic ICs' (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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 3405 matching lines...) Expand 10 before | Expand all | Expand 10 after
3416 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 3416 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
3417 if (FLAG_vector_ics) { 3417 if (FLAG_vector_ics) {
3418 CheckVectorICCleared(f, 0); 3418 CheckVectorICCleared(f, 0);
3419 CHECK(ic_after->ic_state() == DEFAULT); 3419 CHECK(ic_after->ic_state() == DEFAULT);
3420 } else { 3420 } else {
3421 CHECK(IC::IsCleared(ic_after)); 3421 CHECK(IC::IsCleared(ic_after));
3422 } 3422 }
3423 } 3423 }
3424 3424
3425 3425
3426 TEST(IncrementalMarkingPreservesPolymorphicIC) {
3427 if (i::FLAG_always_opt) return;
3428 CcTest::InitializeVM();
3429 v8::HandleScope scope(CcTest::isolate());
3430 v8::Local<v8::Value> obj1, obj2;
3431
3432 {
3433 LocalContext env;
3434 CompileRun("function fun() { this.x = 1; }; var obj = new fun();");
3435 obj1 = env->Global()->Get(v8_str("obj"));
3436 }
3437
3438 {
3439 LocalContext env;
3440 CompileRun("function fun() { this.x = 2; }; var obj = new fun();");
3441 obj2 = env->Global()->Get(v8_str("obj"));
3442 }
3443
3444 // Prepare function f that contains a polymorphic IC for objects
3445 // originating from two different native contexts.
3446 CcTest::global()->Set(v8_str("obj1"), obj1);
3447 CcTest::global()->Set(v8_str("obj2"), obj2);
3448 CompileRun("function f(o) { return o.x; } f(obj1); f(obj1); f(obj2);");
3449 Handle<JSFunction> f = v8::Utils::OpenHandle(
3450 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f"))));
3451
3452 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
3453 CHECK(ic_before->ic_state() == POLYMORPHIC);
3454
3455 // Fire context dispose notification.
3456 SimulateIncrementalMarking(CcTest::heap());
3457 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
3458
3459 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
3460 CHECK(ic_after->ic_state() == POLYMORPHIC);
3461 }
3462
3463
3426 TEST(IncrementalMarkingClearsPolymorphicIC) { 3464 TEST(IncrementalMarkingClearsPolymorphicIC) {
3427 if (i::FLAG_always_opt) return; 3465 if (i::FLAG_always_opt) return;
3428 CcTest::InitializeVM(); 3466 CcTest::InitializeVM();
3429 v8::HandleScope scope(CcTest::isolate()); 3467 v8::HandleScope scope(CcTest::isolate());
3430 v8::Local<v8::Value> obj1, obj2; 3468 v8::Local<v8::Value> obj1, obj2;
3431 3469
3432 { 3470 {
3433 LocalContext env; 3471 LocalContext env;
3434 CompileRun("function fun() { this.x = 1; }; var obj = new fun();"); 3472 CompileRun("function fun() { this.x = 1; }; var obj = new fun();");
3435 obj1 = env->Global()->Get(v8_str("obj")); 3473 obj1 = env->Global()->Get(v8_str("obj"));
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after
4373 " var proto = {'name' : 'weak'};" 4411 " var proto = {'name' : 'weak'};"
4374 " var obj = Object.create(proto);" 4412 " var obj = Object.create(proto);"
4375 " loadIC(obj);" 4413 " loadIC(obj);"
4376 " loadIC(obj);" 4414 " loadIC(obj);"
4377 " loadIC(obj);" 4415 " loadIC(obj);"
4378 " return proto;" 4416 " return proto;"
4379 " })();"); 4417 " })();");
4380 } 4418 }
4381 4419
4382 4420
4421 TEST(WeakMapInPolymorphicLoadIC) {
4422 CheckWeakness(
4423 "function loadIC(obj) {"
4424 " return obj.name;"
4425 "}"
4426 " (function() {"
4427 " var proto = {'name' : 'weak'};"
4428 " var obj = Object.create(proto);"
4429 " loadIC(obj);"
4430 " loadIC(obj);"
4431 " loadIC(obj);"
4432 " var poly = Object.create(proto);"
4433 " poly.x = true;"
4434 " loadIC(poly);"
4435 " return proto;"
4436 " })();");
4437 }
4438
4439
4383 TEST(WeakMapInMonomorphicKeyedLoadIC) { 4440 TEST(WeakMapInMonomorphicKeyedLoadIC) {
4384 // TODO(mvstanton): vector ics need weak support! 4441 // TODO(mvstanton): vector ics need weak support!
4385 if (FLAG_vector_ics) return; 4442 if (FLAG_vector_ics) return;
4386 CheckWeakness("function keyedLoadIC(obj, field) {" 4443 CheckWeakness("function keyedLoadIC(obj, field) {"
4387 " return obj[field];" 4444 " return obj[field];"
4388 "}" 4445 "}"
4389 " (function() {" 4446 " (function() {"
4390 " var proto = {'name' : 'weak'};" 4447 " var proto = {'name' : 'weak'};"
4391 " var obj = Object.create(proto);" 4448 " var obj = Object.create(proto);"
4392 " keyedLoadIC(obj, 'name');" 4449 " keyedLoadIC(obj, 'name');"
4393 " keyedLoadIC(obj, 'name');" 4450 " keyedLoadIC(obj, 'name');"
4394 " keyedLoadIC(obj, 'name');" 4451 " keyedLoadIC(obj, 'name');"
4395 " return proto;" 4452 " return proto;"
4396 " })();"); 4453 " })();");
4397 } 4454 }
4398 4455
4399 4456
4457 TEST(WeakMapInPolymorphicKeyedLoadIC) {
4458 CheckWeakness(
4459 "function keyedLoadIC(obj, field) {"
4460 " return obj[field];"
4461 "}"
4462 " (function() {"
4463 " var proto = {'name' : 'weak'};"
4464 " var obj = Object.create(proto);"
4465 " keyedLoadIC(obj, 'name');"
4466 " keyedLoadIC(obj, 'name');"
4467 " keyedLoadIC(obj, 'name');"
4468 " var poly = Object.create(proto);"
4469 " poly.x = true;"
4470 " keyedLoadIC(poly, 'name');"
4471 " return proto;"
4472 " })();");
4473 }
4474
4475
4400 TEST(WeakMapInMonomorphicStoreIC) { 4476 TEST(WeakMapInMonomorphicStoreIC) {
4401 CheckWeakness("function storeIC(obj, value) {" 4477 CheckWeakness("function storeIC(obj, value) {"
4402 " obj.name = value;" 4478 " obj.name = value;"
4403 "}" 4479 "}"
4404 " (function() {" 4480 " (function() {"
4405 " var proto = {'name' : 'weak'};" 4481 " var proto = {'name' : 'weak'};"
4406 " var obj = Object.create(proto);" 4482 " var obj = Object.create(proto);"
4407 " storeIC(obj, 'x');" 4483 " storeIC(obj, 'x');"
4408 " storeIC(obj, 'x');" 4484 " storeIC(obj, 'x');"
4409 " storeIC(obj, 'x');" 4485 " storeIC(obj, 'x');"
4410 " return proto;" 4486 " return proto;"
4411 " })();"); 4487 " })();");
4412 } 4488 }
4413 4489
4414 4490
4491 TEST(WeakMapInPolymorphicStoreIC) {
4492 CheckWeakness(
4493 "function storeIC(obj, value) {"
4494 " obj.name = value;"
4495 "}"
4496 " (function() {"
4497 " var proto = {'name' : 'weak'};"
4498 " var obj = Object.create(proto);"
4499 " storeIC(obj, 'x');"
4500 " storeIC(obj, 'x');"
4501 " storeIC(obj, 'x');"
4502 " var poly = Object.create(proto);"
4503 " poly.x = true;"
4504 " storeIC(poly, 'x');"
4505 " return proto;"
4506 " })();");
4507 }
4508
4509
4415 TEST(WeakMapInMonomorphicKeyedStoreIC) { 4510 TEST(WeakMapInMonomorphicKeyedStoreIC) {
4416 CheckWeakness("function keyedStoreIC(obj, field, value) {" 4511 CheckWeakness("function keyedStoreIC(obj, field, value) {"
4417 " obj[field] = value;" 4512 " obj[field] = value;"
4418 "}" 4513 "}"
4419 " (function() {" 4514 " (function() {"
4420 " var proto = {'name' : 'weak'};" 4515 " var proto = {'name' : 'weak'};"
4421 " var obj = Object.create(proto);" 4516 " var obj = Object.create(proto);"
4422 " keyedStoreIC(obj, 'x');" 4517 " keyedStoreIC(obj, 'x');"
4423 " keyedStoreIC(obj, 'x');" 4518 " keyedStoreIC(obj, 'x');"
4424 " keyedStoreIC(obj, 'x');" 4519 " keyedStoreIC(obj, 'x');"
4425 " return proto;" 4520 " return proto;"
4426 " })();"); 4521 " })();");
4427 } 4522 }
4428 4523
4429 4524
4525 TEST(WeakMapInPolymorphicKeyedStoreIC) {
4526 CheckWeakness(
4527 "function keyedStoreIC(obj, field, value) {"
4528 " obj[field] = value;"
4529 "}"
4530 " (function() {"
4531 " var proto = {'name' : 'weak'};"
4532 " var obj = Object.create(proto);"
4533 " keyedStoreIC(obj, 'x');"
4534 " keyedStoreIC(obj, 'x');"
4535 " keyedStoreIC(obj, 'x');"
4536 " var poly = Object.create(proto);"
4537 " poly.x = true;"
4538 " keyedStoreIC(poly, 'x');"
4539 " return proto;"
4540 " })();");
4541 }
4542
4543
4430 TEST(WeakMapInMonomorphicCompareNilIC) { 4544 TEST(WeakMapInMonomorphicCompareNilIC) {
4431 CheckWeakness("function compareNilIC(obj) {" 4545 CheckWeakness("function compareNilIC(obj) {"
4432 " return obj == null;" 4546 " return obj == null;"
4433 "}" 4547 "}"
4434 " (function() {" 4548 " (function() {"
4435 " var proto = {'name' : 'weak'};" 4549 " var proto = {'name' : 'weak'};"
4436 " var obj = Object.create(proto);" 4550 " var obj = Object.create(proto);"
4437 " compareNilIC(obj);" 4551 " compareNilIC(obj);"
4438 " compareNilIC(obj);" 4552 " compareNilIC(obj);"
4439 " compareNilIC(obj);" 4553 " compareNilIC(obj);"
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
4812 #ifdef DEBUG 4926 #ifdef DEBUG
4813 TEST(PathTracer) { 4927 TEST(PathTracer) {
4814 CcTest::InitializeVM(); 4928 CcTest::InitializeVM();
4815 v8::HandleScope scope(CcTest::isolate()); 4929 v8::HandleScope scope(CcTest::isolate());
4816 4930
4817 v8::Local<v8::Value> result = CompileRun("'abc'"); 4931 v8::Local<v8::Value> result = CompileRun("'abc'");
4818 Handle<Object> o = v8::Utils::OpenHandle(*result); 4932 Handle<Object> o = v8::Utils::OpenHandle(*result);
4819 CcTest::i_isolate()->heap()->TracePathToObject(*o); 4933 CcTest::i_isolate()->heap()->TracePathToObject(*o);
4820 } 4934 }
4821 #endif // DEBUG 4935 #endif // DEBUG
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698