| 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 2617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2628 | 2628 |
| 2629 TEST(PrototypeTransitionClearing) { | 2629 TEST(PrototypeTransitionClearing) { |
| 2630 if (FLAG_never_compact) return; | 2630 if (FLAG_never_compact) return; |
| 2631 CcTest::InitializeVM(); | 2631 CcTest::InitializeVM(); |
| 2632 Isolate* isolate = CcTest::i_isolate(); | 2632 Isolate* isolate = CcTest::i_isolate(); |
| 2633 Factory* factory = isolate->factory(); | 2633 Factory* factory = isolate->factory(); |
| 2634 v8::HandleScope scope(CcTest::isolate()); | 2634 v8::HandleScope scope(CcTest::isolate()); |
| 2635 v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); | 2635 v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); |
| 2636 | 2636 |
| 2637 CompileRun("var base = {};"); | 2637 CompileRun("var base = {};"); |
| 2638 i::Handle<JSObject> baseObject = | 2638 i::Handle<JSReceiver> baseObject = |
| 2639 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast( | 2639 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast( |
| 2640 CcTest::global()->Get(ctx, v8_str("base")).ToLocalChecked())); | 2640 CcTest::global()->Get(ctx, v8_str("base")).ToLocalChecked())); |
| 2641 | 2641 |
| 2642 int initialTransitions = NumberOfProtoTransitions(baseObject->map()); | 2642 int initialTransitions = NumberOfProtoTransitions(baseObject->map()); |
| 2643 | 2643 |
| 2644 CompileRun( | 2644 CompileRun( |
| 2645 "var live = [];" | 2645 "var live = [];" |
| 2646 "for (var i = 0; i < 10; i++) {" | 2646 "for (var i = 0; i < 10; i++) {" |
| 2647 " var object = {};" | 2647 " var object = {};" |
| 2648 " var prototype = {};" | 2648 " var prototype = {};" |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2870 "f(1); f(2); f(3);" | 2870 "f(1); f(2); f(3);" |
| 2871 "%OptimizeFunctionOnNextCall(f);" | 2871 "%OptimizeFunctionOnNextCall(f);" |
| 2872 "f(4);"); | 2872 "f(4);"); |
| 2873 | 2873 |
| 2874 CHECK_EQ(4, res.As<v8::Object>() | 2874 CHECK_EQ(4, res.As<v8::Object>() |
| 2875 ->GetRealNamedProperty(ctx, v8_str("x")) | 2875 ->GetRealNamedProperty(ctx, v8_str("x")) |
| 2876 .ToLocalChecked() | 2876 .ToLocalChecked() |
| 2877 ->Int32Value(ctx) | 2877 ->Int32Value(ctx) |
| 2878 .FromJust()); | 2878 .FromJust()); |
| 2879 | 2879 |
| 2880 i::Handle<JSObject> o = | 2880 i::Handle<JSReceiver> o = |
| 2881 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res)); | 2881 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res)); |
| 2882 | 2882 |
| 2883 CHECK(CcTest::heap()->InNewSpace(*o)); | 2883 CHECK(CcTest::heap()->InNewSpace(*o)); |
| 2884 } | 2884 } |
| 2885 | 2885 |
| 2886 | 2886 |
| 2887 TEST(OptimizedPretenuringAllocationFolding) { | 2887 TEST(OptimizedPretenuringAllocationFolding) { |
| 2888 i::FLAG_allow_natives_syntax = true; | 2888 i::FLAG_allow_natives_syntax = true; |
| 2889 i::FLAG_expose_gc = true; | 2889 i::FLAG_expose_gc = true; |
| 2890 CcTest::InitializeVM(); | 2890 CcTest::InitializeVM(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2911 "f(); gc();" | 2911 "f(); gc();" |
| 2912 "f(); f();" | 2912 "f(); f();" |
| 2913 "%%OptimizeFunctionOnNextCall(f);" | 2913 "%%OptimizeFunctionOnNextCall(f);" |
| 2914 "f();", | 2914 "f();", |
| 2915 AllocationSite::kPretenureMinimumCreated); | 2915 AllocationSite::kPretenureMinimumCreated); |
| 2916 | 2916 |
| 2917 v8::Local<v8::Value> res = CompileRun(source.start()); | 2917 v8::Local<v8::Value> res = CompileRun(source.start()); |
| 2918 | 2918 |
| 2919 v8::Local<v8::Value> int_array = | 2919 v8::Local<v8::Value> int_array = |
| 2920 v8::Object::Cast(*res)->Get(ctx, v8_str("0")).ToLocalChecked(); | 2920 v8::Object::Cast(*res)->Get(ctx, v8_str("0")).ToLocalChecked(); |
| 2921 i::Handle<JSObject> int_array_handle = | 2921 i::Handle<JSObject> int_array_handle = i::Handle<JSObject>::cast( |
| 2922 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(int_array)); | 2922 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(int_array))); |
| 2923 v8::Local<v8::Value> double_array = | 2923 v8::Local<v8::Value> double_array = |
| 2924 v8::Object::Cast(*res)->Get(ctx, v8_str("1")).ToLocalChecked(); | 2924 v8::Object::Cast(*res)->Get(ctx, v8_str("1")).ToLocalChecked(); |
| 2925 i::Handle<JSObject> double_array_handle = | 2925 i::Handle<JSObject> double_array_handle = i::Handle<JSObject>::cast( |
| 2926 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(double_array)); | 2926 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(double_array))); |
| 2927 | 2927 |
| 2928 i::Handle<JSObject> o = | 2928 i::Handle<JSReceiver> o = |
| 2929 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res)); | 2929 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res)); |
| 2930 CHECK(CcTest::heap()->InOldSpace(*o)); | 2930 CHECK(CcTest::heap()->InOldSpace(*o)); |
| 2931 CHECK(CcTest::heap()->InOldSpace(*int_array_handle)); | 2931 CHECK(CcTest::heap()->InOldSpace(*int_array_handle)); |
| 2932 CHECK(CcTest::heap()->InOldSpace(int_array_handle->elements())); | 2932 CHECK(CcTest::heap()->InOldSpace(int_array_handle->elements())); |
| 2933 CHECK(CcTest::heap()->InOldSpace(*double_array_handle)); | 2933 CHECK(CcTest::heap()->InOldSpace(*double_array_handle)); |
| 2934 CHECK(CcTest::heap()->InOldSpace(double_array_handle->elements())); | 2934 CHECK(CcTest::heap()->InOldSpace(double_array_handle->elements())); |
| 2935 } | 2935 } |
| 2936 | 2936 |
| 2937 | 2937 |
| 2938 TEST(OptimizedPretenuringObjectArrayLiterals) { | 2938 TEST(OptimizedPretenuringObjectArrayLiterals) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2960 " return elements[number_elements - 1];" | 2960 " return elements[number_elements - 1];" |
| 2961 "};" | 2961 "};" |
| 2962 "f(); gc();" | 2962 "f(); gc();" |
| 2963 "f(); f();" | 2963 "f(); f();" |
| 2964 "%%OptimizeFunctionOnNextCall(f);" | 2964 "%%OptimizeFunctionOnNextCall(f);" |
| 2965 "f();", | 2965 "f();", |
| 2966 AllocationSite::kPretenureMinimumCreated); | 2966 AllocationSite::kPretenureMinimumCreated); |
| 2967 | 2967 |
| 2968 v8::Local<v8::Value> res = CompileRun(source.start()); | 2968 v8::Local<v8::Value> res = CompileRun(source.start()); |
| 2969 | 2969 |
| 2970 i::Handle<JSObject> o = | 2970 i::Handle<JSObject> o = Handle<JSObject>::cast( |
| 2971 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res)); | 2971 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res))); |
| 2972 | 2972 |
| 2973 CHECK(CcTest::heap()->InOldSpace(o->elements())); | 2973 CHECK(CcTest::heap()->InOldSpace(o->elements())); |
| 2974 CHECK(CcTest::heap()->InOldSpace(*o)); | 2974 CHECK(CcTest::heap()->InOldSpace(*o)); |
| 2975 } | 2975 } |
| 2976 | 2976 |
| 2977 | 2977 |
| 2978 TEST(OptimizedPretenuringMixedInObjectProperties) { | 2978 TEST(OptimizedPretenuringMixedInObjectProperties) { |
| 2979 i::FLAG_allow_natives_syntax = true; | 2979 i::FLAG_allow_natives_syntax = true; |
| 2980 i::FLAG_expose_gc = true; | 2980 i::FLAG_expose_gc = true; |
| 2981 CcTest::InitializeVM(); | 2981 CcTest::InitializeVM(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3001 " return elements[number_elements - 1];" | 3001 " return elements[number_elements - 1];" |
| 3002 "};" | 3002 "};" |
| 3003 "f(); gc();" | 3003 "f(); gc();" |
| 3004 "f(); f();" | 3004 "f(); f();" |
| 3005 "%%OptimizeFunctionOnNextCall(f);" | 3005 "%%OptimizeFunctionOnNextCall(f);" |
| 3006 "f();", | 3006 "f();", |
| 3007 AllocationSite::kPretenureMinimumCreated); | 3007 AllocationSite::kPretenureMinimumCreated); |
| 3008 | 3008 |
| 3009 v8::Local<v8::Value> res = CompileRun(source.start()); | 3009 v8::Local<v8::Value> res = CompileRun(source.start()); |
| 3010 | 3010 |
| 3011 i::Handle<JSObject> o = | 3011 i::Handle<JSObject> o = Handle<JSObject>::cast( |
| 3012 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res)); | 3012 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res))); |
| 3013 | 3013 |
| 3014 CHECK(CcTest::heap()->InOldSpace(*o)); | 3014 CHECK(CcTest::heap()->InOldSpace(*o)); |
| 3015 FieldIndex idx1 = FieldIndex::ForPropertyIndex(o->map(), 0); | 3015 FieldIndex idx1 = FieldIndex::ForPropertyIndex(o->map(), 0); |
| 3016 FieldIndex idx2 = FieldIndex::ForPropertyIndex(o->map(), 1); | 3016 FieldIndex idx2 = FieldIndex::ForPropertyIndex(o->map(), 1); |
| 3017 CHECK(CcTest::heap()->InOldSpace(o->RawFastPropertyAt(idx1))); | 3017 CHECK(CcTest::heap()->InOldSpace(o->RawFastPropertyAt(idx1))); |
| 3018 if (!o->IsUnboxedDoubleField(idx2)) { | 3018 if (!o->IsUnboxedDoubleField(idx2)) { |
| 3019 CHECK(CcTest::heap()->InOldSpace(o->RawFastPropertyAt(idx2))); | 3019 CHECK(CcTest::heap()->InOldSpace(o->RawFastPropertyAt(idx2))); |
| 3020 } else { | 3020 } else { |
| 3021 CHECK_EQ(1.1, o->RawFastDoublePropertyAt(idx2)); | 3021 CHECK_EQ(1.1, o->RawFastDoublePropertyAt(idx2)); |
| 3022 } | 3022 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3058 " return elements[i - 1];" | 3058 " return elements[i - 1];" |
| 3059 "};" | 3059 "};" |
| 3060 "f(); gc();" | 3060 "f(); gc();" |
| 3061 "f(); f();" | 3061 "f(); f();" |
| 3062 "%%OptimizeFunctionOnNextCall(f);" | 3062 "%%OptimizeFunctionOnNextCall(f);" |
| 3063 "f();", | 3063 "f();", |
| 3064 AllocationSite::kPretenureMinimumCreated); | 3064 AllocationSite::kPretenureMinimumCreated); |
| 3065 | 3065 |
| 3066 v8::Local<v8::Value> res = CompileRun(source.start()); | 3066 v8::Local<v8::Value> res = CompileRun(source.start()); |
| 3067 | 3067 |
| 3068 i::Handle<JSObject> o = | 3068 i::Handle<JSObject> o = Handle<JSObject>::cast( |
| 3069 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res)); | 3069 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res))); |
| 3070 | 3070 |
| 3071 CHECK(CcTest::heap()->InOldSpace(*o)); | 3071 CHECK(CcTest::heap()->InOldSpace(*o)); |
| 3072 CHECK(CcTest::heap()->InOldSpace(o->properties())); | 3072 CHECK(CcTest::heap()->InOldSpace(o->properties())); |
| 3073 } | 3073 } |
| 3074 | 3074 |
| 3075 | 3075 |
| 3076 TEST(OptimizedPretenuringdoubleArrayLiterals) { | 3076 TEST(OptimizedPretenuringdoubleArrayLiterals) { |
| 3077 i::FLAG_allow_natives_syntax = true; | 3077 i::FLAG_allow_natives_syntax = true; |
| 3078 i::FLAG_expose_gc = true; | 3078 i::FLAG_expose_gc = true; |
| 3079 CcTest::InitializeVM(); | 3079 CcTest::InitializeVM(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3098 " return elements[number_elements - 1];" | 3098 " return elements[number_elements - 1];" |
| 3099 "};" | 3099 "};" |
| 3100 "f(); gc();" | 3100 "f(); gc();" |
| 3101 "f(); f();" | 3101 "f(); f();" |
| 3102 "%%OptimizeFunctionOnNextCall(f);" | 3102 "%%OptimizeFunctionOnNextCall(f);" |
| 3103 "f();", | 3103 "f();", |
| 3104 AllocationSite::kPretenureMinimumCreated); | 3104 AllocationSite::kPretenureMinimumCreated); |
| 3105 | 3105 |
| 3106 v8::Local<v8::Value> res = CompileRun(source.start()); | 3106 v8::Local<v8::Value> res = CompileRun(source.start()); |
| 3107 | 3107 |
| 3108 i::Handle<JSObject> o = | 3108 i::Handle<JSObject> o = Handle<JSObject>::cast( |
| 3109 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res)); | 3109 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res))); |
| 3110 | 3110 |
| 3111 CHECK(CcTest::heap()->InOldSpace(o->elements())); | 3111 CHECK(CcTest::heap()->InOldSpace(o->elements())); |
| 3112 CHECK(CcTest::heap()->InOldSpace(*o)); | 3112 CHECK(CcTest::heap()->InOldSpace(*o)); |
| 3113 } | 3113 } |
| 3114 | 3114 |
| 3115 | 3115 |
| 3116 TEST(OptimizedPretenuringNestedMixedArrayLiterals) { | 3116 TEST(OptimizedPretenuringNestedMixedArrayLiterals) { |
| 3117 i::FLAG_allow_natives_syntax = true; | 3117 i::FLAG_allow_natives_syntax = true; |
| 3118 i::FLAG_expose_gc = true; | 3118 i::FLAG_expose_gc = true; |
| 3119 CcTest::InitializeVM(); | 3119 CcTest::InitializeVM(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3139 "};" | 3139 "};" |
| 3140 "f(); gc();" | 3140 "f(); gc();" |
| 3141 "f(); f();" | 3141 "f(); f();" |
| 3142 "%%OptimizeFunctionOnNextCall(f);" | 3142 "%%OptimizeFunctionOnNextCall(f);" |
| 3143 "f();"); | 3143 "f();"); |
| 3144 | 3144 |
| 3145 v8::Local<v8::Value> res = CompileRun(source.start()); | 3145 v8::Local<v8::Value> res = CompileRun(source.start()); |
| 3146 | 3146 |
| 3147 v8::Local<v8::Value> int_array = | 3147 v8::Local<v8::Value> int_array = |
| 3148 v8::Object::Cast(*res)->Get(ctx, v8_str("0")).ToLocalChecked(); | 3148 v8::Object::Cast(*res)->Get(ctx, v8_str("0")).ToLocalChecked(); |
| 3149 i::Handle<JSObject> int_array_handle = | 3149 i::Handle<JSObject> int_array_handle = i::Handle<JSObject>::cast( |
| 3150 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(int_array)); | 3150 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(int_array))); |
| 3151 v8::Local<v8::Value> double_array = | 3151 v8::Local<v8::Value> double_array = |
| 3152 v8::Object::Cast(*res)->Get(ctx, v8_str("1")).ToLocalChecked(); | 3152 v8::Object::Cast(*res)->Get(ctx, v8_str("1")).ToLocalChecked(); |
| 3153 i::Handle<JSObject> double_array_handle = | 3153 i::Handle<JSObject> double_array_handle = i::Handle<JSObject>::cast( |
| 3154 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(double_array)); | 3154 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(double_array))); |
| 3155 | 3155 |
| 3156 Handle<JSObject> o = v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res)); | 3156 Handle<JSObject> o = Handle<JSObject>::cast( |
| 3157 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res))); |
| 3157 CHECK(CcTest::heap()->InOldSpace(*o)); | 3158 CHECK(CcTest::heap()->InOldSpace(*o)); |
| 3158 CHECK(CcTest::heap()->InOldSpace(*int_array_handle)); | 3159 CHECK(CcTest::heap()->InOldSpace(*int_array_handle)); |
| 3159 CHECK(CcTest::heap()->InOldSpace(int_array_handle->elements())); | 3160 CHECK(CcTest::heap()->InOldSpace(int_array_handle->elements())); |
| 3160 CHECK(CcTest::heap()->InOldSpace(*double_array_handle)); | 3161 CHECK(CcTest::heap()->InOldSpace(*double_array_handle)); |
| 3161 CHECK(CcTest::heap()->InOldSpace(double_array_handle->elements())); | 3162 CHECK(CcTest::heap()->InOldSpace(double_array_handle->elements())); |
| 3162 } | 3163 } |
| 3163 | 3164 |
| 3164 | 3165 |
| 3165 TEST(OptimizedPretenuringNestedObjectLiterals) { | 3166 TEST(OptimizedPretenuringNestedObjectLiterals) { |
| 3166 i::FLAG_allow_natives_syntax = true; | 3167 i::FLAG_allow_natives_syntax = true; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 3189 "f(); gc();" | 3190 "f(); gc();" |
| 3190 "f(); f();" | 3191 "f(); f();" |
| 3191 "%%OptimizeFunctionOnNextCall(f);" | 3192 "%%OptimizeFunctionOnNextCall(f);" |
| 3192 "f();", | 3193 "f();", |
| 3193 AllocationSite::kPretenureMinimumCreated); | 3194 AllocationSite::kPretenureMinimumCreated); |
| 3194 | 3195 |
| 3195 v8::Local<v8::Value> res = CompileRun(source.start()); | 3196 v8::Local<v8::Value> res = CompileRun(source.start()); |
| 3196 | 3197 |
| 3197 v8::Local<v8::Value> int_array_1 = | 3198 v8::Local<v8::Value> int_array_1 = |
| 3198 v8::Object::Cast(*res)->Get(ctx, v8_str("0")).ToLocalChecked(); | 3199 v8::Object::Cast(*res)->Get(ctx, v8_str("0")).ToLocalChecked(); |
| 3199 Handle<JSObject> int_array_handle_1 = | 3200 Handle<JSObject> int_array_handle_1 = Handle<JSObject>::cast( |
| 3200 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(int_array_1)); | 3201 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(int_array_1))); |
| 3201 v8::Local<v8::Value> int_array_2 = | 3202 v8::Local<v8::Value> int_array_2 = |
| 3202 v8::Object::Cast(*res)->Get(ctx, v8_str("1")).ToLocalChecked(); | 3203 v8::Object::Cast(*res)->Get(ctx, v8_str("1")).ToLocalChecked(); |
| 3203 Handle<JSObject> int_array_handle_2 = | 3204 Handle<JSObject> int_array_handle_2 = Handle<JSObject>::cast( |
| 3204 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(int_array_2)); | 3205 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(int_array_2))); |
| 3205 | 3206 |
| 3206 Handle<JSObject> o = v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res)); | 3207 Handle<JSObject> o = Handle<JSObject>::cast( |
| 3208 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res))); |
| 3207 CHECK(CcTest::heap()->InOldSpace(*o)); | 3209 CHECK(CcTest::heap()->InOldSpace(*o)); |
| 3208 CHECK(CcTest::heap()->InOldSpace(*int_array_handle_1)); | 3210 CHECK(CcTest::heap()->InOldSpace(*int_array_handle_1)); |
| 3209 CHECK(CcTest::heap()->InOldSpace(int_array_handle_1->elements())); | 3211 CHECK(CcTest::heap()->InOldSpace(int_array_handle_1->elements())); |
| 3210 CHECK(CcTest::heap()->InOldSpace(*int_array_handle_2)); | 3212 CHECK(CcTest::heap()->InOldSpace(*int_array_handle_2)); |
| 3211 CHECK(CcTest::heap()->InOldSpace(int_array_handle_2->elements())); | 3213 CHECK(CcTest::heap()->InOldSpace(int_array_handle_2->elements())); |
| 3212 } | 3214 } |
| 3213 | 3215 |
| 3214 | 3216 |
| 3215 TEST(OptimizedPretenuringNestedDoubleLiterals) { | 3217 TEST(OptimizedPretenuringNestedDoubleLiterals) { |
| 3216 i::FLAG_allow_natives_syntax = true; | 3218 i::FLAG_allow_natives_syntax = true; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 3239 "f(); gc();" | 3241 "f(); gc();" |
| 3240 "f(); f();" | 3242 "f(); f();" |
| 3241 "%%OptimizeFunctionOnNextCall(f);" | 3243 "%%OptimizeFunctionOnNextCall(f);" |
| 3242 "f();", | 3244 "f();", |
| 3243 AllocationSite::kPretenureMinimumCreated); | 3245 AllocationSite::kPretenureMinimumCreated); |
| 3244 | 3246 |
| 3245 v8::Local<v8::Value> res = CompileRun(source.start()); | 3247 v8::Local<v8::Value> res = CompileRun(source.start()); |
| 3246 | 3248 |
| 3247 v8::Local<v8::Value> double_array_1 = | 3249 v8::Local<v8::Value> double_array_1 = |
| 3248 v8::Object::Cast(*res)->Get(ctx, v8_str("0")).ToLocalChecked(); | 3250 v8::Object::Cast(*res)->Get(ctx, v8_str("0")).ToLocalChecked(); |
| 3249 i::Handle<JSObject> double_array_handle_1 = | 3251 i::Handle<JSObject> double_array_handle_1 = i::Handle<JSObject>::cast( |
| 3250 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(double_array_1)); | 3252 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(double_array_1))); |
| 3251 v8::Local<v8::Value> double_array_2 = | 3253 v8::Local<v8::Value> double_array_2 = |
| 3252 v8::Object::Cast(*res)->Get(ctx, v8_str("1")).ToLocalChecked(); | 3254 v8::Object::Cast(*res)->Get(ctx, v8_str("1")).ToLocalChecked(); |
| 3253 i::Handle<JSObject> double_array_handle_2 = | 3255 i::Handle<JSObject> double_array_handle_2 = Handle<JSObject>::cast( |
| 3254 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(double_array_2)); | 3256 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(double_array_2))); |
| 3255 | 3257 |
| 3256 i::Handle<JSObject> o = | 3258 i::Handle<JSObject> o = Handle<JSObject>::cast( |
| 3257 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res)); | 3259 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res))); |
| 3258 CHECK(CcTest::heap()->InOldSpace(*o)); | 3260 CHECK(CcTest::heap()->InOldSpace(*o)); |
| 3259 CHECK(CcTest::heap()->InOldSpace(*double_array_handle_1)); | 3261 CHECK(CcTest::heap()->InOldSpace(*double_array_handle_1)); |
| 3260 CHECK(CcTest::heap()->InOldSpace(double_array_handle_1->elements())); | 3262 CHECK(CcTest::heap()->InOldSpace(double_array_handle_1->elements())); |
| 3261 CHECK(CcTest::heap()->InOldSpace(*double_array_handle_2)); | 3263 CHECK(CcTest::heap()->InOldSpace(*double_array_handle_2)); |
| 3262 CHECK(CcTest::heap()->InOldSpace(double_array_handle_2->elements())); | 3264 CHECK(CcTest::heap()->InOldSpace(double_array_handle_2->elements())); |
| 3263 } | 3265 } |
| 3264 | 3266 |
| 3265 | 3267 |
| 3266 // Test regular array literals allocation. | 3268 // Test regular array literals allocation. |
| 3267 TEST(OptimizedAllocationArrayLiterals) { | 3269 TEST(OptimizedAllocationArrayLiterals) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 3279 "};" | 3281 "};" |
| 3280 "f(); f(); f();" | 3282 "f(); f(); f();" |
| 3281 "%OptimizeFunctionOnNextCall(f);" | 3283 "%OptimizeFunctionOnNextCall(f);" |
| 3282 "f();"); | 3284 "f();"); |
| 3283 CHECK_EQ(static_cast<int>(3.14), v8::Object::Cast(*res) | 3285 CHECK_EQ(static_cast<int>(3.14), v8::Object::Cast(*res) |
| 3284 ->Get(ctx, v8_str("0")) | 3286 ->Get(ctx, v8_str("0")) |
| 3285 .ToLocalChecked() | 3287 .ToLocalChecked() |
| 3286 ->Int32Value(ctx) | 3288 ->Int32Value(ctx) |
| 3287 .FromJust()); | 3289 .FromJust()); |
| 3288 | 3290 |
| 3289 i::Handle<JSObject> o = | 3291 i::Handle<JSObject> o = Handle<JSObject>::cast( |
| 3290 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res)); | 3292 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res))); |
| 3291 | 3293 |
| 3292 CHECK(CcTest::heap()->InNewSpace(o->elements())); | 3294 CHECK(CcTest::heap()->InNewSpace(o->elements())); |
| 3293 } | 3295 } |
| 3294 | 3296 |
| 3295 | 3297 |
| 3296 static int CountMapTransitions(Map* map) { | 3298 static int CountMapTransitions(Map* map) { |
| 3297 return TransitionArray::NumberOfTransitions(map->raw_transitions()); | 3299 return TransitionArray::NumberOfTransitions(map->raw_transitions()); |
| 3298 } | 3300 } |
| 3299 | 3301 |
| 3300 | 3302 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3314 { | 3316 { |
| 3315 AlwaysAllocateScope always_allocate(CcTest::i_isolate()); | 3317 AlwaysAllocateScope always_allocate(CcTest::i_isolate()); |
| 3316 for (int i = 0; i < transitions_count; i++) { | 3318 for (int i = 0; i < transitions_count; i++) { |
| 3317 EmbeddedVector<char, 64> buffer; | 3319 EmbeddedVector<char, 64> buffer; |
| 3318 SNPrintF(buffer, "var o = new F; o.prop%d = %d;", i, i); | 3320 SNPrintF(buffer, "var o = new F; o.prop%d = %d;", i, i); |
| 3319 CompileRun(buffer.start()); | 3321 CompileRun(buffer.start()); |
| 3320 } | 3322 } |
| 3321 CompileRun("var root = new F;"); | 3323 CompileRun("var root = new F;"); |
| 3322 } | 3324 } |
| 3323 | 3325 |
| 3324 i::Handle<JSObject> root = v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast( | 3326 i::Handle<JSReceiver> root = |
| 3325 CcTest::global()->Get(ctx, v8_str("root")).ToLocalChecked())); | 3327 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast( |
| 3328 CcTest::global()->Get(ctx, v8_str("root")).ToLocalChecked())); |
| 3326 | 3329 |
| 3327 // Count number of live transitions before marking. | 3330 // Count number of live transitions before marking. |
| 3328 int transitions_before = CountMapTransitions(root->map()); | 3331 int transitions_before = CountMapTransitions(root->map()); |
| 3329 CompileRun("%DebugPrint(root);"); | 3332 CompileRun("%DebugPrint(root);"); |
| 3330 CHECK_EQ(transitions_count, transitions_before); | 3333 CHECK_EQ(transitions_count, transitions_before); |
| 3331 | 3334 |
| 3332 SimulateIncrementalMarking(CcTest::heap()); | 3335 SimulateIncrementalMarking(CcTest::heap()); |
| 3333 CcTest::heap()->CollectAllGarbage(); | 3336 CcTest::heap()->CollectAllGarbage(); |
| 3334 | 3337 |
| 3335 // Count number of live transitions after marking. Note that one transition | 3338 // Count number of live transitions after marking. Note that one transition |
| 3336 // is left, because 'o' still holds an instance of one transition target. | 3339 // is left, because 'o' still holds an instance of one transition target. |
| 3337 int transitions_after = CountMapTransitions(root->map()); | 3340 int transitions_after = CountMapTransitions(root->map()); |
| 3338 CompileRun("%DebugPrint(root);"); | 3341 CompileRun("%DebugPrint(root);"); |
| 3339 CHECK_EQ(1, transitions_after); | 3342 CHECK_EQ(1, transitions_after); |
| 3340 } | 3343 } |
| 3341 | 3344 |
| 3342 | 3345 |
| 3343 #ifdef DEBUG | 3346 #ifdef DEBUG |
| 3344 static void AddTransitions(int transitions_count) { | 3347 static void AddTransitions(int transitions_count) { |
| 3345 AlwaysAllocateScope always_allocate(CcTest::i_isolate()); | 3348 AlwaysAllocateScope always_allocate(CcTest::i_isolate()); |
| 3346 for (int i = 0; i < transitions_count; i++) { | 3349 for (int i = 0; i < transitions_count; i++) { |
| 3347 EmbeddedVector<char, 64> buffer; | 3350 EmbeddedVector<char, 64> buffer; |
| 3348 SNPrintF(buffer, "var o = new F; o.prop%d = %d;", i, i); | 3351 SNPrintF(buffer, "var o = new F; o.prop%d = %d;", i, i); |
| 3349 CompileRun(buffer.start()); | 3352 CompileRun(buffer.start()); |
| 3350 } | 3353 } |
| 3351 } | 3354 } |
| 3352 | 3355 |
| 3353 | 3356 |
| 3354 static i::Handle<JSObject> GetByName(const char* name) { | 3357 static i::Handle<JSObject> GetByName(const char* name) { |
| 3355 return v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast( | 3358 return i::Handle<JSObject>::cast( |
| 3356 CcTest::global() | 3359 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast( |
| 3357 ->Get(CcTest::isolate()->GetCurrentContext(), v8_str(name)) | 3360 CcTest::global() |
| 3358 .ToLocalChecked())); | 3361 ->Get(CcTest::isolate()->GetCurrentContext(), v8_str(name)) |
| 3362 .ToLocalChecked()))); |
| 3359 } | 3363 } |
| 3360 | 3364 |
| 3361 | 3365 |
| 3362 static void AddPropertyTo( | 3366 static void AddPropertyTo( |
| 3363 int gc_count, Handle<JSObject> object, const char* property_name) { | 3367 int gc_count, Handle<JSObject> object, const char* property_name) { |
| 3364 Isolate* isolate = CcTest::i_isolate(); | 3368 Isolate* isolate = CcTest::i_isolate(); |
| 3365 Factory* factory = isolate->factory(); | 3369 Factory* factory = isolate->factory(); |
| 3366 Handle<String> prop_name = factory->InternalizeUtf8String(property_name); | 3370 Handle<String> prop_name = factory->InternalizeUtf8String(property_name); |
| 3367 Handle<Smi> twenty_three(Smi::FromInt(23), isolate); | 3371 Handle<Smi> twenty_three(Smi::FromInt(23), isolate); |
| 3368 i::FLAG_gc_interval = gc_count; | 3372 i::FLAG_gc_interval = gc_count; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3508 "}" | 3512 "}" |
| 3509 "f(new Object);" | 3513 "f(new Object);" |
| 3510 "f(root);"); | 3514 "f(root);"); |
| 3511 | 3515 |
| 3512 // This bug only triggers with aggressive IC clearing. | 3516 // This bug only triggers with aggressive IC clearing. |
| 3513 CcTest::heap()->AgeInlineCaches(); | 3517 CcTest::heap()->AgeInlineCaches(); |
| 3514 | 3518 |
| 3515 // Explicitly request GC to perform final marking step and sweeping. | 3519 // Explicitly request GC to perform final marking step and sweeping. |
| 3516 CcTest::heap()->CollectAllGarbage(); | 3520 CcTest::heap()->CollectAllGarbage(); |
| 3517 | 3521 |
| 3518 Handle<JSObject> root = v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast( | 3522 Handle<JSReceiver> root = v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast( |
| 3519 CcTest::global() | 3523 CcTest::global() |
| 3520 ->Get(CcTest::isolate()->GetCurrentContext(), v8_str("root")) | 3524 ->Get(CcTest::isolate()->GetCurrentContext(), v8_str("root")) |
| 3521 .ToLocalChecked())); | 3525 .ToLocalChecked())); |
| 3522 | 3526 |
| 3523 // The root object should be in a sane state. | 3527 // The root object should be in a sane state. |
| 3524 CHECK(root->IsJSObject()); | 3528 CHECK(root->IsJSObject()); |
| 3525 CHECK(root->map()->IsMap()); | 3529 CHECK(root->map()->IsMap()); |
| 3526 } | 3530 } |
| 3527 | 3531 |
| 3528 | 3532 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 3551 "%OptimizeFunctionOnNextCall(f);" | 3555 "%OptimizeFunctionOnNextCall(f);" |
| 3552 "f(root);" | 3556 "f(root);" |
| 3553 "%DeoptimizeFunction(f);"); | 3557 "%DeoptimizeFunction(f);"); |
| 3554 | 3558 |
| 3555 // This bug only triggers with aggressive IC clearing. | 3559 // This bug only triggers with aggressive IC clearing. |
| 3556 CcTest::heap()->AgeInlineCaches(); | 3560 CcTest::heap()->AgeInlineCaches(); |
| 3557 | 3561 |
| 3558 // Explicitly request GC to perform final marking step and sweeping. | 3562 // Explicitly request GC to perform final marking step and sweeping. |
| 3559 CcTest::heap()->CollectAllGarbage(); | 3563 CcTest::heap()->CollectAllGarbage(); |
| 3560 | 3564 |
| 3561 Handle<JSObject> root = v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast( | 3565 Handle<JSReceiver> root = v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast( |
| 3562 CcTest::global() | 3566 CcTest::global() |
| 3563 ->Get(CcTest::isolate()->GetCurrentContext(), v8_str("root")) | 3567 ->Get(CcTest::isolate()->GetCurrentContext(), v8_str("root")) |
| 3564 .ToLocalChecked())); | 3568 .ToLocalChecked())); |
| 3565 | 3569 |
| 3566 // The root object should be in a sane state. | 3570 // The root object should be in a sane state. |
| 3567 CHECK(root->IsJSObject()); | 3571 CHECK(root->IsJSObject()); |
| 3568 CHECK(root->map()->IsMap()); | 3572 CHECK(root->map()->IsMap()); |
| 3569 } | 3573 } |
| 3570 | 3574 |
| 3571 | 3575 |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3754 | 3758 |
| 3755 TEST(ICInBuiltInIsClearedAppropriately) { | 3759 TEST(ICInBuiltInIsClearedAppropriately) { |
| 3756 if (i::FLAG_always_opt) return; | 3760 if (i::FLAG_always_opt) return; |
| 3757 CcTest::InitializeVM(); | 3761 CcTest::InitializeVM(); |
| 3758 v8::HandleScope scope(CcTest::isolate()); | 3762 v8::HandleScope scope(CcTest::isolate()); |
| 3759 | 3763 |
| 3760 Handle<JSFunction> apply; | 3764 Handle<JSFunction> apply; |
| 3761 { | 3765 { |
| 3762 LocalContext env; | 3766 LocalContext env; |
| 3763 v8::Local<v8::Value> res = CompileRun("Function.apply"); | 3767 v8::Local<v8::Value> res = CompileRun("Function.apply"); |
| 3764 i::Handle<JSObject> maybe_apply = | 3768 i::Handle<JSReceiver> maybe_apply = |
| 3765 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res)); | 3769 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res)); |
| 3766 apply = i::Handle<JSFunction>::cast(maybe_apply); | 3770 apply = i::Handle<JSFunction>::cast(maybe_apply); |
| 3767 i::Handle<TypeFeedbackVector> vector(apply->shared()->feedback_vector()); | 3771 i::Handle<TypeFeedbackVector> vector(apply->shared()->feedback_vector()); |
| 3768 FeedbackVectorHelper feedback_helper(vector); | 3772 FeedbackVectorHelper feedback_helper(vector); |
| 3769 CHECK_EQ(1, feedback_helper.slot_count()); | 3773 CHECK_EQ(1, feedback_helper.slot_count()); |
| 3770 CheckVectorIC(apply, 0, UNINITIALIZED); | 3774 CheckVectorIC(apply, 0, UNINITIALIZED); |
| 3771 CompileRun( | 3775 CompileRun( |
| 3772 "function b(a1, a2, a3) { return a1 + a2 + a3; }" | 3776 "function b(a1, a2, a3) { return a1 + a2 + a3; }" |
| 3773 "function fun(bar) { bar.apply({}, [1, 2, 3]); };" | 3777 "function fun(bar) { bar.apply({}, [1, 2, 3]); };" |
| 3774 "fun(b); fun(b)"); | 3778 "fun(b); fun(b)"); |
| (...skipping 1791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5566 | 5570 |
| 5567 v8::Local<v8::Value> result = CompileRun( | 5571 v8::Local<v8::Value> result = CompileRun( |
| 5568 "var array = new Array(400);" | 5572 "var array = new Array(400);" |
| 5569 "var tmp = new Array(1000);" | 5573 "var tmp = new Array(1000);" |
| 5570 "array[0] = 10;" | 5574 "array[0] = 10;" |
| 5571 "gc();" | 5575 "gc();" |
| 5572 "gc();" | 5576 "gc();" |
| 5573 "array.shift();" | 5577 "array.shift();" |
| 5574 "array;"); | 5578 "array;"); |
| 5575 | 5579 |
| 5576 Handle<JSObject> o = | 5580 Handle<JSObject> o = Handle<JSObject>::cast( |
| 5577 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(result)); | 5581 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(result))); |
| 5578 CHECK(heap->InOldSpace(o->elements())); | 5582 CHECK(heap->InOldSpace(o->elements())); |
| 5579 CHECK(heap->InOldSpace(*o)); | 5583 CHECK(heap->InOldSpace(*o)); |
| 5580 Page* page = Page::FromAddress(o->elements()->address()); | 5584 Page* page = Page::FromAddress(o->elements()->address()); |
| 5581 CHECK(page->parallel_sweeping_state().Value() <= | 5585 CHECK(page->parallel_sweeping_state().Value() <= |
| 5582 MemoryChunk::kSweepingFinalize || | 5586 MemoryChunk::kSweepingFinalize || |
| 5583 Marking::IsBlack(Marking::MarkBitFrom(o->elements()))); | 5587 Marking::IsBlack(Marking::MarkBitFrom(o->elements()))); |
| 5584 } | 5588 } |
| 5585 | 5589 |
| 5586 | 5590 |
| 5587 UNINITIALIZED_TEST(PromotionQueue) { | 5591 UNINITIALIZED_TEST(PromotionQueue) { |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5715 "for (var i = 0; i < 50; i++) {" | 5719 "for (var i = 0; i < 50; i++) {" |
| 5716 " var key = {'k' : i + 0.1};" | 5720 " var key = {'k' : i + 0.1};" |
| 5717 " weak_map.set(key, 1);" | 5721 " weak_map.set(key, 1);" |
| 5718 " future_keys.push({'x' : i + 0.2});" | 5722 " future_keys.push({'x' : i + 0.2});" |
| 5719 "}" | 5723 "}" |
| 5720 "weak_map"); | 5724 "weak_map"); |
| 5721 if (marking->IsStopped()) { | 5725 if (marking->IsStopped()) { |
| 5722 CcTest::heap()->StartIncrementalMarking(); | 5726 CcTest::heap()->StartIncrementalMarking(); |
| 5723 } | 5727 } |
| 5724 // Incrementally mark the backing store. | 5728 // Incrementally mark the backing store. |
| 5725 Handle<JSObject> obj = | 5729 Handle<JSReceiver> obj = |
| 5726 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(result)); | 5730 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(result)); |
| 5727 Handle<JSWeakCollection> weak_map(reinterpret_cast<JSWeakCollection*>(*obj)); | 5731 Handle<JSWeakCollection> weak_map(reinterpret_cast<JSWeakCollection*>(*obj)); |
| 5728 while (!Marking::IsBlack( | 5732 while (!Marking::IsBlack( |
| 5729 Marking::MarkBitFrom(HeapObject::cast(weak_map->table()))) && | 5733 Marking::MarkBitFrom(HeapObject::cast(weak_map->table()))) && |
| 5730 !marking->IsStopped()) { | 5734 !marking->IsStopped()) { |
| 5731 marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); | 5735 marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); |
| 5732 } | 5736 } |
| 5733 // Stash the backing store in a handle. | 5737 // Stash the backing store in a handle. |
| 5734 Handle<Object> save(weak_map->table(), isolate); | 5738 Handle<Object> save(weak_map->table(), isolate); |
| 5735 // The following line will update the backing store. | 5739 // The following line will update the backing store. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5775 CcTest::InitializeVM(); | 5779 CcTest::InitializeVM(); |
| 5776 Isolate* isolate = CcTest::i_isolate(); | 5780 Isolate* isolate = CcTest::i_isolate(); |
| 5777 Heap* heap = isolate->heap(); | 5781 Heap* heap = isolate->heap(); |
| 5778 Factory* factory = isolate->factory(); | 5782 Factory* factory = isolate->factory(); |
| 5779 HandleScope scope(isolate); | 5783 HandleScope scope(isolate); |
| 5780 CompileRun("function cls() { this.x = 10; }"); | 5784 CompileRun("function cls() { this.x = 10; }"); |
| 5781 Handle<WeakCell> weak_prototype; | 5785 Handle<WeakCell> weak_prototype; |
| 5782 { | 5786 { |
| 5783 HandleScope inner_scope(isolate); | 5787 HandleScope inner_scope(isolate); |
| 5784 v8::Local<v8::Value> result = CompileRun("cls.prototype"); | 5788 v8::Local<v8::Value> result = CompileRun("cls.prototype"); |
| 5785 Handle<JSObject> proto = | 5789 Handle<JSReceiver> proto = |
| 5786 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(result)); | 5790 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(result)); |
| 5787 weak_prototype = inner_scope.CloseAndEscape(factory->NewWeakCell(proto)); | 5791 weak_prototype = inner_scope.CloseAndEscape(factory->NewWeakCell(proto)); |
| 5788 } | 5792 } |
| 5789 CHECK(!weak_prototype->cleared()); | 5793 CHECK(!weak_prototype->cleared()); |
| 5790 CompileRun( | 5794 CompileRun( |
| 5791 "var a = { };" | 5795 "var a = { };" |
| 5792 "a.x = new cls();" | 5796 "a.x = new cls();" |
| 5793 "cls.prototype = null;"); | 5797 "cls.prototype = null;"); |
| 5794 for (int i = 0; i < 4; i++) { | 5798 for (int i = 0; i < 4; i++) { |
| 5795 heap->CollectAllGarbage(); | 5799 heap->CollectAllGarbage(); |
| 5796 } | 5800 } |
| 5797 // The map of a.x keeps prototype alive | 5801 // The map of a.x keeps prototype alive |
| 5798 CHECK(!weak_prototype->cleared()); | 5802 CHECK(!weak_prototype->cleared()); |
| 5799 // Change the map of a.x and make the previous map garbage collectable. | 5803 // Change the map of a.x and make the previous map garbage collectable. |
| 5800 CompileRun("a.x.__proto__ = {};"); | 5804 CompileRun("a.x.__proto__ = {};"); |
| 5801 for (int i = 0; i < 4; i++) { | 5805 for (int i = 0; i < 4; i++) { |
| 5802 heap->CollectAllGarbage(); | 5806 heap->CollectAllGarbage(); |
| 5803 } | 5807 } |
| 5804 CHECK(weak_prototype->cleared()); | 5808 CHECK(weak_prototype->cleared()); |
| 5805 } | 5809 } |
| 5806 | 5810 |
| 5807 | 5811 |
| 5808 Handle<WeakCell> AddRetainedMap(Isolate* isolate, Heap* heap) { | 5812 Handle<WeakCell> AddRetainedMap(Isolate* isolate, Heap* heap) { |
| 5809 HandleScope inner_scope(isolate); | 5813 HandleScope inner_scope(isolate); |
| 5810 Handle<Map> map = Map::Create(isolate, 1); | 5814 Handle<Map> map = Map::Create(isolate, 1); |
| 5811 v8::Local<v8::Value> result = | 5815 v8::Local<v8::Value> result = |
| 5812 CompileRun("(function () { return {x : 10}; })();"); | 5816 CompileRun("(function () { return {x : 10}; })();"); |
| 5813 Handle<JSObject> proto = | 5817 Handle<JSReceiver> proto = |
| 5814 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(result)); | 5818 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(result)); |
| 5815 Map::SetPrototype(map, proto); | 5819 Map::SetPrototype(map, proto); |
| 5816 heap->AddRetainedMap(map); | 5820 heap->AddRetainedMap(map); |
| 5817 return inner_scope.CloseAndEscape(Map::WeakCellForMap(map)); | 5821 return inner_scope.CloseAndEscape(Map::WeakCellForMap(map)); |
| 5818 } | 5822 } |
| 5819 | 5823 |
| 5820 | 5824 |
| 5821 void CheckMapRetainingFor(int n) { | 5825 void CheckMapRetainingFor(int n) { |
| 5822 FLAG_retain_maps_for_n_gc = n; | 5826 FLAG_retain_maps_for_n_gc = n; |
| 5823 Isolate* isolate = CcTest::i_isolate(); | 5827 Isolate* isolate = CcTest::i_isolate(); |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6450 isolate->IncrementJsCallsFromApiCounter(); | 6454 isolate->IncrementJsCallsFromApiCounter(); |
| 6451 isolate->IncrementJsCallsFromApiCounter(); | 6455 isolate->IncrementJsCallsFromApiCounter(); |
| 6452 isolate->IncrementJsCallsFromApiCounter(); | 6456 isolate->IncrementJsCallsFromApiCounter(); |
| 6453 calls_per_ms = memory_reducer->SampleAndGetJsCallsPerMs(4); | 6457 calls_per_ms = memory_reducer->SampleAndGetJsCallsPerMs(4); |
| 6454 CheckDoubleEquals(2, calls_per_ms); | 6458 CheckDoubleEquals(2, calls_per_ms); |
| 6455 } | 6459 } |
| 6456 | 6460 |
| 6457 | 6461 |
| 6458 } // namespace internal | 6462 } // namespace internal |
| 6459 } // namespace v8 | 6463 } // namespace v8 |
| OLD | NEW |