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

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

Issue 10963005: Fix missing slot recodring during clearing of CallICs. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « src/ic-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 2
3 #include <stdlib.h> 3 #include <stdlib.h>
4 4
5 #include "v8.h" 5 #include "v8.h"
6 6
7 #include "compilation-cache.h"
7 #include "execution.h" 8 #include "execution.h"
8 #include "factory.h" 9 #include "factory.h"
9 #include "macro-assembler.h" 10 #include "macro-assembler.h"
10 #include "global-handles.h" 11 #include "global-handles.h"
12 #include "stub-cache.h"
11 #include "cctest.h" 13 #include "cctest.h"
12 14
13 using namespace v8::internal; 15 using namespace v8::internal;
14 16
15 static v8::Persistent<v8::Context> env; 17 static v8::Persistent<v8::Context> env;
16 18
17 static void InitializeVM() { 19 static void InitializeVM() {
18 if (env.IsEmpty()) env = v8::Context::New(); 20 if (env.IsEmpty()) env = v8::Context::New();
19 v8::HandleScope scope; 21 v8::HandleScope scope;
20 env->Enter(); 22 env->Enter();
(...skipping 2216 matching lines...) Expand 10 before | Expand all | Expand 10 after
2237 // External source is being retained by the stack trace. 2239 // External source is being retained by the stack trace.
2238 CHECK(!resource->IsDisposed()); 2240 CHECK(!resource->IsDisposed());
2239 2241
2240 CompileRun("error.stack; error.stack;"); 2242 CompileRun("error.stack; error.stack;");
2241 HEAP->CollectAllAvailableGarbage(); 2243 HEAP->CollectAllAvailableGarbage();
2242 // External source has been released. 2244 // External source has been released.
2243 CHECK(resource->IsDisposed()); 2245 CHECK(resource->IsDisposed());
2244 2246
2245 delete resource; 2247 delete resource;
2246 } 2248 }
2249
2250
2251 TEST(Regression144230) {
2252 InitializeVM();
2253 v8::HandleScope scope;
2254
2255 // First make sure that the uninitialized CallIC stub is on a single page
2256 // that will later be selected as an evacuation candidate.
2257 {
2258 v8::HandleScope inner_scope;
2259 AlwaysAllocateScope always_allocate;
2260 SimulateFullSpace(HEAP->code_space());
2261 ISOLATE->stub_cache()->ComputeCallInitialize(9, RelocInfo::CODE_TARGET);
2262 }
2263
2264 // Second compile a CallIC and execute it once so that it gets patched to
2265 // the pre-monomorphic stub. These code objects are on yet another page.
2266 {
2267 v8::HandleScope inner_scope;
2268 AlwaysAllocateScope always_allocate;
2269 SimulateFullSpace(HEAP->code_space());
2270 CompileRun("var o = { f:function(a,b,c,d,e,f,g,h,i) {}};"
2271 "function call() { o.f(1,2,3,4,5,6,7,8,9); };"
2272 "call();");
2273 }
2274
2275 // Third we fill up the last page of the code space so that it does not get
2276 // chosen as an evacuation candidate.
2277 {
2278 v8::HandleScope inner_scope;
2279 AlwaysAllocateScope always_allocate;
2280 CompileRun("for (var i = 0; i < 2000; i++) {"
2281 " eval('function f' + i + '() { return ' + i +'; };' +"
2282 " 'f' + i + '();');"
2283 "}");
2284 }
2285 HEAP->CollectAllGarbage(Heap::kNoGCFlags);
2286
2287 // Fourth is the tricky part. Make sure the code containing the CallIC is
2288 // visited first without clearing the IC. The shared function info is then
2289 // visited later, causing the CallIC to be cleared.
2290 Handle<String> name = FACTORY->LookupAsciiSymbol("call");
2291 Handle<GlobalObject> global(ISOLATE->context()->global_object());
2292 MaybeObject* maybe_call = global->GetProperty(*name);
2293 JSFunction* call = JSFunction::cast(maybe_call->ToObjectChecked());
2294 USE(global->SetProperty(*name, Smi::FromInt(0), NONE, kNonStrictMode));
2295 ISOLATE->compilation_cache()->Clear();
2296 call->shared()->set_ic_age(HEAP->global_ic_age() + 1);
2297 Handle<Object> call_code(call->code());
2298 Handle<Object> call_function(call);
2299
2300 // Now we are ready to mess up the heap.
2301 HEAP->CollectAllGarbage(Heap::kReduceMemoryFootprintMask);
2302
2303 // Either heap verification caught the problem already or we go kaboom once
2304 // the CallIC is executed the next time.
2305 USE(global->SetProperty(*name, *call_function, NONE, kNonStrictMode));
2306 CompileRun("call();");
2307 }
OLDNEW
« no previous file with comments | « src/ic-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698