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

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

Issue 1524803003: [Interpreter] Add support for Load / Store to Lookup slots. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@init_eval_impl
Patch Set: Fixed nits. Created 5 years 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 3075 matching lines...) Expand 10 before | Expand all | Expand 10 after
3086 std::string source( 3086 std::string source(
3087 InterpreterTester::SourceForBody(to_name_tests[i].first)); 3087 InterpreterTester::SourceForBody(to_name_tests[i].first));
3088 InterpreterTester tester(handles.main_isolate(), source.c_str()); 3088 InterpreterTester tester(handles.main_isolate(), source.c_str());
3089 auto callable = tester.GetCallable<>(); 3089 auto callable = tester.GetCallable<>();
3090 3090
3091 Handle<i::Object> return_value = callable().ToHandleChecked(); 3091 Handle<i::Object> return_value = callable().ToHandleChecked();
3092 CHECK(return_value->SameValue(*to_name_tests[i].second)); 3092 CHECK(return_value->SameValue(*to_name_tests[i].second));
3093 } 3093 }
3094 } 3094 }
3095 3095
3096
3097 TEST(InterpreterLookupSlot) {
3098 HandleAndZoneScope handles;
3099 i::Isolate* isolate = handles.main_isolate();
3100 i::Factory* factory = isolate->factory();
3101
3102 // TODO(mythria): Add more tests when we have support for eval/with.
3103 const char* function_prologue = "var f;"
3104 "var x = 1;"
3105 "function f1() {"
3106 " eval(\"function t() {";
3107 const char* function_epilogue = " }; f = t;\");"
3108 "}"
3109 "f1();";
3110
3111
3112 std::pair<const char*, Handle<Object>> lookup_slot[] = {
3113 {"return x;", handle(Smi::FromInt(1), isolate)},
3114 {"return typeof x;", factory->NewStringFromStaticChars("number")},
3115 {"x = 10; return x;", handle(Smi::FromInt(10), isolate)},
3116 {"'use strict'; x = 20; return x;", handle(Smi::FromInt(20), isolate)},
3117 };
3118
3119 for (size_t i = 0; i < arraysize(lookup_slot); i++) {
3120 std::string script = std::string(function_prologue) +
3121 std::string(lookup_slot[i].first) +
3122 std::string(function_epilogue);
3123
3124 InterpreterTester tester(handles.main_isolate(), script.c_str(), "t");
3125 auto callable = tester.GetCallable<>();
3126
3127 Handle<i::Object> return_value = callable().ToHandleChecked();
3128 CHECK(return_value->SameValue(*lookup_slot[i].second));
3129 }
3130 }
3131
3096 } // namespace interpreter 3132 } // namespace interpreter
3097 } // namespace internal 3133 } // namespace internal
3098 } // namespace v8 3134 } // 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