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

Unified Diff: test/unittests/compiler/bytecode-graph-builder-unittest.cc

Issue 1448913002: [Interpreter] Add support for keyed load / store ICs and named store IC to (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@graph_builder_load
Patch Set: Made the binding of return value of the store explicit. Created 5 years, 1 month 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 | « test/cctest/compiler/test-run-bytecode-graph-builder.cc ('k') | test/unittests/compiler/node-test-utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/compiler/bytecode-graph-builder-unittest.cc
diff --git a/test/unittests/compiler/bytecode-graph-builder-unittest.cc b/test/unittests/compiler/bytecode-graph-builder-unittest.cc
index 5263ec941c99ea34844fb905544800917450e3d6..62b511fe8a0563dfbe16d1359f918a913dac7da5 100644
--- a/test/unittests/compiler/bytecode-graph-builder-unittest.cc
+++ b/test/unittests/compiler/bytecode-graph-builder-unittest.cc
@@ -365,9 +365,9 @@ TEST_F(BytecodeGraphBuilderTest, CallProperty0) {
size_t func_name_index = array_builder.GetConstantPoolEntry(func_name);
interpreter::Register reg0 = interpreter::Register(0);
- array_builder.LoadNamedProperty(
- array_builder.Parameter(1), func_name_index,
- vector->GetIndex(load_slot), LanguageMode::SLOPPY)
+ array_builder.LoadNamedProperty(array_builder.Parameter(1), func_name_index,
+ vector->GetIndex(load_slot),
+ LanguageMode::SLOPPY)
.StoreAccumulatorInRegister(reg0)
.Call(reg0, array_builder.Parameter(1), 0, vector->GetIndex(call_slot))
.Return();
@@ -408,9 +408,9 @@ TEST_F(BytecodeGraphBuilderTest, CallProperty2) {
interpreter::Register reg1 = interpreter::Register(1);
interpreter::Register reg2 = interpreter::Register(2);
interpreter::Register reg3 = interpreter::Register(3);
- array_builder.LoadNamedProperty(
- array_builder.Parameter(1), func_name_index,
- vector->GetIndex(load_slot), LanguageMode::SLOPPY)
+ array_builder.LoadNamedProperty(array_builder.Parameter(1), func_name_index,
+ vector->GetIndex(load_slot),
+ LanguageMode::SLOPPY)
.StoreAccumulatorInRegister(reg0)
.LoadAccumulatorWithRegister(array_builder.Parameter(1))
.StoreAccumulatorInRegister(reg1)
@@ -591,6 +591,136 @@ TEST_F(BytecodeGraphBuilderTest, Delete) {
}
}
+
+TEST_F(BytecodeGraphBuilderTest, KeyedLoad) {
+ const int kValue = 100;
+ const bool kWideBytecode[] = {false, true};
+ TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) {
+ TRACED_FOREACH(bool, wide_bytecode, kWideBytecode) {
+ FeedbackVectorSpec feedback_spec(zone());
+ if (wide_bytecode) {
+ for (int i = 0; i < 128; i++) {
+ feedback_spec.AddLoadICSlot();
+ }
+ }
+ FeedbackVectorSlot slot = feedback_spec.AddLoadICSlot();
+ Handle<TypeFeedbackVector> vector =
+ NewTypeFeedbackVector(isolate(), &feedback_spec);
+
+ interpreter::BytecodeArrayBuilder array_builder(isolate(), zone());
+ array_builder.set_locals_count(1);
+ array_builder.set_context_count(0);
+ array_builder.set_parameter_count(2);
+
+ array_builder.LoadLiteral(Smi::FromInt(kValue))
+ .LoadKeyedProperty(array_builder.Parameter(1), vector->GetIndex(slot),
+ language_mode)
+ .Return();
+ Graph* graph = GetCompletedGraph(array_builder.ToBytecodeArray(), vector,
+ language_mode);
+
+ Node* ret = graph->end()->InputAt(0);
+ Node* start = graph->start();
+
+ Matcher<Node*> feedback_vector_matcher = IsFeedbackVector(start, start);
+ Matcher<Node*> load_keyed_matcher =
+ IsJSLoadProperty(IsParameter(1), IsNumberConstant(kValue),
+ feedback_vector_matcher, start, start);
+
+ EXPECT_THAT(ret, IsReturn(load_keyed_matcher, _, _));
+ }
+ }
+}
+
+
+TEST_F(BytecodeGraphBuilderTest, NamedStore) {
+ const int kValue = 100;
+ const bool kWideBytecode[] = {false, true};
+ TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) {
+ TRACED_FOREACH(bool, wide_bytecode, kWideBytecode) {
+ FeedbackVectorSpec feedback_spec(zone());
+ if (wide_bytecode) {
+ for (int i = 0; i < 128; i++) {
+ feedback_spec.AddLoadICSlot();
+ }
+ }
+ FeedbackVectorSlot slot = feedback_spec.AddLoadICSlot();
+ Handle<TypeFeedbackVector> vector =
+ NewTypeFeedbackVector(isolate(), &feedback_spec);
+
+ interpreter::BytecodeArrayBuilder array_builder(isolate(), zone());
+ array_builder.set_locals_count(1);
+ array_builder.set_context_count(0);
+ array_builder.set_parameter_count(2);
+
+ Handle<Name> name = GetName(isolate(), "val");
+ size_t name_index = array_builder.GetConstantPoolEntry(name);
+
+ array_builder.LoadLiteral(Smi::FromInt(kValue))
+ .StoreNamedProperty(array_builder.Parameter(1), name_index,
+ vector->GetIndex(slot), language_mode)
+ .Return();
+ Graph* graph = GetCompletedGraph(array_builder.ToBytecodeArray(), vector,
+ language_mode);
+
+ Node* ret = graph->end()->InputAt(0);
+ Node* start = graph->start();
+
+ Matcher<Node*> feedback_vector_matcher = IsFeedbackVector(start, start);
+ Matcher<Node*> store_named_matcher =
+ IsJSStoreNamed(name, IsParameter(1), IsNumberConstant(kValue),
+ feedback_vector_matcher, start, start);
+
+ EXPECT_THAT(ret, IsReturn(_, store_named_matcher, _));
+ }
+ }
+}
+
+
+TEST_F(BytecodeGraphBuilderTest, KeyedStore) {
+ const int kValue = 100;
+ const int kKey = 10;
+ const bool kWideBytecode[] = {false, true};
+ TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) {
+ TRACED_FOREACH(bool, wide_bytecode, kWideBytecode) {
+ FeedbackVectorSpec feedback_spec(zone());
+ if (wide_bytecode) {
+ for (int i = 0; i < 128; i++) {
+ feedback_spec.AddStoreICSlot();
+ }
+ }
+ FeedbackVectorSlot slot = feedback_spec.AddStoreICSlot();
+ Handle<TypeFeedbackVector> vector =
+ NewTypeFeedbackVector(isolate(), &feedback_spec);
+
+ interpreter::BytecodeArrayBuilder array_builder(isolate(), zone());
+ array_builder.set_locals_count(1);
+ array_builder.set_context_count(0);
+ array_builder.set_parameter_count(2);
+
+ array_builder.LoadLiteral(Smi::FromInt(kKey))
+ .StoreAccumulatorInRegister(interpreter::Register(0))
+ .LoadLiteral(Smi::FromInt(kValue))
+ .StoreKeyedProperty(array_builder.Parameter(1),
+ interpreter::Register(0), vector->GetIndex(slot),
+ language_mode)
+ .Return();
+ Graph* graph = GetCompletedGraph(array_builder.ToBytecodeArray(), vector,
+ language_mode);
+
+ Node* ret = graph->end()->InputAt(0);
+ Node* start = graph->start();
+
+ Matcher<Node*> feedback_vector_matcher = IsFeedbackVector(start, start);
+ Matcher<Node*> store_keyed_matcher = IsJSStoreProperty(
+ IsParameter(1), IsNumberConstant(kKey), IsNumberConstant(kValue),
+ feedback_vector_matcher, start, start);
+
+ EXPECT_THAT(ret, IsReturn(_, store_keyed_matcher, _));
+ }
+ }
+}
+
} // namespace compiler
} // namespace internal
} // namespace v8
« no previous file with comments | « test/cctest/compiler/test-run-bytecode-graph-builder.cc ('k') | test/unittests/compiler/node-test-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698