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

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

Issue 398053002: Introduce FLAG_vector_ics. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE. Created 6 years, 5 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/x64/lithium-x64.cc ('k') | test/cctest/test-heap.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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
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<FixedArray> feedback_vector(f->shared()->feedback_vector());
310 310
311 // Verify that we gathered feedback. 311 // Verify that we gathered feedback.
312 CHECK_EQ(1, feedback_vector->length()); 312 int expected_count = FLAG_vector_ics ? 2 : 1;
313 CHECK(feedback_vector->get(0)->IsJSFunction()); 313 CHECK_EQ(expected_count, feedback_vector->length());
314 CHECK(feedback_vector->get(expected_count - 1)->IsJSFunction());
314 315
315 CompileRun("%OptimizeFunctionOnNextCall(f); f(fun1);"); 316 CompileRun("%OptimizeFunctionOnNextCall(f); f(fun1);");
316 317
317 // Verify that the feedback is still "gathered" despite a recompilation 318 // Verify that the feedback is still "gathered" despite a recompilation
318 // of the full code. 319 // of the full code.
319 CHECK(f->IsOptimized()); 320 CHECK(f->IsOptimized());
320 CHECK(f->shared()->has_deoptimization_support()); 321 CHECK(f->shared()->has_deoptimization_support());
321 CHECK(f->shared()->feedback_vector()->get(0)->IsJSFunction()); 322 CHECK(f->shared()->feedback_vector()->
323 get(expected_count - 1)->IsJSFunction());
322 } 324 }
323 325
324 326
325 TEST(FeedbackVectorUnaffectedByScopeChanges) { 327 TEST(FeedbackVectorUnaffectedByScopeChanges) {
326 if (i::FLAG_always_opt || !i::FLAG_lazy) return; 328 if (i::FLAG_always_opt || !i::FLAG_lazy) return;
327 CcTest::InitializeVM(); 329 CcTest::InitializeVM();
328 v8::HandleScope scope(CcTest::isolate()); 330 v8::HandleScope scope(CcTest::isolate());
329 331
330 CompileRun("function builder() {" 332 CompileRun("function builder() {"
331 " call_target = function() { return 3; };" 333 " call_target = function() { return 3; };"
332 " return (function() {" 334 " return (function() {"
333 " eval('');" 335 " eval('');"
334 " return function() {" 336 " return function() {"
335 " 'use strict';" 337 " 'use strict';"
336 " call_target();" 338 " call_target();"
337 " }" 339 " }"
338 " })();" 340 " })();"
339 "}" 341 "}"
340 "morphing_call = builder();"); 342 "morphing_call = builder();");
341 343
342 Handle<JSFunction> f = 344 Handle<JSFunction> f =
343 v8::Utils::OpenHandle( 345 v8::Utils::OpenHandle(
344 *v8::Handle<v8::Function>::Cast( 346 *v8::Handle<v8::Function>::Cast(
345 CcTest::global()->Get(v8_str("morphing_call")))); 347 CcTest::global()->Get(v8_str("morphing_call"))));
346 348
347 // morphing_call should have one feedback vector slot for the call to 349 int expected_count = FLAG_vector_ics ? 2 : 1;
348 // call_target(). 350 CHECK_EQ(expected_count, f->shared()->feedback_vector()->length());
349 CHECK_EQ(1, f->shared()->feedback_vector()->length());
350 // And yet it's not compiled. 351 // And yet it's not compiled.
351 CHECK(!f->shared()->is_compiled()); 352 CHECK(!f->shared()->is_compiled());
352 353
353 CompileRun("morphing_call();"); 354 CompileRun("morphing_call();");
354 355
355 // The vector should have the same size despite the new scoping. 356 // The vector should have the same size despite the new scoping.
356 CHECK_EQ(1, f->shared()->feedback_vector()->length()); 357 CHECK_EQ(expected_count, f->shared()->feedback_vector()->length());
357 CHECK(f->shared()->is_compiled()); 358 CHECK(f->shared()->is_compiled());
358 } 359 }
359 360
360 361
361 // Test that optimized code for different closures is actually shared 362 // Test that optimized code for different closures is actually shared
362 // immediately by the FastNewClosureStub when run in the same context. 363 // immediately by the FastNewClosureStub when run in the same context.
363 TEST(OptimizedCodeSharing) { 364 TEST(OptimizedCodeSharing) {
364 // Skip test if --cache-optimized-code is not activated by default because 365 // Skip test if --cache-optimized-code is not activated by default because
365 // FastNewClosureStub that is baked into the snapshot is incorrect. 366 // FastNewClosureStub that is baked into the snapshot is incorrect.
366 if (!FLAG_cache_optimized_code) return; 367 if (!FLAG_cache_optimized_code) return;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 CompileRun("function f() { a = 12345678 }; f();"); 440 CompileRun("function f() { a = 12345678 }; f();");
440 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); 441 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f"));
441 CompileRun("function f(x) { a = 12345678 + x}; f(1);"); 442 CompileRun("function f(x) { a = 12345678 + x}; f(1);");
442 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); 443 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f"));
443 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); 444 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);");
444 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); 445 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f"));
445 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); 446 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);");
446 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); 447 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f"));
447 } 448 }
448 #endif 449 #endif
OLDNEW
« no previous file with comments | « src/x64/lithium-x64.cc ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698