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

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: Incorporate comments on patchset 13. 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/execution.h" 7 #include "src/execution.h"
8 #include "src/handles.h" 8 #include "src/handles.h"
9 #include "src/interpreter/bytecode-array-builder.h" 9 #include "src/interpreter/bytecode-array-builder.h"
10 #include "src/interpreter/interpreter.h" 10 #include "src/interpreter/interpreter.h"
(...skipping 3287 matching lines...) Expand 10 before | Expand all | Expand 10 after
3298 std::string(function_epilogue); 3298 std::string(function_epilogue);
3299 3299
3300 InterpreterTester tester(handles.main_isolate(), script.c_str(), "t"); 3300 InterpreterTester tester(handles.main_isolate(), script.c_str(), "t");
3301 auto callable = tester.GetCallable<>(); 3301 auto callable = tester.GetCallable<>();
3302 3302
3303 Handle<i::Object> return_value = callable().ToHandleChecked(); 3303 Handle<i::Object> return_value = callable().ToHandleChecked();
3304 CHECK(return_value->SameValue(*delete_lookup_slot[i].second)); 3304 CHECK(return_value->SameValue(*delete_lookup_slot[i].second));
3305 } 3305 }
3306 } 3306 }
3307 3307
3308
3309 TEST(JumpWithConstantsAndWideConstants) {
3310 HandleAndZoneScope handles;
3311 auto isolate = handles.main_isolate();
3312 auto factory = isolate->factory();
3313 const int kStep = 13;
3314 for (int constants = 3; constants < 256 + 3 * kStep; constants += kStep) {
3315 std::ostringstream filler_os;
3316 // Generate a string that consumes constant pool entries and
3317 // spread out branch distances in script below.
3318 for (int i = 0; i < constants; i++) {
3319 filler_os << "var x_ = 'x_" << i << "';\n";
3320 }
3321 std::string filler(filler_os.str());
3322 std::ostringstream script_os;
3323 script_os << "function " << InterpreterTester::function_name() << "(a) {\n";
3324 script_os << " " << filler;
3325 script_os << " for (var i = a; i < 2; i++) {\n";
3326 script_os << " " << filler;
3327 script_os << " if (i == 0) { " << filler << "i = 10; continue; }\n";
3328 script_os << " else if (i == a) { " << filler << "i = 12; break; }\n";
3329 script_os << " else { " << filler << " }\n";
3330 script_os << " }\n";
3331 script_os << " return i;\n";
3332 script_os << "}\n";
3333 std::string script(script_os.str());
3334 for (int a = 0; a < 3; a++) {
3335 InterpreterTester tester(handles.main_isolate(), script.c_str());
3336 auto callable = tester.GetCallable<Handle<Object>>();
3337 Handle<Object> return_val =
3338 callable(factory->NewNumberFromInt(a)).ToHandleChecked();
3339 static const int results[] = {11, 12, 2};
3340 CHECK_EQ(Handle<Smi>::cast(return_val)->value(), results[a]);
3341 }
3342 }
3343 }
3344
3308 } // namespace interpreter 3345 } // namespace interpreter
3309 } // namespace internal 3346 } // namespace internal
3310 } // namespace v8 3347 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/interpreter/test-bytecode-generator.cc ('k') | test/unittests/interpreter/bytecode-array-builder-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698