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

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

Issue 771033003: Revert 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
« no previous file with comments | « test/cctest/cctest.status ('k') | test/mjsunit/opt-elements-kind.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 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
3464 TEST(IncrementalMarkingClearsPolymorphicIC) { 3426 TEST(IncrementalMarkingClearsPolymorphicIC) {
3465 if (i::FLAG_always_opt) return; 3427 if (i::FLAG_always_opt) return;
3466 CcTest::InitializeVM(); 3428 CcTest::InitializeVM();
3467 v8::HandleScope scope(CcTest::isolate()); 3429 v8::HandleScope scope(CcTest::isolate());
3468 v8::Local<v8::Value> obj1, obj2; 3430 v8::Local<v8::Value> obj1, obj2;
3469 3431
3470 { 3432 {
3471 LocalContext env; 3433 LocalContext env;
3472 CompileRun("function fun() { this.x = 1; }; var obj = new fun();"); 3434 CompileRun("function fun() { this.x = 1; }; var obj = new fun();");
3473 obj1 = env->Global()->Get(v8_str("obj")); 3435 obj1 = env->Global()->Get(v8_str("obj"));
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after
4411 " var proto = {'name' : 'weak'};" 4373 " var proto = {'name' : 'weak'};"
4412 " var obj = Object.create(proto);" 4374 " var obj = Object.create(proto);"
4413 " loadIC(obj);" 4375 " loadIC(obj);"
4414 " loadIC(obj);" 4376 " loadIC(obj);"
4415 " loadIC(obj);" 4377 " loadIC(obj);"
4416 " return proto;" 4378 " return proto;"
4417 " })();"); 4379 " })();");
4418 } 4380 }
4419 4381
4420 4382
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
4440 TEST(WeakMapInMonomorphicKeyedLoadIC) { 4383 TEST(WeakMapInMonomorphicKeyedLoadIC) {
4441 // TODO(mvstanton): vector ics need weak support! 4384 // TODO(mvstanton): vector ics need weak support!
4442 if (FLAG_vector_ics) return; 4385 if (FLAG_vector_ics) return;
4443 CheckWeakness("function keyedLoadIC(obj, field) {" 4386 CheckWeakness("function keyedLoadIC(obj, field) {"
4444 " return obj[field];" 4387 " return obj[field];"
4445 "}" 4388 "}"
4446 " (function() {" 4389 " (function() {"
4447 " var proto = {'name' : 'weak'};" 4390 " var proto = {'name' : 'weak'};"
4448 " var obj = Object.create(proto);" 4391 " var obj = Object.create(proto);"
4449 " keyedLoadIC(obj, 'name');" 4392 " keyedLoadIC(obj, 'name');"
4450 " keyedLoadIC(obj, 'name');" 4393 " keyedLoadIC(obj, 'name');"
4451 " keyedLoadIC(obj, 'name');" 4394 " keyedLoadIC(obj, 'name');"
4452 " return proto;" 4395 " return proto;"
4453 " })();"); 4396 " })();");
4454 } 4397 }
4455 4398
4456 4399
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
4476 TEST(WeakMapInMonomorphicStoreIC) { 4400 TEST(WeakMapInMonomorphicStoreIC) {
4477 CheckWeakness("function storeIC(obj, value) {" 4401 CheckWeakness("function storeIC(obj, value) {"
4478 " obj.name = value;" 4402 " obj.name = value;"
4479 "}" 4403 "}"
4480 " (function() {" 4404 " (function() {"
4481 " var proto = {'name' : 'weak'};" 4405 " var proto = {'name' : 'weak'};"
4482 " var obj = Object.create(proto);" 4406 " var obj = Object.create(proto);"
4483 " storeIC(obj, 'x');" 4407 " storeIC(obj, 'x');"
4484 " storeIC(obj, 'x');" 4408 " storeIC(obj, 'x');"
4485 " storeIC(obj, 'x');" 4409 " storeIC(obj, 'x');"
4486 " return proto;" 4410 " return proto;"
4487 " })();"); 4411 " })();");
4488 } 4412 }
4489 4413
4490 4414
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
4510 TEST(WeakMapInMonomorphicKeyedStoreIC) { 4415 TEST(WeakMapInMonomorphicKeyedStoreIC) {
4511 CheckWeakness("function keyedStoreIC(obj, field, value) {" 4416 CheckWeakness("function keyedStoreIC(obj, field, value) {"
4512 " obj[field] = value;" 4417 " obj[field] = value;"
4513 "}" 4418 "}"
4514 " (function() {" 4419 " (function() {"
4515 " var proto = {'name' : 'weak'};" 4420 " var proto = {'name' : 'weak'};"
4516 " var obj = Object.create(proto);" 4421 " var obj = Object.create(proto);"
4517 " keyedStoreIC(obj, 'x');" 4422 " keyedStoreIC(obj, 'x');"
4518 " keyedStoreIC(obj, 'x');" 4423 " keyedStoreIC(obj, 'x');"
4519 " keyedStoreIC(obj, 'x');" 4424 " keyedStoreIC(obj, 'x');"
4520 " return proto;" 4425 " return proto;"
4521 " })();"); 4426 " })();");
4522 } 4427 }
4523 4428
4524 4429
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
4544 TEST(WeakMapInMonomorphicCompareNilIC) { 4430 TEST(WeakMapInMonomorphicCompareNilIC) {
4545 CheckWeakness("function compareNilIC(obj) {" 4431 CheckWeakness("function compareNilIC(obj) {"
4546 " return obj == null;" 4432 " return obj == null;"
4547 "}" 4433 "}"
4548 " (function() {" 4434 " (function() {"
4549 " var proto = {'name' : 'weak'};" 4435 " var proto = {'name' : 'weak'};"
4550 " var obj = Object.create(proto);" 4436 " var obj = Object.create(proto);"
4551 " compareNilIC(obj);" 4437 " compareNilIC(obj);"
4552 " compareNilIC(obj);" 4438 " compareNilIC(obj);"
4553 " compareNilIC(obj);" 4439 " compareNilIC(obj);"
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
4926 #ifdef DEBUG 4812 #ifdef DEBUG
4927 TEST(PathTracer) { 4813 TEST(PathTracer) {
4928 CcTest::InitializeVM(); 4814 CcTest::InitializeVM();
4929 v8::HandleScope scope(CcTest::isolate()); 4815 v8::HandleScope scope(CcTest::isolate());
4930 4816
4931 v8::Local<v8::Value> result = CompileRun("'abc'"); 4817 v8::Local<v8::Value> result = CompileRun("'abc'");
4932 Handle<Object> o = v8::Utils::OpenHandle(*result); 4818 Handle<Object> o = v8::Utils::OpenHandle(*result);
4933 CcTest::i_isolate()->heap()->TracePathToObject(*o); 4819 CcTest::i_isolate()->heap()->TracePathToObject(*o);
4934 } 4820 }
4935 #endif // DEBUG 4821 #endif // DEBUG
OLDNEW
« no previous file with comments | « test/cctest/cctest.status ('k') | test/mjsunit/opt-elements-kind.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698