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

Unified Diff: test/cctest/interpreter/test-bytecode-generator.cc

Issue 1410853002: [Interpreter] Add support for RegExp literals. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/interpreter/interpreter.cc ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/interpreter/test-bytecode-generator.cc
diff --git a/test/cctest/interpreter/test-bytecode-generator.cc b/test/cctest/interpreter/test-bytecode-generator.cc
index 9dcfb5b01960a2dea91ef138c850da3b94d64f1e..cd6e776f15ad953051a5d15f8f030b7cc3335870 100644
--- a/test/cctest/interpreter/test-bytecode-generator.cc
+++ b/test/cctest/interpreter/test-bytecode-generator.cc
@@ -2046,6 +2046,75 @@ TEST(FunctionLiterals) {
}
+TEST(RegExpLiterals) {
+ InitializedHandleScope handle_scope;
+ BytecodeGeneratorHelper helper;
+ Zone zone;
+
+ FeedbackVectorSpec feedback_spec(&zone);
+ feedback_spec.AddLoadICSlot();
+ FeedbackVectorSlot slot2 = feedback_spec.AddLoadICSlot();
+
+ Handle<i::TypeFeedbackVector> vector =
+ i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec);
+
+ ExpectedSnippet<const char*> snippets[] = {
+ {"return /ab+d/;",
+ 1 * kPointerSize,
+ 1,
+ 10,
+ {
+ B(LdaConstant), U8(0), //
+ B(Star), R(0), //
+ B(LdaConstant), U8(1), //
+ B(CreateRegExpLiteral), U8(0), R(0), //
+ B(Return), //
+ },
+ 2,
+ {"", "ab+d"}},
+ {"return /(\\w+)\\s(\\w+)/i;",
+ 1 * kPointerSize,
+ 1,
+ 10,
+ {
+ B(LdaConstant), U8(0), //
+ B(Star), R(0), //
+ B(LdaConstant), U8(1), //
+ B(CreateRegExpLiteral), U8(0), R(0), //
+ B(Return), //
+ },
+ 2,
+ {"i", "(\\w+)\\s(\\w+)"}},
+ {"return /ab+d/.exec('abdd');",
+ 3 * kPointerSize,
+ 1,
+ 27,
+ {
+ B(LdaConstant), U8(0), //
+ B(Star), R(2), //
+ B(LdaConstant), U8(1), //
+ B(CreateRegExpLiteral), U8(0), R(2), //
+ B(Star), R(1), //
+ B(LdaConstant), U8(2), //
+ B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), //
+ B(Star), R(0), //
+ B(LdaConstant), U8(3), //
+ B(Star), R(2), //
+ B(Call), R(0), R(1), U8(1), //
+ B(Return), //
+ },
+ 4,
+ {"", "ab+d", "exec", "abdd"}},
+ };
+
+ for (size_t i = 0; i < arraysize(snippets); i++) {
+ Handle<BytecodeArray> bytecode_array =
+ helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
+ CheckBytecodeArrayEqual(snippets[i], bytecode_array);
+ }
+}
+
+
TEST(ArrayLiterals) {
InitializedHandleScope handle_scope;
BytecodeGeneratorHelper helper;
« no previous file with comments | « src/interpreter/interpreter.cc ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698