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

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

Issue 1449373002: [Interpreter] Add support for global loads / stores / calls to BytecodeGraphBuilder. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@rmcilroy-0000
Patch Set: Rebase. 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 0cebf7d8c342d5d5c165c549b66f1801a9d525cf..db13ae0940c34eee5d15b333437878c63c5f0e50 100644
--- a/test/unittests/compiler/bytecode-graph-builder-unittest.cc
+++ b/test/unittests/compiler/bytecode-graph-builder-unittest.cc
@@ -440,6 +440,93 @@ TEST_F(BytecodeGraphBuilderTest, CallProperty2) {
}
+TEST_F(BytecodeGraphBuilderTest, LoadGlobal) {
+ const TypeofMode kTypeOfModes[] = {TypeofMode::NOT_INSIDE_TYPEOF,
+ TypeofMode::INSIDE_TYPEOF};
+ const bool kWideBytecode[] = {false, true};
+ TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) {
+ TRACED_FOREACH(TypeofMode, typeof_mode, kTypeOfModes) {
+ 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(0);
+ array_builder.set_context_count(0);
+ array_builder.set_parameter_count(1);
+
+ Handle<Name> name = GetName(isolate(), "global");
+ size_t name_index = array_builder.GetConstantPoolEntry(name);
+
+ array_builder.LoadGlobal(name_index, vector->GetIndex(slot),
+ language_mode, typeof_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_global_matcher = IsJSLoadGlobal(
+ name, typeof_mode, feedback_vector_matcher, start, start);
+
+ EXPECT_THAT(ret, IsReturn(load_global_matcher, _, _));
+ }
+ }
+ }
+}
+
+
+TEST_F(BytecodeGraphBuilderTest, StoreGlobal) {
+ 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(0);
+ array_builder.set_context_count(0);
+ array_builder.set_parameter_count(1);
+
+ Handle<Name> name = GetName(isolate(), "global");
+ size_t name_index = array_builder.GetConstantPoolEntry(name);
+
+ array_builder.LoadLiteral(Smi::FromInt(321))
+ .StoreGlobal(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*> value_matcher = IsNumberConstant(321);
+ Matcher<Node*> feedback_vector_matcher = IsFeedbackVector(start, start);
+ Matcher<Node*> store_global_matcher = IsJSStoreGlobal(
+ name, value_matcher, feedback_vector_matcher, start, start);
+
+ EXPECT_THAT(ret, IsReturn(_, store_global_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