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

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

Issue 941503003: Revert "Remove IC age from Code." (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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/objects-inl.h ('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 3375 matching lines...) Expand 10 before | Expand all | Expand 10 after
3386 static void CheckVectorIC(Handle<JSFunction> f, int ic_slot_index, 3386 static void CheckVectorIC(Handle<JSFunction> f, int ic_slot_index,
3387 InlineCacheState desired_state) { 3387 InlineCacheState desired_state) {
3388 Handle<TypeFeedbackVector> vector = 3388 Handle<TypeFeedbackVector> vector =
3389 Handle<TypeFeedbackVector>(f->shared()->feedback_vector()); 3389 Handle<TypeFeedbackVector>(f->shared()->feedback_vector());
3390 FeedbackVectorICSlot slot(ic_slot_index); 3390 FeedbackVectorICSlot slot(ic_slot_index);
3391 LoadICNexus nexus(vector, slot); 3391 LoadICNexus nexus(vector, slot);
3392 CHECK(nexus.StateFromFeedback() == desired_state); 3392 CHECK(nexus.StateFromFeedback() == desired_state);
3393 } 3393 }
3394 3394
3395 3395
3396 static void CheckVectorICCleared(Handle<JSFunction> f, int ic_slot_index) {
3397 Handle<TypeFeedbackVector> vector =
3398 Handle<TypeFeedbackVector>(f->shared()->feedback_vector());
3399 FeedbackVectorICSlot slot(ic_slot_index);
3400 LoadICNexus nexus(vector, slot);
3401 CHECK(IC::IsCleared(&nexus));
3402 }
3403
3404
3396 TEST(IncrementalMarkingPreservesMonomorphicIC) { 3405 TEST(IncrementalMarkingPreservesMonomorphicIC) {
3397 if (i::FLAG_always_opt) return; 3406 if (i::FLAG_always_opt) return;
3398 CcTest::InitializeVM(); 3407 CcTest::InitializeVM();
3399 v8::HandleScope scope(CcTest::isolate()); 3408 v8::HandleScope scope(CcTest::isolate());
3400 3409
3401 // Prepare function f that contains a monomorphic IC for object 3410 // Prepare function f that contains a monomorphic IC for object
3402 // originating from the same native context. 3411 // originating from the same native context.
3403 CompileRun("function fun() { this.x = 1; }; var obj = new fun();" 3412 CompileRun("function fun() { this.x = 1; }; var obj = new fun();"
3404 "function f(o) { return o.x; } f(obj); f(obj);"); 3413 "function f(o) { return o.x; } f(obj); f(obj);");
3405 Handle<JSFunction> f = 3414 Handle<JSFunction> f =
(...skipping 15 matching lines...) Expand all
3421 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 3430 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
3422 if (FLAG_vector_ics) { 3431 if (FLAG_vector_ics) {
3423 CheckVectorIC(f, 0, MONOMORPHIC); 3432 CheckVectorIC(f, 0, MONOMORPHIC);
3424 CHECK(ic_after->ic_state() == DEFAULT); 3433 CHECK(ic_after->ic_state() == DEFAULT);
3425 } else { 3434 } else {
3426 CHECK(ic_after->ic_state() == MONOMORPHIC); 3435 CHECK(ic_after->ic_state() == MONOMORPHIC);
3427 } 3436 }
3428 } 3437 }
3429 3438
3430 3439
3440 TEST(IncrementalMarkingClearsMonomorphicIC) {
3441 if (i::FLAG_always_opt) return;
3442 CcTest::InitializeVM();
3443 v8::HandleScope scope(CcTest::isolate());
3444 v8::Local<v8::Value> obj1;
3445
3446 {
3447 LocalContext env;
3448 CompileRun("function fun() { this.x = 1; }; var obj = new fun();");
3449 obj1 = env->Global()->Get(v8_str("obj"));
3450 }
3451
3452 // Prepare function f that contains a monomorphic IC for object
3453 // originating from a different native context.
3454 CcTest::global()->Set(v8_str("obj1"), obj1);
3455 CompileRun("function f(o) { return o.x; } f(obj1); f(obj1);");
3456 Handle<JSFunction> f = v8::Utils::OpenHandle(
3457 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f"))));
3458
3459 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
3460 if (FLAG_vector_ics) {
3461 CheckVectorIC(f, 0, MONOMORPHIC);
3462 CHECK(ic_before->ic_state() == DEFAULT);
3463 } else {
3464 CHECK(ic_before->ic_state() == MONOMORPHIC);
3465 }
3466
3467 // Fire context dispose notification.
3468 CcTest::isolate()->ContextDisposedNotification();
3469 SimulateIncrementalMarking(CcTest::heap());
3470 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
3471
3472 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
3473 if (FLAG_vector_ics) {
3474 CheckVectorICCleared(f, 0);
3475 CHECK(ic_after->ic_state() == DEFAULT);
3476 } else {
3477 CHECK(IC::IsCleared(ic_after));
3478 }
3479 }
3480
3481
3431 TEST(IncrementalMarkingPreservesPolymorphicIC) { 3482 TEST(IncrementalMarkingPreservesPolymorphicIC) {
3432 if (i::FLAG_always_opt) return; 3483 if (i::FLAG_always_opt) return;
3433 CcTest::InitializeVM(); 3484 CcTest::InitializeVM();
3434 v8::HandleScope scope(CcTest::isolate()); 3485 v8::HandleScope scope(CcTest::isolate());
3435 v8::Local<v8::Value> obj1, obj2; 3486 v8::Local<v8::Value> obj1, obj2;
3436 3487
3437 { 3488 {
3438 LocalContext env; 3489 LocalContext env;
3439 CompileRun("function fun() { this.x = 1; }; var obj = new fun();"); 3490 CompileRun("function fun() { this.x = 1; }; var obj = new fun();");
3440 obj1 = env->Global()->Get(v8_str("obj")); 3491 obj1 = env->Global()->Get(v8_str("obj"));
(...skipping 28 matching lines...) Expand all
3469 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 3520 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
3470 if (FLAG_vector_ics) { 3521 if (FLAG_vector_ics) {
3471 CheckVectorIC(f, 0, POLYMORPHIC); 3522 CheckVectorIC(f, 0, POLYMORPHIC);
3472 CHECK(ic_after->ic_state() == DEFAULT); 3523 CHECK(ic_after->ic_state() == DEFAULT);
3473 } else { 3524 } else {
3474 CHECK(ic_after->ic_state() == POLYMORPHIC); 3525 CHECK(ic_after->ic_state() == POLYMORPHIC);
3475 } 3526 }
3476 } 3527 }
3477 3528
3478 3529
3530 TEST(IncrementalMarkingClearsPolymorphicIC) {
3531 if (i::FLAG_always_opt) return;
3532 CcTest::InitializeVM();
3533 v8::HandleScope scope(CcTest::isolate());
3534 v8::Local<v8::Value> obj1, obj2;
3535
3536 {
3537 LocalContext env;
3538 CompileRun("function fun() { this.x = 1; }; var obj = new fun();");
3539 obj1 = env->Global()->Get(v8_str("obj"));
3540 }
3541
3542 {
3543 LocalContext env;
3544 CompileRun("function fun() { this.x = 2; }; var obj = new fun();");
3545 obj2 = env->Global()->Get(v8_str("obj"));
3546 }
3547
3548 // Prepare function f that contains a polymorphic IC for objects
3549 // originating from two different native contexts.
3550 CcTest::global()->Set(v8_str("obj1"), obj1);
3551 CcTest::global()->Set(v8_str("obj2"), obj2);
3552 CompileRun("function f(o) { return o.x; } f(obj1); f(obj1); f(obj2);");
3553 Handle<JSFunction> f = v8::Utils::OpenHandle(
3554 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f"))));
3555
3556 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
3557 if (FLAG_vector_ics) {
3558 CheckVectorIC(f, 0, POLYMORPHIC);
3559 CHECK(ic_before->ic_state() == DEFAULT);
3560 } else {
3561 CHECK(ic_before->ic_state() == POLYMORPHIC);
3562 }
3563
3564 // Fire context dispose notification.
3565 CcTest::isolate()->ContextDisposedNotification();
3566 SimulateIncrementalMarking(CcTest::heap());
3567 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
3568
3569 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
3570 if (FLAG_vector_ics) {
3571 CheckVectorICCleared(f, 0);
3572 CHECK(ic_before->ic_state() == DEFAULT);
3573 } else {
3574 CHECK(IC::IsCleared(ic_after));
3575 }
3576 }
3577
3578
3479 class SourceResource : public v8::String::ExternalOneByteStringResource { 3579 class SourceResource : public v8::String::ExternalOneByteStringResource {
3480 public: 3580 public:
3481 explicit SourceResource(const char* data) 3581 explicit SourceResource(const char* data)
3482 : data_(data), length_(strlen(data)) { } 3582 : data_(data), length_(strlen(data)) { }
3483 3583
3484 virtual void Dispose() { 3584 virtual void Dispose() {
3485 i::DeleteArray(data_); 3585 i::DeleteArray(data_);
3486 data_ = NULL; 3586 data_ = NULL;
3487 } 3587 }
3488 3588
(...skipping 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after
4986 #ifdef DEBUG 5086 #ifdef DEBUG
4987 TEST(PathTracer) { 5087 TEST(PathTracer) {
4988 CcTest::InitializeVM(); 5088 CcTest::InitializeVM();
4989 v8::HandleScope scope(CcTest::isolate()); 5089 v8::HandleScope scope(CcTest::isolate());
4990 5090
4991 v8::Local<v8::Value> result = CompileRun("'abc'"); 5091 v8::Local<v8::Value> result = CompileRun("'abc'");
4992 Handle<Object> o = v8::Utils::OpenHandle(*result); 5092 Handle<Object> o = v8::Utils::OpenHandle(*result);
4993 CcTest::i_isolate()->heap()->TracePathToObject(*o); 5093 CcTest::i_isolate()->heap()->TracePathToObject(*o);
4994 } 5094 }
4995 #endif // DEBUG 5095 #endif // DEBUG
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698