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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/interpreter/interpreter.cc ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2028 matching lines...) Expand 10 before | Expand all | Expand 10 after
2039 }; 2039 };
2040 2040
2041 for (size_t i = 0; i < arraysize(snippets); i++) { 2041 for (size_t i = 0; i < arraysize(snippets); i++) {
2042 Handle<BytecodeArray> bytecode_array = 2042 Handle<BytecodeArray> bytecode_array =
2043 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 2043 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
2044 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 2044 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
2045 } 2045 }
2046 } 2046 }
2047 2047
2048 2048
2049 TEST(RegExpLiterals) {
2050 InitializedHandleScope handle_scope;
2051 BytecodeGeneratorHelper helper;
2052 Zone zone;
2053
2054 FeedbackVectorSpec feedback_spec(&zone);
2055 feedback_spec.AddLoadICSlot();
2056 FeedbackVectorSlot slot2 = feedback_spec.AddLoadICSlot();
2057
2058 Handle<i::TypeFeedbackVector> vector =
2059 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec);
2060
2061 ExpectedSnippet<const char*> snippets[] = {
2062 {"return /ab+d/;",
2063 1 * kPointerSize,
2064 1,
2065 10,
2066 {
2067 B(LdaConstant), U8(0), //
2068 B(Star), R(0), //
2069 B(LdaConstant), U8(1), //
2070 B(CreateRegExpLiteral), U8(0), R(0), //
2071 B(Return), //
2072 },
2073 2,
2074 {"", "ab+d"}},
2075 {"return /(\\w+)\\s(\\w+)/i;",
2076 1 * kPointerSize,
2077 1,
2078 10,
2079 {
2080 B(LdaConstant), U8(0), //
2081 B(Star), R(0), //
2082 B(LdaConstant), U8(1), //
2083 B(CreateRegExpLiteral), U8(0), R(0), //
2084 B(Return), //
2085 },
2086 2,
2087 {"i", "(\\w+)\\s(\\w+)"}},
2088 {"return /ab+d/.exec('abdd');",
2089 3 * kPointerSize,
2090 1,
2091 27,
2092 {
2093 B(LdaConstant), U8(0), //
2094 B(Star), R(2), //
2095 B(LdaConstant), U8(1), //
2096 B(CreateRegExpLiteral), U8(0), R(2), //
2097 B(Star), R(1), //
2098 B(LdaConstant), U8(2), //
2099 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), //
2100 B(Star), R(0), //
2101 B(LdaConstant), U8(3), //
2102 B(Star), R(2), //
2103 B(Call), R(0), R(1), U8(1), //
2104 B(Return), //
2105 },
2106 4,
2107 {"", "ab+d", "exec", "abdd"}},
2108 };
2109
2110 for (size_t i = 0; i < arraysize(snippets); i++) {
2111 Handle<BytecodeArray> bytecode_array =
2112 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
2113 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
2114 }
2115 }
2116
2117
2049 TEST(ArrayLiterals) { 2118 TEST(ArrayLiterals) {
2050 InitializedHandleScope handle_scope; 2119 InitializedHandleScope handle_scope;
2051 BytecodeGeneratorHelper helper; 2120 BytecodeGeneratorHelper helper;
2052 Zone zone; 2121 Zone zone;
2053 2122
2054 FeedbackVectorSpec feedback_spec(&zone); 2123 FeedbackVectorSpec feedback_spec(&zone);
2055 FeedbackVectorSlot slot1 = feedback_spec.AddKeyedStoreICSlot(); 2124 FeedbackVectorSlot slot1 = feedback_spec.AddKeyedStoreICSlot();
2056 FeedbackVectorSlot slot2 = feedback_spec.AddKeyedStoreICSlot(); 2125 FeedbackVectorSlot slot2 = feedback_spec.AddKeyedStoreICSlot();
2057 FeedbackVectorSlot slot3 = feedback_spec.AddKeyedStoreICSlot(); 2126 FeedbackVectorSlot slot3 = feedback_spec.AddKeyedStoreICSlot();
2058 2127
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
2666 for (size_t i = 0; i < arraysize(snippets); i++) { 2735 for (size_t i = 0; i < arraysize(snippets); i++) {
2667 Handle<BytecodeArray> bytecode_array = 2736 Handle<BytecodeArray> bytecode_array =
2668 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 2737 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
2669 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 2738 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
2670 } 2739 }
2671 } 2740 }
2672 2741
2673 } // namespace interpreter 2742 } // namespace interpreter
2674 } // namespace internal 2743 } // namespace internal
2675 } // namespace v8 2744 } // namespace v8
OLDNEW
« 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