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

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

Issue 196283015: Revert "Moved type feedback vector to SharedFunctionInfo." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 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/full-codegen-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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 v8::String::NewFromUtf8(CcTest::isolate(), buffer.start()); 305 v8::String::NewFromUtf8(CcTest::isolate(), buffer.start());
306 v8::Script::Compile(script_body, &origin)->Run(); 306 v8::Script::Compile(script_body, &origin)->Run();
307 v8::Local<v8::Function> f = 307 v8::Local<v8::Function> f =
308 v8::Local<v8::Function>::Cast(context->Global()->Get( 308 v8::Local<v8::Function>::Cast(context->Global()->Get(
309 v8::String::NewFromUtf8(CcTest::isolate(), "f"))); 309 v8::String::NewFromUtf8(CcTest::isolate(), "f")));
310 CHECK_EQ(i, f->GetScriptLineNumber()); 310 CHECK_EQ(i, f->GetScriptLineNumber());
311 } 311 }
312 } 312 }
313 313
314 314
315 TEST(FeedbackVectorPreservedAcrossRecompiles) {
316 if (i::FLAG_always_opt || !i::FLAG_crankshaft) return;
317 i::FLAG_allow_natives_syntax = true;
318 CcTest::InitializeVM();
319 if (!CcTest::i_isolate()->use_crankshaft()) return;
320 v8::HandleScope scope(CcTest::isolate());
321
322 // Make sure function f has a call that uses a type feedback slot.
323 CompileRun("function fun() {};"
324 "fun1 = fun;"
325 "function f(a) { a(); } f(fun1);");
326
327 Handle<JSFunction> f =
328 v8::Utils::OpenHandle(
329 *v8::Handle<v8::Function>::Cast(
330 CcTest::global()->Get(v8_str("f"))));
331
332 // We shouldn't have deoptimization support. We want to recompile and
333 // verify that our feedback vector preserves information.
334 CHECK(!f->shared()->has_deoptimization_support());
335 Handle<FixedArray> feedback_vector(f->shared()->feedback_vector());
336
337 // Verify that we gathered feedback.
338 CHECK_EQ(1, feedback_vector->length());
339 CHECK(feedback_vector->get(0)->IsJSFunction());
340
341 CompileRun("%OptimizeFunctionOnNextCall(f); f(fun1);");
342
343 // Verify that the feedback is still "gathered" despite a recompilation
344 // of the full code.
345 CHECK(f->shared()->has_deoptimization_support());
346 CHECK(f->shared()->feedback_vector()->get(0)->IsJSFunction());
347 }
348
349
350 TEST(FeedbackVectorRecreatedOnScopeChanges) {
351 if (i::FLAG_always_opt || !i::FLAG_lazy) return;
352 CcTest::InitializeVM();
353 v8::HandleScope scope(CcTest::isolate());
354
355 CompileRun("function builder() {"
356 " call_target = function() { return 3; };"
357 " return (function() {"
358 " eval('');"
359 " return function() {"
360 " 'use strict';"
361 " call_target();"
362 " }"
363 " })();"
364 "}"
365 "morphing_call = builder();");
366
367 Handle<JSFunction> f =
368 v8::Utils::OpenHandle(
369 *v8::Handle<v8::Function>::Cast(
370 CcTest::global()->Get(v8_str("morphing_call"))));
371
372 // morphing_call should have one feedback vector slot for the call to
373 // call_target(), scoping analysis having been performed.
374 CHECK_EQ(1, f->shared()->feedback_vector()->length());
375 // And yet it's not compiled.
376 CHECK(!f->shared()->is_compiled());
377
378 CompileRun("morphing_call();");
379
380 // On scoping analysis after lazy compile, the call is now a global
381 // call which needs no feedback vector slot.
382 CHECK_EQ(0, f->shared()->feedback_vector()->length());
383 CHECK(f->shared()->is_compiled());
384 }
385
386
387 // Test that optimized code for different closures is actually shared 315 // Test that optimized code for different closures is actually shared
388 // immediately by the FastNewClosureStub when run in the same context. 316 // immediately by the FastNewClosureStub when run in the same context.
389 TEST(OptimizedCodeSharing) { 317 TEST(OptimizedCodeSharing) {
390 // Skip test if --cache-optimized-code is not activated by default because 318 // Skip test if --cache-optimized-code is not activated by default because
391 // FastNewClosureStub that is baked into the snapshot is incorrect. 319 // FastNewClosureStub that is baked into the snapshot is incorrect.
392 if (!FLAG_cache_optimized_code) return; 320 if (!FLAG_cache_optimized_code) return;
393 FLAG_stress_compaction = false; 321 FLAG_stress_compaction = false;
394 FLAG_allow_natives_syntax = true; 322 FLAG_allow_natives_syntax = true;
395 CcTest::InitializeVM(); 323 CcTest::InitializeVM();
396 v8::HandleScope scope(CcTest::isolate()); 324 v8::HandleScope scope(CcTest::isolate());
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 CompileRun("function f() { a = 12345678 }; f();"); 393 CompileRun("function f() { a = 12345678 }; f();");
466 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); 394 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f"));
467 CompileRun("function f(x) { a = 12345678 + x}; f(1);"); 395 CompileRun("function f(x) { a = 12345678 + x}; f(1);");
468 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); 396 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f"));
469 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); 397 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);");
470 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); 398 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f"));
471 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); 399 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);");
472 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); 400 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f"));
473 } 401 }
474 #endif 402 #endif
OLDNEW
« no previous file with comments | « src/x64/full-codegen-x64.cc ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698