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

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

Issue 650073002: vector-based ICs did not update type feedback counts correctly. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE. Created 6 years, 2 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 | « test/cctest/cctest.gyp ('k') | test/cctest/test-feedback-vector.cc » ('j') | 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 // 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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 "function f(a) { a(); } f(fun1);"); 299 "function f(a) { a(); } f(fun1);");
300 300
301 Handle<JSFunction> f = 301 Handle<JSFunction> f =
302 v8::Utils::OpenHandle( 302 v8::Utils::OpenHandle(
303 *v8::Handle<v8::Function>::Cast( 303 *v8::Handle<v8::Function>::Cast(
304 CcTest::global()->Get(v8_str("f")))); 304 CcTest::global()->Get(v8_str("f"))));
305 305
306 // We shouldn't have deoptimization support. We want to recompile and 306 // We shouldn't have deoptimization support. We want to recompile and
307 // verify that our feedback vector preserves information. 307 // verify that our feedback vector preserves information.
308 CHECK(!f->shared()->has_deoptimization_support()); 308 CHECK(!f->shared()->has_deoptimization_support());
309 Handle<FixedArray> feedback_vector(f->shared()->feedback_vector()); 309 Handle<TypeFeedbackVector> feedback_vector(f->shared()->feedback_vector());
310 310
311 // Verify that we gathered feedback. 311 // Verify that we gathered feedback.
312 int expected_count = FLAG_vector_ics ? 2 : 1; 312 int expected_slots = 0;
313 CHECK_EQ(expected_count, feedback_vector->length()); 313 int expected_ic_slots = FLAG_vector_ics ? 2 : 1;
314 CHECK(feedback_vector->get(expected_count - 1)->IsJSFunction()); 314 CHECK_EQ(expected_slots, feedback_vector->Slots());
315 CHECK_EQ(expected_ic_slots, feedback_vector->ICSlots());
316 FeedbackVectorICSlot slot_for_a(FLAG_vector_ics ? 1 : 0);
317 CHECK(feedback_vector->Get(slot_for_a)->IsJSFunction());
315 318
316 CompileRun("%OptimizeFunctionOnNextCall(f); f(fun1);"); 319 CompileRun("%OptimizeFunctionOnNextCall(f); f(fun1);");
317 320
318 // Verify that the feedback is still "gathered" despite a recompilation 321 // Verify that the feedback is still "gathered" despite a recompilation
319 // of the full code. 322 // of the full code.
320 CHECK(f->IsOptimized()); 323 CHECK(f->IsOptimized());
321 CHECK(f->shared()->has_deoptimization_support()); 324 CHECK(f->shared()->has_deoptimization_support());
322 CHECK(f->shared()->feedback_vector()-> 325 CHECK(f->shared()->feedback_vector()->Get(slot_for_a)->IsJSFunction());
323 get(expected_count - 1)->IsJSFunction());
324 } 326 }
325 327
326 328
327 TEST(FeedbackVectorUnaffectedByScopeChanges) { 329 TEST(FeedbackVectorUnaffectedByScopeChanges) {
328 if (i::FLAG_always_opt || !i::FLAG_lazy) return; 330 if (i::FLAG_always_opt || !i::FLAG_lazy) return;
329 CcTest::InitializeVM(); 331 CcTest::InitializeVM();
330 v8::HandleScope scope(CcTest::isolate()); 332 v8::HandleScope scope(CcTest::isolate());
331 333
332 CompileRun("function builder() {" 334 CompileRun("function builder() {"
333 " call_target = function() { return 3; };" 335 " call_target = function() { return 3; };"
334 " return (function() {" 336 " return (function() {"
335 " eval('');" 337 " eval('');"
336 " return function() {" 338 " return function() {"
337 " 'use strict';" 339 " 'use strict';"
338 " call_target();" 340 " call_target();"
339 " }" 341 " }"
340 " })();" 342 " })();"
341 "}" 343 "}"
342 "morphing_call = builder();"); 344 "morphing_call = builder();");
343 345
344 Handle<JSFunction> f = 346 Handle<JSFunction> f =
345 v8::Utils::OpenHandle( 347 v8::Utils::OpenHandle(
346 *v8::Handle<v8::Function>::Cast( 348 *v8::Handle<v8::Function>::Cast(
347 CcTest::global()->Get(v8_str("morphing_call")))); 349 CcTest::global()->Get(v8_str("morphing_call"))));
348 350
349 int expected_count = FLAG_vector_ics ? 2 : 1; 351 int expected_slots = 0;
350 CHECK_EQ(expected_count, f->shared()->feedback_vector()->length()); 352 int expected_ic_slots = FLAG_vector_ics ? 2 : 1;
353 CHECK_EQ(expected_slots, f->shared()->feedback_vector()->Slots());
354 CHECK_EQ(expected_ic_slots, f->shared()->feedback_vector()->ICSlots());
355
351 // And yet it's not compiled. 356 // And yet it's not compiled.
352 CHECK(!f->shared()->is_compiled()); 357 CHECK(!f->shared()->is_compiled());
353 358
354 CompileRun("morphing_call();"); 359 CompileRun("morphing_call();");
355 360
356 // The vector should have the same size despite the new scoping. 361 // The vector should have the same size despite the new scoping.
357 CHECK_EQ(expected_count, f->shared()->feedback_vector()->length()); 362 CHECK_EQ(expected_slots, f->shared()->feedback_vector()->Slots());
363 CHECK_EQ(expected_ic_slots, f->shared()->feedback_vector()->ICSlots());
358 CHECK(f->shared()->is_compiled()); 364 CHECK(f->shared()->is_compiled());
359 } 365 }
360 366
361 367
362 // Test that optimized code for different closures is actually shared 368 // Test that optimized code for different closures is actually shared
363 // immediately by the FastNewClosureStub when run in the same context. 369 // immediately by the FastNewClosureStub when run in the same context.
364 TEST(OptimizedCodeSharing) { 370 TEST(OptimizedCodeSharing) {
365 // Skip test if --cache-optimized-code is not activated by default because 371 // Skip test if --cache-optimized-code is not activated by default because
366 // FastNewClosureStub that is baked into the snapshot is incorrect. 372 // FastNewClosureStub that is baked into the snapshot is incorrect.
367 if (!FLAG_cache_optimized_code) return; 373 if (!FLAG_cache_optimized_code) return;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 CompileRun("function f() { a = 12345678 }; f();"); 446 CompileRun("function f() { a = 12345678 }; f();");
441 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); 447 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f"));
442 CompileRun("function f(x) { a = 12345678 + x}; f(1);"); 448 CompileRun("function f(x) { a = 12345678 + x}; f(1);");
443 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); 449 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f"));
444 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); 450 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);");
445 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); 451 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f"));
446 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); 452 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);");
447 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); 453 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f"));
448 } 454 }
449 #endif 455 #endif
OLDNEW
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/cctest/test-feedback-vector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698