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

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

Issue 178463007: Moved type feedback vector to SharedFunctionInfo. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Ports and comment response. 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
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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 v8::String::NewFromUtf8(CcTest::isolate(), buffer.start()); 306 v8::String::NewFromUtf8(CcTest::isolate(), buffer.start());
307 v8::Script::Compile(script_body, &origin)->Run(); 307 v8::Script::Compile(script_body, &origin)->Run();
308 v8::Local<v8::Function> f = 308 v8::Local<v8::Function> f =
309 v8::Local<v8::Function>::Cast(context->Global()->Get( 309 v8::Local<v8::Function>::Cast(context->Global()->Get(
310 v8::String::NewFromUtf8(CcTest::isolate(), "f"))); 310 v8::String::NewFromUtf8(CcTest::isolate(), "f")));
311 CHECK_EQ(i, f->GetScriptLineNumber()); 311 CHECK_EQ(i, f->GetScriptLineNumber());
312 } 312 }
313 } 313 }
314 314
315 315
316 TEST(FeedbackVectorPreservedAcrossRecompiles) {
317 if (i::FLAG_always_opt || !i::FLAG_crankshaft) return;
318 i::FLAG_allow_natives_syntax = true;
319 CcTest::InitializeVM();
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
316 // Test that optimized code for different closures is actually shared 350 // Test that optimized code for different closures is actually shared
317 // immediately by the FastNewClosureStub when run in the same context. 351 // immediately by the FastNewClosureStub when run in the same context.
318 TEST(OptimizedCodeSharing) { 352 TEST(OptimizedCodeSharing) {
319 // Skip test if --cache-optimized-code is not activated by default because 353 // Skip test if --cache-optimized-code is not activated by default because
320 // FastNewClosureStub that is baked into the snapshot is incorrect. 354 // FastNewClosureStub that is baked into the snapshot is incorrect.
321 if (!FLAG_cache_optimized_code) return; 355 if (!FLAG_cache_optimized_code) return;
322 FLAG_stress_compaction = false; 356 FLAG_stress_compaction = false;
323 FLAG_allow_natives_syntax = true; 357 FLAG_allow_natives_syntax = true;
324 CcTest::InitializeVM(); 358 CcTest::InitializeVM();
325 v8::HandleScope scope(CcTest::isolate()); 359 v8::HandleScope scope(CcTest::isolate());
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 CompileRun("function f() { a = 12345678 }; f();"); 428 CompileRun("function f() { a = 12345678 }; f();");
395 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); 429 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f"));
396 CompileRun("function f(x) { a = 12345678 + x}; f(1);"); 430 CompileRun("function f(x) { a = 12345678 + x}; f(1);");
397 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); 431 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f"));
398 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); 432 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);");
399 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); 433 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f"));
400 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); 434 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);");
401 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); 435 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f"));
402 } 436 }
403 #endif 437 #endif
OLDNEW
« src/runtime.cc ('K') | « 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