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

Side by Side Diff: test/cctest/interpreter/test-bytecode-generator.cc

Issue 1385623002: [Interpreter]: Add support for strict mode load / store ICs. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 #include "src/interpreter/bytecode-array-iterator.h" 8 #include "src/interpreter/bytecode-array-iterator.h"
9 #include "src/interpreter/bytecode-generator.h" 9 #include "src/interpreter/bytecode-generator.h"
10 #include "src/interpreter/interpreter.h" 10 #include "src/interpreter/interpreter.h"
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 B(LdaConstant), U8(0), // 478 B(LdaConstant), U8(0), //
479 B(LoadIC), R(1), U8(vector->GetIndex(slot1)), // 479 B(LoadIC), R(1), U8(vector->GetIndex(slot1)), //
480 B(Star), R(0), // 480 B(Star), R(0), //
481 B(Ldar), R(helper.kLastParamIndex), // 481 B(Ldar), R(helper.kLastParamIndex), //
482 B(Star), R(1), // 482 B(Star), R(1), //
483 B(LdaSmi8), U8(-124), // 483 B(LdaSmi8), U8(-124), //
484 B(KeyedLoadIC), R(1), U8(vector->GetIndex(slot2)), // 484 B(KeyedLoadIC), R(1), U8(vector->GetIndex(slot2)), //
485 B(Return) // 485 B(Return) //
486 }, 486 },
487 1, 487 1,
488 {"name"}}}; 488 {"name"}},
489 {"function f(a) { \"use strict\"; return a.name; }\nf({name : \"test\"})",
490 1 * kPointerSize,
491 2,
492 12,
493 {
494 // TODO(rmcilroy) Avoid unnecessary LdaConstant for "use strict"
495 // expression, or any other unused literal expression.
496 B(LdaConstant), U8(0), //
497 B(Ldar), R(helper.kLastParamIndex), //
498 B(Star), R(0), //
499 B(LdaConstant), U8(1), //
500 B(LoadICStrict), R(0), U8(vector->GetIndex(slot1)), //
501 B(Return) //
502 },
503 2,
504 {"use strict", "name"}},
505 {"function f(a, b) { \"use strict\"; return a[b]; }\n"
506 "f({arg : \"test\"}, \"arg\")",
507 1 * kPointerSize,
508 3,
509 12,
510 {
511 // TODO(rmcilroy) Avoid unnecessary LdaConstant for "use strict"
512 // expression, or any other unused literal expression.
513 B(LdaConstant), U8(0), //
514 B(Ldar), R(helper.kLastParamIndex - 1), //
515 B(Star), R(0), //
516 B(Ldar), R(helper.kLastParamIndex), //
517 B(KeyedLoadICStrict), R(0), U8(vector->GetIndex(slot1)), //
518 B(Return) //
519 },
520 1,
521 {"use strict"}}};
489 for (size_t i = 0; i < arraysize(snippets); i++) { 522 for (size_t i = 0; i < arraysize(snippets); i++) {
490 Handle<BytecodeArray> bytecode_array = 523 Handle<BytecodeArray> bytecode_array =
491 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); 524 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName);
492 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 525 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
493 } 526 }
494 } 527 }
495 528
496 529
497 TEST(PropertyStores) { 530 TEST(PropertyStores) {
498 InitializedHandleScope handle_scope; 531 InitializedHandleScope handle_scope;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 B(Star), R(1), // 616 B(Star), R(1), //
584 B(Ldar), R(helper.kLastParamIndex), // 617 B(Ldar), R(helper.kLastParamIndex), //
585 B(Star), R(2), // 618 B(Star), R(2), //
586 B(LdaSmi8), U8(-124), // 619 B(LdaSmi8), U8(-124), //
587 B(KeyedLoadIC), R(2), U8(vector->GetIndex(slot1)), // 620 B(KeyedLoadIC), R(2), U8(vector->GetIndex(slot1)), //
588 B(StoreIC), R(0), R(1), U8(vector->GetIndex(slot2)), // 621 B(StoreIC), R(0), R(1), U8(vector->GetIndex(slot2)), //
589 B(LdaUndefined), // 622 B(LdaUndefined), //
590 B(Return) // 623 B(Return) //
591 }, 624 },
592 1, 625 1,
593 {"name"}}}; 626 {"name"}},
627 {"function f(a) { \"use strict\"; a.name = \"val\"; }\n"
628 "f({name : \"test\"})",
629 2 * kPointerSize,
630 2,
631 18,
632 {
633 // TODO(rmcilroy) Avoid unnecessary LdaConstant for "use strict"
634 // expression, or any other unused literal expression.
635 B(LdaConstant), U8(0), //
636 B(Ldar), R(helper.kLastParamIndex), //
637 B(Star), R(0), //
638 B(LdaConstant), U8(1), //
639 B(Star), R(1), //
640 B(LdaConstant), U8(2), //
641 B(StoreICStrict), R(0), R(1), U8(vector->GetIndex(slot1)), //
642 B(LdaUndefined), //
643 B(Return) //
644 },
645 3,
646 {"use strict", "name", "val"}},
647 {"function f(a, b) { \"use strict\"; a[b] = \"val\"; }\n"
648 "f({arg : \"test\"}, \"arg\")",
649 2 * kPointerSize,
650 3,
651 18,
652 {
653 // TODO(rmcilroy) Avoid unnecessary LdaConstant for "use strict"
654 // expression, or any other unused literal expression.
655 B(LdaConstant), U8(0), //
656 B(Ldar), R(helper.kLastParamIndex - 1), //
657 B(Star), R(0), //
658 B(Ldar), R(helper.kLastParamIndex), //
659 B(Star), R(1), //
660 B(LdaConstant), U8(1), //
661 B(KeyedStoreICStrict), R(0), R(1), U8(vector->GetIndex(slot1)), //
662 B(LdaUndefined), //
663 B(Return) //
664 },
665 2,
666 {"use strict", "val"}}};
594 for (size_t i = 0; i < arraysize(snippets); i++) { 667 for (size_t i = 0; i < arraysize(snippets); i++) {
595 Handle<BytecodeArray> bytecode_array = 668 Handle<BytecodeArray> bytecode_array =
596 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); 669 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName);
597 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 670 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
598 } 671 }
599 } 672 }
600 673
601 674
602 #define FUNC_ARG "new (function Obj() { this.func = function() { return; }})()" 675 #define FUNC_ARG "new (function Obj() { this.func = function() { return; }})()"
603 676
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 for (size_t i = 0; i < arraysize(snippets); i++) { 1254 for (size_t i = 0; i < arraysize(snippets); i++) {
1182 Handle<BytecodeArray> bytecode_array = 1255 Handle<BytecodeArray> bytecode_array =
1183 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 1256 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
1184 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 1257 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
1185 } 1258 }
1186 } 1259 }
1187 1260
1188 } // namespace interpreter 1261 } // namespace interpreter
1189 } // namespace internal 1262 } // namespace internal
1190 } // namespace v8 1263 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698