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

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

Issue 1129853002: Removing FLAG_vector_ics. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Comment response. 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 | « test/cctest/test-feedback-vector.cc ('k') | no next file » | 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 3454 matching lines...) Expand 10 before | Expand all | Expand 10 after
3465 // Prepare function f that contains a monomorphic IC for object 3465 // Prepare function f that contains a monomorphic IC for object
3466 // originating from the same native context. 3466 // originating from the same native context.
3467 CompileRun("function fun() { this.x = 1; }; var obj = new fun();" 3467 CompileRun("function fun() { this.x = 1; }; var obj = new fun();"
3468 "function f(o) { return o.x; } f(obj); f(obj);"); 3468 "function f(o) { return o.x; } f(obj); f(obj);");
3469 Handle<JSFunction> f = 3469 Handle<JSFunction> f =
3470 v8::Utils::OpenHandle( 3470 v8::Utils::OpenHandle(
3471 *v8::Handle<v8::Function>::Cast( 3471 *v8::Handle<v8::Function>::Cast(
3472 CcTest::global()->Get(v8_str("f")))); 3472 CcTest::global()->Get(v8_str("f"))));
3473 3473
3474 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 3474 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
3475 if (FLAG_vector_ics) { 3475 CheckVectorIC(f, 0, MONOMORPHIC);
3476 CheckVectorIC(f, 0, MONOMORPHIC); 3476 CHECK(ic_before->ic_state() == DEFAULT);
3477 CHECK(ic_before->ic_state() == DEFAULT);
3478 } else {
3479 CHECK(ic_before->ic_state() == MONOMORPHIC);
3480 }
3481 3477
3482 SimulateIncrementalMarking(CcTest::heap()); 3478 SimulateIncrementalMarking(CcTest::heap());
3483 CcTest::heap()->CollectAllGarbage(); 3479 CcTest::heap()->CollectAllGarbage();
3484 3480
3485 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 3481 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
3486 if (FLAG_vector_ics) { 3482 CheckVectorIC(f, 0, MONOMORPHIC);
3487 CheckVectorIC(f, 0, MONOMORPHIC); 3483 CHECK(ic_after->ic_state() == DEFAULT);
3488 CHECK(ic_after->ic_state() == DEFAULT);
3489 } else {
3490 CHECK(ic_after->ic_state() == MONOMORPHIC);
3491 }
3492 } 3484 }
3493 3485
3494 3486
3495 TEST(IncrementalMarkingClearsMonomorphicIC) { 3487 TEST(IncrementalMarkingClearsMonomorphicIC) {
3496 if (i::FLAG_always_opt) return; 3488 if (i::FLAG_always_opt) return;
3497 CcTest::InitializeVM(); 3489 CcTest::InitializeVM();
3498 v8::HandleScope scope(CcTest::isolate()); 3490 v8::HandleScope scope(CcTest::isolate());
3499 v8::Local<v8::Value> obj1; 3491 v8::Local<v8::Value> obj1;
3500 3492
3501 { 3493 {
3502 LocalContext env; 3494 LocalContext env;
3503 CompileRun("function fun() { this.x = 1; }; var obj = new fun();"); 3495 CompileRun("function fun() { this.x = 1; }; var obj = new fun();");
3504 obj1 = env->Global()->Get(v8_str("obj")); 3496 obj1 = env->Global()->Get(v8_str("obj"));
3505 } 3497 }
3506 3498
3507 // Prepare function f that contains a monomorphic IC for object 3499 // Prepare function f that contains a monomorphic IC for object
3508 // originating from a different native context. 3500 // originating from a different native context.
3509 CcTest::global()->Set(v8_str("obj1"), obj1); 3501 CcTest::global()->Set(v8_str("obj1"), obj1);
3510 CompileRun("function f(o) { return o.x; } f(obj1); f(obj1);"); 3502 CompileRun("function f(o) { return o.x; } f(obj1); f(obj1);");
3511 Handle<JSFunction> f = v8::Utils::OpenHandle( 3503 Handle<JSFunction> f = v8::Utils::OpenHandle(
3512 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))); 3504 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f"))));
3513 3505
3514 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 3506 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
3515 if (FLAG_vector_ics) { 3507 CheckVectorIC(f, 0, MONOMORPHIC);
3516 CheckVectorIC(f, 0, MONOMORPHIC); 3508 CHECK(ic_before->ic_state() == DEFAULT);
3517 CHECK(ic_before->ic_state() == DEFAULT);
3518 } else {
3519 CHECK(ic_before->ic_state() == MONOMORPHIC);
3520 }
3521 3509
3522 // Fire context dispose notification. 3510 // Fire context dispose notification.
3523 CcTest::isolate()->ContextDisposedNotification(); 3511 CcTest::isolate()->ContextDisposedNotification();
3524 SimulateIncrementalMarking(CcTest::heap()); 3512 SimulateIncrementalMarking(CcTest::heap());
3525 CcTest::heap()->CollectAllGarbage(); 3513 CcTest::heap()->CollectAllGarbage();
3526 3514
3527 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 3515 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
3528 if (FLAG_vector_ics) { 3516 CheckVectorICCleared(f, 0);
3529 CheckVectorICCleared(f, 0); 3517 CHECK(ic_after->ic_state() == DEFAULT);
3530 CHECK(ic_after->ic_state() == DEFAULT);
3531 } else {
3532 CHECK(IC::IsCleared(ic_after));
3533 }
3534 } 3518 }
3535 3519
3536 3520
3537 TEST(IncrementalMarkingPreservesPolymorphicIC) { 3521 TEST(IncrementalMarkingPreservesPolymorphicIC) {
3538 if (i::FLAG_always_opt) return; 3522 if (i::FLAG_always_opt) return;
3539 CcTest::InitializeVM(); 3523 CcTest::InitializeVM();
3540 v8::HandleScope scope(CcTest::isolate()); 3524 v8::HandleScope scope(CcTest::isolate());
3541 v8::Local<v8::Value> obj1, obj2; 3525 v8::Local<v8::Value> obj1, obj2;
3542 3526
3543 { 3527 {
(...skipping 10 matching lines...) Expand all
3554 3538
3555 // Prepare function f that contains a polymorphic IC for objects 3539 // Prepare function f that contains a polymorphic IC for objects
3556 // originating from two different native contexts. 3540 // originating from two different native contexts.
3557 CcTest::global()->Set(v8_str("obj1"), obj1); 3541 CcTest::global()->Set(v8_str("obj1"), obj1);
3558 CcTest::global()->Set(v8_str("obj2"), obj2); 3542 CcTest::global()->Set(v8_str("obj2"), obj2);
3559 CompileRun("function f(o) { return o.x; } f(obj1); f(obj1); f(obj2);"); 3543 CompileRun("function f(o) { return o.x; } f(obj1); f(obj1); f(obj2);");
3560 Handle<JSFunction> f = v8::Utils::OpenHandle( 3544 Handle<JSFunction> f = v8::Utils::OpenHandle(
3561 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))); 3545 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f"))));
3562 3546
3563 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 3547 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
3564 if (FLAG_vector_ics) { 3548 CheckVectorIC(f, 0, POLYMORPHIC);
3565 CheckVectorIC(f, 0, POLYMORPHIC); 3549 CHECK(ic_before->ic_state() == DEFAULT);
3566 CHECK(ic_before->ic_state() == DEFAULT);
3567 } else {
3568 CHECK(ic_before->ic_state() == POLYMORPHIC);
3569 }
3570 3550
3571 // Fire context dispose notification. 3551 // Fire context dispose notification.
3572 SimulateIncrementalMarking(CcTest::heap()); 3552 SimulateIncrementalMarking(CcTest::heap());
3573 CcTest::heap()->CollectAllGarbage(); 3553 CcTest::heap()->CollectAllGarbage();
3574 3554
3575 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 3555 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
3576 if (FLAG_vector_ics) { 3556 CheckVectorIC(f, 0, POLYMORPHIC);
3577 CheckVectorIC(f, 0, POLYMORPHIC); 3557 CHECK(ic_after->ic_state() == DEFAULT);
3578 CHECK(ic_after->ic_state() == DEFAULT);
3579 } else {
3580 CHECK(ic_after->ic_state() == POLYMORPHIC);
3581 }
3582 } 3558 }
3583 3559
3584 3560
3585 TEST(IncrementalMarkingClearsPolymorphicIC) { 3561 TEST(IncrementalMarkingClearsPolymorphicIC) {
3586 if (i::FLAG_always_opt) return; 3562 if (i::FLAG_always_opt) return;
3587 CcTest::InitializeVM(); 3563 CcTest::InitializeVM();
3588 v8::HandleScope scope(CcTest::isolate()); 3564 v8::HandleScope scope(CcTest::isolate());
3589 v8::Local<v8::Value> obj1, obj2; 3565 v8::Local<v8::Value> obj1, obj2;
3590 3566
3591 { 3567 {
(...skipping 10 matching lines...) Expand all
3602 3578
3603 // Prepare function f that contains a polymorphic IC for objects 3579 // Prepare function f that contains a polymorphic IC for objects
3604 // originating from two different native contexts. 3580 // originating from two different native contexts.
3605 CcTest::global()->Set(v8_str("obj1"), obj1); 3581 CcTest::global()->Set(v8_str("obj1"), obj1);
3606 CcTest::global()->Set(v8_str("obj2"), obj2); 3582 CcTest::global()->Set(v8_str("obj2"), obj2);
3607 CompileRun("function f(o) { return o.x; } f(obj1); f(obj1); f(obj2);"); 3583 CompileRun("function f(o) { return o.x; } f(obj1); f(obj1); f(obj2);");
3608 Handle<JSFunction> f = v8::Utils::OpenHandle( 3584 Handle<JSFunction> f = v8::Utils::OpenHandle(
3609 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))); 3585 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f"))));
3610 3586
3611 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 3587 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
3612 if (FLAG_vector_ics) { 3588 CheckVectorIC(f, 0, POLYMORPHIC);
3613 CheckVectorIC(f, 0, POLYMORPHIC); 3589 CHECK(ic_before->ic_state() == DEFAULT);
3614 CHECK(ic_before->ic_state() == DEFAULT);
3615 } else {
3616 CHECK(ic_before->ic_state() == POLYMORPHIC);
3617 }
3618 3590
3619 // Fire context dispose notification. 3591 // Fire context dispose notification.
3620 CcTest::isolate()->ContextDisposedNotification(); 3592 CcTest::isolate()->ContextDisposedNotification();
3621 SimulateIncrementalMarking(CcTest::heap()); 3593 SimulateIncrementalMarking(CcTest::heap());
3622 CcTest::heap()->CollectAllGarbage(); 3594 CcTest::heap()->CollectAllGarbage();
3623 3595
3624 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 3596 CheckVectorICCleared(f, 0);
3625 if (FLAG_vector_ics) { 3597 CHECK(ic_before->ic_state() == DEFAULT);
3626 CheckVectorICCleared(f, 0);
3627 CHECK(ic_before->ic_state() == DEFAULT);
3628 } else {
3629 CHECK(IC::IsCleared(ic_after));
3630 }
3631 } 3598 }
3632 3599
3633 3600
3634 class SourceResource : public v8::String::ExternalOneByteStringResource { 3601 class SourceResource : public v8::String::ExternalOneByteStringResource {
3635 public: 3602 public:
3636 explicit SourceResource(const char* data) 3603 explicit SourceResource(const char* data)
3637 : data_(data), length_(strlen(data)) { } 3604 : data_(data), length_(strlen(data)) { }
3638 3605
3639 virtual void Dispose() { 3606 virtual void Dispose() {
3640 i::DeleteArray(data_); 3607 i::DeleteArray(data_);
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after
4723 Handle<JSFunction> GetFunctionByName(Isolate* isolate, const char* name) { 4690 Handle<JSFunction> GetFunctionByName(Isolate* isolate, const char* name) {
4724 Handle<String> str = isolate->factory()->InternalizeUtf8String(name); 4691 Handle<String> str = isolate->factory()->InternalizeUtf8String(name);
4725 Handle<Object> obj = 4692 Handle<Object> obj =
4726 Object::GetProperty(isolate->global_object(), str).ToHandleChecked(); 4693 Object::GetProperty(isolate->global_object(), str).ToHandleChecked();
4727 return Handle<JSFunction>::cast(obj); 4694 return Handle<JSFunction>::cast(obj);
4728 } 4695 }
4729 4696
4730 4697
4731 void CheckIC(Code* code, Code::Kind kind, SharedFunctionInfo* shared, 4698 void CheckIC(Code* code, Code::Kind kind, SharedFunctionInfo* shared,
4732 int ic_slot, InlineCacheState state) { 4699 int ic_slot, InlineCacheState state) {
4733 if (FLAG_vector_ics && 4700 if (kind == Code::LOAD_IC || kind == Code::KEYED_LOAD_IC ||
4734 (kind == Code::LOAD_IC || kind == Code::KEYED_LOAD_IC || 4701 kind == Code::CALL_IC) {
4735 kind == Code::CALL_IC)) {
4736 TypeFeedbackVector* vector = shared->feedback_vector(); 4702 TypeFeedbackVector* vector = shared->feedback_vector();
4737 FeedbackVectorICSlot slot(ic_slot); 4703 FeedbackVectorICSlot slot(ic_slot);
4738 if (kind == Code::LOAD_IC) { 4704 if (kind == Code::LOAD_IC) {
4739 LoadICNexus nexus(vector, slot); 4705 LoadICNexus nexus(vector, slot);
4740 CHECK_EQ(nexus.StateFromFeedback(), state); 4706 CHECK_EQ(nexus.StateFromFeedback(), state);
4741 } else if (kind == Code::KEYED_LOAD_IC) { 4707 } else if (kind == Code::KEYED_LOAD_IC) {
4742 KeyedLoadICNexus nexus(vector, slot); 4708 KeyedLoadICNexus nexus(vector, slot);
4743 CHECK_EQ(nexus.StateFromFeedback(), state); 4709 CHECK_EQ(nexus.StateFromFeedback(), state);
4744 } else if (kind == Code::CALL_IC) { 4710 } else if (kind == Code::CALL_IC) {
4745 CallICNexus nexus(vector, slot); 4711 CallICNexus nexus(vector, slot);
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
5476 shared.SetWeak(&shared, SharedHasBeenCollected, 5442 shared.SetWeak(&shared, SharedHasBeenCollected,
5477 v8::WeakCallbackType::kParameter); 5443 v8::WeakCallbackType::kParameter);
5478 builtin_exports.SetWeak(&builtin_exports, BuiltinExportsHasBeenCollected, 5444 builtin_exports.SetWeak(&builtin_exports, BuiltinExportsHasBeenCollected,
5479 v8::WeakCallbackType::kParameter); 5445 v8::WeakCallbackType::kParameter);
5480 5446
5481 CcTest::heap()->CollectAllAvailableGarbage("fire weak callbacks"); 5447 CcTest::heap()->CollectAllAvailableGarbage("fire weak callbacks");
5482 5448
5483 CHECK(shared_has_been_collected); 5449 CHECK(shared_has_been_collected);
5484 CHECK(builtin_exports_has_been_collected); 5450 CHECK(builtin_exports_has_been_collected);
5485 } 5451 }
OLDNEW
« no previous file with comments | « test/cctest/test-feedback-vector.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698