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

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

Issue 1319833004: [Interpreter] Add support for property store operations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int_implicit_ret
Patch Set: Add DCHECK 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 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 c62e5efff9f2a93756f4022d64469b85d4f1f252..1faaa707af2173bbc873e9c8f55ae039a1027965 100644
--- a/test/cctest/interpreter/test-bytecode-generator.cc
+++ b/test/cctest/interpreter/test-bytecode-generator.cc
@@ -21,6 +21,7 @@ class BytecodeGeneratorHelper {
-InterpreterFrameConstants::kLastParamFromRegisterPointer / kPointerSize;
BytecodeGeneratorHelper() {
+ i::FLAG_vector_stores = true;
i::FLAG_ignition = true;
i::FLAG_ignition_filter = kFunctionName;
CcTest::i_isolate()->interpreter()->Initialize();
@@ -79,6 +80,7 @@ TEST(PrimitiveReturnStatements) {
BytecodeGeneratorHelper helper;
ExpectedSnippet<void*> snippets[] = {
+ {"", 0, 1, 2, {B(LdaUndefined), B(Return)}, 0},
{"return;", 0, 1, 2, {B(LdaUndefined), B(Return)}, 0},
{"return null;", 0, 1, 2, {B(LdaNull), B(Return)}, 0},
{"return true;", 0, 1, 2, {B(LdaTrue), B(Return)}, 0},
@@ -418,6 +420,110 @@ TEST(PropertyLoads) {
}
}
+
+TEST(PropertyStores) {
+ InitializedHandleScope handle_scope;
+ BytecodeGeneratorHelper helper;
+
+ Code::Kind ic_kinds[] = { i::Code::STORE_IC, i::Code::STORE_IC };
+ FeedbackVectorSpec feedback_spec(0, 1, ic_kinds);
+ Handle<i::TypeFeedbackVector> vector =
+ helper.factory()->NewTypeFeedbackVector(&feedback_spec);
+
+ ExpectedSnippet<const char*> snippets[] = {
+ {"function f(a) { a.name = \"val\"; }\nf({name : \"test\"})",
+ 2 * kPointerSize, 2, 16,
+ {
+ B(Ldar), R(helper.kLastParamIndex),
+ B(Star), R(0),
+ B(LdaConstant), U8(0),
+ B(Star), R(1),
+ B(LdaConstant), U8(1),
+ B(StoreIC), R(0), R(1), U8(vector->first_ic_slot_index()),
+ B(LdaUndefined),
+ B(Return)
+ },
+ 2, { "name", "val" }
+ },
+ {"function f(a) { a[\"key\"] = \"val\"; }\nf({key : \"test\"})",
+ 2 * kPointerSize, 2, 16,
+ {
+ B(Ldar), R(helper.kLastParamIndex),
+ B(Star), R(0),
+ B(LdaConstant), U8(0),
+ B(Star), R(1),
+ B(LdaConstant), U8(1),
+ B(StoreIC), R(0), R(1), U8(vector->first_ic_slot_index()),
+ B(LdaUndefined),
+ B(Return)
+ },
+ 2, { "key", "val" }
+ },
+ {"function f(a) { a[100] = \"val\"; }\nf({100 : \"test\"})",
+ 2 * kPointerSize, 2, 16,
+ {
+ B(Ldar), R(helper.kLastParamIndex),
+ B(Star), R(0),
+ B(LdaSmi8), U8(100),
+ B(Star), R(1),
+ B(LdaConstant), U8(0),
+ B(KeyedStoreIC), R(0), R(1), U8(vector->first_ic_slot_index()),
+ B(LdaUndefined),
+ B(Return)
+ },
+ 1, { "val" }
+ },
+ {"function f(a, b) { a[b] = \"val\"; }\nf({arg : \"test\"}, \"arg\")",
+ 2 * kPointerSize, 3, 16,
+ {
+ B(Ldar), R(helper.kLastParamIndex - 1),
+ B(Star), R(0),
+ B(Ldar), R(helper.kLastParamIndex),
+ B(Star), R(1),
+ B(LdaConstant), U8(0),
+ B(KeyedStoreIC), R(0), R(1), U8(vector->first_ic_slot_index()),
+ B(LdaUndefined),
+ B(Return)
+ },
+ 1, { "val" }
+ },
+ {"function f(a) { a.name = a[-124]; }\n"
+ "f({\"-124\" : \"test\", name : 123 })",
+ 3 * kPointerSize, 2, 23,
+ {
+ B(Ldar), R(helper.kLastParamIndex),
+ B(Star), R(0),
+ B(LdaConstant), U8(0),
+ B(Star), R(1),
+ B(Ldar), R(helper.kLastParamIndex),
+ B(Star), R(2),
+ B(LdaSmi8), U8(-124),
+ B(KeyedLoadIC), R(2), U8(vector->first_ic_slot_index()),
+ B(StoreIC), R(0), R(1), U8(vector->first_ic_slot_index() + 2),
+ B(LdaUndefined),
+ B(Return)
+ },
+ 1, { "name" }
+ }
+ };
+ size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]);
+ for (size_t i = 0; i < num_snippets; i++) {
+ Handle<BytecodeArray> ba =
+ helper.MakeBytecode(snippets[i].code_snippet, "f");
+ CHECK_EQ(ba->frame_size(), snippets[i].frame_size);
+ CHECK_EQ(ba->parameter_count(), snippets[i].parameter_count);
+ CHECK_EQ(ba->length(), snippets[i].bytecode_length);
+ CHECK(!memcmp(ba->GetFirstBytecodeAddress(), snippets[i].bytecode,
+ ba->length()));
+ CHECK_EQ(ba->constant_pool()->length(), snippets[i].constant_count);
+ for (int j = 0; j < snippets[i].constant_count; j++) {
+ Handle<String> expected =
+ helper.factory()->NewStringFromAsciiChecked(snippets[i].constants[j]);
+ CHECK(String::cast(ba->constant_pool()->get(j))->Equals(*expected));
+ }
+ }
+}
+
} // namespace interpreter
} // namespace internal
} // namespance v8
« 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