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

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

Issue 1583783003: [Interpreter] Adds support for variable/function declarations in lookup slots. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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/compiler.h" 7 #include "src/compiler.h"
8 #include "src/interpreter/bytecode-array-iterator.h" 8 #include "src/interpreter/bytecode-array-iterator.h"
9 #include "src/interpreter/bytecode-generator.h" 9 #include "src/interpreter/bytecode-generator.h"
10 #include "src/interpreter/interpreter.h" 10 #include "src/interpreter/interpreter.h"
(...skipping 6210 matching lines...) Expand 10 before | Expand all | Expand 10 after
6221 B(Return), // 6221 B(Return), //
6222 }, 6222 },
6223 1, 6223 1,
6224 {"x"}}, 6224 {"x"}},
6225 }; 6225 };
6226 6226
6227 for (size_t i = 0; i < arraysize(snippets); i++) { 6227 for (size_t i = 0; i < arraysize(snippets); i++) {
6228 std::string script = std::string(function_prologue) + 6228 std::string script = std::string(function_prologue) +
6229 std::string(snippets[i].code_snippet) + 6229 std::string(snippets[i].code_snippet) +
6230 std::string(function_epilogue); 6230 std::string(function_epilogue);
6231 // TODO(mythria): use * as filter when function declarations are supported
6232 // inside eval.
6233 Handle<BytecodeArray> bytecode_array = 6231 Handle<BytecodeArray> bytecode_array =
6234 helper.MakeBytecode(script.c_str(), "t", "f"); 6232 helper.MakeBytecode(script.c_str(), "*", "f");
6235 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 6233 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
6236 } 6234 }
6237 } 6235 }
6238 6236
6239 6237
6240 TEST(LookupSlotWideInEval) { 6238 TEST(LookupSlotWideInEval) {
6241 InitializedHandleScope handle_scope; 6239 InitializedHandleScope handle_scope;
6242 BytecodeGeneratorHelper helper; 6240 BytecodeGeneratorHelper helper;
6243 6241
6244 const char* function_prologue = 6242 const char* function_prologue =
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
6318 }, 6316 },
6319 257, 6317 257,
6320 {REPEAT_256(COMMA, InstanceType::HEAP_NUMBER_TYPE), 6318 {REPEAT_256(COMMA, InstanceType::HEAP_NUMBER_TYPE),
6321 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, 6319 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
6322 }; 6320 };
6323 6321
6324 for (size_t i = 0; i < arraysize(snippets); i++) { 6322 for (size_t i = 0; i < arraysize(snippets); i++) {
6325 std::string script = std::string(function_prologue) + 6323 std::string script = std::string(function_prologue) +
6326 std::string(snippets[i].code_snippet) + 6324 std::string(snippets[i].code_snippet) +
6327 std::string(function_epilogue); 6325 std::string(function_epilogue);
6328 // TODO(mythria): use * as filter when function declarations are supported
6329 // inside eval.
6330 Handle<BytecodeArray> bytecode_array = 6326 Handle<BytecodeArray> bytecode_array =
6331 helper.MakeBytecode(script.c_str(), "t", "f"); 6327 helper.MakeBytecode(script.c_str(), "*", "f");
6332 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 6328 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
6333 } 6329 }
6334 } 6330 }
6335 6331
6336 6332
6333 TEST(LookupSlotVariableDecl) {
6334 InitializedHandleScope handle_scope;
6335 BytecodeGeneratorHelper helper;
rmcilroy 2016/01/14 11:21:12 no need for these variables (I thought the compile
mythria 2016/01/15 11:27:04 Done.
6336 // TODO(mythria): tests for variable/function declaration in lookup slots.
6337 }
6338
6339
6337 TEST(DeleteLookupSlotInEval) { 6340 TEST(DeleteLookupSlotInEval) {
6338 InitializedHandleScope handle_scope; 6341 InitializedHandleScope handle_scope;
6339 BytecodeGeneratorHelper helper; 6342 BytecodeGeneratorHelper helper;
6340 6343
6341 const char* function_prologue = "var f;" 6344 const char* function_prologue = "var f;"
6342 "var x = 1;" 6345 "var x = 1;"
6343 "z = 10;" 6346 "z = 10;"
6344 "function f1() {" 6347 "function f1() {"
6345 " var y;" 6348 " var y;"
6346 " eval(\"function t() {"; 6349 " eval(\"function t() {";
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
6381 }, 6384 },
6382 1, 6385 1,
6383 {"z"}}, 6386 {"z"}},
6384 }; 6387 };
6385 6388
6386 for (size_t i = 0; i < arraysize(snippets); i++) { 6389 for (size_t i = 0; i < arraysize(snippets); i++) {
6387 std::string script = std::string(function_prologue) + 6390 std::string script = std::string(function_prologue) +
6388 std::string(snippets[i].code_snippet) + 6391 std::string(snippets[i].code_snippet) +
6389 std::string(function_epilogue); 6392 std::string(function_epilogue);
6390 Handle<BytecodeArray> bytecode_array = 6393 Handle<BytecodeArray> bytecode_array =
6391 helper.MakeBytecode(script.c_str(), "t", "f"); 6394 helper.MakeBytecode(script.c_str(), "*", "f");
6392 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 6395 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
6393 } 6396 }
6394 } 6397 }
6395 6398
6396 } // namespace interpreter 6399 } // namespace interpreter
6397 } // namespace internal 6400 } // namespace internal
6398 } // namespace v8 6401 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698