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 3061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3072 // supposed to (untypically) write to the receiver, not the holder. This is | 3072 // supposed to (untypically) write to the receiver, not the holder. This is |
3073 // to emulate the behavior of a data property. | 3073 // to emulate the behavior of a data property. |
3074 | 3074 |
3075 ReleaseStackTraceDataTest(source1, getter); | 3075 ReleaseStackTraceDataTest(source1, getter); |
3076 ReleaseStackTraceDataTest(source2, getter); | 3076 ReleaseStackTraceDataTest(source2, getter); |
3077 ReleaseStackTraceDataTest(source3, getter); | 3077 ReleaseStackTraceDataTest(source3, getter); |
3078 ReleaseStackTraceDataTest(source4, getter); | 3078 ReleaseStackTraceDataTest(source4, getter); |
3079 } | 3079 } |
3080 | 3080 |
3081 | 3081 |
3082 TEST(Regression144230) { | |
3083 i::FLAG_stress_compaction = false; | |
3084 CcTest::InitializeVM(); | |
3085 Isolate* isolate = CcTest::i_isolate(); | |
3086 Heap* heap = isolate->heap(); | |
3087 HandleScope scope(isolate); | |
3088 | |
3089 // First make sure that the uninitialized CallIC stub is on a single page | |
3090 // that will later be selected as an evacuation candidate. | |
3091 { | |
3092 HandleScope inner_scope(isolate); | |
3093 AlwaysAllocateScope always_allocate; | |
3094 SimulateFullSpace(heap->code_space()); | |
3095 isolate->stub_cache()->ComputeCallInitialize(9); | |
3096 } | |
3097 | |
3098 // Second compile a CallIC and execute it once so that it gets patched to | |
3099 // the pre-monomorphic stub. These code objects are on yet another page. | |
3100 { | |
3101 HandleScope inner_scope(isolate); | |
3102 AlwaysAllocateScope always_allocate; | |
3103 SimulateFullSpace(heap->code_space()); | |
3104 CompileRun("var o = { f:function(a,b,c,d,e,f,g,h,i) {}};" | |
3105 "function call() { o.f(1,2,3,4,5,6,7,8,9); };" | |
3106 "call();"); | |
3107 } | |
3108 | |
3109 // Third we fill up the last page of the code space so that it does not get | |
3110 // chosen as an evacuation candidate. | |
3111 { | |
3112 HandleScope inner_scope(isolate); | |
3113 AlwaysAllocateScope always_allocate; | |
3114 CompileRun("for (var i = 0; i < 2000; i++) {" | |
3115 " eval('function f' + i + '() { return ' + i +'; };' +" | |
3116 " 'f' + i + '();');" | |
3117 "}"); | |
3118 } | |
3119 heap->CollectAllGarbage(Heap::kNoGCFlags); | |
3120 | |
3121 // Fourth is the tricky part. Make sure the code containing the CallIC is | |
3122 // visited first without clearing the IC. The shared function info is then | |
3123 // visited later, causing the CallIC to be cleared. | |
3124 Handle<String> name = isolate->factory()->InternalizeUtf8String("call"); | |
3125 Handle<GlobalObject> global(isolate->context()->global_object()); | |
3126 Handle<Smi> zero(Smi::FromInt(0), isolate); | |
3127 MaybeObject* maybe_call = global->GetProperty(*name); | |
3128 JSFunction* call = JSFunction::cast(maybe_call->ToObjectChecked()); | |
3129 JSReceiver::SetProperty(global, name, zero, NONE, kNonStrictMode); | |
3130 isolate->compilation_cache()->Clear(); | |
3131 call->shared()->set_ic_age(heap->global_ic_age() + 1); | |
3132 Handle<Object> call_code(call->code(), isolate); | |
3133 Handle<Object> call_function(call, isolate); | |
3134 | |
3135 // Now we are ready to mess up the heap. | |
3136 heap->CollectAllGarbage(Heap::kReduceMemoryFootprintMask); | |
3137 | |
3138 // Either heap verification caught the problem already or we go kaboom once | |
3139 // the CallIC is executed the next time. | |
3140 JSReceiver::SetProperty(global, name, call_function, NONE, kNonStrictMode); | |
3141 CompileRun("call();"); | |
3142 } | |
3143 | |
3144 | |
3145 TEST(Regress159140) { | 3082 TEST(Regress159140) { |
3146 i::FLAG_allow_natives_syntax = true; | 3083 i::FLAG_allow_natives_syntax = true; |
3147 i::FLAG_flush_code_incrementally = true; | 3084 i::FLAG_flush_code_incrementally = true; |
3148 CcTest::InitializeVM(); | 3085 CcTest::InitializeVM(); |
3149 Isolate* isolate = CcTest::i_isolate(); | 3086 Isolate* isolate = CcTest::i_isolate(); |
3150 Heap* heap = isolate->heap(); | 3087 Heap* heap = isolate->heap(); |
3151 HandleScope scope(isolate); | 3088 HandleScope scope(isolate); |
3152 | 3089 |
3153 // Perform one initial GC to enable code flushing. | 3090 // Perform one initial GC to enable code flushing. |
3154 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 3091 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3742 code = scope.CloseAndEscape(Handle<Code>(bar->code())); | 3679 code = scope.CloseAndEscape(Handle<Code>(bar->code())); |
3743 } | 3680 } |
3744 | 3681 |
3745 // Now make sure that a gc should get rid of the function | 3682 // Now make sure that a gc should get rid of the function |
3746 for (int i = 0; i < 4; i++) { | 3683 for (int i = 0; i < 4; i++) { |
3747 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 3684 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
3748 } | 3685 } |
3749 | 3686 |
3750 ASSERT(code->marked_for_deoptimization()); | 3687 ASSERT(code->marked_for_deoptimization()); |
3751 } | 3688 } |
OLD | NEW |