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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 } | 342 } |
343 } | 343 } |
344 | 344 |
345 | 345 |
346 // Test that optimized code for different closures is actually shared | 346 // Test that optimized code for different closures is actually shared |
347 // immediately by the FastNewClosureStub when run in the same context. | 347 // immediately by the FastNewClosureStub when run in the same context. |
348 TEST(OptimizedCodeSharing) { | 348 TEST(OptimizedCodeSharing) { |
349 // Skip test if --cache-optimized-code is not activated by default because | 349 // Skip test if --cache-optimized-code is not activated by default because |
350 // FastNewClosureStub that is baked into the snapshot is incorrect. | 350 // FastNewClosureStub that is baked into the snapshot is incorrect. |
351 if (!FLAG_cache_optimized_code) return; | 351 if (!FLAG_cache_optimized_code) return; |
| 352 FLAG_stress_compaction = false; |
352 FLAG_allow_natives_syntax = true; | 353 FLAG_allow_natives_syntax = true; |
353 CcTest::InitializeVM(); | 354 CcTest::InitializeVM(); |
354 v8::HandleScope scope(CcTest::isolate()); | 355 v8::HandleScope scope(CcTest::isolate()); |
355 for (int i = 0; i < 10; i++) { | 356 for (int i = 0; i < 10; i++) { |
356 LocalContext env; | 357 LocalContext env; |
357 env->Global()->Set(v8::String::New("x"), v8::Integer::New(i)); | 358 env->Global()->Set(v8::String::New("x"), v8::Integer::New(i)); |
358 CompileRun("function MakeClosure() {" | 359 CompileRun("function MakeClosure() {" |
359 " return function() { return x; };" | 360 " return function() { return x; };" |
360 "}" | 361 "}" |
361 "var closure0 = MakeClosure();" | 362 "var closure0 = MakeClosure();" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 CompileRun("function f() { a = 12345678 }; f();"); | 421 CompileRun("function f() { a = 12345678 }; f();"); |
421 CheckCodeForUnsafeLiteral(GetJSFunction(CcTest::env()->Global(), "f")); | 422 CheckCodeForUnsafeLiteral(GetJSFunction(CcTest::env()->Global(), "f")); |
422 CompileRun("function f(x) { a = 12345678 + x}; f(1);"); | 423 CompileRun("function f(x) { a = 12345678 + x}; f(1);"); |
423 CheckCodeForUnsafeLiteral(GetJSFunction(CcTest::env()->Global(), "f")); | 424 CheckCodeForUnsafeLiteral(GetJSFunction(CcTest::env()->Global(), "f")); |
424 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); | 425 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); |
425 CheckCodeForUnsafeLiteral(GetJSFunction(CcTest::env()->Global(), "f")); | 426 CheckCodeForUnsafeLiteral(GetJSFunction(CcTest::env()->Global(), "f")); |
426 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); | 427 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); |
427 CheckCodeForUnsafeLiteral(GetJSFunction(CcTest::env()->Global(), "f")); | 428 CheckCodeForUnsafeLiteral(GetJSFunction(CcTest::env()->Global(), "f")); |
428 } | 429 } |
429 #endif | 430 #endif |
OLD | NEW |