OLD | NEW |
---|---|
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 #include "test/cctest/cctest.h" | 6 #include "test/cctest/cctest.h" |
7 | 7 |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
10 #include "src/execution.h" | 10 #include "src/execution.h" |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
409 " return y;" | 409 " return y;" |
410 "}" | 410 "}" |
411 "a = 3;" | 411 "a = 3;" |
412 "testvar({});"); | 412 "testvar({});"); |
413 | 413 |
414 Handle<JSFunction> f = GetFunction("testvar"); | 414 Handle<JSFunction> f = GetFunction("testvar"); |
415 | 415 |
416 // There should be two LOAD_ICs, one for a and one for y at the end. | 416 // There should be two LOAD_ICs, one for a and one for y at the end. |
417 Handle<TypeFeedbackVector> feedback_vector = | 417 Handle<TypeFeedbackVector> feedback_vector = |
418 handle(f->shared()->feedback_vector(), isolate); | 418 handle(f->shared()->feedback_vector(), isolate); |
419 CHECK_EQ(2, feedback_vector->ICSlots()); | 419 CHECK_EQ(FLAG_vector_stores ? 4 : 2, feedback_vector->ICSlots()); |
Jakob Kummerow
2015/09/03 11:27:40
suggestion:
if (FLAG_vector_stores) {
CHECK_EQ(
mvstanton
2015/09/03 15:25:27
I like it, done.
| |
420 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(0)) == Code::LOAD_IC); | 420 int index = FLAG_vector_stores ? 1 : 0; |
421 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(1)) == Code::LOAD_IC); | 421 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(index)) == Code::LOAD_IC); |
422 index = FLAG_vector_stores ? 3 : 1; | |
423 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(index)) == Code::LOAD_IC); | |
422 | 424 |
423 CompileRun( | 425 CompileRun( |
424 "function testprop(x) {" | 426 "function testprop(x) {" |
425 " x.blue = a;" | 427 " x.blue = a;" |
426 "}" | 428 "}" |
427 "testprop({ blue: 3 });"); | 429 "testprop({ blue: 3 });"); |
428 | 430 |
429 f = GetFunction("testprop"); | 431 f = GetFunction("testprop"); |
430 | 432 |
431 // There should be one LOAD_IC, for the load of a. | 433 // There should be one LOAD_IC, for the load of a. |
432 feedback_vector = handle(f->shared()->feedback_vector(), isolate); | 434 feedback_vector = handle(f->shared()->feedback_vector(), isolate); |
433 CHECK_EQ(1, feedback_vector->ICSlots()); | 435 CHECK_EQ(FLAG_vector_stores ? 2 : 1, feedback_vector->ICSlots()); |
434 | 436 |
435 CompileRun( | 437 CompileRun( |
436 "function testpropfunc(x) {" | 438 "function testpropfunc(x) {" |
437 " x().blue = a;" | 439 " x().blue = a;" |
438 " return x().blue;" | 440 " return x().blue;" |
439 "}" | 441 "}" |
440 "function makeresult() { return { blue: 3 }; }" | 442 "function makeresult() { return { blue: 3 }; }" |
441 "testpropfunc(makeresult);"); | 443 "testpropfunc(makeresult);"); |
442 | 444 |
443 f = GetFunction("testpropfunc"); | 445 f = GetFunction("testpropfunc"); |
444 | 446 |
445 // There should be 2 LOAD_ICs and 2 CALL_ICs. | 447 // There should be 2 LOAD_ICs and 2 CALL_ICs. |
446 feedback_vector = handle(f->shared()->feedback_vector(), isolate); | 448 feedback_vector = handle(f->shared()->feedback_vector(), isolate); |
447 CHECK_EQ(4, feedback_vector->ICSlots()); | 449 CHECK_EQ(FLAG_vector_stores ? 5 : 4, feedback_vector->ICSlots()); |
448 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(0)) == Code::CALL_IC); | 450 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(0)) == Code::CALL_IC); |
449 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(1)) == Code::LOAD_IC); | 451 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(1)) == Code::LOAD_IC); |
450 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(2)) == Code::CALL_IC); | 452 CHECK(feedback_vector->GetKind( |
451 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(3)) == Code::LOAD_IC); | 453 FeedbackVectorICSlot(FLAG_vector_stores ? 3 : 2)) == Code::CALL_IC); |
Jakob Kummerow
2015/09/03 11:27:40
suggestion:
int slot = 0;
CHECK(...(FeedbackVecto
mvstanton
2015/09/03 15:25:27
Allow me to follow up on this suggestion in a foll
| |
454 CHECK(feedback_vector->GetKind( | |
455 FeedbackVectorICSlot(FLAG_vector_stores ? 4 : 3)) == Code::LOAD_IC); | |
452 | 456 |
453 CompileRun( | 457 CompileRun( |
454 "function testkeyedprop(x) {" | 458 "function testkeyedprop(x) {" |
455 " x[0] = a;" | 459 " x[0] = a;" |
456 " return x[0];" | 460 " return x[0];" |
457 "}" | 461 "}" |
458 "testkeyedprop([0, 1, 2]);"); | 462 "testkeyedprop([0, 1, 2]);"); |
459 | 463 |
460 f = GetFunction("testkeyedprop"); | 464 f = GetFunction("testkeyedprop"); |
461 | 465 |
462 // There should be 1 LOAD_ICs for the load of a, and one KEYED_LOAD_IC for the | 466 // There should be 1 LOAD_ICs for the load of a, and one KEYED_LOAD_IC for the |
463 // load of x[0] in the return statement. | 467 // load of x[0] in the return statement. |
464 feedback_vector = handle(f->shared()->feedback_vector(), isolate); | 468 feedback_vector = handle(f->shared()->feedback_vector(), isolate); |
465 CHECK_EQ(2, feedback_vector->ICSlots()); | 469 CHECK_EQ(FLAG_vector_stores ? 3 : 2, feedback_vector->ICSlots()); |
466 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(0)) == Code::LOAD_IC); | 470 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(0)) == Code::LOAD_IC); |
467 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(1)) == | 471 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot( |
468 Code::KEYED_LOAD_IC); | 472 FLAG_vector_stores ? 2 : 1)) == Code::KEYED_LOAD_IC); |
469 | 473 |
470 CompileRun( | 474 CompileRun( |
471 "function testcompound(x) {" | 475 "function testcompound(x) {" |
472 " x.old = x.young = x.in_between = a;" | 476 " x.old = x.young = x.in_between = a;" |
473 " return x.old + x.young;" | 477 " return x.old + x.young;" |
474 "}" | 478 "}" |
475 "testcompound({ old: 3, young: 3, in_between: 3 });"); | 479 "testcompound({ old: 3, young: 3, in_between: 3 });"); |
476 | 480 |
477 f = GetFunction("testcompound"); | 481 f = GetFunction("testcompound"); |
478 | 482 |
479 // There should be 3 LOAD_ICs, for load of a and load of x.old and x.young. | 483 // There should be 3 LOAD_ICs, for load of a and load of x.old and x.young. |
480 feedback_vector = handle(f->shared()->feedback_vector(), isolate); | 484 feedback_vector = handle(f->shared()->feedback_vector(), isolate); |
481 CHECK_EQ(3, feedback_vector->ICSlots()); | 485 CHECK_EQ(FLAG_vector_stores ? 6 : 3, feedback_vector->ICSlots()); |
482 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(0)) == Code::LOAD_IC); | 486 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(0)) == Code::LOAD_IC); |
483 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(1)) == Code::LOAD_IC); | 487 CHECK(feedback_vector->GetKind( |
484 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(2)) == Code::LOAD_IC); | 488 FeedbackVectorICSlot(FLAG_vector_stores ? 4 : 1)) == Code::LOAD_IC); |
489 CHECK(feedback_vector->GetKind( | |
490 FeedbackVectorICSlot(FLAG_vector_stores ? 5 : 2)) == Code::LOAD_IC); | |
491 } | |
492 | |
493 | |
494 TEST(VectorStoreICBasic) { | |
495 if (i::FLAG_always_opt) return; | |
496 if (!i::FLAG_vector_stores) return; | |
497 | |
498 CcTest::InitializeVM(); | |
499 LocalContext context; | |
500 v8::HandleScope scope(context->GetIsolate()); | |
501 Isolate* isolate = CcTest::i_isolate(); | |
502 | |
503 // Function f has 3 LoadICs, one for each o, but the ICs share the same | |
Jakob Kummerow
2015/09/03 11:27:40
lolwut?
mvstanton
2015/09/03 15:25:27
Cosmically weird comment removed :).
| |
504 // feedback vector IC slot. | |
505 CompileRun( | |
506 "function f(a) {" | |
507 " a.foo = 5;" | |
508 "}" | |
509 "var a = { foo: 3 };" | |
510 "f(a);" | |
511 "f(a);" | |
512 "f(a);"); | |
513 Handle<JSFunction> f = GetFunction("f"); | |
514 // There should be one IC slot. | |
515 Handle<TypeFeedbackVector> feedback_vector = | |
516 Handle<TypeFeedbackVector>(f->shared()->feedback_vector(), isolate); | |
517 CHECK_EQ(1, feedback_vector->ICSlots()); | |
518 FeedbackVectorICSlot slot(0); | |
519 StoreICNexus nexus(feedback_vector, slot); | |
520 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); | |
485 } | 521 } |
486 } | 522 } |
OLD | NEW |