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

Side by Side Diff: test/cctest/interpreter/test-interpreter.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 "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/base/utils/random-number-generator.h"
7 #include "src/execution.h" 8 #include "src/execution.h"
8 #include "src/handles.h" 9 #include "src/handles.h"
9 #include "src/interpreter/bytecode-array-builder.h" 10 #include "src/interpreter/bytecode-array-builder.h"
10 #include "src/interpreter/interpreter.h" 11 #include "src/interpreter/interpreter.h"
11 #include "test/cctest/cctest.h" 12 #include "test/cctest/cctest.h"
12 #include "test/cctest/test-feedback-vector.h" 13 #include "test/cctest/test-feedback-vector.h"
13 14
14 namespace v8 { 15 namespace v8 {
15 namespace internal { 16 namespace internal {
16 namespace interpreter { 17 namespace interpreter {
(...skipping 3170 matching lines...) Expand 10 before | Expand all | Expand 10 after
3187 std::string(function_epilogue); 3188 std::string(function_epilogue);
3188 3189
3189 InterpreterTester tester(handles.main_isolate(), script.c_str(), "t"); 3190 InterpreterTester tester(handles.main_isolate(), script.c_str(), "t");
3190 auto callable = tester.GetCallable<>(); 3191 auto callable = tester.GetCallable<>();
3191 3192
3192 Handle<i::Object> return_value = callable().ToHandleChecked(); 3193 Handle<i::Object> return_value = callable().ToHandleChecked();
3193 CHECK(return_value->SameValue(*delete_lookup_slot[i].second)); 3194 CHECK(return_value->SameValue(*delete_lookup_slot[i].second));
3194 } 3195 }
3195 } 3196 }
3196 3197
3198
3199 TEST(JumpWithConstantsAndWideConstants) {
3200 HandleAndZoneScope handles;
3201 auto isolate = handles.main_isolate();
3202 auto factory = isolate->factory();
3203 const int kStep = 19;
3204 int start = isolate->random_number_generator()->NextInt(kStep);
rmcilroy 2016/01/05 13:46:10 Ditto regarding random number generator.
oth 2016/01/05 18:31:59 Done. Plus removed the double use of stringstream
3205 for (int constants = start; constants < 256 + 3 * kStep; constants += kStep) {
3206 std::stringstream os;
3207 // Generate a string that consumes constant pool entries and
3208 // spread out branch distances in script below.
3209 for (int i = 0; i < constants; i++) {
3210 os << "var x_ = 'x_" << i << "';\n";
3211 }
3212 std::string filler(os.str());
3213 os.str("");
3214 os << "function " << InterpreterTester::function_name() << "(a) {\n";
3215 os << " " << filler;
3216 os << " for (var i = a; i < 2; i++) {\n";
3217 os << " " << filler;
3218 os << " if (i == 0) { " << filler << "i = 10; continue; }\n";
3219 os << " else if (i == a) { " << filler << "i = 12; break; }\n";
3220 os << " else { " << filler << " }\n";
3221 os << " }\n";
3222 os << " return i;\n";
3223 os << "}\n";
3224 std::string script(os.str());
3225 for (int a = 0; a < 3; a++) {
3226 InterpreterTester tester(handles.main_isolate(), script.c_str());
3227 auto callable = tester.GetCallable<Handle<Object>>();
3228 Handle<Object> return_val =
3229 callable(factory->NewNumberFromInt(a)).ToHandleChecked();
3230 static const int results[] = {11, 12, 2};
3231 CHECK_EQ(Handle<Smi>::cast(return_val)->value(), results[a]);
3232 }
3233 }
3234 }
3235
3197 } // namespace interpreter 3236 } // namespace interpreter
3198 } // namespace internal 3237 } // namespace internal
3199 } // namespace v8 3238 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698