OLD | NEW |
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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 int expected_slots = 0; | 364 int expected_slots = 0; |
365 int expected_ic_slots = 2; | 365 int expected_ic_slots = 2; |
366 CHECK_EQ(expected_slots, f->shared()->feedback_vector()->Slots()); | 366 CHECK_EQ(expected_slots, f->shared()->feedback_vector()->Slots()); |
367 CHECK_EQ(expected_ic_slots, f->shared()->feedback_vector()->ICSlots()); | 367 CHECK_EQ(expected_ic_slots, f->shared()->feedback_vector()->ICSlots()); |
368 } | 368 } |
369 | 369 |
370 | 370 |
371 // Test that optimized code for different closures is actually shared | 371 // Test that optimized code for different closures is actually shared |
372 // immediately by the FastNewClosureStub when run in the same context. | 372 // immediately by the FastNewClosureStub when run in the same context. |
373 TEST(OptimizedCodeSharing) { | 373 TEST(OptimizedCodeSharing) { |
374 // Skip test if --cache-optimized-code is not activated by default because | |
375 // FastNewClosureStub that is baked into the snapshot is incorrect. | |
376 if (!FLAG_cache_optimized_code) return; | |
377 FLAG_stress_compaction = false; | 374 FLAG_stress_compaction = false; |
378 FLAG_allow_natives_syntax = true; | 375 FLAG_allow_natives_syntax = true; |
| 376 FLAG_cache_optimized_code = true; |
379 CcTest::InitializeVM(); | 377 CcTest::InitializeVM(); |
380 v8::HandleScope scope(CcTest::isolate()); | 378 v8::HandleScope scope(CcTest::isolate()); |
381 for (int i = 0; i < 10; i++) { | 379 for (int i = 0; i < 10; i++) { |
382 LocalContext env; | 380 LocalContext env; |
383 env->Global()->Set(v8::String::NewFromUtf8(CcTest::isolate(), "x"), | 381 env->Global()->Set(v8::String::NewFromUtf8(CcTest::isolate(), "x"), |
384 v8::Integer::New(CcTest::isolate(), i)); | 382 v8::Integer::New(CcTest::isolate(), i)); |
385 CompileRun("function MakeClosure() {" | 383 CompileRun("function MakeClosure() {" |
386 " return function() { return x; };" | 384 " return function() { return x; };" |
387 "}" | 385 "}" |
388 "var closure0 = MakeClosure();" | 386 "var closure0 = MakeClosure();" |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 CompileRun("function f() { a = 12345678 }; f();"); | 558 CompileRun("function f() { a = 12345678 }; f();"); |
561 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 559 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
562 CompileRun("function f(x) { a = 12345678 + x}; f(1);"); | 560 CompileRun("function f(x) { a = 12345678 + x}; f(1);"); |
563 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 561 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
564 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); | 562 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); |
565 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 563 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
566 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); | 564 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); |
567 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 565 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
568 } | 566 } |
569 #endif | 567 #endif |
OLD | NEW |