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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 CHECK(f->shared()->is_compiled()); | 359 CHECK(f->shared()->is_compiled()); |
360 CHECK(!f->shared()->feedback_vector()->is_empty()); | 360 CHECK(!f->shared()->feedback_vector()->is_empty()); |
361 } | 361 } |
362 | 362 |
363 | 363 |
364 // Test that optimized code for different closures is actually shared | 364 // Test that optimized code for different closures is actually shared |
365 // immediately by the FastNewClosureStub when run in the same context. | 365 // immediately by the FastNewClosureStub when run in the same context. |
366 TEST(OptimizedCodeSharing1) { | 366 TEST(OptimizedCodeSharing1) { |
367 FLAG_stress_compaction = false; | 367 FLAG_stress_compaction = false; |
368 FLAG_allow_natives_syntax = true; | 368 FLAG_allow_natives_syntax = true; |
369 FLAG_cache_optimized_code = true; | |
370 CcTest::InitializeVM(); | 369 CcTest::InitializeVM(); |
371 v8::HandleScope scope(CcTest::isolate()); | 370 v8::HandleScope scope(CcTest::isolate()); |
372 for (int i = 0; i < 3; i++) { | 371 for (int i = 0; i < 3; i++) { |
373 LocalContext env; | 372 LocalContext env; |
374 env->Global()->Set(v8::String::NewFromUtf8(CcTest::isolate(), "x"), | 373 env->Global()->Set(v8::String::NewFromUtf8(CcTest::isolate(), "x"), |
375 v8::Integer::New(CcTest::isolate(), i)); | 374 v8::Integer::New(CcTest::isolate(), i)); |
376 CompileRun( | 375 CompileRun( |
377 "function MakeClosure() {" | 376 "function MakeClosure() {" |
378 " return function() { return x; };" | 377 " return function() { return x; };" |
379 "}" | 378 "}" |
(...skipping 12 matching lines...) Expand all Loading... |
392 CHECK_EQ(fun1->code(), fun2->code()); | 391 CHECK_EQ(fun1->code(), fun2->code()); |
393 } | 392 } |
394 } | 393 } |
395 | 394 |
396 | 395 |
397 // Test that optimized code for different closures is actually shared | 396 // Test that optimized code for different closures is actually shared |
398 // immediately by the FastNewClosureStub when run different contexts. | 397 // immediately by the FastNewClosureStub when run different contexts. |
399 TEST(OptimizedCodeSharing2) { | 398 TEST(OptimizedCodeSharing2) { |
400 if (FLAG_stress_compaction) return; | 399 if (FLAG_stress_compaction) return; |
401 FLAG_allow_natives_syntax = true; | 400 FLAG_allow_natives_syntax = true; |
402 FLAG_cache_optimized_code = true; | |
403 FLAG_native_context_specialization = false; | 401 FLAG_native_context_specialization = false; |
404 FLAG_turbo_cache_shared_code = true; | 402 FLAG_turbo_cache_shared_code = true; |
405 const char* flag = "--turbo-filter=*"; | 403 const char* flag = "--turbo-filter=*"; |
406 FlagList::SetFlagsFromString(flag, StrLength(flag)); | 404 FlagList::SetFlagsFromString(flag, StrLength(flag)); |
407 CcTest::InitializeVM(); | 405 CcTest::InitializeVM(); |
408 v8::HandleScope scope(CcTest::isolate()); | 406 v8::HandleScope scope(CcTest::isolate()); |
409 v8::Local<v8::Script> script = v8_compile( | 407 v8::Local<v8::Script> script = v8_compile( |
410 "function MakeClosure() {" | 408 "function MakeClosure() {" |
411 " return function() { return x; };" | 409 " return function() { return x; };" |
412 "}"); | 410 "}"); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 CHECK_EQ(*reference_code, fun2->code()); | 446 CHECK_EQ(*reference_code, fun2->code()); |
449 } | 447 } |
450 } | 448 } |
451 | 449 |
452 | 450 |
453 // Test that optimized code for different closures is actually shared | 451 // Test that optimized code for different closures is actually shared |
454 // immediately by the FastNewClosureStub without context-dependent entries. | 452 // immediately by the FastNewClosureStub without context-dependent entries. |
455 TEST(OptimizedCodeSharing3) { | 453 TEST(OptimizedCodeSharing3) { |
456 if (FLAG_stress_compaction) return; | 454 if (FLAG_stress_compaction) return; |
457 FLAG_allow_natives_syntax = true; | 455 FLAG_allow_natives_syntax = true; |
458 FLAG_cache_optimized_code = true; | |
459 FLAG_native_context_specialization = false; | 456 FLAG_native_context_specialization = false; |
460 FLAG_turbo_cache_shared_code = true; | 457 FLAG_turbo_cache_shared_code = true; |
461 const char* flag = "--turbo-filter=*"; | 458 const char* flag = "--turbo-filter=*"; |
462 FlagList::SetFlagsFromString(flag, StrLength(flag)); | 459 FlagList::SetFlagsFromString(flag, StrLength(flag)); |
463 CcTest::InitializeVM(); | 460 CcTest::InitializeVM(); |
464 v8::HandleScope scope(CcTest::isolate()); | 461 v8::HandleScope scope(CcTest::isolate()); |
465 v8::Local<v8::Script> script = v8_compile( | 462 v8::Local<v8::Script> script = v8_compile( |
466 "function MakeClosure() {" | 463 "function MakeClosure() {" |
467 " return function() { return x; };" | 464 " return function() { return x; };" |
468 "}"); | 465 "}"); |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 CompileRun("function f() { a = 12345678 }; f();"); | 690 CompileRun("function f() { a = 12345678 }; f();"); |
694 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 691 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
695 CompileRun("function f(x) { a = 12345678 + x}; f(1);"); | 692 CompileRun("function f(x) { a = 12345678 + x}; f(1);"); |
696 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 693 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
697 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); | 694 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); |
698 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 695 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
699 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); | 696 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); |
700 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 697 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
701 } | 698 } |
702 #endif | 699 #endif |
OLD | NEW |