OLD | NEW |
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 3660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3671 | 3671 |
3672 static void CheckVectorICCleared(Handle<JSFunction> f, int slot_index) { | 3672 static void CheckVectorICCleared(Handle<JSFunction> f, int slot_index) { |
3673 Handle<TypeFeedbackVector> vector = | 3673 Handle<TypeFeedbackVector> vector = |
3674 Handle<TypeFeedbackVector>(f->shared()->feedback_vector()); | 3674 Handle<TypeFeedbackVector>(f->shared()->feedback_vector()); |
3675 FeedbackVectorSlot slot(slot_index); | 3675 FeedbackVectorSlot slot(slot_index); |
3676 LoadICNexus nexus(vector, slot); | 3676 LoadICNexus nexus(vector, slot); |
3677 CHECK(IC::IsCleared(&nexus)); | 3677 CHECK(IC::IsCleared(&nexus)); |
3678 } | 3678 } |
3679 | 3679 |
3680 | 3680 |
3681 TEST(ICInBuiltInIsClearedAppropriately) { | |
3682 if (i::FLAG_always_opt) return; | |
3683 CcTest::InitializeVM(); | |
3684 v8::HandleScope scope(CcTest::isolate()); | |
3685 | |
3686 Handle<JSFunction> apply; | |
3687 { | |
3688 LocalContext env; | |
3689 v8::Local<v8::Value> res = CompileRun("Function.apply"); | |
3690 i::Handle<JSReceiver> maybe_apply = | |
3691 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res)); | |
3692 apply = i::Handle<JSFunction>::cast(maybe_apply); | |
3693 i::Handle<TypeFeedbackVector> vector(apply->shared()->feedback_vector()); | |
3694 FeedbackVectorHelper feedback_helper(vector); | |
3695 CHECK_EQ(1, feedback_helper.slot_count()); | |
3696 CheckVectorIC(apply, 0, UNINITIALIZED); | |
3697 CompileRun( | |
3698 "function b(a1, a2, a3) { return a1 + a2 + a3; }" | |
3699 "function fun(bar) { bar.apply({}, [1, 2, 3]); };" | |
3700 "fun(b); fun(b)"); | |
3701 CheckVectorIC(apply, 0, MONOMORPHIC); | |
3702 } | |
3703 | |
3704 // Fire context dispose notification. | |
3705 CcTest::isolate()->ContextDisposedNotification(); | |
3706 SimulateIncrementalMarking(CcTest::heap()); | |
3707 CcTest::heap()->CollectAllGarbage(); | |
3708 | |
3709 // The IC in apply has been cleared, ready to learn again. | |
3710 CheckVectorIC(apply, 0, PREMONOMORPHIC); | |
3711 } | |
3712 | |
3713 | |
3714 TEST(IncrementalMarkingPreservesMonomorphicConstructor) { | 3681 TEST(IncrementalMarkingPreservesMonomorphicConstructor) { |
3715 if (i::FLAG_always_opt) return; | 3682 if (i::FLAG_always_opt) return; |
3716 CcTest::InitializeVM(); | 3683 CcTest::InitializeVM(); |
3717 v8::HandleScope scope(CcTest::isolate()); | 3684 v8::HandleScope scope(CcTest::isolate()); |
3718 v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); | 3685 v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); |
3719 // Prepare function f that contains a monomorphic IC for object | 3686 // Prepare function f that contains a monomorphic IC for object |
3720 // originating from the same native context. | 3687 // originating from the same native context. |
3721 CompileRun( | 3688 CompileRun( |
3722 "function fun() { this.x = 1; };" | 3689 "function fun() { this.x = 1; };" |
3723 "function f(o) { return new o(); } f(fun); f(fun);"); | 3690 "function f(o) { return new o(); } f(fun); f(fun);"); |
(...skipping 2762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6486 isolate->IncrementJsCallsFromApiCounter(); | 6453 isolate->IncrementJsCallsFromApiCounter(); |
6487 isolate->IncrementJsCallsFromApiCounter(); | 6454 isolate->IncrementJsCallsFromApiCounter(); |
6488 isolate->IncrementJsCallsFromApiCounter(); | 6455 isolate->IncrementJsCallsFromApiCounter(); |
6489 calls_per_ms = memory_reducer->SampleAndGetJsCallsPerMs(4); | 6456 calls_per_ms = memory_reducer->SampleAndGetJsCallsPerMs(4); |
6490 CheckDoubleEquals(2, calls_per_ms); | 6457 CheckDoubleEquals(2, calls_per_ms); |
6491 } | 6458 } |
6492 | 6459 |
6493 | 6460 |
6494 } // namespace internal | 6461 } // namespace internal |
6495 } // namespace v8 | 6462 } // namespace v8 |
OLD | NEW |