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

Side by Side Diff: test/cctest/interpreter/test-interpreter.cc

Issue 1555063002: [Interpreter] Adds support for wide variant of load/store lookup slots. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Updated tests to address review comments. 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 3084 matching lines...) Expand 10 before | Expand all | Expand 10 after
3095 "function f1() {" 3095 "function f1() {"
3096 " eval(\"function t() {"; 3096 " eval(\"function t() {";
3097 const char* function_epilogue = " }; f = t;\");" 3097 const char* function_epilogue = " }; f = t;\");"
3098 "}" 3098 "}"
3099 "f1();"; 3099 "f1();";
3100 3100
3101 3101
3102 std::pair<const char*, Handle<Object>> lookup_slot[] = { 3102 std::pair<const char*, Handle<Object>> lookup_slot[] = {
3103 {"return x;", handle(Smi::FromInt(1), isolate)}, 3103 {"return x;", handle(Smi::FromInt(1), isolate)},
3104 {"return typeof x;", factory->NewStringFromStaticChars("number")}, 3104 {"return typeof x;", factory->NewStringFromStaticChars("number")},
3105 {"return typeof dummy;", factory->NewStringFromStaticChars("undefined")},
3105 {"x = 10; return x;", handle(Smi::FromInt(10), isolate)}, 3106 {"x = 10; return x;", handle(Smi::FromInt(10), isolate)},
3106 {"'use strict'; x = 20; return x;", handle(Smi::FromInt(20), isolate)}, 3107 {"'use strict'; x = 20; return x;", handle(Smi::FromInt(20), isolate)},
3107 }; 3108 };
3108 3109
3109 for (size_t i = 0; i < arraysize(lookup_slot); i++) { 3110 for (size_t i = 0; i < arraysize(lookup_slot); i++) {
3110 std::string script = std::string(function_prologue) + 3111 std::string script = std::string(function_prologue) +
3111 std::string(lookup_slot[i].first) + 3112 std::string(lookup_slot[i].first) +
3112 std::string(function_epilogue); 3113 std::string(function_epilogue);
3113 3114
3114 InterpreterTester tester(handles.main_isolate(), script.c_str(), "t"); 3115 InterpreterTester tester(handles.main_isolate(), script.c_str(), "t");
3115 auto callable = tester.GetCallable<>(); 3116 auto callable = tester.GetCallable<>();
3116 3117
3117 Handle<i::Object> return_value = callable().ToHandleChecked(); 3118 Handle<i::Object> return_value = callable().ToHandleChecked();
3118 CHECK(return_value->SameValue(*lookup_slot[i].second)); 3119 CHECK(return_value->SameValue(*lookup_slot[i].second));
3119 } 3120 }
3120 } 3121 }
3121 3122
3122 3123
3124 TEST(InterpreterLookupSlotWide) {
3125 HandleAndZoneScope handles;
3126 i::Isolate* isolate = handles.main_isolate();
3127 i::Factory* factory = isolate->factory();
3128
3129 const char* function_prologue =
3130 "var f;"
3131 "var x = 1;"
3132 "function f1() {"
3133 " eval(\"function t() {";
3134 const char* function_epilogue =
3135 " }; f = t;\");"
3136 "}"
3137 "f1();";
3138 std::ostringstream str;
3139 str << "var y = 2.3;";
3140 for (int i = 1; i < 256; i++) {
3141 str << "y = " << 2.3 + i << ";";
3142 }
3143 std::string init_function_body = str.str();
3144
3145 std::pair<std::string, Handle<Object>> lookup_slot[] = {
3146 {init_function_body + "return x;", handle(Smi::FromInt(1), isolate)},
3147 {init_function_body + "return typeof x;",
3148 factory->NewStringFromStaticChars("number")},
3149 {init_function_body + "return x = 10;",
3150 handle(Smi::FromInt(10), isolate)},
3151 {"'use strict';" + init_function_body + "x = 20; return x;",
3152 handle(Smi::FromInt(20), isolate)},
3153 };
3154
3155 for (size_t i = 0; i < arraysize(lookup_slot); i++) {
3156 std::string script = std::string(function_prologue) + lookup_slot[i].first +
3157 std::string(function_epilogue);
3158
3159 InterpreterTester tester(handles.main_isolate(), script.c_str(), "t");
3160 auto callable = tester.GetCallable<>();
3161
3162 Handle<i::Object> return_value = callable().ToHandleChecked();
3163 CHECK(return_value->SameValue(*lookup_slot[i].second));
3164 }
3165 }
3166
3167
3123 TEST(TemporaryRegisterAllocation) { 3168 TEST(TemporaryRegisterAllocation) {
3124 HandleAndZoneScope handles; 3169 HandleAndZoneScope handles;
3125 i::Isolate* isolate = handles.main_isolate(); 3170 i::Isolate* isolate = handles.main_isolate();
3126 i::Factory* factory = isolate->factory(); 3171 i::Factory* factory = isolate->factory();
3127 3172
3128 std::pair<const char*, Handle<Object>> reg_tests[] = { 3173 std::pair<const char*, Handle<Object>> reg_tests[] = {
3129 {"function add(a, b, c) {" 3174 {"function add(a, b, c) {"
3130 " return a + b + c;" 3175 " return a + b + c;"
3131 "}" 3176 "}"
3132 "function f() {" 3177 "function f() {"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
3190 auto callable = tester.GetCallable<>(); 3235 auto callable = tester.GetCallable<>();
3191 3236
3192 Handle<i::Object> return_value = callable().ToHandleChecked(); 3237 Handle<i::Object> return_value = callable().ToHandleChecked();
3193 CHECK(return_value->SameValue(*delete_lookup_slot[i].second)); 3238 CHECK(return_value->SameValue(*delete_lookup_slot[i].second));
3194 } 3239 }
3195 } 3240 }
3196 3241
3197 } // namespace interpreter 3242 } // namespace interpreter
3198 } // namespace internal 3243 } // namespace internal
3199 } // namespace v8 3244 } // 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