Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(294)

Side by Side Diff: test/cctest/test-feedback-vector.cc

Issue 1328603003: Vector ICs: platform support for vector-based stores. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: mips build fixes. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/x64/code-stubs-x64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 if (FLAG_vector_stores) {
420 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(0)) == Code::LOAD_IC); 420 CHECK_EQ(4, feedback_vector->ICSlots());
421 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(1)) == Code::LOAD_IC); 421 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(0)) == Code::STORE_IC);
422 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(1)) == Code::LOAD_IC);
423 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(2)) == Code::STORE_IC);
424 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(3)) == Code::LOAD_IC);
425 } else {
426 CHECK_EQ(2, feedback_vector->ICSlots());
427 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(0)) == Code::LOAD_IC);
428 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(1)) == Code::LOAD_IC);
429 }
422 430
423 CompileRun( 431 CompileRun(
424 "function testprop(x) {" 432 "function testprop(x) {"
425 " x.blue = a;" 433 " x.blue = a;"
426 "}" 434 "}"
427 "testprop({ blue: 3 });"); 435 "testprop({ blue: 3 });");
428 436
429 f = GetFunction("testprop"); 437 f = GetFunction("testprop");
430 438
431 // There should be one LOAD_IC, for the load of a. 439 // There should be one LOAD_IC, for the load of a.
432 feedback_vector = handle(f->shared()->feedback_vector(), isolate); 440 feedback_vector = handle(f->shared()->feedback_vector(), isolate);
433 CHECK_EQ(1, feedback_vector->ICSlots()); 441 if (FLAG_vector_stores) {
442 CHECK_EQ(2, feedback_vector->ICSlots());
443 } else {
444 CHECK_EQ(1, feedback_vector->ICSlots());
445 }
434 446
435 CompileRun( 447 CompileRun(
436 "function testpropfunc(x) {" 448 "function testpropfunc(x) {"
437 " x().blue = a;" 449 " x().blue = a;"
438 " return x().blue;" 450 " return x().blue;"
439 "}" 451 "}"
440 "function makeresult() { return { blue: 3 }; }" 452 "function makeresult() { return { blue: 3 }; }"
441 "testpropfunc(makeresult);"); 453 "testpropfunc(makeresult);");
442 454
443 f = GetFunction("testpropfunc"); 455 f = GetFunction("testpropfunc");
444 456
445 // There should be 2 LOAD_ICs and 2 CALL_ICs. 457 // There should be 2 LOAD_ICs and 2 CALL_ICs.
446 feedback_vector = handle(f->shared()->feedback_vector(), isolate); 458 feedback_vector = handle(f->shared()->feedback_vector(), isolate);
447 CHECK_EQ(4, feedback_vector->ICSlots()); 459 if (FLAG_vector_stores) {
448 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(0)) == Code::CALL_IC); 460 CHECK_EQ(5, feedback_vector->ICSlots());
449 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(1)) == Code::LOAD_IC); 461 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(0)) == Code::CALL_IC);
450 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(2)) == Code::CALL_IC); 462 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(1)) == Code::LOAD_IC);
451 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(3)) == Code::LOAD_IC); 463 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(2)) == Code::STORE_IC);
464 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(3)) == Code::CALL_IC);
465 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(4)) == Code::LOAD_IC);
466 } else {
467 CHECK_EQ(4, feedback_vector->ICSlots());
468 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(0)) == Code::CALL_IC);
469 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(1)) == Code::LOAD_IC);
470 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(2)) == Code::CALL_IC);
471 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(3)) == Code::LOAD_IC);
472 }
452 473
453 CompileRun( 474 CompileRun(
454 "function testkeyedprop(x) {" 475 "function testkeyedprop(x) {"
455 " x[0] = a;" 476 " x[0] = a;"
456 " return x[0];" 477 " return x[0];"
457 "}" 478 "}"
458 "testkeyedprop([0, 1, 2]);"); 479 "testkeyedprop([0, 1, 2]);");
459 480
460 f = GetFunction("testkeyedprop"); 481 f = GetFunction("testkeyedprop");
461 482
462 // There should be 1 LOAD_ICs for the load of a, and one KEYED_LOAD_IC for the 483 // 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. 484 // load of x[0] in the return statement.
464 feedback_vector = handle(f->shared()->feedback_vector(), isolate); 485 feedback_vector = handle(f->shared()->feedback_vector(), isolate);
465 CHECK_EQ(2, feedback_vector->ICSlots()); 486 if (FLAG_vector_stores) {
466 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(0)) == Code::LOAD_IC); 487 CHECK_EQ(3, feedback_vector->ICSlots());
467 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(1)) == 488 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(0)) == Code::LOAD_IC);
468 Code::KEYED_LOAD_IC); 489 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(1)) ==
490 Code::KEYED_STORE_IC);
491 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(2)) ==
492 Code::KEYED_LOAD_IC);
493 } else {
494 CHECK_EQ(2, feedback_vector->ICSlots());
495 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(0)) == Code::LOAD_IC);
496 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(1)) ==
497 Code::KEYED_LOAD_IC);
498 }
469 499
470 CompileRun( 500 CompileRun(
471 "function testcompound(x) {" 501 "function testcompound(x) {"
472 " x.old = x.young = x.in_between = a;" 502 " x.old = x.young = x.in_between = a;"
473 " return x.old + x.young;" 503 " return x.old + x.young;"
474 "}" 504 "}"
475 "testcompound({ old: 3, young: 3, in_between: 3 });"); 505 "testcompound({ old: 3, young: 3, in_between: 3 });");
476 506
477 f = GetFunction("testcompound"); 507 f = GetFunction("testcompound");
478 508
479 // There should be 3 LOAD_ICs, for load of a and load of x.old and x.young. 509 // 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); 510 feedback_vector = handle(f->shared()->feedback_vector(), isolate);
481 CHECK_EQ(3, feedback_vector->ICSlots()); 511 if (FLAG_vector_stores) {
482 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(0)) == Code::LOAD_IC); 512 CHECK_EQ(6, feedback_vector->ICSlots());
483 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(1)) == Code::LOAD_IC); 513 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(0)) == Code::LOAD_IC);
484 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(2)) == Code::LOAD_IC); 514 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(1)) == Code::STORE_IC);
515 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(2)) == Code::STORE_IC);
516 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(3)) == Code::STORE_IC);
517 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(4)) == Code::LOAD_IC);
518 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(5)) == Code::LOAD_IC);
519 } else {
520 CHECK_EQ(3, feedback_vector->ICSlots());
521 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(0)) == Code::LOAD_IC);
522 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(1)) == Code::LOAD_IC);
523 CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(2)) == Code::LOAD_IC);
524 }
525 }
526
527
528 TEST(VectorStoreICBasic) {
529 if (i::FLAG_always_opt) return;
530 if (!i::FLAG_vector_stores) return;
531
532 CcTest::InitializeVM();
533 LocalContext context;
534 v8::HandleScope scope(context->GetIsolate());
535 Isolate* isolate = CcTest::i_isolate();
536
537 CompileRun(
538 "function f(a) {"
539 " a.foo = 5;"
540 "}"
541 "var a = { foo: 3 };"
542 "f(a);"
543 "f(a);"
544 "f(a);");
545 Handle<JSFunction> f = GetFunction("f");
546 // There should be one IC slot.
547 Handle<TypeFeedbackVector> feedback_vector =
548 Handle<TypeFeedbackVector>(f->shared()->feedback_vector(), isolate);
549 CHECK_EQ(1, feedback_vector->ICSlots());
550 FeedbackVectorICSlot slot(0);
551 StoreICNexus nexus(feedback_vector, slot);
552 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback());
485 } 553 }
486 } 554 }
OLDNEW
« no previous file with comments | « src/x64/code-stubs-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698