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

Side by Side Diff: test/cctest/compiler/test-run-bytecode-graph-builder.cc

Issue 1546683002: [Interpreter] Add support for jumps using constants with wide operands. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Tweak constant-array-builder-unittest.cc. Created 4 years, 11 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
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 <utility> 5 #include <utility>
6 6
7 #include "src/base/utils/random-number-generator.h"
7 #include "src/compiler/pipeline.h" 8 #include "src/compiler/pipeline.h"
8 #include "src/execution.h" 9 #include "src/execution.h"
9 #include "src/handles.h" 10 #include "src/handles.h"
10 #include "src/interpreter/bytecode-array-builder.h" 11 #include "src/interpreter/bytecode-array-builder.h"
11 #include "src/interpreter/interpreter.h" 12 #include "src/interpreter/interpreter.h"
12 #include "src/parsing/parser.h" 13 #include "src/parsing/parser.h"
13 #include "test/cctest/cctest.h" 14 #include "test/cctest/cctest.h"
14 15
15 namespace v8 { 16 namespace v8 {
16 namespace internal { 17 namespace internal {
(...skipping 2082 matching lines...) Expand 10 before | Expand all | Expand 10 after
2099 snippets[i].code_snippet, kFunctionName); 2100 snippets[i].code_snippet, kFunctionName);
2100 2101
2101 BytecodeGraphTester tester(isolate, zone, script.start()); 2102 BytecodeGraphTester tester(isolate, zone, script.start());
2102 auto callable = tester.GetCallable<>(); 2103 auto callable = tester.GetCallable<>();
2103 Handle<Object> return_value = callable().ToHandleChecked(); 2104 Handle<Object> return_value = callable().ToHandleChecked();
2104 CHECK(return_value->SameValue(*snippets[i].return_value())); 2105 CHECK(return_value->SameValue(*snippets[i].return_value()));
2105 } 2106 }
2106 } 2107 }
2107 2108
2108 2109
2110 TEST(JumpWithConstantsAndWideConstants) {
2111 HandleAndZoneScope scope;
2112 auto isolate = scope.main_isolate();
2113 const int kStep = 19;
2114 int start = isolate->random_number_generator()->NextInt(kStep);
rmcilroy 2016/01/05 13:46:10 Do you really need this random number generator? I
oth 2016/01/05 18:31:59 Done. The hope was the bots ran different seeds an
2115 for (int constants = start; constants < 256 + 3 * kStep; constants += kStep) {
2116 std::stringstream os;
2117 // Generate a string that consumes constant pool entries and
2118 // spread out branch distances in script below.
2119 for (int i = 0; i < constants; i++) {
2120 os << "var x_ = 'x_" << i << "';\n";
2121 }
2122 std::string filler(os.str());
2123 os.str("");
rmcilroy 2016/01/05 13:46:10 Please use a different std::stringstream rather t
oth 2016/01/05 18:31:59 Done.
2124 os << "function " << kFunctionName << "(a) {\n";
2125 os << " " << filler;
2126 os << " for (var i = a; i < 2; i++) {\n";
2127 os << " " << filler;
2128 os << " if (i == 0) { " << filler << "i = 10; continue; }\n";
2129 os << " else if (i == a) { " << filler << "i = 12; break; }\n";
2130 os << " else { " << filler << " }\n";
2131 os << " }\n";
2132 os << " return i;\n";
2133 os << "}\n";
2134 os << kFunctionName << "(0);\n";
2135 std::string script(os.str());
2136 auto factory = isolate->factory();
2137 auto zone = scope.main_zone();
2138 for (int a = 0; a < 3; a++) {
2139 BytecodeGraphTester tester(isolate, zone, script.c_str());
2140 auto callable = tester.GetCallable<Handle<Object>>();
2141 Handle<Object> return_val =
2142 callable(factory->NewNumberFromInt(a)).ToHandleChecked();
2143 static const int results[] = {11, 12, 2};
2144 CHECK_EQ(Handle<Smi>::cast(return_val)->value(), results[a]);
2145 }
2146 }
2147 }
2148
2109 } // namespace compiler 2149 } // namespace compiler
2110 } // namespace internal 2150 } // namespace internal
2111 } // namespace v8 2151 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698