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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 *v8::Handle<v8::Function>::Cast( | 303 *v8::Handle<v8::Function>::Cast( |
304 CcTest::global()->Get(v8_str("f")))); | 304 CcTest::global()->Get(v8_str("f")))); |
305 | 305 |
306 // We shouldn't have deoptimization support. We want to recompile and | 306 // We shouldn't have deoptimization support. We want to recompile and |
307 // verify that our feedback vector preserves information. | 307 // verify that our feedback vector preserves information. |
308 CHECK(!f->shared()->has_deoptimization_support()); | 308 CHECK(!f->shared()->has_deoptimization_support()); |
309 Handle<TypeFeedbackVector> feedback_vector(f->shared()->feedback_vector()); | 309 Handle<TypeFeedbackVector> feedback_vector(f->shared()->feedback_vector()); |
310 | 310 |
311 // Verify that we gathered feedback. | 311 // Verify that we gathered feedback. |
312 int expected_slots = 0; | 312 int expected_slots = 0; |
313 int expected_ic_slots = 2; | 313 int expected_ic_slots = 1; |
314 CHECK_EQ(expected_slots, feedback_vector->Slots()); | 314 CHECK_EQ(expected_slots, feedback_vector->Slots()); |
315 CHECK_EQ(expected_ic_slots, feedback_vector->ICSlots()); | 315 CHECK_EQ(expected_ic_slots, feedback_vector->ICSlots()); |
316 FeedbackVectorICSlot slot_for_a(1); | 316 FeedbackVectorICSlot slot_for_a(0); |
317 Object* object = feedback_vector->Get(slot_for_a); | 317 Object* object = feedback_vector->Get(slot_for_a); |
318 CHECK(object->IsWeakCell() && | 318 CHECK(object->IsWeakCell() && |
319 WeakCell::cast(object)->value()->IsJSFunction()); | 319 WeakCell::cast(object)->value()->IsJSFunction()); |
320 | 320 |
321 CompileRun("%OptimizeFunctionOnNextCall(f); f(fun1);"); | 321 CompileRun("%OptimizeFunctionOnNextCall(f); f(fun1);"); |
322 | 322 |
323 // Verify that the feedback is still "gathered" despite a recompilation | 323 // Verify that the feedback is still "gathered" despite a recompilation |
324 // of the full code. | 324 // of the full code. |
325 CHECK(f->IsOptimized()); | 325 CHECK(f->IsOptimized()); |
326 CHECK(f->shared()->has_deoptimization_support()); | 326 CHECK(f->shared()->has_deoptimization_support()); |
(...skipping 28 matching lines...) Expand all Loading... |
355 // Not compiled, and so no feedback vector allocated yet. | 355 // Not compiled, and so no feedback vector allocated yet. |
356 CHECK(!f->shared()->is_compiled()); | 356 CHECK(!f->shared()->is_compiled()); |
357 CHECK_EQ(0, f->shared()->feedback_vector()->Slots()); | 357 CHECK_EQ(0, f->shared()->feedback_vector()->Slots()); |
358 CHECK_EQ(0, f->shared()->feedback_vector()->ICSlots()); | 358 CHECK_EQ(0, f->shared()->feedback_vector()->ICSlots()); |
359 | 359 |
360 CompileRun("morphing_call();"); | 360 CompileRun("morphing_call();"); |
361 | 361 |
362 // Now a feedback vector is allocated. | 362 // Now a feedback vector is allocated. |
363 CHECK(f->shared()->is_compiled()); | 363 CHECK(f->shared()->is_compiled()); |
364 int expected_slots = 0; | 364 int expected_slots = 0; |
365 int expected_ic_slots = 3; | 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 | 374 // Skip test if --cache-optimized-code is not activated by default because |
375 // FastNewClosureStub that is baked into the snapshot is incorrect. | 375 // FastNewClosureStub that is baked into the snapshot is incorrect. |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 CompileRun("function f() { a = 12345678 }; f();"); | 560 CompileRun("function f() { a = 12345678 }; f();"); |
561 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 561 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
562 CompileRun("function f(x) { a = 12345678 + x}; f(1);"); | 562 CompileRun("function f(x) { a = 12345678 + x}; f(1);"); |
563 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 563 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
564 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); | 564 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); |
565 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 565 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
566 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); | 566 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); |
567 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 567 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
568 } | 568 } |
569 #endif | 569 #endif |
OLD | NEW |