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 2808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2819 // Check size. | 2819 // Check size. |
2820 DescriptorArray* descriptors = internal_obj->map()->instance_descriptors(); | 2820 DescriptorArray* descriptors = internal_obj->map()->instance_descriptors(); |
2821 ObjectHashTable* hashtable = ObjectHashTable::cast( | 2821 ObjectHashTable* hashtable = ObjectHashTable::cast( |
2822 internal_obj->RawFastPropertyAt(descriptors->GetFieldIndex(0))); | 2822 internal_obj->RawFastPropertyAt(descriptors->GetFieldIndex(0))); |
2823 // HashTable header (5) and 4 initial entries (8). | 2823 // HashTable header (5) and 4 initial entries (8). |
2824 CHECK_LE(hashtable->SizeFor(hashtable->length()), 13 * kPointerSize); | 2824 CHECK_LE(hashtable->SizeFor(hashtable->length()), 13 * kPointerSize); |
2825 } | 2825 } |
2826 } | 2826 } |
2827 | 2827 |
2828 | 2828 |
2829 TEST(IncrementalMarkingClearsTypeFeedbackCells) { | 2829 TEST(IncrementalMarkingClearsTypeFeedbackInfo) { |
2830 if (i::FLAG_always_opt) return; | 2830 if (i::FLAG_always_opt) return; |
2831 CcTest::InitializeVM(); | 2831 CcTest::InitializeVM(); |
2832 v8::HandleScope scope(CcTest::isolate()); | 2832 v8::HandleScope scope(CcTest::isolate()); |
2833 v8::Local<v8::Value> fun1, fun2; | 2833 v8::Local<v8::Value> fun1, fun2; |
2834 | 2834 |
2835 { | 2835 { |
2836 LocalContext env; | 2836 LocalContext env; |
2837 CompileRun("function fun() {};"); | 2837 CompileRun("function fun() {};"); |
2838 fun1 = env->Global()->Get(v8_str("fun")); | 2838 fun1 = env->Global()->Get(v8_str("fun")); |
2839 } | 2839 } |
2840 | 2840 |
2841 { | 2841 { |
2842 LocalContext env; | 2842 LocalContext env; |
2843 CompileRun("function fun() {};"); | 2843 CompileRun("function fun() {};"); |
2844 fun2 = env->Global()->Get(v8_str("fun")); | 2844 fun2 = env->Global()->Get(v8_str("fun")); |
2845 } | 2845 } |
2846 | 2846 |
2847 // Prepare function f that contains type feedback for closures | 2847 // Prepare function f that contains type feedback for closures |
2848 // originating from two different native contexts. | 2848 // originating from two different native contexts. |
2849 CcTest::global()->Set(v8_str("fun1"), fun1); | 2849 CcTest::global()->Set(v8_str("fun1"), fun1); |
2850 CcTest::global()->Set(v8_str("fun2"), fun2); | 2850 CcTest::global()->Set(v8_str("fun2"), fun2); |
2851 CompileRun("function f(a, b) { a(); b(); } f(fun1, fun2);"); | 2851 CompileRun("function f(a, b) { a(); b(); } f(fun1, fun2);"); |
| 2852 |
2852 Handle<JSFunction> f = | 2853 Handle<JSFunction> f = |
2853 v8::Utils::OpenHandle( | 2854 v8::Utils::OpenHandle( |
2854 *v8::Handle<v8::Function>::Cast( | 2855 *v8::Handle<v8::Function>::Cast( |
2855 CcTest::global()->Get(v8_str("f")))); | 2856 CcTest::global()->Get(v8_str("f")))); |
2856 Handle<TypeFeedbackCells> cells(TypeFeedbackInfo::cast( | |
2857 f->shared()->code()->type_feedback_info())->type_feedback_cells()); | |
2858 | 2857 |
2859 CHECK_EQ(2, cells->CellCount()); | 2858 Handle<FixedArray> feedback_vector(TypeFeedbackInfo::cast( |
2860 CHECK(cells->GetCell(0)->value()->IsJSFunction()); | 2859 f->shared()->code()->type_feedback_info())->feedback_vector()); |
2861 CHECK(cells->GetCell(1)->value()->IsJSFunction()); | 2860 |
| 2861 CHECK_EQ(2, feedback_vector->length()); |
| 2862 CHECK(feedback_vector->get(0)->IsJSFunction()); |
| 2863 CHECK(feedback_vector->get(1)->IsJSFunction()); |
2862 | 2864 |
2863 SimulateIncrementalMarking(); | 2865 SimulateIncrementalMarking(); |
2864 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); | 2866 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); |
2865 | 2867 |
2866 CHECK_EQ(2, cells->CellCount()); | 2868 CHECK_EQ(2, feedback_vector->length()); |
2867 CHECK(cells->GetCell(0)->value()->IsTheHole()); | 2869 CHECK(feedback_vector->get(0)->IsTheHole()); |
2868 CHECK(cells->GetCell(1)->value()->IsTheHole()); | 2870 CHECK(feedback_vector->get(1)->IsTheHole()); |
2869 } | 2871 } |
2870 | 2872 |
2871 | 2873 |
2872 static Code* FindFirstIC(Code* code, Code::Kind kind) { | 2874 static Code* FindFirstIC(Code* code, Code::Kind kind) { |
2873 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET) | | 2875 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET) | |
2874 RelocInfo::ModeMask(RelocInfo::CONSTRUCT_CALL) | | 2876 RelocInfo::ModeMask(RelocInfo::CONSTRUCT_CALL) | |
2875 RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID); | 2877 RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID); |
2876 for (RelocIterator it(code, mask); !it.done(); it.next()) { | 2878 for (RelocIterator it(code, mask); !it.done(); it.next()) { |
2877 RelocInfo* info = it.rinfo(); | 2879 RelocInfo* info = it.rinfo(); |
2878 Code* target = Code::GetCodeFromTargetAddress(info->target_address()); | 2880 Code* target = Code::GetCodeFromTargetAddress(info->target_address()); |
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3679 code = scope.CloseAndEscape(Handle<Code>(bar->code())); | 3681 code = scope.CloseAndEscape(Handle<Code>(bar->code())); |
3680 } | 3682 } |
3681 | 3683 |
3682 // Now make sure that a gc should get rid of the function | 3684 // Now make sure that a gc should get rid of the function |
3683 for (int i = 0; i < 4; i++) { | 3685 for (int i = 0; i < 4; i++) { |
3684 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 3686 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
3685 } | 3687 } |
3686 | 3688 |
3687 ASSERT(code->marked_for_deoptimization()); | 3689 ASSERT(code->marked_for_deoptimization()); |
3688 } | 3690 } |
OLD | NEW |